Image generation method, device and readable storage medium

Through the alternating optimization training of the generator and the discriminator, the target generator is generated, which solves the accuracy and controllability problems of generating pictures of rare characters in the existing technology, realizes a method of quickly and accurately generating pictures of rare characters, and improves the performance of the model. Recognition ability.

CN111598075BActive Publication Date: 2024-09-20WEBANK (CHINA)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010446590.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-05-25
Publication Date
2024-09-20
Estimated Expiration
2040-05-25

AI Technical Summary

Technical Problem

The existing technology is difficult to quickly and accurately generate a large number of pictures of rare characters, which affects the accuracy of the model's recognition of rare characters. In particular, the pictures generated by the rule-based generation method are very different from the real pictures, and the generation results based on the adversarial network are uncontrollable and lack randomness.

Method used

By calling the generator and the discriminator for alternate optimization training, the target generator is generated, the generator is used to add style noise to increase randomness, and the discriminator is used to identify text comparisons to ensure the accuracy and controllability of the generated rare word pictures.

Benefits of technology

It achieves the rapid and accurate generation of a large number of pictures containing rare characters, taking into account randomness and controllability, and improves the accuracy of the model in identifying rare characters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111598075B
    Figure CN111598075B
Patent Text Reader

Abstract

The present invention discloses a method, device, equipment and readable storage medium for generating pictures, the method comprising: calling a generator to process a simulated picture and a real picture respectively, generating a first picture and a second picture corresponding to the simulated picture, and a third picture and a fourth picture corresponding to the real picture; optimizing and training the generator according to the simulated picture and the second picture, the real picture and the fourth picture; calling a discriminator to distinguish the real picture and the first picture, and the third picture and the simulated picture respectively, and optimizing and training the discriminator based on the discrimination result; after the training of the generator and the discriminator is completed, a target generator is obtained to process the received pictures to be processed based on the target generator to generate multiple final pictures. The final pictures containing uncommon characters generated by the target generator of the present invention take into account randomness, controllability and accuracy, and realize the rapid and accurate generation of a large number of final pictures containing uncommon characters.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of financial technology (Fintech), and in particular to a picture generation method, device and readable storage medium. Background Art

[0002] With the continuous development of financial technology (Fintech), especially Internet technology finance, more and more technologies (such as artificial intelligence, big data, cloud storage, etc.) are applied in the financial field. However, the financial field also puts forward higher requirements for various technologies, such as requiring the rapid and accurate generation of a large number of rare character images for model training to improve the accuracy of the model in recognizing rare characters.

[0003] The recognition of uncommon characters in the document text recognition process relies on a large amount of annotated data, but the proportion of uncommon characters in the natural language corpus is far from enough, and there are even cases where the uncommon characters in the recognition process do not exist in the training set. Currently, the uncommon character images are mainly generated based on rules and based on adversarial networks; among them, for rule-based, it cuts out the text-free part of the real document in actual use as the background, prints the uncommon characters on the background, and adds blur, noise and other methods to make the generated image closer to the real data; but the generated image is still very different from the real image, which makes the generalization ability of the real image very poor, affecting the accuracy of recognition after training. For adversarial networks, the content generated is uncontrollable or lacks randomness, and may generate text images that do not contain uncommon characters, or generate the same image for each training.

[0004] Therefore, how to quickly and accurately generate a large number of rare character images is a technical problem that needs to be solved urgently. Summary of the invention

[0005] The main purpose of the present invention is to provide a picture generation method, device and readable storage medium, aiming to solve the technical problem in the prior art that it is difficult to quickly and accurately generate a large number of rare character pictures.

[0006] To achieve the above object, the present invention provides a method for generating an image, the method comprising the following steps:

[0007] Calling a generator to process the simulated image and the real image respectively, generating a first image and a second image corresponding to the simulated image, and a third image and a fourth image corresponding to the real image;

[0008] Optimizing and training the generator according to the simulated image and the second image, the real image and the fourth image;

[0009] Calling a discriminator to distinguish the real image and the first image, and the third image and the simulated image respectively, and optimizing and training the discriminator based on the distinction results;

[0010] After the generator and the discriminator are trained, a target generator is obtained to process the received images to be processed based on the target generator to generate multiple final images.

[0011] Optionally, the discriminator includes a first true-false discriminator and a second true-false discriminator;

[0012] The steps of calling the discriminator to distinguish the real picture and the first picture, and the third picture and the simulated picture respectively, and optimizing and training the discriminator based on the distinction results include:

[0013] Based on the second true and false discriminator, the real image and the first image are distinguished to generate a second true and false loss value of the second cross entropy loss function in the second true and false discriminator, and based on the first true and false discriminator, the third image and the simulated image are distinguished to generate a first true and false loss value of the first cross entropy loss function in the first true and false discriminator;

[0014] The discriminator is optimized and trained according to the first true and false loss value and the second true and false loss value.

[0015] Optionally, the step of distinguishing the real image and the first image based on the second true-false discriminator to generate a second true-false loss value of the second cross entropy loss function in the second true-false discriminator, and distinguishing the third image and the simulated image based on the first true-false discriminator to generate a first true-false loss value of the first cross entropy loss function in the first true-false discriminator includes:

[0016] The parameters of the generator are fixed, and the first image is marked as a pseudo-domain image and then transmitted to a second true-false discriminator, and the true-false discrimination is performed on the marked first image to generate a first discrimination result;

[0017] Based on the second true-false discriminator, distinguish the real image from the first image to generate a second discrimination result, and generate a second true-false loss value of the second cross entropy loss function in the second true-false discriminator according to the first discrimination result and the second discrimination result;

[0018] Marking the third image as a real domain image and transmitting it to the first true-false discriminator, performing true-false discrimination on the marked third image to generate a third discrimination result;

[0019] Based on the first true and false discriminator, the third image and the simulated image are distinguished and discriminated to generate a fourth discrimination result, and according to the third discrimination result and the fourth discrimination result, a first true and false loss value of the first cross entropy loss function in the first true and false discriminator is generated.

[0020] Optionally, the discriminator further includes a first OCR discriminator and a second OCR discriminator, and the step of optimizing the discriminator according to the first true and false loss value and the second true and false loss value includes:

[0021] Based on the first OCR discriminator recognizing the text in the simulated image and the third image, a first OCR loss value of a first loss function in the first OCR discriminator is generated, and based on the second OCR discriminator recognizing the text in the real image and the first image, a second OCR loss value of a second loss function in the second OCR discriminator is generated;

[0022] Determine whether the first true-false loss value and the second true-false loss value are both less than a preset cross-entropy threshold, and whether the first OCR loss value and the second OCR loss value are both less than a preset function threshold;

[0023] If the first true-false loss value and the second true-false loss value are both less than a preset cross-entropy threshold, and the first OCR loss value and the second OCR loss value are both less than a preset function threshold, the training of the discriminator is completed;

[0024] If any one of the first true-false loss value and the second true-false loss value is not less than a preset cross-entropy threshold, or any one of the first OCR loss value and the second OCR loss value is not less than a preset function threshold, the step of calling the generator to process the simulated image and the real image respectively to generate a first image and a second image corresponding to the simulated image is executed to optimize the training of the discriminator.

[0025] Optionally, the step of generating a first OCR loss value of a first loss function in the first OCR discriminator based on the recognition of the text in the simulated image and the third image by the first OCR discriminator, and generating a second OCR loss value of a second loss function in the second OCR discriminator based on the recognition of the text in the real image and the first image by the second OCR discriminator comprises:

[0026] The parameters of the generator are fixed, and the text in the third image is marked as real text in the real domain and then transmitted to the first OCR discriminator, and the real and fake text in the marked third image are identified to generate a first recognition result;

[0027] Based on the first OCR discriminator, distinguish and recognize the text in the simulation image and the third image to generate a second recognition result, and generate a first OCR loss value of a first loss function in the first OCR discriminator according to the first recognition result and the second recognition result;

[0028] Marking the text in the first image as simulated text in the real domain and transmitting it to the second OCR discriminator, performing true and false recognition on the marked text in the first image, and generating a third recognition result;

[0029] Based on the second OCR discriminator, the text in the real image and the first image is distinguished and recognized to generate a fourth recognition result, and according to the third recognition result and the fourth recognition result, a second OCR loss value of the second loss function in the second OCR discriminator is generated.

[0030] Optionally, the step of optimizing the training of the generator according to the simulated image and the second image, the real image and the fourth image includes:

[0031] The parameters in the discriminator are fixed, and a distance function value of a distance loss function in the generator is determined according to the similarity between the simulated image and the second image, and the similarity between the real image and the fourth image;

[0032] Determine whether the distance function value is less than a preset distance threshold, and if so, complete the optimization training of the generator;

[0033] If it is not less than a preset distance threshold, the generator is optimized and trained based on the first true and false discriminator, the second true and false discriminator, the first OCR discriminator and the second OCR discriminator.

[0034] Optionally, the step of optimizing the generator based on the first true and false discriminator, the second true and false discriminator, the first OCR discriminator and the second OCR discriminator includes:

[0035] The first image is transmitted to a second true-false discriminator for processing to obtain a first gradient, and the text in the first image is recognized based on the second OCR discriminator to obtain a second gradient;

[0036] The first gradient and the second gradient are transmitted to a generator to update parameters in the generator, and the generator is called to process the simulated image and the real image respectively to generate a first image and a second image corresponding to the simulated image;

[0037] The third image is transmitted to the first true-false discriminator for processing to obtain a third gradient, and the text in the third image is recognized based on the first OCR discriminator to obtain a fourth gradient;

[0038] The third gradient and the fourth gradient are transmitted to the generator to update the parameters in the generator, and the generator is called to process the simulated image and the real image respectively to generate a third image and a fourth image corresponding to the real image, so as to optimize the training of the generator.

[0039] Optionally, the step of transmitting the first image to a second true-false discriminator for processing to obtain a first gradient, and recognizing text in the first image based on the second OCR discriminator to obtain a second gradient includes:

[0040] Marking the first image as real and transmitting it to a second true-false discriminator for identification to generate a first gradient;

[0041] The text in the first image is marked as real text and then transmitted to the second OCR discriminator for recognition to generate a second gradient.

[0042] Optionally, before the step of calling the generator to process the simulated image and the real image respectively, the method includes:

[0043] Obtaining random noise, and encoding the random noise to generate a noise code;

[0044] Based on the noise layer to be added of the generator, converting the noise encoding into a scale factor and an offset factor, and generating style noise according to the scale factor and the offset factor;

[0045] The style noise is added to each of the noise layers to be added.

[0046] Furthermore, in order to achieve the above object, the present invention also provides a picture generating device, the picture generating device comprising:

[0047] A first calling module, used for calling a generator to process the simulated image and the real image respectively, and generating a first image and a second image corresponding to the simulated image, and a third image and a fourth image corresponding to the real image;

[0048] A training module, used for optimizing the training of the generator according to the simulated image and the second image, the real image and the fourth image;

[0049] A second calling module is used to call a discriminator to distinguish the real picture and the first picture, and the third picture and the simulated picture respectively, and optimize the discriminator based on the discrimination results;

[0050] A generation module is used to obtain a target generator after the generator and the discriminator are trained, so as to process the received images to be processed based on the target generator to generate multiple final images.

[0051] Furthermore, to achieve the above-mentioned purpose, the present invention also provides a picture generating device, which includes a memory, a processor, and a picture generating program stored in the memory and executable on the processor, and the picture generating program, when executed by the processor, implements the steps of the picture generating method as described above.

[0052] Furthermore, to achieve the above-mentioned purpose, the present invention also provides a readable storage medium, on which a picture generation program is stored, and when the picture generation program is executed by a processor, the steps of the picture generation method as described above are implemented.

[0053] The picture generation method of the present invention is provided with a mechanism for generating multiple pictures containing uncommon characters based on a target generator obtained by training a generator and a discriminator. First, a real picture carrying uncommon characters is generated as a simulated picture, and then the generator is called to process the simulated picture to generate a first picture and a second picture, and the generator is called to process the real picture to generate a third picture and a fourth picture; then, the generator is optimized and trained according to the simulated picture and the second picture, and the real picture and the fourth picture; at the same time, the discriminator is called to distinguish the real picture and the first picture, and the third picture and the simulated picture respectively, and the discriminator is optimized and trained according to the discrimination results; after the training of the generator and the discriminator is completed, the target generator is obtained. Thereafter, the picture to be processed for generating the uncommon character picture is obtained, and it is processed by the target generator to generate multiple final pictures containing uncommon characters. Because the generator can add various types of style noise, the randomness of the trained target generator is increased, and a better transformation effect is achieved; at the same time, the discriminator can identify and compare the text in the picture, which is beneficial to the accuracy and controllability of the trained target generator. Therefore, the final image containing uncommon characters generated by the target generator takes into account randomness, controllability and accuracy, and realizes the rapid and accurate generation of a large number of final images containing uncommon characters. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] Figure 1 A schematic diagram of the structure of the device hardware operating environment involved in the embodiment of the image generation device of the present invention;

[0055] Figure 2 This is a schematic diagram of the process of the first embodiment of the image generation method of the present invention;

[0056] Figure 3 A schematic diagram of functional modules of a preferred embodiment of the image generating device of the present invention;

[0057] Figure 4 A schematic diagram of the training process of a specific embodiment of the image generation solution of the present invention.

[0058] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0059] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0060] The present invention provides a picture generating device, referring to Figure 1 , Figure 1 This is a schematic diagram of the structure of the device hardware operating environment involved in the embodiment of the image generation device of the present invention.

[0061] like Figure 1 As shown, the image generation device may include: a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or it may be a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0062] Those skilled in the art will understand that Figure 1 The hardware structure of the image generating device shown in the figure does not constitute a limitation on the image generating device, and may include more or fewer components than shown in the figure, or a combination of certain components, or a different arrangement of components.

[0063] like Figure 1 As shown, the memory 1005 as a readable storage medium may include an operating system, a network communication module, a user interface module, and a picture generation program. The operating system is a program for managing and controlling the picture generation device and software resources, and supports the operation of the network communication module, the user interface module, the picture generation program, and other programs or software; the network communication module is used to manage and control the network interface 1004; the user interface module is used to manage and control the user interface 1003.

[0064] exist Figure 1In the hardware structure of the picture generation device shown, the network interface 1004 is mainly used to connect to the background server and communicate data with the background server; the user interface 1003 is mainly used to connect to the client (user end) and communicate data with the client; the processor 1001 can call the picture generation program stored in the memory 1005 and perform the following operations:

[0065] Calling a generator to process the simulated image and the real image respectively, generating a first image and a second image corresponding to the simulated image, and a third image and a fourth image corresponding to the real image;

[0066] Optimizing and training the generator according to the simulated image and the second image, the real image and the fourth image;

[0067] Calling a discriminator to distinguish the real image and the first image, and the third image and the simulated image respectively, and optimizing and training the discriminator based on the distinction results;

[0068] After the generator and the discriminator are trained, a target generator is obtained to process the received images to be processed based on the target generator to generate multiple final images.

[0069] Further, the discriminator includes a first true-false discriminator and a second true-false discriminator, and the first discrimination result includes a second true-false loss value;

[0070] The steps of calling the discriminator to distinguish the real picture and the first picture, and the third picture and the simulated picture respectively, and optimizing and training the discriminator based on the distinction results include:

[0071] Based on the second true and false discriminator, the real image and the first image are distinguished to generate a second true and false loss value of the second cross entropy loss function in the second true and false discriminator, and based on the first true and false discriminator, the third image and the simulated image are distinguished to generate a first true and false loss value of the first cross entropy loss function in the first true and false discriminator;

[0072] The discriminator is optimized and trained according to the first true and false loss value and the second true and false loss value.

[0073] Further, the step of distinguishing the real image and the first image based on the second true and false discriminator to generate a second true and false loss value of the second cross entropy loss function in the second true and false discriminator, and distinguishing the third image and the simulated image based on the first true and false discriminator to generate a first true and false loss value of the first cross entropy loss function in the first true and false discriminator includes:

[0074] The parameters of the generator are fixed, and the first image is marked as a pseudo-domain image and then transmitted to a second true-false discriminator, and the true-false discrimination is performed on the marked first image to generate a first discrimination result;

[0075] Based on the second true-false discriminator, distinguish the real image from the first image to generate a second discrimination result, and generate a second true-false loss value of the second cross entropy loss function in the second true-false discriminator according to the first discrimination result and the second discrimination result;

[0076] Marking the third image as a real domain image and transmitting it to the first true-false discriminator, performing true-false discrimination on the marked third image to generate a third discrimination result;

[0077] Based on the first true and false discriminator, the third image and the simulated image are distinguished and discriminated to generate a fourth discrimination result, and according to the third discrimination result and the fourth discrimination result, a first true and false loss value of the first cross entropy loss function in the first true and false discriminator is generated.

[0078] Furthermore, the discriminator further includes a first OCR discriminator and a second OCR discriminator, and the step of optimizing and training the discriminator according to the first true and false loss value and the second true and false loss value includes:

[0079] Based on the first OCR discriminator recognizing the text in the simulated image and the third image, a first OCR loss value of a first loss function in the first OCR discriminator is generated, and based on the second OCR discriminator recognizing the text in the real image and the first image, a second OCR loss value of a second loss function in the second OCR discriminator is generated;

[0080] Determine whether the first true-false loss value and the second true-false loss value are both less than a preset cross-entropy threshold, and whether the first OCR loss value and the second OCR loss value are both less than a preset function threshold;

[0081] If the first true-false loss value and the second true-false loss value are both less than a preset cross-entropy threshold, and the first OCR loss value and the second OCR loss value are both less than a preset function threshold, the training of the discriminator is completed;

[0082] If any one of the first true-false loss value and the second true-false loss value is not less than a preset cross-entropy threshold, or any one of the first OCR loss value and the second OCR loss value is not less than a preset function threshold, the step of calling the generator to process the simulated image and the real image respectively to generate a first image and a second image corresponding to the simulated image is executed to optimize the training of the discriminator.

[0083] Further, the step of generating a first OCR loss value of a first loss function in the first OCR discriminator based on identifying the text in the simulated image and the third image by the first OCR discriminator, and generating a second OCR loss value of a second loss function in the second OCR discriminator based on identifying the text in the real image and the first image by the second OCR discriminator includes:

[0084] The parameters of the generator are fixed, and the text in the third image is marked as real text in the real domain and then transmitted to the first OCR discriminator, and the real and fake text in the marked third image are identified to generate a first recognition result;

[0085] Based on the first OCR discriminator, distinguish and recognize the text in the simulation image and the third image to generate a second recognition result, and generate a first OCR loss value of a first loss function in the first OCR discriminator according to the first recognition result and the second recognition result;

[0086] Marking the text in the first image as simulated text in the real domain and transmitting it to the second OCR discriminator, performing true and false recognition on the marked text in the first image, and generating a third recognition result;

[0087] Based on the second OCR discriminator, the text in the real image and the first image is distinguished and recognized to generate a fourth recognition result, and according to the third recognition result and the fourth recognition result, a second OCR loss value of the second loss function in the second OCR discriminator is generated.

[0088] Furthermore, the step of optimizing the training of the generator according to the simulated image and the second image, the real image and the fourth image includes:

[0089] The parameters in the discriminator are fixed, and a distance function value of a distance loss function in the generator is determined according to the similarity between the simulated image and the second image, and the similarity between the real image and the fourth image;

[0090] Determine whether the distance function value is less than a preset distance threshold, and if so, complete the optimization training of the generator;

[0091] If it is not less than a preset distance threshold, the generator is optimized and trained based on the first true and false discriminator, the second true and false discriminator, the first OCR discriminator and the second OCR discriminator.

[0092] Furthermore, the step of optimizing and training the generator based on the first true and false discriminator, the second true and false discriminator, the first OCR discriminator and the second OCR discriminator includes:

[0093] The first image is transmitted to a second true-false discriminator for processing to obtain a first gradient, and the text in the first image is recognized based on the second OCR discriminator to obtain a second gradient;

[0094] The first gradient and the second gradient are transmitted to a generator to update parameters in the generator, and the generator is called to process the simulated image and the real image respectively to generate a first image and a second image corresponding to the simulated image;

[0095] The third image is transmitted to the first true-false discriminator for processing to obtain a third gradient, and the text in the third image is recognized based on the first OCR discriminator to obtain a fourth gradient;

[0096] The third gradient and the fourth gradient are transmitted to the generator to update the parameters in the generator, and the generator is called to process the simulated image and the real image respectively to generate a third image and a fourth image corresponding to the real image, so as to optimize the training of the generator.

[0097] Furthermore, the step of transmitting the first image to the second true-false discriminator for processing to obtain a first gradient, and recognizing text in the first image based on the second OCR discriminator to obtain a second gradient includes:

[0098] Marking the first image as real and transmitting it to a second true-false discriminator for identification to generate a first gradient;

[0099] The text in the first image is marked as real text and then transmitted to the second OCR discriminator for recognition to generate a second gradient.

[0100] Furthermore, before the step of calling the generator to process the simulated image and the real image respectively, the processor 1001 may call the image generation program stored in the memory 1005 and perform the following operations:

[0101] Obtaining random noise, and encoding the random noise to generate a noise code;

[0102] Based on the noise layer to be added of the generator, converting the noise encoding into a scale factor and an offset factor, and generating style noise according to the scale factor and the offset factor;

[0103] The style noise is added to each of the noise layers to be added.

[0104] The specific implementation of the image generation device of the present invention is basically the same as the embodiments of the image generation method described below, and will not be repeated here.

[0105] The invention also provides a picture generating method.

[0106] Reference Figure 2 , Figure 2 Schematic diagram of the process of the first embodiment of the image generation method of the present invention.

[0107] The embodiment of the present invention provides an embodiment of a method for generating an image. It should be noted that although a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than that shown here. Specifically, the method for generating an image in this embodiment includes:

[0108] Step S10, calling a generator to process the simulated image and the real image respectively, generating a first image and a second image corresponding to the simulated image, and a third image and a fourth image corresponding to the real image;

[0109] Step S20, optimizing and training the generator according to the simulated image and the second image, the real image and the fourth image;

[0110] The image generation method in this embodiment is applied to a server, which includes a trained target generator, and is suitable for generating multiple final images containing rare characters through the target generator. The target generator is generated by training a generator and a discriminator, and both the generator and the discriminator exist in the form of a neural network model, which together constitute an overall model. The target generator is a sub-model in the overall model, and the sub-model is obtained by training the overall model.

[0111] During the training process, first obtain real pictures with uncommon characters from the training set, and then read the text labels carried by the real pictures. The text labels are labels set for the uncommon characters in each real picture, which are used to indicate the content of the uncommon characters, that is, which uncommon characters are specifically contained in the real picture. Thereafter, according to the size requirements in the pre-set generation rules, obtain a background picture that meets the size requirements, and add the uncommon characters represented by the text labels in the real picture to the background picture to generate a simulated picture. The real picture and the simulated picture can also be formed into a real-simulated picture pair to reflect the corresponding relationship between the two, which is convenient for tracking during the training process.

[0112] Furthermore, based on the generated real pictures and simulated pictures, the generator and discriminator in the overall model are trained to obtain the target generator. The generator is used to generate multiple pictures from real pictures and simulated pictures, and the discriminator is used to distinguish the pictures generated by the generator from the original pictures, where the original pictures are real pictures or simulated pictures used to generate pictures. If the discriminator has difficulty distinguishing the generated pictures from the original pictures, it means that the higher the similarity between the pictures generated by the generator and the original pictures, the closer the generated pictures containing uncommon characters are to the real pictures containing uncommon characters, so that the training can be iterated cyclically to obtain the target generator.

[0113] Furthermore, before the generator generates multiple images from real images or simulated images containing rare characters, it first adds style noise to the generator to ensure the randomness of the images generated by the generator. Style noise represents the influence of the external environment on the image presentation effect, such as light, color, etc. Specifically, before calling the generator to process the simulated image and the real image separately, it also includes:

[0114] Step a1, obtaining random noise, and encoding the random noise to generate a noise code;

[0115] Step a2, based on the noise layer to be added of the generator, converting the noise encoding into a scale factor and an offset factor, and generating style noise according to the scale factor and the offset factor;

[0116] Step a3: adding the style noise to each of the noise layers to be added.

[0117] Furthermore, random noise is generated by a preset noise generation function. After the generated random noise is obtained, it is encoded by a deep neural network to generate a noise code. Thereafter, the backbone network layer to which noise needs to be added in the generator is used as the noise layer to be added, and the noise code is converted into a scale factor and an offset factor in the noise layer to be added. The noise layer to be added includes at least an upsampling layer and a ResNet block. The hidden layer of the backbone network as the noise layer to be added is first normalized, multiplied by the scale factor, and then the offset factor is added to generate style noise to be added to the noise layer to be added of the style generator. Because the generator adds style noise to each upsampling layer and block, it is equivalent to applying style noise at different scale levels, which is conducive to the randomness of the generated image.

[0118] Furthermore, in order to ensure the consistency between the picture generated by the generator based on the real picture or the simulated picture and the original picture, the generator of this embodiment includes a first generator and a second generator, the first generator is used to generate a fake picture as a real picture, and the second generator is used to generate a real picture as a fake picture. The generation performance of the first generator and the second generator is optimized by combining the generation of the first generator with the restoration of the second generator. Specifically, the steps of calling the generator to process the simulated picture and the real picture respectively, generating the first picture and the second picture corresponding to the simulated picture, and the third picture and the fourth picture corresponding to the real picture include:

[0119] Step S11, generating a first picture from the simulation picture based on a first generator, and generating a second picture from the first picture based on a second generator;

[0120] Step S12: Generate a third picture from the real picture based on the second generator, and generate a fourth picture from the third picture based on the first generator.

[0121] Furthermore, the simulated image is processed by the first generator to generate the first image, and then the second image is processed by the second generator to obtain the second image. Since the function of the first generator is to generate a fake image into a real image, and the function of the second generator is to generate a real image into a fake image, the first image obtained by the simulated image through the first generator represents the effect of the first generator generating a real image, and the second image obtained by the first image through the second generator represents the effect of the second generator restoring the fake image. In this way, the processing performance of the first generator and the second generator from fake to real to fake is trained by the similarity between the second image generated by the generation and restoration process and the simulated image, so as to achieve the optimization training of the generator. At the same time, the real image is processed by the second generator to generate a third image, which represents the effect of the second generator generating a fake image, and the third image is processed by the first generator to obtain a fourth image, which represents the effect of the first generator restoring the real image. In this way, by comparing the similarity between the fourth image generated by the generation and restoration process and the real image, the second generator and the first generator are trained to perform image processing from true to false to true, thereby achieving optimized training of the generator.

[0122] Step S30, calling a discriminator to distinguish the real picture and the first picture, and the third picture and the simulated picture respectively, and optimizing and training the discriminator based on the distinction results;

[0123] Furthermore, after the generator generates the simulated image as the first image and the second image, and generates the real image as the third image and the fourth image, the discriminator is called to distinguish the real image from the first image, and to distinguish the third image from the simulated image, and to generate respective distinction results to characterize the distinction between the real image and the second image by the discriminator, and the distinction between the simulated image and the third image. Corresponding to the first generator and the second generator, the discriminator includes a first true-false discriminator and a second true-false discriminator. The first true-false discriminator is used to distinguish the image generated by the second generator from the original image, and the second true-false discriminator is used to distinguish the image generated by the first generator from the original image; the effect of the image generated by the generator is characterized by the difficulty of distinction. The more difficult it is to distinguish, the closer the generated image is to the original image, and the better the effect of the image generated by the generator. Specifically, the steps of calling the discriminator to distinguish the real image from the first image, and the third image from the simulated image, respectively, and optimizing the training of the discriminator based on the distinction results include:

[0124] Step S31, based on the second true and false discriminator, the real picture and the first picture are discriminated, and a second true and false loss value of the second cross entropy loss function in the second true and false discriminator is generated, and based on the first true and false discriminator, the third picture and the simulated picture are discriminated, and a first true and false loss value of the first cross entropy loss function in the first true and false discriminator is generated;

[0125] Step S32: Optimize and train the discriminator according to the first true and false loss value and the second true and false loss value.

[0126] Furthermore, the first generator transmits the generated first image to the second true-false discriminator, and the second true-false discriminator discriminates the first image and the real image to generate a discrimination result, and generates a second true-false loss value of the second cross-entropy loss function in the second true-false discriminator based on the discrimination result. The second cross-entropy loss function characterizes the accuracy of the second true-false discriminator in discriminating the first image and the real image. The smaller the second true-false loss value, the higher the discrimination accuracy. At the same time, the second generator transmits the generated third image to the first true-false discriminator, and the first true-false discriminator discriminates the third image and the simulated image to generate a discrimination result, and generates a first true-false loss value of the first cross-entropy loss function in the first true-false discriminator based on the discrimination result. The first cross-entropy loss function characterizes the accuracy of the first true-false discriminator in discriminating the third image and the simulated image. The smaller the first true-false loss value, the higher the discrimination accuracy.

[0127] Furthermore, when the magnitude of the first true-false loss value and the second true-false loss value do not meet the requirements, indicating that the discrimination accuracy of the first true-false discriminator and the second true-false discriminator is not high, it is necessary to continue training the first true-false discriminator and the second true-false discriminator. That is, the discriminator is optimized and trained according to the magnitude of the first true-false loss value and the second true-false loss value.

[0128] Understandably, the real picture contains uncommon characters, and the simulated picture is generated based on the uncommon characters in the real picture, so that the first picture obtained by processing the simulated picture by the first generator also contains uncommon characters, and the third picture obtained by processing the real picture by the second generator also contains uncommon characters. In order to ensure the accuracy of the uncommon characters generated in the first picture and the third picture, the discriminator in this embodiment also includes a first OCR (Optical Character Recognition) discriminator and a second OCR discriminator. The first OCR discriminator is used to compare and identify the text in the simulated picture and the third picture, and the second OCR discriminator is used to compare and identify the text in the real picture and the first picture; the effect of the picture text generated by the generator is characterized by the accuracy of recognition. The higher the recognition accuracy, the closer the generated picture text is to the original picture text, and the better the effect of the picture text generated by the generator. The quality of the discriminator's own discrimination effect is related to the first true and false discriminator, the second true and false discriminator, the first OCR discriminator and the second OCR discriminator, and it is necessary to combine the loss functions of the four to train together. Specifically, according to the first true and false loss value and the second true and false loss value, the step of optimizing the training of the discriminator includes:

[0129] Step S321, based on the first OCR discriminator identifying the text in the simulated image and the third image, generating a first OCR loss value of the first loss function in the first OCR discriminator, and based on the second OCR discriminator identifying the text in the real image and the first image, generating a second OCR loss value of the second loss function in the second OCR discriminator;

[0130] Step S322, determining whether the first true-false loss value and the second true-false loss value are both less than a preset cross-entropy threshold, and whether the first OCR loss value and the second OCR loss value are both less than a preset function threshold;

[0131] Step S323: If the first true-false loss value and the second true-false loss value are both smaller than a preset cross-entropy threshold, and the first OCR loss value and the second OCR loss value are both smaller than a preset function threshold, the training of the discriminator is completed;

[0132] Step S324: If any one of the first true-false loss value and the second true-false loss value is not less than a preset cross-entropy threshold, or any one of the first OCR loss value and the second OCR loss value is not less than a preset function threshold, then the step of calling the generator to process the simulated image and the real image respectively to generate a first image and a second image corresponding to the simulated image is executed to optimize the training of the discriminator.

[0133] Furthermore, the text in the simulated image and the text in the third image are recognized by the first OCR discriminator to generate a recognition result, and a first OCR loss value of the first loss function in the first OCR discriminator is generated based on the recognition result. The first loss function represents the accuracy of the first OCR discriminator in recognizing the text in the simulated image and the text in the third image. The smaller the first OCR loss value, the higher the recognition accuracy. At the same time, the text in the real image and the text in the first image are recognized by the second OCR discriminator to generate a recognition result, and a second OCR loss value of the second loss function in the second OCR discriminator is generated based on the recognition result. The second loss function represents the accuracy of the second OCR discriminator in recognizing the text in the real image and the text in the first image. The smaller the second OCR loss value, the higher the recognition accuracy.

[0134] Furthermore, when the magnitude of the first OCR loss value and the second OCR loss value do not meet the requirements, indicating that the recognition accuracy of the first OCR discriminator and the second OCR discriminator is not high, it is necessary to continue training the first OCR discriminator and the second OCR discriminator. That is, the discriminator is optimized and trained according to the magnitude of the first OCR loss value and the second OCR loss value.

[0135] Since the performance of the discriminator is related to the first true and false discriminator, the second true and false discriminator, the first OCR discriminator and the second OCR discriminator, in order to determine the quality of the discriminant performance of the discriminator, a preset cross entropy threshold characterizing the discrimination performance of the first true and false discriminator and the second true and false discriminator, and a preset function threshold characterizing the performance of the first OCR discriminator and the second OCR discriminator are pre-set. The first true and false loss value and the second true and false loss value are respectively compared with the preset cross entropy threshold to determine whether the first true and false loss value and the second true and false loss value are both less than the preset cross entropy threshold; at the same time, the first OCR loss value and the second OCR loss value are respectively compared with the preset function threshold to determine whether the first OCR loss value and the second OCR loss value are both less than the preset function threshold. If the first true and false loss value and the second true and false loss value are both less than the preset cross entropy threshold, and the first OCR loss value and the second true and false loss value are both less than the preset function threshold, it means that the first true and false discriminator, the second true and false discriminator, the first OCR discriminator and the second OCR discriminator all have good performance, and the discriminator has good discrimination ability, thereby completing the training of the discriminator. On the contrary, if any one of the first true and false loss value and the second true and false loss value is not less than the preset cross entropy threshold, or any one of the first OCR loss value and the second OCR loss value is not less than the preset function threshold, that is, any one of the first true and false discriminator, the second true and false discriminator, the first OCR discriminator and the second OCR discriminator has a performance that does not meet the requirements, indicating that the performance of the discriminator does not meet the requirements, and it is necessary to continue to optimize the training. Each training starts with generating a simulated image as the first image, and the simulated image and the real image are processed separately by the generator to generate the first image and the second image corresponding to the simulated image. The training is repeated in this way until the first true-false loss value and the second true-false loss value are both less than the preset cross-entropy threshold, and the first OCR loss value and the second OCR loss value are both less than the preset function threshold, indicating that the performance of the discriminator meets the requirements and the training of the discriminator is completed.

[0136] Furthermore, after the generator including the first generator and the second generator, and the discriminator including the first true and false discriminator, the second true and false discriminator, the first OCR discriminator and the second OCR discriminator are all trained, the first generator is formed into a target generator to generate multiple pictures corresponding to real pictures containing uncommon characters through the target generator.

[0137] Step S40, after the generator and the discriminator are trained, a target generator is obtained to process the received image to be processed based on the target generator to generate multiple final images.

[0138] Furthermore, after the generator and the discriminator are trained and the target generator is obtained, the target generator can be used to generate the final image containing the rare characters, and the original image used to generate the rare character image is received and used as the image to be processed. According to the pre-set generation rules, the image to be processed is generated as a simulated image, and then the simulated image is transmitted to the target generator, and processed by the target generator to generate multiple rare character images for model training, so as to form a rare character recognition model and recognize the rare characters in various files.

[0139] Please refer to Figure 4 In a specific embodiment, style generator A is the first generator, style generator B is the second generator, true and false discriminator A is the first true and false discriminator, true and false discriminator B is the second true and false discriminator, OCR discriminator A is the first OCR discriminator, and OCR discriminator B is the second OCR discriminator. The real picture B is a real picture with rare characters, and the simulated picture A is a simulated picture generated by the real picture B through a pre-set generation rule; A* is the first picture, A** is the second picture, B* is the third picture, and B** is the fourth picture. Through the similarity between A and A**, and the similarity between B and B**, the generator including style generator A and style generator B is optimized and trained; at the same time, the true and false discriminator B and OCR discriminator B are optimized and trained through B and A*, and the true and false discriminator A and OCR discriminator A are optimized and trained through A and B*. In this way, the optimized training of the generator and the discriminator is achieved, and the trained style generator A is obtained as the target generator, and then multiple final pictures containing uncommon characters are generated through the target generator.

[0140] The picture generation method of the present invention is provided with a mechanism for generating multiple pictures containing uncommon characters based on a target generator obtained by training a generator and a discriminator. First, a real picture carrying uncommon characters is generated as a simulated picture, and then the generator is called to process the simulated picture to generate a first picture and a second picture, and the generator is called to process the real picture to generate a third picture and a fourth picture; then, the generator is optimized and trained according to the simulated picture and the second picture, and the real picture and the fourth picture; at the same time, the discriminator is called to distinguish the real picture and the first picture, and the third picture and the simulated picture respectively, and the discriminator is optimized and trained according to the discrimination results; after the training of the generator and the discriminator is completed, the target generator is obtained. Thereafter, the picture to be processed for generating the uncommon character picture is obtained, and it is processed by the target generator to generate multiple final pictures containing uncommon characters. Because the generator can add various types of style noise, the randomness of the trained target generator is increased, and a better transformation effect is achieved; at the same time, the discriminator can identify and compare the text in the picture, which is beneficial to the accuracy and controllability of the trained target generator. Therefore, the final image containing uncommon characters generated by the target generator takes into account randomness, controllability and accuracy, and realizes the rapid and accurate generation of a large number of final images containing uncommon characters.

[0141] Furthermore, based on the first embodiment of the image generating method of the present invention, a second embodiment of the image generating method of the present invention is proposed.

[0142] The difference between the second embodiment of the image generation method and the first embodiment of the image generation method is that the steps of distinguishing the real image and the first image based on the second true and false discriminator to generate a second true and false loss value of the second cross entropy loss function in the second true and false discriminator, and distinguishing the third image and the simulated image based on the first true and false discriminator to generate a first true and false loss value of the first cross entropy loss function in the first true and false discriminator include:

[0143] Step S311, the parameters of the generator are fixed, and the first image is marked as a pseudo-domain image and then transmitted to the second true-false discriminator, and the true-false discrimination is performed on the marked first image to generate a first discrimination result;

[0144] Step S312, distinguishing the real image and the first image based on the second true-false discriminator to generate a second discrimination result, and generating a second true-false loss value of a second cross entropy loss function in the second true-false discriminator according to the first discrimination result and the second discrimination result;

[0145] Step S313, marking the third image as a real domain image and transmitting it to the first true-false discriminator, performing true-false discrimination on the marked third image to generate a third discrimination result;

[0146] Step S314: distinguish and discriminate the third image from the simulated image based on the first true-false discriminator to generate a fourth discrimination result, and generate a first true-false loss value of the first cross entropy loss function in the first true-false discriminator based on the third discrimination result and the fourth discrimination result.

[0147] This embodiment optimizes the first true-false discriminator and the second true-false discriminator, and the optimization includes at least two parts, one is to accurately distinguish the authenticity of a picture, and the other is to accurately distinguish two similar pictures. During the optimization process, the parameters of the generator are set to be fixed; for the authenticity of the picture, a pseudo-domain mark is added to the first picture, and the first picture is marked as a pseudo-domain picture and then transmitted to the second true-false discriminator, and the authenticity of the first picture after the mark is distinguished by the second true-false discriminator to generate a first identification result. For the accurate distinction of similar pictures, the real picture and the second picture are transmitted to the second true-false discriminator for distinction and identification, and a second identification result is generated. Then, based on the first identification result and the second identification result, a second true-false loss value of the second cross entropy loss function in the second true-false discriminator is generated. Through the second true-false loss value, the second true-false discriminator is cyclically optimized in terms of authenticity and similarity.

[0148] At the same time, for the first true-false discriminator, add a true domain mark to the third image, mark the third image as a true domain image and transmit it to the first true-false discriminator, and use the first true-false discriminator to distinguish the authenticity of the marked third image to generate a third identification result. At the same time, the third image and the simulated image are transmitted to the first true-false discriminator for distinction and identification to generate a fourth identification result. Then, based on the third identification result and the fourth identification result, the first true-false loss value of the first cross entropy loss function in the first true-false discriminator is generated. The first true-false loss value is used to perform cyclic optimization on the first true-false discriminator in terms of true-false identification and similarity identification.

[0149] This embodiment optimizes the first true and false discriminator by the first true and false loss value of the first cross entropy loss function in the first true and false discriminator, and optimizes the second true and false discriminator by the second true and false loss value of the second cross entropy loss function in the second true and false discriminator, so that the recognition of true and false images and similar images is more accurate.

[0150] Furthermore, based on the first or second embodiment of the image generating method of the present invention, a third embodiment of the image generating method of the present invention is proposed.

[0151] The difference between the third embodiment of the image generation method and the first or second embodiment of the image generation method is that the steps of generating a first OCR loss value of a first loss function in the first OCR discriminator based on the first OCR discriminator recognizing the text in the simulated image and the third image, and generating a second OCR loss value of a second loss function in the second OCR discriminator based on the second OCR discriminator recognizing the text in the real image and the first image include:

[0152] Step b1, fixing the parameters of the generator, marking the text in the third image as real text in the real domain and transmitting it to the first OCR discriminator, performing true and false identification on the marked text in the third image, and generating a first recognition result;

[0153] Step b2, distinguishing and identifying the text in the simulation image and the third image based on the first OCR discriminator, generating a second recognition result, and generating a first OCR loss value of a first loss function in the first OCR discriminator according to the first recognition result and the second recognition result;

[0154] Step b3, marking the text in the first image as simulated text of the real domain and transmitting it to the second OCR discriminator, performing true and false identification on the marked text in the first image, and generating a third recognition result;

[0155] Step b4: Based on the second OCR discriminator, distinguish and identify the text in the real image and the first image to generate a fourth recognition result, and generate a second OCR loss value of the second loss function in the second OCR discriminator based on the third recognition result and the fourth recognition result.

[0156] This embodiment optimizes the first OCR discriminator and the second OCR discriminator, and the optimization also includes two parts, one is to accurately identify the authenticity of the text in a picture, and the other is to accurately distinguish similar texts in different pictures. In the optimization process, the parameters of the generator are also set to be fixed, and the first loss function of the first OCR discriminator and the second loss function of the second OCR discriminator are set based on the CTC (Connectionist temporal classification) loss function. Among them, the CTC loss function is used to solve the decoding problem of indefinite length labels. Assuming that the size of the predicted character set is x, the input graph is represented as a sequence of length k in the last hidden layer of the neural network. Each position will predict a character or a blank character (the number of categories is x+1). The CTC algorithm will merge the same characters and generate a predicted string. The final string output by the model is the most likely, and the predicted string processed by the merge and the final output string are a many-to-one relationship. In this embodiment, based on the first loss function and the second loss function set by the CTC loss function, 2x+1 character predictions are made at each position of the k sequences, including 1 empty character, x real domain characters, and x corresponding pseudo domain characters. The difference between the real character and the pseudo character of the same character is x.

[0157] Furthermore, in this embodiment, for the first OCR discriminator, the true sample is the simulated image, the pseudo sample is the third image, and the first OCR discriminator should accurately discriminate the text of the simulated image in the true domain, and accurately discriminate the text of the third image in the pseudo domain. For the second OCR discriminator, the true sample is the real image, the pseudo sample is the first image, and the second OCR discriminator should accurately discriminate the text of the real image in the true domain, and accurately discriminate the text of the first image in the pseudo domain.

[0158] Furthermore, for the authenticity identification of the image text of the first OCR discriminator, a real text mark of the real domain is added to the text of the third image, that is, the text of the third image is marked as the real text of the real domain and then transmitted to the first OCR discriminator, and the authenticity of the text in the third image after the mark is identified by the first OCR discriminator to generate a first recognition result. For the recognition of similar text in different images, the simulated image and the third image are transmitted to the first OCR discriminator, and the first OCR discriminator segments the two according to the segmentation category to obtain multiple segmentation sub-images of the simulated image and multiple segmentation sub-images of the third image. The first OCR discriminator identifies the segmentation sub-images of the two to obtain a second recognition result. Among them, the second recognition result is composed of the recognition sub-results between each segmentation sub-image of the simulated image and each corresponding segmentation sub-image in the third image. The more accurate each recognition sub-result is, the more accurate the second recognition result is. Then, based on the first recognition result and the second recognition result, a first OCR loss value of a first loss function in the first OCR discriminator is generated; and the first OCR discriminator is cyclically optimized in terms of authenticity identification and similarity distinction of texts through the first OCR loss value.

[0159] Furthermore, for the authenticity identification of the image text by the second OCR discriminator, a simulated text mark of the real domain is added to the text in the first image, that is, the text of the first image is marked as simulated text of the real domain and then transmitted to the second OCR discriminator, and the authenticity of the text in the first image after the mark is identified by the second OCR discriminator to generate a third recognition result. For the identification of similar text in different images, the real image and the first image are transmitted to the second OCR discriminator, and the second OCR discriminator segments the two according to the segmentation category to obtain multiple segmentation sub-images of the real image and multiple segmentation sub-images of the first image. The second OCR discriminator identifies the segmentation sub-images of the two to obtain a fourth recognition result. Among them, the fourth recognition result is composed of the recognition sub-results between each segmentation sub-image of the real image and each corresponding segmentation sub-image in the first image. The more accurate each recognition sub-result is, the more accurate the fourth recognition result is. Then, based on the third recognition result and the fourth recognition result, a second OCR loss value of the second loss function in the second OCR discriminator is generated; and the second OCR discriminator is cyclically optimized in terms of authenticity identification and similarity distinction of texts through the second OCR loss value.

[0160] This embodiment optimizes the first OCR discriminator by the first OCR loss value of the first loss function in the first OCR discriminator, and optimizes the second OCR discriminator by the second OCR loss value of the second loss function in the second OCR discriminator, so that the recognition of true and false text and similar text in the picture is more accurate.

[0161] Furthermore, based on the first, second or third embodiment of the image generating method of the present invention, a fourth embodiment of the image generating method of the present invention is proposed.

[0162] The difference between the fourth embodiment of the picture generation method and the first, second or third embodiment of the picture generation method is that the step of optimizing and training the generator according to the simulated picture and the second picture, the real picture and the fourth picture includes:

[0163] Step S221, fixing the parameters in the discriminator, and determining the distance function value of the distance loss function in the generator according to the similarity between the simulated image and the second image, and the similarity between the real image and the fourth image;

[0164] Step S222, determining whether the distance function value is less than a preset distance threshold, if so, completing the optimization training of the generator;

[0165] Step S223: If the distance is not less than the preset distance threshold, the generator is optimized and trained based on the first true and false discriminator, the second true and false discriminator, the first OCR discriminator and the second OCR discriminator.

[0166] This embodiment optimizes and trains the generator. During the optimization process, the parameters in the discriminator are set to be fixed, and the similarity between the simulated image and the second image is determined by the Euclidean distance or the cosine distance to characterize the similarity between the second image obtained after the simulated image is processed by the first generator and the second generator and the simulated image before processing. The higher the similarity, the better the processing effect of the simulated image from fake-true-fake by the first generator and the second generator. At the same time, the similarity between the real image and the fourth image is determined by the Euclidean distance and the cosine distance to characterize the similarity between the fourth image obtained after the real image is processed by the second generator and the first generator and the real image before processing. The higher the similarity, the better the processing effect of the real image from true-false-true by the second generator and the first generator. Then, the clustering function value of the distance loss function in the generator is determined by the similarity between the simulated image and the second image, and the similarity between the real image and the fourth image. Among them, the distance loss function characterizes the processing performance of the generator. The higher the similarity, the smaller the distance function value of the distance loss function, and the better the processing performance of the generator.

[0167] Furthermore, in order to characterize the size of the distance function value, a preset distance threshold is pre-set, and the generated distance function value is compared with the preset distance threshold to determine whether the distance function value is less than the preset distance threshold. If it is less than the preset distance threshold, it is characterized that the processing performance of the generator meets the requirements and the optimization training of the generator is completed. If the clustering function value is not less than the preset distance threshold, it means that the processing performance of the generator still needs to be optimized, so the generator is optimized based on the first true and false discriminator, the second true and false discriminator, the first OCR discriminator and the second OCR discriminator. The training cycle continues until the distance function value of the distance loss function is less than the preset distance threshold, and the optimization training of the generator is completed. Specifically, the steps of optimizing the generator based on the first true and false discriminator, the second true and false discriminator, the first OCR discriminator and the second OCR discriminator include:

[0168] Step c1, transmitting the first image to a second true-false discriminator for processing to obtain a first gradient, and recognizing text in the first image based on the second OCR discriminator to obtain a second gradient;

[0169] Furthermore, the first image generated by the first generator is transmitted to the second true-false discriminator for discrimination processing, and the first gradient is obtained according to the result of the discrimination processing. At the same time, the text in the first image is recognized by the second OCR discriminator, and the second gradient is obtained according to the result of the recognition processing. Then, the generator is optimized by the generated first gradient and second gradient. Among them, the steps of transmitting the first image to the second true-false discriminator for processing to obtain the first gradient, and recognizing the text in the first image based on the second OCR discriminator to obtain the second gradient include:

[0170] Step c11, marking the first image as real and transmitting it to a second true-false discriminator for identification to generate a first gradient;

[0171] Step c12: Mark the text in the first image as real text and transmit it to the second OCR discriminator for recognition to generate a second gradient.

[0172] Step c2, transmitting the first gradient and the second gradient to a generator to update parameters in the generator, and executing the step of calling the generator to process the simulated image and the real image respectively to generate a first image and a second image corresponding to the simulated image;

[0173] Furthermore, a true mark is added to the first image, and the first image is marked as true and then transmitted to the second true-false discriminator, and the authenticity of the marked first image is discriminated by the second true-false discriminator, and the first gradient is generated according to the discrimination result. At the same time, a true text mark is added to the text in the first image, and the text in the first image is marked as true text and then transmitted to the second OCR discriminator, and the authenticity of the marked first image text is discriminated by the second OCR discriminator, and the second gradient is generated according to the recognition result.

[0174] Furthermore, the first gradient and the second gradient are transmitted to the first generator in the generator to update the parameters in the first generator, and after the update, the first generator generates the simulated image as the first image to continue training and optimizing the first generator.

[0175] Step c3, transmitting the third image to the first true-false discriminator for processing to obtain a third gradient, and recognizing the text in the third image based on the first OCR discriminator to obtain a fourth gradient;

[0176] Step c4, transmitting the third gradient and the fourth gradient to the generator to update the parameters in the generator, and executing the step of calling the generator to process the simulated image and the real image respectively to generate a third image and a fourth image corresponding to the real image, so as to optimize the training of the generator.

[0177] While optimizing the first generator in the generator, the second generator in the generator is optimized. Specifically, the third image generated by the second generator is transmitted to the first true-false discriminator for discrimination processing, and a third gradient is obtained based on the result of the discrimination processing. At the same time, the text in the third image is recognized by the first OCR discriminator, and a fourth gradient is obtained based on the result of the recognition processing. Then, the generator is optimized by the generated third gradient and fourth gradient. Among them, the steps of transmitting the third image to the first true-false discriminator for processing to obtain the third gradient, and recognizing the text in the third image based on the first OCR discriminator to obtain the fourth gradient include:

[0178] Step c31, marking the third image as simulated and transmitting it to the first true-false discriminator for discrimination to generate a third gradient;

[0179] Step c32: Mark the text in the third image as simulated text and transmit it to the first OCR discriminator for recognition to generate a fourth gradient.

[0180] Furthermore, a simulation mark is added to the third image, and the third image is marked as simulated and then transmitted to the first true-false discriminator, and the authenticity of the marked third image is discriminated by the first true-false discriminator, and a third gradient is generated according to the discrimination result. Simultaneously, a simulation text mark is added to the text in the first image, and the text in the first image is marked as simulated text and then transmitted to the first OCR discriminator, and the authenticity of the marked third image text is discriminated by the first OCR discriminator, and a fourth gradient is generated according to the recognition result.

[0181] Furthermore, the third gradient and the fourth gradient are transmitted to the second generator in the generator to update the parameters in the second generator, and after the update, the second generator generates the real picture as the third picture to continue to train and optimize the second generator. This implementation realizes the optimization training of the generator by optimizing the first generator and the second generator to improve the similarity between the first picture and the real picture, that is, the generated multiple final pictures containing uncommon characters are closer to the original generated pictures containing uncommon characters.

[0182] The invention also provides a picture generating device.

[0183] Reference Figure 3 , Figure 3 This is a functional module diagram of a first embodiment of a picture generation device of the present invention. The picture generation device comprises:

[0184] A first calling module 10 is used to call a generator to process the simulated image and the real image respectively, and generate a first image and a second image corresponding to the simulated image, and a third image and a fourth image corresponding to the real image;

[0185] A training module 20, configured to optimize the training of the generator according to the simulated image and the second image, the real image and the fourth image;

[0186] The second calling module 30 is used to call the discriminator to distinguish the real picture and the first picture, and the third picture and the simulated picture respectively, and optimize the discriminator based on the discrimination results;

[0187] The generation module 40 is used to obtain a target generator after the generator and the discriminator are trained, so as to process the received to-be-processed pictures based on the target generator to generate a plurality of final pictures.

[0188] Further, the generator includes a first generator and a second generator;

[0189] The second calling module 30 also includes:

[0190] A first generating unit is used to distinguish the real image and the first image based on the second true and false discriminator, generate a second true and false loss value of the second cross entropy loss function in the second true and false discriminator, and distinguish the third image and the simulated image based on the first true and false discriminator, and generate a first true and false loss value of the first cross entropy loss function in the first true and false discriminator;

[0191] The first training unit is used to optimize the training of the discriminator according to the first true and false loss value and the second true and false loss value.

[0192] Furthermore, the first generating unit is further used for:

[0193] The parameters of the generator are fixed, and the first image is marked as a pseudo-domain image and then transmitted to a second true-false discriminator, and the true-false discrimination is performed on the marked first image to generate a first discrimination result;

[0194] Based on the second true-false discriminator, distinguish the real image from the first image to generate a second discrimination result, and generate a second true-false loss value of the second cross entropy loss function in the second true-false discriminator according to the first discrimination result and the second discrimination result;

[0195] Marking the third image as a real domain image and transmitting it to the first true-false discriminator, performing true-false discrimination on the marked third image to generate a third discrimination result;

[0196] Based on the first true and false discriminator, the third image and the simulated image are distinguished and discriminated to generate a fourth discrimination result, and according to the third discrimination result and the fourth discrimination result, a first true and false loss value of the first cross entropy loss function in the first true and false discriminator is generated.

[0197] Furthermore, the discriminator further includes a first OCR discriminator and a second OCR discriminator, and the first training unit is further used for:

[0198] Based on the first OCR discriminator recognizing the text in the simulated image and the third image, a first OCR loss value of a first loss function in the first OCR discriminator is generated, and based on the second OCR discriminator recognizing the text in the real image and the first image, a second OCR loss value of a second loss function in the second OCR discriminator is generated;

[0199] Determine whether the first true-false loss value and the second true-false loss value are both less than a preset cross-entropy threshold, and whether the first OCR loss value and the second OCR loss value are both less than a preset function threshold;

[0200] If the first true-false loss value and the second true-false loss value are both less than a preset cross-entropy threshold, and the first OCR loss value and the second OCR loss value are both less than a preset function threshold, the training of the discriminator is completed;

[0201] If any one of the first true-false loss value and the second true-false loss value is not less than a preset cross-entropy threshold, or any one of the first OCR loss value and the second OCR loss value is not less than a preset function threshold, the step of calling the generator to process the simulated image and the real image respectively to generate a first image and a second image corresponding to the simulated image is executed to optimize the training of the discriminator.

[0202] Furthermore, the first training unit is also used for:

[0203] The parameters of the generator are fixed, and the text in the third image is marked as real text in the real domain and then transmitted to the first OCR discriminator, and the real and fake text in the marked third image are identified to generate a first recognition result;

[0204] Based on the first OCR discriminator, distinguish and recognize the text in the simulation image and the third image to generate a second recognition result, and generate a first OCR loss value of a first loss function in the first OCR discriminator according to the first recognition result and the second recognition result;

[0205] Marking the text in the first image as simulated text in the real domain and transmitting it to the second OCR discriminator, performing true and false recognition on the marked text in the first image, and generating a third recognition result;

[0206] Based on the second OCR discriminator, the text in the real image and the first image is distinguished and recognized to generate a fourth recognition result, and according to the third recognition result and the fourth recognition result, a second OCR loss value of the second loss function in the second OCR discriminator is generated.

[0207] Furthermore, the training module 20 also includes:

[0208] A determination unit, configured to fix the parameters in the discriminator, and determine the distance function value of the distance loss function in the generator according to the similarity between the simulated image and the second image, and the similarity between the real image and the fourth image;

[0209] A judging unit, used to judge whether the distance function value is less than a preset distance threshold, and if so, complete the optimization training of the generator;

[0210] A training unit is used to optimize the generator based on the first true and false discriminator, the second true and false discriminator, the first OCR discriminator and the second OCR discriminator if the distance is not less than a preset distance threshold.

[0211] Furthermore, the training unit is also used for:

[0212] The first image is transmitted to a second true-false discriminator for processing to obtain a first gradient, and the text in the first image is recognized based on the second OCR discriminator to obtain a second gradient;

[0213] The first gradient and the second gradient are transmitted to a generator to update parameters in the generator, and the generator is called to process the simulated image and the real image respectively to generate a first image and a second image corresponding to the simulated image;

[0214] The third image is transmitted to the first true-false discriminator for processing to obtain a third gradient, and the text in the third image is recognized based on the first OCR discriminator to obtain a fourth gradient;

[0215] The third gradient and the fourth gradient are transmitted to the generator to update the parameters in the generator, and the generator is called to process the simulated image and the real image respectively to generate a third image and a fourth image corresponding to the real image, so as to optimize the training of the generator.

[0216] Furthermore, the training unit is also used for:

[0217] Marking the first image as real and transmitting it to a second true-false discriminator for identification to generate a first gradient;

[0218] The text in the first image is marked as real text and then transmitted to the second OCR discriminator for recognition to generate a second gradient.

[0219] Furthermore, the image generating device further includes:

[0220] An acquisition module, used for acquiring random noise, and encoding the random noise to generate a noise code;

[0221] A conversion module, configured to convert the noise code into a scale factor and an offset factor based on the noise layer to be added of the generator, and generate style noise according to the scale factor and the offset factor;

[0222] An adding module is used to add the style noise to each of the noise layers to be added.

[0223] Furthermore, the first calling module 10 further includes:

[0224] A second generating unit is configured to generate a first picture from the simulated picture based on the first generator, generate a second picture from the first picture based on the second generator, generate a third picture from the real picture based on the second generator, and generate a fourth picture from the third picture based on the first generator;

[0225] The second training unit is used to optimize the training of the generator according to the simulated picture and the second picture, the real picture and the fourth picture.

[0226] The specific implementation of the image generation device of the present invention is basically the same as the embodiments of the above-mentioned image generation method, and will not be repeated here.

[0227] In addition, an embodiment of the present invention further provides a readable storage medium.

[0228] The readable storage medium stores a picture generation program, and when the picture generation program is executed by the processor, the steps of the picture generation method described above are implemented.

[0229] The readable storage medium of the present invention may be a computer-readable storage medium, and its specific implementation is substantially the same as that of the above-mentioned picture generation method embodiments, and will not be described in detail here.

[0230] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the enlightenment of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims. All equivalent structures or equivalent process changes made using the contents of the specification and drawings of the present invention, or directly or indirectly used in other related technical fields, are protected by the present invention.

Claims

1. A method for generating an image, characterized in that: The image generation method comprises the following steps: Calling a generator to process the simulated image and the real image respectively, generating a first image and a second image corresponding to the simulated image, and a third image and a fourth image corresponding to the real image; Optimizing and training the generator according to the simulated image and the second image, the real image and the fourth image; Calling a discriminator to distinguish the real image and the first image, and the third image and the simulated image respectively, and optimizing and training the discriminator based on the distinction results; After the generator and the discriminator are trained, a target generator is obtained to process the received to-be-processed pictures based on the target generator to generate a plurality of final pictures; The discriminator includes a first true-false discriminator and a second true-false discriminator; The steps of calling the discriminator to distinguish the real picture and the first picture, and the third picture and the simulated picture respectively, and optimizing and training the discriminator based on the distinction results include: Based on the second true and false discriminator, the real image and the first image are distinguished to generate a second true and false loss value of the second cross entropy loss function in the second true and false discriminator, and based on the first true and false discriminator, the third image and the simulated image are distinguished to generate a first true and false loss value of the first cross entropy loss function in the first true and false discriminator; Optimizing and training the discriminator according to the first true and false loss value and the second true and false loss value; The discriminator further includes a first OCR discriminator and a second OCR discriminator, and the step of optimizing the discriminator according to the first true and false loss value and the second true and false loss value includes: Based on the first OCR discriminator recognizing the text in the simulated image and the third image, a first OCR loss value of a first loss function in the first OCR discriminator is generated, and based on the second OCR discriminator recognizing the text in the real image and the first image, a second OCR loss value of a second loss function in the second OCR discriminator is generated; Determine whether the first true-false loss value and the second true-false loss value are both less than a preset cross-entropy threshold, and whether the first OCR loss value and the second OCR loss value are both less than a preset function threshold; If the first true-false loss value and the second true-false loss value are both less than a preset cross-entropy threshold, and the first OCR loss value and the second OCR loss value are both less than a preset function threshold, the training of the discriminator is completed; If any one of the first true-false loss value and the second true-false loss value is not less than a preset cross-entropy threshold, or any one of the first OCR loss value and the second OCR loss value is not less than a preset function threshold, the step of calling the generator to process the simulated image and the real image respectively to generate a first image and a second image corresponding to the simulated image is executed to optimize the training of the discriminator.

2. The image generation method according to claim 1, characterized in that: The steps of distinguishing the real image and the first image based on the second true-false discriminator to generate a second true-false loss value of the second cross entropy loss function in the second true-false discriminator, and distinguishing the third image and the simulated image based on the first true-false discriminator to generate a first true-false loss value of the first cross entropy loss function in the first true-false discriminator include: The parameters of the generator are fixed, and the first image is marked as a pseudo-domain image and then transmitted to a second true-false discriminator, and the true-false discrimination is performed on the marked first image to generate a first discrimination result; Distinguishing the real image from the first image based on the second true-false discriminator to generate a second discrimination result, and generating a second true-false loss value of a second cross entropy loss function in the second true-false discriminator according to the first discrimination result and the second discrimination result; Marking the third image as a real domain image and transmitting it to the first true-false discriminator, performing true-false discrimination on the marked third image to generate a third discrimination result; Based on the first true and false discriminator, the third image and the simulated image are distinguished and discriminated to generate a fourth discrimination result, and according to the third discrimination result and the fourth discrimination result, a first true and false loss value of the first cross entropy loss function in the first true and false discriminator is generated.

3. The image generation method according to claim 1, characterized in that: The steps of generating a first OCR loss value of a first loss function in the first OCR discriminator based on recognizing the text in the simulated image and the third image by the first OCR discriminator, and generating a second OCR loss value of a second loss function in the second OCR discriminator based on recognizing the text in the real image and the first image by the second OCR discriminator include: The parameters of the generator are fixed, and the text in the third image is marked as real text in the real domain and then transmitted to the first OCR discriminator, and the real and fake text in the marked third image are identified to generate a first recognition result; Based on the first OCR discriminator, distinguish and recognize the text in the simulation image and the third image to generate a second recognition result, and generate a first OCR loss value of a first loss function in the first OCR discriminator according to the first recognition result and the second recognition result; Marking the text in the first image as simulated text in the real domain and transmitting it to the second OCR discriminator, performing true and false recognition on the marked text in the first image, and generating a third recognition result; Based on the second OCR discriminator, the text in the real image and the first image is distinguished and recognized to generate a fourth recognition result, and according to the third recognition result and the fourth recognition result, a second OCR loss value of the second loss function in the second OCR discriminator is generated.

4. The image generation method according to claim 1, characterized in that: The step of optimizing the training of the generator according to the simulated image and the second image, the real image and the fourth image comprises: The parameters in the discriminator are fixed, and a distance function value of a distance loss function in the generator is determined according to the similarity between the simulated image and the second image, and the similarity between the real image and the fourth image; Determine whether the distance function value is less than a preset distance threshold, and if so, complete the optimization training of the generator; If it is not less than a preset distance threshold, the generator is optimized and trained based on the first true and false discriminator, the second true and false discriminator, the first OCR discriminator and the second OCR discriminator.

5. The image generation method according to claim 4, characterized in that: The step of optimizing and training the generator based on the first true and false discriminator, the second true and false discriminator, the first OCR discriminator and the second OCR discriminator comprises: The first image is transmitted to a second true-false discriminator for processing to obtain a first gradient, and the text in the first image is recognized based on the second OCR discriminator to obtain a second gradient; The first gradient and the second gradient are transmitted to a generator to update parameters in the generator, and the generator is called to process the simulated image and the real image respectively to generate a first image and a second image corresponding to the simulated image; The third image is transmitted to the first true-false discriminator for processing to obtain a third gradient, and the text in the third image is recognized based on the first OCR discriminator to obtain a fourth gradient; The third gradient and the fourth gradient are transmitted to the generator to update the parameters in the generator, and the generator is called to process the simulated image and the real image respectively to generate a third image and a fourth image corresponding to the real image, so as to optimize the training of the generator.

6. The image generation method according to claim 5, characterized in that: The step of transmitting the first image to the second true-false discriminator for processing to obtain a first gradient, and recognizing text in the first image based on the second OCR discriminator to obtain a second gradient includes: Marking the first image as real and transmitting it to a second true-false discriminator for identification to generate a first gradient; The text in the first image is marked as real text and then transmitted to the second OCR discriminator for recognition to generate a second gradient.

7. The image generation method according to any one of claims 1 to 6, characterized in that: Before the step of calling the generator to process the simulated image and the real image respectively, the method includes: Obtaining random noise, and encoding the random noise to generate a noise code; Based on the noise layer to be added of the generator, converting the noise encoding into a scale factor and an offset factor, and generating style noise according to the scale factor and the offset factor; The style noise is added to each of the noise layers to be added.

8. A picture generating device, characterized in that: The image generating device comprises a memory, a processor and an image generating program stored in the memory and executable on the processor, wherein the image generating program, when executed by the processor, implements the steps of the image generating method according to any one of claims 1 to 7.

9. A readable storage medium, characterized in that: The readable storage medium stores a picture generation program, and when the picture generation program is executed by a processor, the steps of the picture generation method according to any one of claims 1 to 7 are implemented.