A training method, device, equipment and storage medium for license plate generation model
By combining the extraction of style and content features with the generator, the problem of a single style of license plate images in the existing technology is solved, and the generation of license plate images with diversified styles and high fidelity is achieved, which is suitable for supplementing training data for license plate recognition models.
Patent Information
- Application Number
- CN202410908974.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-08
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-07-08
AI Technical Summary
It is difficult to generate license plate images with diverse styles and high fidelity with existing technology. Existing methods can only generate a style consistent with the reference image and cannot generate license plate images of any style.
Extract style features from randomly sampled style vectors through the style extractor, extract content features from the license plate reference image in combination with the content extractor, use the generator to generate the license plate image, and perform the model on the generation loss function and the discriminant loss function of the discriminator Training to achieve style diversity and realistic license plate image generation.
It improves the fidelity and style diversity of the license plate images generated by the license plate generation model, and can generate high-quality license plate images with diverse styles, which is suitable for supplementing the training data of the license plate recognition model.
Smart Images

Figure CN118506130B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of deep learning and image recognition, and in particular relates to a training method, device, equipment and storage medium for a license plate generation model. Background Art
[0002] The license plate recognition model based on deep learning is data-driven, so it is heavily dependent on the quality of training images, and the license plate recognition model is prone to overfitting the license plate numbers in the training set. In addition, since different license plates are distributed over a wide area, manual collection of license plate images and annotations is time-consuming and laborious. Therefore, generating license plates to supplement training data is a potential solution to improve the performance of license plate recognition models, among which the style diversity and visual realism of the generated license plates are important.
[0003] In order to supplement the data for training recognition, some scholars proposed a method based on artificial synthesis. This method proposes to render the randomly sampled license plate number on a blank license plate background according to the specified font size, and then superimpose artificially designed noise to simulate the shooting noise caused by real shooting. However, such as different lighting conditions and bad weather, these complex noises generated in the process of collecting images in natural scenes are difficult to synthesize. Therefore, in order to generate realistic images, some researchers in the past proposed to convert artificially synthesized license plates into license plates with real environmental noise based on image translation. These methods regard the synthesized license plate and the real license plate as images in two different fields, aiming to learn the conversion function between the real domain and the synthetic domain. Therefore, for the same synthetic image, these methods can only generate a corresponding real image, and cannot generate images of multiple styles. To solve this problem, Sun et al. proposed to extract text content features and style features from different images respectively, and then combine the two to generate realistic license plates. However, the style of the license plate generated by this method can only be consistent with the reference image, and it is impossible to generate images of any style. In summary, it is still challenging to generate license plates with diverse styles. Summary of the invention
[0004] The purpose of the present invention is to provide a method, device, equipment and storage medium for training a license plate generation model, aiming to solve the problem that the license plate generated by the license plate generation model has low realism and single style due to the prior art.
[0005] On the one hand, the present invention provides a method for training a license plate generation model, wherein the license plate generation model includes a style extractor, a content extractor, and a generator, and the method includes the following steps:
[0006] Extracting style features from the randomly sampled style vectors by the style extractor;
[0007] Extracting license plate content features from the license plate reference image by means of the content extractor;
[0008] Generate a license plate image by the generator according to the style features and the license plate content features;
[0009] The license plate generation model is trained based on the license plate image, the generation loss function of the license plate generation model and the discriminant loss function of a pre-built discriminator.
[0010] Preferably, the style extractor includes a style encoding module and a style modulation module, and the step of extracting style features from the randomly sampled style vector by the style extractor includes:
[0011] Extracting features from the style vector using the style encoding module to obtain the style features;
[0012] The style features are broadcasted to different network layers of the generator through the style modulation module.
[0013] Preferably, each network layer of the generator corresponds to one style modulation module, and the step of broadcasting the style feature to different network layers of the generator through the style modulation module comprises:
[0014] According to the resolution of each network layer in the generator, the granularity of the style feature is adjusted by the style adjustment module corresponding to the network layer in the generator, and the adjusted style feature is input into the network layer corresponding to the generator.
[0015] Preferably, the content extractor includes a perspective transformation module and a content encoding module, and the step of extracting the license plate content features from the license plate reference image by the content extractor includes:
[0016] According to the style feature, the direction of characters in the license plate reference image is transformed by the perspective transformation module to obtain the transformed license plate reference image;
[0017] The content encoding module is used to extract features of the converted license plate reference image to obtain the license plate content features.
[0018] Preferably, according to the style feature, the perspective transformation module is used to transform the direction of characters in the license plate reference image to obtain the transformed license plate reference image, comprising:
[0019] Predicting the position to be converted of the reference point of the license plate reference image according to the style feature through the positioning network in the perspective transformation module;
[0020] According to the position to be converted, the license plate reference image is non-rigidly deformed by using thin plate spline transformation to obtain the converted license plate reference image.
[0021] Preferably, the content encoding module includes six stacked residual modules, and each residual module is connected to a downsampling module, wherein the residual module is used for feature extraction, and the downsampling module is used to perform two-fold downsampling on the features extracted by the residual module.
[0022] Preferably, the step of generating a license plate image by the generator according to the style feature and the license plate content feature comprises:
[0023] Based on the style features and the license plate content features, respectively generating image features corresponding to the resolution of the network layer through each network layer of the generator;
[0024] All the image features are fused to obtain the license plate image.
[0025] On the other hand, the present invention provides a training device for a license plate generation model, wherein the license plate generation model includes a style extractor, a content extractor, and a generator, and the device includes:
[0026] A style feature extraction unit, configured to extract style features from the randomly sampled style vectors through the style extractor;
[0027] a content feature extraction unit, used to extract license plate content features from the license plate reference image through the content extractor;
[0028] A license plate image generating unit, configured to generate a license plate image through the generator according to the style feature and the license plate content feature;
[0029] The generation model training unit is used to train the license plate generation model based on the license plate image, the generation loss function of the license plate generation model and the discriminant loss function of the pre-built discriminator.
[0030] On the other hand, the present invention also provides a computing device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps described in the above-mentioned method for training a license plate generation model are implemented.
[0031] On the other hand, the present invention also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps described in the above-mentioned training method for a license plate generation model.
[0032] The present invention extracts style features from a randomly sampled style vector through a style extractor in a license plate generation model, extracts license plate content features from a license plate reference image through a content extractor in the license plate generation model, generates a license plate image through a generator in the license plate generation model according to the style features and the license plate content features, and trains the license plate generation model based on the license plate image, a generation loss function of the license plate generation model and a discriminant loss function of a pre-constructed discriminator, thereby improving the fidelity of the license plate generated by the license plate generation model and the diversity of the license plate style. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 is a flow chart for implementing the training method of the license plate generation model provided in the first embodiment of the present invention;
[0034] Figure 2 It is a schematic diagram of the overall structure of the license plate generation model in the license plate generation model training method provided in the first embodiment of the present invention;
[0035] Figure 3 This is a flow chart of the method for generating a multi-style license plate provided in the second embodiment of the present invention;
[0036] Figure 4 It is a structural schematic diagram of a training device for a license plate generation model provided in Embodiment 3 of the present invention;
[0037] Figure 5 It is a schematic diagram of the structure of a computing device provided in Embodiment 4 of the present invention. DETAILED DESCRIPTION
[0038] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0039] The specific implementation of the present invention is described in detail below in conjunction with specific embodiments:
[0040] Embodiment 1:
[0041] Figure 1 The implementation process of the training method of the license plate generation model provided in the first embodiment of the present invention is shown. For the convenience of explanation, only the part related to the embodiment of the present invention is shown, which is described in detail as follows:
[0042] In step S101, style features are extracted from randomly sampled style vectors by a style extractor in a license plate generation model.
[0043] The embodiment of the present invention is applicable to computing devices, such as personal computers, servers, etc. In the embodiment of the present invention, the license plate generation model is used to generate license plates to supplement the training data of the license plate recognition model, which includes a style extractor, a content extractor, and a generator. First, the style vector provided for the training of the license plate generation model is randomly sampled, and then the style extractor extracts the style features from the randomly sampled style vector to provide style information for the subsequent generator, such as lighting conditions, blur, etc., wherein the style vector is used to describe specific style attributes of the license plate (for example, orientation, color, clarity, light intensity, etc.).
[0044] In a feasible embodiment, the style extractor includes a style encoding module and a style modulation module, wherein the style encoding module is used to extract style features, and the style modulation module is used to control the granularity of the style features to obtain style features of different granularities.
[0045] In another feasible embodiment, when extracting style features from randomly sampled style vectors by a style extractor, the extraction of style features is achieved by the following steps:
[0046] (1) Extract features from the style vector through the style encoding module to obtain style features;
[0047] In an embodiment of the present invention, the specific structure of the style encoding module is a nonlinear mapping network, which includes eight fully connected layers, and each layer is connected to a leaky rectified linear unit (Leaky ReLU) activation layer. The style encoding module of this structure is used to extract features of the style vector to obtain style features with richer feature representation, and the style features are input into the style adjustment module.
[0048] (2) The style features are broadcast to different network layers of the generator through the style modulation module.
[0049] In an embodiment of the present invention, a style modulation module is designed in the style extractor, and the style features are broadcasted and transmitted to different network layers in the generator through the style modulation module to control the style of the image generated by the generator.
[0050] In a feasible embodiment, each network layer of the generator corresponds to a style modulation module, that is, the number of style modulation modules in the style extractor is the same as the number of network layers in the generator, and each style modulation module is composed of two parts, style modulation and style demodulation, so that the subsequent license plate generation model can generate multi-style license plate images while maintaining visual consistency and stability.
[0051] In another feasible embodiment, when broadcasting the style features to different network layers of the generator through the style modulation module, the granularity of the style features is first adjusted according to the resolution of each network layer in the generator through the style adjustment module corresponding to the network layer in the generator, and then the adjusted style features are input into the corresponding network layer of the generator.
[0052] In the embodiment of the present invention, in the style modulation stage of the style modulation module, the style features are first embedded in the mapping through the linear function corresponding to each layer of the generator to control the style of different granularities. Then, based on the scaled convolution weights of the corresponding layer, the style features are scaled to integrate the style information. At the same time, the weight modulation formula w is used. i ′=fl i (s i )·w i The corresponding weights of each network layer in the generator after modulation are obtained. Then, in order to ensure that too much noise or unstable factors are not introduced in the style modulation process, the weight demodulation formula is used in the style demodulation stage of the style modulation module. The modulated weights are normalized so that the output has unit standard deviation, ensuring that when style features are introduced into the generator, the size and range of the weights remain controllable and do not cause instability or oversensitivity of the generator, where i represents the i-th layer of the generator, s i is the style feature of the input i-th layer, w i ′ is the weight of the i-th layer after modulation, fl i () is the linear function corresponding to the i-th layer, w i ″ is the weight of the i-th layer after demodulation, k, h, w are the kernel size of the input channel and convolution weights, respectively, and ε is a small constant used to avoid division by zero.
[0053] Through the above steps (1) and (2), the style extractor extracts style features from the randomly sampled style vector, so that the subsequent generator can generate an image with a specified style.
[0054] In step S102, the license plate content features are extracted from the license plate reference image by the content extractor in the license plate generation model.
[0055] In an embodiment of the present invention, taking into account that the actually collected license plates have different degrees of perspective deformation due to various shooting angles, a direction-aware content extractor is designed in the license plate generation model. The content extractor extracts license plate content features from a license plate reference image, wherein the license plate reference image is obtained by rendering according to specified text.
[0056] In a feasible embodiment, the content extractor includes a perspective transformation module (PerspectiveTransformation Module, PTM) and a content encoding module, so as to achieve control over the character content of the generated license plate.
[0057] In another feasible embodiment, the extraction of license plate content features is achieved through the following steps:
[0058] (1) According to the style features, the character directions in the license plate reference image are transformed through the perspective transformation module to obtain a transformed license plate reference image;
[0059] In an embodiment of the present invention, according to the style features, the direction of the characters in the license plate reference image is converted through a perspective transformation module to obtain a converted license plate reference image. Specifically, the style features (including the direction information of the characters in the license plate) are first read through the perspective transformation module, and then the horizontal license plate reference image (that is, the characters in the license plate reference image are horizontal) is converted into a license plate reference image of arbitrary direction that conforms to the style features (that is, the characters in the license plate reference image after the conversion are non-horizontal and in arbitrary direction).
[0060] When the character directions in the license plate reference image are converted by the perspective transformation module according to the style features to obtain the converted license plate reference image, preferably, the image conversion is achieved by the following steps:
[0061] ① The positioning network in the perspective transformation module predicts the position of the reference point of the license plate reference image to be transformed according to the style features;
[0062] In an embodiment of the present invention, since the shape of an image can be defined by several reference points, based on this, four vertices of the license plate reference image are selected as reference points. Based on the reference points, the mapping relationship between the pixel values of the reference points before and after the transformation is calculated according to the style features through the positioning network in the perspective transformation module. The position to be transformed is obtained according to the mapping relationship, thereby achieving the control of the direction and degree of perspective transformation, wherein the position to be transformed is the coordinate information corresponding to the reference point of the transformed license plate reference image, which is an eight-dimensional tensor representing the standardized coordinates of the reference point. The positioning network consists of three fully connected layers, and each fully connected layer is connected to a ReLU activation function. In addition, in order to make the initial regression value four vertices, the weight of the last fully connected layer of the positioning network is initialized to 0, and the bias is initialized to the coordinates of the four vertices, and (-1,-1) can be used to represent the upper left vertex and (1,1) can be used to represent the lower right vertex.
[0063] ② According to the position to be converted, the thin plate spline transform is used to perform non-rigid deformation on the license plate reference image to obtain the converted license plate reference image.
[0064] In an embodiment of the present invention, according to the initial position of the reference point (i.e., the coordinate information corresponding to the reference point of the original license plate reference image before conversion) and the position to be converted, a thin plate spline (TPS) transformation is used to sample the license plate reference image to obtain a license plate reference image after perspective transformation.
[0065] Through the above steps ① and ②, the mapping relationship between the pixel values before and after the transformation is calculated according to the positions of the reference points before and after the transformation. The transformed license plate reference image can be obtained by sampling the original license plate reference image according to this relationship.
[0066] (2) The converted license plate reference image is subjected to feature extraction through the content encoding module to obtain the license plate content features.
[0067] In an embodiment of the present invention, the content encoding module is a convolutional network with a gradually decreasing spatial resolution, which includes six stacked network layers, each of which includes a residual module, and each network layer downsamples the features extracted by the residual module by a factor of two, so that the spatial size (height and width) of the feature map is halved after each network layer, thereby realizing the extraction of multi-level features of the license plate reference image and helping the network to learn more abstract and global features.
[0068] When the converted license plate reference image is subjected to feature extraction through the content encoding module, specifically, the license plate reference image first passes through the residual module of the first layer to extract preliminary features, and then the preliminary features are downsampled by two to obtain the license plate content features of the first layer, and then these license plate content features are transmitted and transformed layer by layer through subsequent network layers, and each layer learns a higher level of feature representation, and as the network goes deeper, the spatial resolution of the obtained license plate content features gradually decreases, and finally, license plate content features of different scales are obtained through the content encoding module (that is, a license plate content feature of a scale can be obtained through each network layer of the content encoding module, and in the shallower layers of the network, the spatial size of the license plate content feature is larger and contains more detailed information, while in the deeper layers of the network, the spatial size of the license plate content feature is smaller but contains higher level semantic information).
[0069] Through the above steps (1)-(2), the license plate content features are extracted from the license plate reference image by the content extractor, thereby ensuring the controllability of the text in the subsequently generated image.
[0070] In a feasible embodiment, the multi-scale license plate content features are spliced onto the features of the same resolution in the generator, thereby ensuring that the generator can obtain sufficient glyph details and improving the authenticity of the license plate generated by the generator.
[0071] In step S103, a license plate image is generated by a generator in a license plate generation model according to the style features and the license plate content features.
[0072] In an embodiment of the present invention, the generator accepts style features and license plate content features as input to generate a license plate image, wherein the network structure of the generator is symmetrical with the content encoder, that is, it is a neural network with gradually increasing image resolution. Specifically, the input image features of (512, 4, 4) are eventually upgraded to image features of (512, 256, 256) by gradually increasing the resolution.
[0073] In a feasible embodiment, the following steps are used to generate a license plate image by a generator in a license plate generation model according to style features and license plate content features:
[0074] (1) Based on the style features and license plate content features, each network layer of the generator generates image features corresponding to the resolution of the network layer;
[0075] In an embodiment of the present invention, the generator learns the overall style at a lower resolution, such as the distribution of color blocks, and gradually learns the texture of local details as the resolution increases. In this way, style features are embedded in each stage of the generator to control styles of different granularities. In addition, considering that glyphs have high requirements for local details and are prone to generating incorrect character structures, license plate content features are embedded in both low-resolution and high-resolution features. Based on this, each network layer of the generator performs feature splicing on the style features and license plate content features input to this layer to obtain image features corresponding to the resolution of this layer.
[0076] In a feasible embodiment, since embedding license plate content features in a high-resolution network layer will affect the diversity of the generated license plates, it is chosen to embed the license plate content features into a network layer with a resolution of 4 to 64 to be spliced with the corresponding style features, thereby ensuring the rationality of the glyphs and the diversity of styles.
[0077] (2) All image features are fused to obtain the license plate image.
[0078] In an embodiment of the present invention, an RGB conversion module (referred to as: toRGB module) with the same network structure as the style modulation module is pre-constructed, and a toRGB module is connected after each network layer of the generator. The toRGB module is used to read the image features of different resolutions output by the corresponding network layer in the generator, and generate a three-channel tensor, that is, the image features output by each network layer of the generator are converted into a three-channel image feature. For example, after the image feature of (512, 16, 16) is processed by the toRGB module, the image feature of (3, 16, 16) is output. Finally, the multiple image features of different resolutions processed by the toRGB module are feature fused, and the image with the highest resolution obtained is used as the license plate image finally output by the generator.
[0079] In a feasible embodiment, when all image features are fused, low-resolution image features are first upsampled twice and then added to high-resolution image features for feature fusion, thereby enhancing image quality and improving image visual effects.
[0080] Through the above steps (1) and (2), a license plate image is generated by a generator in a license plate generation model according to style features and license plate content features, thereby improving the realism of the generated license plate image and the diversity of license plate styles.
[0081] In step S104, the license plate generation model is trained based on the license plate image, the generation loss function of the license plate generation model, and the discriminant loss function of the pre-built discriminator.
[0082] In an embodiment of the present invention, based on the license plate image, the generation loss function of the license plate generation model and the discriminant loss function of a pre-built discriminator, the license plate generation model is adversarially trained in an end-to-end manner so that the generator can generate high-quality images.
[0083] In a feasible embodiment, the discriminator includes a color image discriminator and an image gradient discriminator, and the discriminant loss function of the discriminator is composed of the loss function of the color image discriminator and the loss function of the image gradient discriminator, so as to avoid the appearance of unnatural patterns and textures in the generated license plate image and improve the realism of the generated license plate image. Among them, the color image discriminator takes the image as input, and the output is the confidence level indicating whether the image is a real image or a forged image. Its detailed structure is the same as StyleGAN v2. The image gradient discriminator takes the gradient map of the image as input, and the output is the score of whether the gradient map is reasonable. The gradient map of the image is obtained by convolving the image with the following convolution kernel:
[0084]
[0085] Among them, k x and k y They are the convolution kernels used to calculate the horizontal and vertical gradients respectively. The total gradient of the image can be obtained by concatenating the gradients in the horizontal and vertical directions in the channel dimension.
[0086] In another feasible embodiment, the generation loss function L of the license plate generation model is G for:
[0087]
[0088] Among them, I G =G(c,s), c is the license plate content feature, s is the style feature, G is the generator, I G The license plate image generated by the generator, D rgb is the color image discriminator, D grad is the image gradient discriminator, I R is the real image, f g () is the gradient calculation function, λ G is a hyperparameter set to 1.
[0089] In another feasible embodiment, the discriminant loss function of the discriminator is Among them, λ D is a hyperparameter set to 1, is the loss function of the color image discriminator, is the loss function of the image gradient discriminator, which are set as:
[0090]
[0091]
[0092] Figure 2 The overall structure and training process framework of the license plate generation model are shown as follows: Figure 2As shown, first, the style features are extracted from the style vector through the style encoding module in the style extractor, and the extracted style features are broadcast to different network layers of the generator through the style modulation module in the style extractor. Then, based on the license plate reference image (for example, the license plate image of AADAAAA9) and the style features, the horizontal license plate reference image is converted into a multi-directional license plate reference image through the PTM in the content extractor. Then, the multi-level features are extracted from the converted license plate reference image through the content encoding module in the content extractor, and the extracted license plate content features are respectively transmitted to the layers with the same resolution in the generator. After that, each layer in the generator respectively splices the input style features and license plate content features, and the spliced image features The features are converted through the toRGB module for channel conversion. Before the image features of multiple resolutions are obtained after the channel conversion for feature fusion, the low-resolution image features are first upsampled by a factor of two and then added to the high-resolution image features for feature fusion. The fused image with the highest resolution is used as the license plate image finally output by the generator. Finally, the license plate image is input into the discriminator for identification. The model parameters of the license plate generation model are adjusted according to the loss value of the discriminator and the loss value of the license plate generation model, and the step of extracting style features from the randomly sampled style vector through the style extractor is continued to be executed to train the license plate generation model again until the losses of the license plate generation model and the discriminator are converged and the training of the license plate generation model is completed.
[0093] In an embodiment of the present invention, style features are extracted from randomly sampled style vectors by a style extractor in a license plate generation model, license plate content features are extracted from a license plate reference image by a content extractor in the license plate generation model, a license plate image is generated by a generator in the license plate generation model based on the style features and the license plate content features, and the license plate generation model is trained based on the license plate image, the generation loss function of the license plate generation model, and the discriminant loss function of a pre-constructed discriminator, thereby improving the realism of the license plate generated by the license plate generation model and the diversity of the license plate style.
[0094] Embodiment 2:
[0095] Figure 3 The implementation process of the method for generating a multi-style license plate provided by the second embodiment of the present invention is shown. For the convenience of explanation, only the part related to the embodiment of the present invention is shown, which is described in detail as follows:
[0096] Based on the license plate generation model trained in Example 1, the generation of multi-style license plates is achieved through the following steps:
[0097] In step S301, style features are extracted from the randomly sampled style vectors by a style extractor of the license plate generation model;
[0098] In step S302, the license plate content features are extracted from the license plate glyph image by the content extractor of the license plate generation model;
[0099] In step S303, a target license plate image is generated by a generator of a license plate generation model according to the style features and the license plate content features.
[0100] In the embodiment of the present invention, the implementation principle of step S301 to step S303 is the same as that of step S101 to step S103 in the first embodiment, and will not be repeated here.
[0101] In order to evaluate the effectiveness of the multi-style license plates generated by the license plate generation model trained in Example 1, we verified its effectiveness from three aspects: qualitative results, quantitative results (i.e., FID), and recognition performance based on training of generated images. The details are as follows:
[0102] ① Qualitative results: In the experiments of generating license plates based on reference images using the method of this application, the method based on artificial synthesis, the Pix2Pix method, the CycleGAN method, the AsymCycleGAN method, the method without PTM, and the method without Grad, it was found that the method based on artificial synthesis could not synthesize the environmental noise brought by the real scene, such as camera shooting noise and complex lighting changes; in addition, the character structure generated by the Pix2Pix method was incorrect, because Pix2Pix is only applicable to color conversion between image pairs with consistent content structure, and performs poorly when converting horizontal character images into non-horizontal license plate images, which will change the shape of the characters; CycleGAN and AsymCycleGAN generated results with a unified style, because they aim to learn the mapping function between the source domain and the target domain, and there is no explicit style modeling and the style cannot be changed; on the contrary, the license plates generated by this application are the most realistic and have the most diverse styles.
[0103] Table 1
[0104]
[0105] ② Quantitative results: As shown in Table 1 above, the evaluation results of the present invention on the quantitative index of FID (Fréchet Inception Distance) are measured. The lower the FID value, the better the generation effect. "Text controllable?" means that the method can generate images of specified text, which means that the corresponding license plate label will be generated along with the image, so it can be directly applied to the training of the recognition network. In order to avoid the interference of different text content, i.e., license plate numbers, on the FID calculation, all controllable text generation methods use the same license plate number set as the training set. The FID value of the CCPD-Green test set (CCPD-Green includes a total of 11,776 green license plates, and its official training test partitioning protocol was used in the experiment) is 35, which can represent the similarity of the distribution of two subsets of real license plates under the same acquisition conditions. It can be seen that, except that the FID of the present invention and StyleGAN is comparable to the test set, the FID values of all generation methods are very high, which is consistent with the presentation of qualitative results. In addition, although the FID of StyleGAN is low, the license plate text generated by it is not controllable, so it cannot be used for the training of the recognition model. It can be concluded that the present application can generate license plates with controllable text and close to real image distribution.
[0106] Table 2
[0107]
[0108] ③ Recognition performance based on training of generated images: This experiment aims to evaluate the usability of generated license plate images for recognition tasks. The specific steps are to train the recognition network using the generated license plates and test them on the CCPD-Green test set to verify the impact on the recognition model. The recognition model adopts an encoding-decoding architecture. The encoder is the same as Holistic CNN(), and the decoder is a structure based on RNN attention. All experiments follow the same training settings. Then, after the training is completed, the word-level accuracy (denoted as ACC-W) and character-level accuracy (denoted as ACC-C) are used to measure the recognition performance of different models. During the generation process, each method generates the same set of license plate numbers as the CCPD-Green training set to verify whether the generated images can replace the original training set. As shown in Table 2 above, this application achieved the best recognition performance, which shows that the distribution of its generated images in the recognition space is similar to that of the CCPD-Green training set, proving the effectiveness of the proposed method.
[0109] Table 3
[0110]
[0111] In addition, the recognition model is sensitive to the license plate number, i.e., the character combination seen during training. Many previous studies have used generated images as supplementary data to improve recognition performance and robustness. Therefore, 30,000 images are randomly generated as a supplement to the training data to verify the effectiveness of the generation method. In Table 3, 'Aug' represents image enhancement during training, including random blur, Gaussian noise, and perspective transformation. As shown in Table 3, although performance improvement can be achieved through image enhancement during training, adding generated samples can improve performance more significantly. In addition, it can be seen that the best recognition performance can be achieved by supplementing the generated images by this application, and image enhancement on this basis can further improve performance.
[0112] Embodiment three:
[0113] Figure 4 The structure of the training device for the license plate generation model provided in the third embodiment of the present invention is shown. For the convenience of description, only the part related to the embodiment of the present invention is shown, including:
[0114] A style feature extraction unit 41, used to extract style features from the randomly sampled style vectors through a style extractor in the license plate generation model;
[0115] A content feature extraction unit 42, used to extract license plate content features from the license plate reference image through a content extractor in the license plate generation model;
[0116] A license plate image generating unit 43, used to generate a license plate image through a generator in a license plate generation model according to style features and license plate content features;
[0117] The generation model training unit 44 is used to train the license plate generation model based on the license plate image, the generation loss function of the license plate generation model and the discriminant loss function of the pre-built discriminator.
[0118] In the embodiment of the present invention, each unit of the training device for the license plate generation model can be implemented by a corresponding hardware or software unit, and each unit can be an independent software or hardware unit, or can be integrated into a software or hardware unit, which is not intended to limit the present invention. Specifically, the implementation of each unit can refer to the description of the aforementioned embodiment 1, which will not be repeated here.
[0119] Embodiment 4:
[0120] Figure 5 The structure of a computing device provided by a fourth embodiment of the present invention is shown. For ease of description, only the parts related to the embodiment of the present invention are shown.
[0121] The computing device 5 of the embodiment of the present invention includes a processor 50, a memory 51, and a computer program 52 stored in the memory 51 and executable on the processor 50. When the processor 50 executes the computer program 52, the steps in the training method embodiment of the license plate generation model are implemented, such as Figure 1 Alternatively, when the processor 50 executes the computer program 52, the functions of each unit in the above-mentioned device embodiments are realized, for example Figure 4 Function of the unit shown.
[0122] In an embodiment of the present invention, style features are extracted from randomly sampled style vectors by a style extractor in a license plate generation model, license plate content features are extracted from a license plate reference image by a content extractor in the license plate generation model, a license plate image is generated by a generator in the license plate generation model based on the style features and the license plate content features, and the license plate generation model is trained based on the license plate image, the generation loss function of the license plate generation model, and the discriminant loss function of a pre-constructed discriminator, thereby improving the realism of the license plate generated by the license plate generation model and the diversity of the license plate style.
[0123] The computing device of the embodiment of the present invention may be a personal computer or a server. The steps implemented when the processor 50 in the computing device 5 executes the computer program 52 to implement a training method for a license plate generation model can be referred to the description of the aforementioned method embodiment, which will not be repeated here.
[0124] Embodiment five:
[0125] In an embodiment of the present invention, a computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned training method for a license plate generation model are implemented, for example, Figure 1 Alternatively, when the computer program is executed by a processor, the functions of each unit in the above-mentioned device embodiments are realized, for example Figure 4 Function of the unit shown.
[0126] In an embodiment of the present invention, style features are extracted from randomly sampled style vectors by a style extractor in a license plate generation model, license plate content features are extracted from a license plate reference image by a content extractor in the license plate generation model, a license plate image is generated by a generator in the license plate generation model based on the style features and the license plate content features, and the license plate generation model is trained based on the license plate image, the generation loss function of the license plate generation model, and the discriminant loss function of a pre-constructed discriminator, thereby improving the realism of the license plate generated by the license plate generation model and the diversity of the license plate style.
[0127] The computer-readable storage medium of the embodiment of the present invention may include any entity or device or recording medium capable of carrying computer program code, for example, ROM / RAM, magnetic disk, optical disk, flash memory and other memories.
[0128] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for training a license plate generation model, characterized in that: The license plate generation model includes a style extractor, a content extractor and a generator, and the method includes the following steps: Extracting style features from the randomly sampled style vectors by the style extractor; Extracting license plate content features from the license plate reference image by means of the content extractor, wherein the content extractor comprises a perspective transformation module and a content encoding module; Generate a license plate image by the generator according to the style features and the license plate content features; Training the license plate generation model based on the license plate image, the generation loss function of the license plate generation model, and the discriminant loss function of a pre-built discriminator; The step of extracting the license plate content features from the license plate reference image by the content extractor includes: According to the style feature, the direction of characters in the license plate reference image is transformed by the perspective transformation module to obtain the transformed license plate reference image; The content encoding module is used to extract features of the converted license plate reference image to obtain the license plate content features.
2. The method according to claim 1, characterized in that The style extractor includes a style encoding module and a style modulation module. The step of extracting style features from a randomly sampled style vector by the style extractor includes: Extracting features from the style vector using the style encoding module to obtain the style features; The style features are broadcasted to different network layers of the generator through the style modulation module.
3. The method according to claim 2, characterized in that Each network layer of the generator corresponds to one style modulation module, and the step of broadcasting the style feature to different network layers of the generator through the style modulation module comprises: According to the resolution of each network layer in the generator, the granularity of the style feature is adjusted by the style adjustment module corresponding to the network layer in the generator, and the adjusted style feature is input into the network layer corresponding to the generator, wherein the granularity of the style feature refers to the expression intensity and detail level of the style feature at different network levels in the generator.
4. The method according to claim 1, characterized in that According to the style feature, the direction of characters in the license plate reference image is converted by the perspective transformation module to obtain the converted license plate reference image, comprising: Predicting the position to be converted of the reference point of the license plate reference image according to the style feature through the positioning network in the perspective transformation module; According to the position to be converted, the license plate reference image is non-rigidly deformed by using thin plate spline transformation to obtain the converted license plate reference image.
5. The method according to claim 1, characterized in that The content encoding module includes six stacked residual modules, and each residual module is connected to a downsampling module, wherein the residual module is used for feature extraction, and the downsampling module is used to perform two-fold downsampling on the features extracted by the residual module.
6. The method according to claim 1, characterized in that The step of generating a license plate image by the generator according to the style feature and the license plate content feature comprises: Based on the style features and the license plate content features, respectively generating image features corresponding to the resolution of the network layer through each network layer of the generator; All the image features are fused to obtain the license plate image.
7. A training device for a license plate generation model, characterized in that: The license plate generation model includes a style extractor, a content extractor and a generator, and the device includes: A style feature extraction unit, configured to extract style features from the randomly sampled style vectors through the style extractor; A content feature extraction unit, configured to extract license plate content features from a license plate reference image through the content extractor, wherein the content extractor includes a perspective transformation module and a content encoding module. When extracting the license plate content features from the license plate reference image through the content extractor, the direction of characters in the license plate reference image is transformed through the perspective transformation module according to the style features to obtain the transformed license plate reference image; and feature extraction is performed on the transformed license plate reference image through the content encoding module to obtain the license plate content features; A license plate image generating unit, configured to generate a license plate image through the generator according to the style feature and the license plate content feature; The generation model training unit is used to train the license plate generation model based on the license plate image, the generation loss function of the license plate generation model and the discriminant loss function of the pre-built discriminator.
8. A computing device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
