Training method of image generation model and image generation method and device

Through the training method of the image generation model, deeply integrated verification codes are generated, which solves the problem that existing verification codes are easily identified and improves the security and difficulty of verification codes.

CN119810242APending Publication Date: 2025-04-11ANT ZHIXIN HANGZHOU INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411998131.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

In the existing verification code generation scheme, the generated verification code is easily recognized by automated programs and loses the role of security verification.

Method used

Using the training method of image generation model, the combination of control network and U-shaped network is used to generate deeply integrated images, increasing the complexity of text and background, making it difficult to extract text through conventional image processing technology.

Benefits of technology

It improves the security of verification codes, increases the difficulty for attackers to identify text in verification codes through conventional image processing techniques, and maintains the convenience of recognition for human users.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119810242A_ABST
    Figure CN119810242A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a training method of an image generation model and an image generation method and device, the image generation model comprises a first network and a second network, and the training method comprises the following steps: inputting a first image containing a character pattern into a pre-trained first network to obtain a first image feature of the first image; acquiring a first text feature corresponding to the first description of the first background pattern, and inputting the first image feature, the first text feature and a preset first noise into a pre-trained second network to obtain a second image; obtaining a third image according to the second image and the first noise; inputting the first image feature, the first text feature and the second image into a second network to obtain second noise; and determining a noise difference according to the first noise and the second noise, and updating network parameters of the first network for the purpose of reducing the noise difference.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] One or more embodiments of the present specification relate to the field of image generation technology, and in particular, to a training method for an image generation model, an image generation method, and an image generation device. Background Art

[0002] CAPTCHA (Completely Automated Public Turing test to tell computers and humans apart) is a technical means for distinguishing between human users and automated programs (such as robots). For example, by showing an image-based CAPTCHA to an operating user, the human user can provide feedback on the verification information indicated in the image CAPTCHA, thereby using the human cognitive advantage to verify whether the operating user is a human user or an automated program. However, in some scenarios, the CAPTCHA generated by the existing CAPTCHA generation scheme can still be recognized by an automated program, thus losing the function of security verification. Summary of the invention

[0003] The embodiments in this specification aim to provide a training method, an image generation method and a device for an image generation model, which can not only generate a unique background pattern and text arrangement for each generated image, but also generate images in which the text and the background pattern are deeply integrated, thereby increasing the difficulty of extracting the text from the fused image through conventional image processing technology and solving the shortcomings of the prior art.

[0004] According to a first aspect, a training method for an image generation model is provided, wherein the image generation model comprises a first network and a second network, including:

[0005] Obtain a first image corresponding to a first text, input the first image into a pre-trained first network, and obtain a first image feature of the first image; obtain a first text feature corresponding to a first description of a first background pattern, input the first image feature, the first text feature, and a preset first noise into a pre-trained second network, and obtain a second image;

[0006] A third image is obtained based on the second image and the first noise; the first image feature, the first text feature, and the third image are input into the second network to obtain a second noise; a noise difference is determined based on the first noise and the second noise, and the network parameters of the first network are updated with the purpose of reducing the noise difference.

[0007] In a possible implementation manner, the first noise is Gaussian noise;

[0008] The obtaining of the third image according to the second image and the first noise includes: adding a random amount of Gaussian distribution to the pixel value of each pixel of the second image to obtain the third image.

[0009] In a possible implementation manner, the first network is a control network Control Net, and the second network is a U-type network UNet.

[0010] In a possible implementation, the image generation model further includes a pre-trained text encoder, and obtaining a first text feature corresponding to a first description of a first background pattern includes: inputting the first description into the text encoder to obtain the first text feature.

[0011] In a possible implementation, acquiring the first image corresponding to the first text includes: generating the first image for the first text according to a layout setting for each character in the first text.

[0012] In a possible implementation manner, the layout setting for each character in the first text includes: one or more of the position, arrangement order, and font of each character in the first image.

[0013] In a possible implementation manner, the background color of the first image is black, and the color of the character pattern in the first image is white.

[0014] According to a second aspect, there is provided an image generation method, comprising:

[0015] Obtain a fourth image corresponding to the second text, input the fourth image into the first network updated by the above method, and obtain a second image feature of the fourth image; obtain a second text feature corresponding to the second description of the second background pattern;

[0016] The second image feature, the second text feature, and the preset second noise are input into the second network to obtain a fifth image.

[0017] In a possible implementation manner, the fifth image is used as a verification code.

[0018] According to a third aspect, a training device for an image generation model is provided, wherein the image generation model includes a first network and a second network, including:

[0019] A first acquisition unit is configured to acquire a first image corresponding to a first text, input the first image into a pre-trained first network, and obtain a first image feature of the first image; acquire a first text feature corresponding to a first description of a first background pattern, and input the first image feature, the first text feature, and a preset first noise into a pre-trained second network to obtain a second image;

[0020] The training unit is configured to obtain a third image based on the second image and the first noise; input the first image feature, the first text feature, and the third image into the second network to obtain a second noise; determine a noise difference based on the first noise and the second noise, and update the network parameters of the first network with the purpose of reducing the noise difference.

[0021] According to a fourth aspect, there is provided an image generating device, comprising:

[0022] The second acquisition unit is configured to acquire a fourth image corresponding to the second text, input the fourth image into the first network updated by the above method, and obtain a second image feature of the fourth image; and acquire a second text feature corresponding to a second description of the second background pattern;

[0023] The generating unit is configured to input the second image feature, the second text feature, and the preset second noise into the second network to obtain a fifth image.

[0024] According to a fifth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed in a computer, the computer executes the method described in the first aspect and the second aspect.

[0025] According to a sixth aspect, a computing device is provided, comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method described in the first aspect and the second aspect is implemented.

[0026] By using one or more of the methods, devices, computing devices, and storage media in the above aspects, not only can a unique background pattern and text arrangement be generated for each generated image, but also an image in which the text and the background pattern are deeply integrated can be generated, thereby increasing the difficulty of extracting the text from the integrated image using conventional image processing technology. In turn, the security of the generated image used as a verification code is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.

[0028] Figure 1 A schematic diagram of a scheme for generating a verification code;

[0029] Figure 2A flowchart showing a method for training an image generation model according to an embodiment of the present specification;

[0030] Figure 3 A schematic diagram showing the acquisition of a fused image according to an embodiment of the present specification;

[0031] Figure 4 A schematic diagram showing an update control network according to an embodiment of the present specification;

[0032] Figure 5 A flowchart showing an image generation method according to an embodiment of the present specification;

[0033] Figure 6 A structural diagram showing a training device for an image generation model according to an embodiment of the present specification;

[0034] Figure 7 A structural diagram of an image generating device according to an embodiment of the present specification is shown. DETAILED DESCRIPTION

[0035] The solution provided in this invention book will be described below in conjunction with the accompanying drawings.

[0036] As mentioned above, verification codes are a technical means for distinguishing between human users and automated programs (such as robots). For example, by showing the verification code in the form of an image to the operating user, the human user can provide feedback on the verification information indicated in the verification code, thereby taking advantage of human cognitive advantages to verify whether the operating user is a human user or an automated program. However, in some scenarios, the verification code generated by the existing verification code generation scheme can still be recognized by the automated program, thus losing the function of security verification. Figure 1 A schematic diagram of a scheme for generating a verification code. Figure 1As shown, the existing verification code generation scheme can, for example, generate a verification code according to the target text that the user wants to recognize, and the preset text selection rules, image conversion rules or text reasoning rules. In one example, for example, if the target text is "correct answer", a random text sequence can be generated according to the preset text selection rules, such as "answer is correct, beautiful case, confirmed", and the image corresponding to the random text sequence is generated as a verification code. The purpose is to enable the user to select the correct text from the verification code in sequence, so as to determine whether the user is a real user based on whether the text is selected and whether the selection order is correct. In another example, for example, according to the preset image conversion rules, each text pattern in the corresponding image of the target text can be rotated in different directions with different degrees of inclination, or the font or color of each text pattern can be changed respectively, so as to generate a verification code. The purpose is to enable the user to input text according to the verification code, so as to determine whether the user is a real user based on whether the input text is correct. In another example, for example, if the target text is "5", a text sequence can be generated according to the preset text reasoning rules, such as "2+3=", and the image corresponding to the text sequence is generated as a verification code. Its purpose is to allow the user to input numeric characters according to the verification code, so as to determine whether the user is a real user based on whether the input characters are correct.

[0037] However, this solution has the following problems: First, although the images generated according to the text selection rules, image conversion rules or text reasoning rules are easy for human users to understand, the text patterns in such verification codes are usually less integrated with the background patterns, so attackers can easily separate them from the background patterns through computer vision technology. With the development of computer vision technology, it has become easier to identify objects, texts and even image rotation angles in images, further reducing the difficulty for attackers to identify text patterns in verification codes through automated scripts, for example. Second, whether the text patterns are generated according to the text selection rules, image transformation rules or simple math problem reasoning, these rules themselves are usually relatively simple. For example, the text selection rules usually involve limited fonts, styles and vocabulary, and the image conversion rules only involve limited image rotation angles or font transformations. Attackers can easily identify the text in these text patterns, for example, by training machine learning models, or infer the answer based on the recognized text. Third, according to the existing solutions, if the text selection rules, image conversion rules or text reasoning rules are set to be more complex in order to improve security, such as increasing the difficulty of text reasoning or increasing the degree of deformation of text characters. This will cause the rules to become too complicated, which will reduce the pass rate of human users and reduce the user experience of normal human users.

[0038] In order to solve the above technical problems, the embodiments of this specification provide a training method for an image generation model. The image generation model can be based on a diffusion model, and specifically, can include a control network (Control Net) and a U-net (U-Net). The training method mainly includes: inputting the character base map obtained according to the target text into a pre-trained control network to obtain image features; determining the corresponding text features according to the description of the background pattern, and inputting the image features, text features and preset noise into a pre-trained U-net to obtain a fused image. Then, an intermediate image can be obtained based on the fused image and the preset noise; and the image features, text features and the intermediate image are input into the U-net to obtain predicted noise; the noise difference is determined based on the preset noise and the predicted noise, and the network parameters of the control network are updated based on the noise difference.

[0039] The advantages of this method are as follows: First, the image generation model trained by this method can generate random and complex background images, such as background images that can contain natural scenery, abstract patterns and noise textures. The increase in background complexity increases the difficulty for attackers to remove the background and recognize text by conventional image segmentation or filtering. Second, the image generation model trained by this method can generate images in which text and background are deeply integrated, such as the edge of the text can be integrated into the background, or the color of the text and the background color can form a gradient effect. The increase in the degree of integration between text and background eliminates the easy separation of "text-background" in conventional verification codes, and further increases the difficulty for attackers to extract text in verification codes through conventional image processing techniques (such as edge detection and color separation). Third, by combining the character layout setting for the character background, the image generation model can generate a unique background and text arrangement for each verification code, so that the same text content has different visual expressions each time the verification code is generated. This dynamic generation feature makes it difficult for attackers to effectively train machine learning models to identify the generation mode of images by collecting a large number of samples of generated images, so as to achieve the purpose of distinguishing the text in the generated images. Fourthly, although the images generated by the image generation model trained by this method increase the difficulty of recognizing the text therein by conventional image segmentation technology or training machine learning models, they are still easy for human users to recognize, thus not reducing the user experience.

[0040] Figure 2 FIG. 1 is a flow chart showing a method for training an image generation model according to an embodiment of the present specification. Figure 2 As shown, the image generation model includes a first network and a second network, and the method includes at least the following steps:

[0041] Step S201, obtaining a first image corresponding to a first text, inputting the first image into a pre-trained first network, and obtaining a first image feature of the first image; obtaining a first text feature corresponding to a first description of a first background pattern, and inputting the first image feature, the first text feature, and a preset first noise into a pre-trained second network, and obtaining a second image;

[0042] Step S203, obtaining a third image based on the second image and the first noise; inputting the first image feature, the first text feature, and the third image into the second network to obtain a second noise; determining a noise difference based on the first noise and the second noise, and updating the network parameters of the first network with the purpose of reducing the noise difference.

[0043] First, in step S201, a first image corresponding to a first text may be obtained, and the first image may be input into a pre-trained first network to obtain a first image feature of the first image. Also, a first text feature corresponding to a first description of a first background pattern may be obtained. Furthermore, the first image feature, the first text feature, and a preset first noise may be input into a pre-trained second network to obtain a second image. The first image may be an image containing a character pattern in the first text. In different embodiments, the specific content of the first text may be different, and this specification does not limit this. In different embodiments, the language of the first text may also be the language of a different country or region.

[0044] In different embodiments, the specific manner of acquiring the first image may be different. In one embodiment, the first image for the first text may be generated according to the layout settings for each character in the first text. In different specific embodiments, the layout settings for each character in the first text may be different. In a specific embodiment, the layout settings for each character in the first text may specifically be, for example, one or more of the position, arrangement order, glyph, and font of each character in the first image.

[0045] In different embodiments, the color of the character pattern in the first image may be different, and the background color in the first image may also be different. For example, in one embodiment, the color of the character pattern in the first image is white, and the background color of the first image is black, that is, the first image may be an image with white characters on a black background.

[0046] After acquiring the first image, the first image can be input into the first network to obtain the image features of the first image (i.e., the first image features). In one embodiment, the first network can be a control network (Control Net). The control network (Control Net), a neural network for controlling the generation process, can use various types of conditional information, such as edges, depths, semantic segmentation maps, etc. to constrain the image generation process so that the generated image meets the expected conditions. For example, in the example where the first image is white text and black background, the image features of the white background and black text image extracted by the control network can provide guidance for the second network (e.g., UNet) to generate images in subsequent steps, so that the text therein is consistent with the first image in terms of, for example, text style, position, etc. In different embodiments, the control network can be based on different specific types of neural networks, and this specification does not limit this.

[0047] The first description is a text description of the content included in the background pattern in the fused image (second image) generated in the subsequent step. In different embodiments, the specific content described in the first description is different. In a specific embodiment, the first description can be, for example, "a scene full of flowers". In different embodiments, the language of the first description can also be the language of different countries or regions.

[0048] In different embodiments, the specific method of obtaining the text feature (first text feature) corresponding to the first description may also be different. In one embodiment, the first description can be input into the text encoder to obtain the first text feature. A text encoder (Text Encoder) is a neural network or software module used to convert text information into corresponding features (usually in vector form, or called text encoding). The text encoder can convert complex semantic and grammatical information in the text into digital vectors that can be processed by a computer. In different specific embodiments, the specific type of the text encoder or the specific neural network type on which the text encoder is based may be different, and this specification does not limit this.

[0049] After obtaining the first image feature and the first text feature, the first image feature, the first text feature, and the preset first noise can be input into a pre-trained second network to obtain a second image (fused image). In one embodiment, the second network can be a U-type network UNet. The U-net is a network that can be used for image segmentation or image synthesis tasks, and can have an encoder-decoder structure. Among them, the encoder part is used to extract image features. The decoder generates a segmentation map of the original image or a synthetic map for the original image based on the image features. In different specific embodiments, the encoder and decoder in the U-net can be based on different specific types of neural networks, and this specification does not limit this. In different embodiments, the first noise can be different noises. In one embodiment, for example, it can be Gaussian noise. In different specific embodiments, it can also be Gaussian noise with different means and standard deviations.

[0050] The pre-trained first network (control network) and the pre-trained second network (U-shaped network) can constitute an image generation model based on a diffusion model. Conventionally, a noise map can be obtained from the original image through a diffusion model, or the original image can be obtained from the noise map. Among them, the original image to obtain the noise map is also called forward diffusion. The process of forward diffusion is the process of gradually adding noise to the original image to obtain the noise map. Taking the Gaussian noise map as an example, in each step of diffusion, Gaussian noise can be generated according to a specific mean and standard deviation, and added to the current image. As the number of diffusion steps increases, the noise in the image gradually increases, and finally an image that is approximately pure noise is obtained. For example, there is a clear landscape photo at first. After multiple forward diffusion operations, the photo will gradually become blurred until it becomes a noise map. The reverse process of obtaining the noise map from the original image can be called the denoising process. The pre-trained diffusion model has learned the characteristics and distribution laws of the image under different noise levels. Therefore, given the noise map, it is possible to gradually predict and remove the noise and restore the original image.

[0051] In this embodiment, the generation process can be guided by adding a control signal (e.g., white text on a black background) through the control network. Furthermore, on the basis of the conventional diffusion model, a control module is added, which can extract the features of the external control signal and input the control features into the U-shaped network, so as to control the image generated by the U-shaped network to be more in line with the instructions of the control signal. The U-shaped network is used to generate a fused image based on the noise, the features of the control network input, and the text features of the text description of the background pattern.

[0052] Specifically, in one embodiment, the method for acquiring the second image (fused image) can be expressed as the following formula:

[0053] y1=UNET(E t (t),Controlnet (x),e1) (1)

[0054] Among them, y1 is the second image, x is the first image (text background), t is the first text, Et() is the text encoder, Control net() is the control network, e1 is the first noise, UNET() is the U-shaped network, and y1 is the second image (fused image).

[0055] Figure 3 FIG. 2 is a schematic diagram showing a method of obtaining a fused image according to an embodiment of the present specification. Figure 3 As shown, for example, the text background image x can be input into a pre-trained control network to obtain image features. The text description t of the background pattern is input into the text encoder Et to obtain the corresponding text features. The image features, text features and preset noise e1 are input into a pre-trained U-shaped network to obtain a fused image y1.

[0056] Thereafter, in step S203, a third image may be obtained based on the second image and the first noise. The first image feature, the first text feature, and the third image are input into the second network to obtain the second noise. Furthermore, a noise difference may be determined based on the first noise and the second noise, and the network parameters of the first network may be updated with the purpose of reducing the noise difference.

[0057] In different embodiments, the specific method of obtaining the third image may be different according to the second image and the first noise. In the embodiment where the first noise is Gaussian noise, a random amount of Gaussian distribution may be added to the pixel value of each pixel of the second image to obtain the third image.

[0058] After obtaining the third image, the first image feature, the first text feature, and the third image can be input into the second network to obtain the second noise. The second network (for example, a U-shaped network) can generate a fitted noise map (a noise map corresponding to the second noise) based on the input fusion image (first image), the feature of the control network input (the first image feature), and the text feature of the text description of the background pattern (the first text feature). Furthermore, the noise difference can be determined based on the first noise and the second noise, and the network parameters of the first network can be updated with the purpose of reducing the noise difference. In different embodiments, the specific method of updating the network parameters of the first network can be different. In a specific embodiment, the network parameters of the first network can be updated based on the back propagation algorithm (BP, Back Propagation). In another embodiment, the network parameters of the first network and the second network can also be updated with the purpose of reducing the noise difference. In the above manner, the quality of the control features extracted by the first network can be improved, and the image generated by the second network can be better integrated with the control features, so that it is more difficult to be recognized when used as a verification code, for example.

[0059] In a specific embodiment, the second noise can be obtained by the following formula:

[0060] e2=UNET (E t (t),Controlnet (x),y2) (2)

[0061] Among them, y2 is the third image (middle image), x is the first image, t is the first text, Et() is the text encoder, Control net() is the control network, UNET() is the U-shaped network, and e2 is the second noise.

[0062] In different embodiments, the specific manner of determining the noise difference based on the first noise and the second noise may also be different. In one embodiment, the noise difference is determined based on the Euclidean distance between the first noise and the second noise. In a specific example, the manner of determining the noise difference can be expressed as the following formula:

[0063] L=||e2-e1||2 (3)

[0064] Among them, e1 is the first noise, e2 is the second noise, ||…||2 is the 2-norm (also called Euclidean norm) distance, and L is the noise difference.

[0065] Figure 4 FIG. 2 is a schematic diagram showing an update control network according to an embodiment of the present specification. Figure 4As shown, for example, an intermediate image y2 can be obtained based on the fused image y1 and the preset noise e1. The image features of the text background image x obtained by the control network, the text features of the text description t of the background pattern obtained by the text encoder Et, and the intermediate image y2 are input into the U-shaped network to obtain the predicted noise e2. Furthermore, the noise difference L is determined based on the preset noise and the predicted noise, and the network parameters of the control network are updated based on the noise difference L.

[0066] The above describes a training method for an image generation model provided by an embodiment of this specification. Another embodiment of this specification also provides a corresponding image generation method. Figure 5 FIG. 1 is a flow chart showing an image generation method according to an embodiment of the present specification. Figure 5 As shown, the method comprises at least the following steps:

[0067] Step S501, obtaining a fourth image corresponding to the second text, inputting the fourth image into the first network updated by the above method, and obtaining a second image feature of the fourth image; and obtaining a second text feature corresponding to a second description of a second background pattern.

[0068] In different embodiments, the second text may be different specific texts. In an embodiment, the second description may also be a description of different background patterns, which is not limited in this specification. In an embodiment, the specific method of obtaining the fourth image corresponding to the second text and the second text feature corresponding to the second description may be similar to the method of obtaining the first image and the method of obtaining the first text feature in step S301. For details, please refer to the description of step S301, which will not be repeated here.

[0069] Step S503, inputting the second image feature, the second text feature, and the preset second noise into the second network to obtain a fifth image. In different embodiments, the second noise can be different specific noises. In this way, different noises can also be added in the generation process of different images, thereby further increasing the randomness in the image generation process, making it more difficult for an attacker to reversely restore the image generation mode based on the generated image, and increasing the difficulty of identifying the text in the generated image.

[0070] In one embodiment, the fifth image may be used as a verification code (CAPTCHA, Complete Automated Public Testing to Tell Computers and Humans Apart).

[0071] The above describes a training method for an image generation model provided by an embodiment of the present specification. Another embodiment of the present specification also provides a training device for an image generation model. Figure 6 The structure diagram of a training device for an image generation model according to an embodiment of the present specification is shown. The image true and false recognition model includes at least a first network and a second network, such as Figure 6 As shown, the training device 600 includes:

[0072] The first acquisition unit 61 is configured to determine a layout setting for each character in the first text, determine a first image corresponding to the first text, input the first image into a pre-trained first network, and obtain a first image feature of the first image; obtain a first text feature corresponding to a first description of a first background pattern, input the first image feature, the first text feature, and a preset first noise into a pre-trained second network, and obtain a second image;

[0073] The training unit 62 is configured to obtain a third image based on the second image and the first noise; input the first image feature, the first text feature, and the third image into the second network to obtain a second noise; determine a noise difference based on the first noise and the second noise, and update the network parameters of the first network with the purpose of reducing the noise difference.

[0074] According to another aspect of the present specification, an image generating device is provided. Figure 7 FIG. 2 shows a structural diagram of an image generating device according to an embodiment of the present specification. Figure 7 As shown, the device 700 includes:

[0075] The second acquisition unit 71 is configured to acquire a fourth image corresponding to the second text, input the fourth image into the first network updated by the above method, and obtain a second image feature of the fourth image; and acquire a second text feature corresponding to the second description of the second background pattern;

[0076] The generating unit 72 is configured to input the second image feature, the second text feature, and the preset second noise into the second network to obtain a fifth image.

[0077] On another aspect, the present specification provides a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute any one of the above methods.

[0078] On another aspect, the present specification provides a computing device, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, any one of the above methods is implemented.

[0079] It should be understood that the descriptions such as “first” and “second” in this article are only used to distinguish similar concepts for the sake of simplicity of description and do not have any other limiting effect.

[0080] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the present invention can be implemented by hardware, software, firmware or any combination thereof. When implemented by software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium.

[0081] For the convenience of description, the above devices are described in various modules according to their functions. Of course, when implementing one or more of the present specification, the functions of each module can be implemented in the same or more software and / or hardware, or the module implementing the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0082] Although one or more embodiments of the present specification provide method operation steps as described in the embodiments or flow charts, more or less operation steps may be included based on conventional or non-creative means. The order of steps listed in the embodiments is only one way of executing the order of many steps, and does not represent the only execution order. When the device or terminal product in practice is executed, it can be executed in sequence or in parallel according to the method shown in the embodiments or the drawings (for example, a parallel processor or a multi-threaded processing environment, or even a distributed data processing environment). The term "include", "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, product or equipment including a series of elements includes not only those elements, but also includes other elements that are not explicitly listed, or also includes elements inherent to such a process, method, product or equipment. In the absence of more restrictions, it is not excluded that there are other identical or equivalent elements in the process, method, product or equipment including the elements. For example, if the words first, second, etc. are used to represent the name, they do not represent any specific order.

[0083] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solution of the present invention should be included in the scope of protection of the present invention.

Claims

1. A training method for an image generation model, wherein the image generation model comprises a first network and a second network, comprising: Acquire a first image corresponding to a first text, input the first image into a pre-trained first network, and obtain a first image feature of the first image; Acquire a first text feature corresponding to a first description of a first background pattern, input the first image feature, the first text feature, and a preset first noise into a pre-trained second network, and obtain a second image; A third image is obtained based on the second image and the first noise; the first image feature, the first text feature, and the third image are input into the second network to obtain a second noise; a noise difference is determined based on the first noise and the second noise, and a network parameter of the first network is updated with the purpose of reducing the noise difference.

2. The method according to claim 1, wherein: The first noise is Gaussian noise; The obtaining of the third image according to the second image and the first noise includes: adding a random amount of Gaussian distribution to the pixel value of each pixel of the second image to obtain the third image.

3. The method according to claim 1, wherein: The first network is a control network Control Net, and the second network is a U-type network UNet.

4. The method according to claim 1, wherein: The image generation model also includes a pre-trained text encoder, and obtaining a first text feature corresponding to a first description of a first background pattern includes: inputting the first description into the text encoder to obtain the first text feature.

5. The method according to claim 1, wherein: Acquiring a first image corresponding to a first text includes: generating a first image for the first text according to a layout setting for each character in the first text.

6. The method according to claim 5, wherein: The layout setting for each character in the first text includes: one or more of the position, arrangement order, glyph, and font of each character in the first image.

7. The method according to claim 1, wherein: The background color of the first image is black, and the color of the character pattern in the first image is white.

8. A method for generating an image, comprising: Obtain a fourth image corresponding to the second text, input the fourth image into the first network updated by the method of claim 1, and obtain a second image feature of the fourth image; obtain a second text feature corresponding to a second description of the second background pattern; The second image feature, the second text feature, and the preset second noise are input into the second network to obtain a fifth image.

9. The method according to claim 8, wherein: The fifth image is used as a verification code.

10. A training device for an image generation model, the image generation model comprising a first network and a second network, comprising: A first acquisition unit is configured to determine a layout setting for each character in a first text, determine a first image corresponding to the first text, input the first image into a pre-trained first network, and obtain a first image feature of the first image; obtain a first text feature corresponding to a first description of a first background pattern, input the first image feature, the first text feature, and a preset first noise into a pre-trained second network, and obtain a second image; A training unit configured to obtain a third image according to the second image and the first noise; The first image feature, the first text feature, and the third image are input into the second network to obtain a second noise; a noise difference is determined based on the first noise and the second noise, and a network parameter of the first network is updated with the purpose of reducing the noise difference.

11. An image generating device, comprising: A second acquisition unit is configured to acquire a fourth image corresponding to the second text, input the fourth image into the first network updated by the method of claim 1, and obtain a second image feature of the fourth image; and acquire a second text feature corresponding to a second description of the second background pattern; The generating unit is configured to input the second image feature, the second text feature, and the preset second noise into the second network to obtain a fifth image.

12. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute the method according to any one of claims 1 to 9.

13. A computing device, comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method according to any one of claims 1 to 9 is implemented.