Test image generation method, apparatus, device, storage medium, and program product

CN122597559APending Publication Date: 2026-08-18CHINA MOBILE FINANCIAL TECHNOLOGY CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610554195.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-04-24
Publication Date
2026-08-18

AI Technical Summary

Technical Problem

[0004]本发明的目的在于提供一种测试图像生成方法、装置、设备、存储介质及程序产品,用以解决人工生成测试图像效率低且质量差的问题

Benefits of technology

[0037]本发明实施例中,通过获取随机噪声和第一测试需求信息,所述第一测试需求信息包括字符内容、字符长度、字符类型、干扰类型中的至少一项;将所述随机噪声和所述第一测试需求信息输入至第一生成器,得到符合测试需求的第一测试图像;其中,所述第一生成器是基于生成式对抗网络训练得到的,所述生成式对抗网络中的生成器包括依次串联的几何结构层、语义特征层和细节生成层,所述几何结构层输出的生成图像的字符长度、所述语义特征层输出的生成图像的字符内容和字符类型、所述细节生成层输出的生成图像的细节纹理均由与图像生成相关的条件特征向量控制输出,这样,通过训练加入了生成图像的条件控制的生成式对抗网络得到的第一生成器,能够使得到的测试图像符合测试需求,提升测试图像的生成效率与质量。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122597559A_ABST
    Figure CN122597559A_ABST
Patent Text Reader

Abstract

The present application provides a kind of test image generation method, device, equipment, storage medium and program product.The method of the present application comprises: obtaining random noise and first test requirement information, and the first test requirement information includes at least one of character content, character length, character type and interference type;Random noise and first test requirement information are input to first generator, and first test image that meets test requirement is obtained;Wherein, first generator is obtained based on generative adversarial network training, and the generator in generative adversarial network includes geometric structure layer, semantic feature layer and detail generation layer connected in turn, and the output of geometric structure layer, semantic feature layer and detail generation layer is all controlled by the condition feature vector related to image generation.The first generator of the present application is obtained by training the generative adversarial network that adds the condition control of generated image, can make the test image obtained to meet test requirement, improve the generation efficiency and quality of test image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and in particular to a test image generation method, apparatus, device, storage medium, and program product. Background Technology

[0002] Web test image generation is a technique specifically designed to construct image data for testing web applications. These generated images are used to verify the web application's image processing capabilities, such as: CAPTCHA recognition, user-generated content (UGC) moderation (e.g., sensitive content filtering), image rendering performance, and display compatibility.

[0003] Currently, manually generating test images is the most basic and intuitive method. However, when manually generating test CAPTCHAs, testers need to manually draw, modify, or synthesize them according to web functions and test scenarios. This process not only consumes a lot of manpower and time, but the generated images also struggle to cover complex and diverse real-world usage scenarios, easily overlooking edge cases and abnormal data, thus affecting the comprehensiveness and accuracy of the test. Furthermore, as web applications expand in scale and increase in complexity, the efficiency and quality issues of manually generating test images become even more prominent. Summary of the Invention

[0004] The purpose of this invention is to provide a test image generation method, apparatus, device, storage medium, and program product to solve the problems of low efficiency and poor quality of manually generated test images.

[0005] To achieve the above objectives, in a first aspect, embodiments of the present invention provide a test image generation method, comprising:

[0006] Obtain random noise and first test requirement information, wherein the first test requirement information includes at least one of character content, character length, character type, and interference type;

[0007] The random noise and the first test requirement information are input into the first generator to obtain a first test image that meets the test requirements. The first generator is trained based on a generative adversarial network. The generator in the generative adversarial network includes a geometric structure layer, a semantic feature layer and a detail generation layer connected in series. The character length of the generated image output by the geometric structure layer, the character content and character type of the generated image output by the semantic feature layer, and the detail texture of the generated image output by the detail generation layer are all controlled by conditional feature vectors related to image generation.

[0008] In some embodiments, each level of the generator includes multiple parallel instances consisting of generation blocks, each generation block comprising a concatenated convolutional layer, a bilinear interpolation upsampling layer, and a residual block.

[0009] The discriminator of the generative adversarial network comprises multiple cascaded discriminator blocks, each of which includes a residual block, a bilinear interpolation downsampling layer, and a convolutional layer, which are cascaded in sequence.

[0010] In some embodiments, the method further includes:

[0011] Obtain a training dataset, which includes multiple training data sets, each of which includes an image sample and a conditional feature vector corresponding to the image sample;

[0012] The generative adversarial network is pre-trained unsupervised based on the training dataset and random noise that follows a normal distribution to obtain a first generative adversarial network.

[0013] Based on the generated image output by the generator in the pre-training phase, the first generative adversarial network is trained in a supervised manner using a conditional encoder to obtain the first generator.

[0014] In some embodiments, the step of unsupervised pre-training of the generative adversarial network based on the training dataset and normally distributed random noise to obtain a first generative adversarial network includes:

[0015] The generative adversarial network is iteratively trained based on the training dataset and random noise that follows a normal distribution.

[0016] Based on the first loss function, the network parameters corresponding to the generator in the generative adversarial network are updated, and based on the second loss function, the network parameters corresponding to the discriminator in the generative adversarial network are updated until the iteration termination condition is met, thus obtaining the first generative adversarial network.

[0017] The second loss function is the sum of the discriminator's loss on the real image and the discriminator's loss on the generated image.

[0018] In some embodiments, the conditional feature vector includes a character length feature vector, a character content feature vector, a character type feature vector, and an interference type feature vector;

[0019] The iterative training of the generative adversarial network based on the training dataset and normally distributed random noise includes:

[0020] Based on the conditional feature vector and the random noise, traverse all generation paths constructed by each layer instance in the generator to obtain the generated image output by each generation path;

[0021] During the training process for each generation path, the geometric structure layer is controlled by the character length feature vector, the semantic feature layer is controlled by the character content feature vector and the character type feature vector, and the detail generation layer is controlled by the interference type feature vector.

[0022] In some embodiments, the first generator is obtained by supervising the first generative adversarial network using a conditional encoder based on the generated image output by the generator in the pre-training phase, including:

[0023] For each training iteration, the generated image based on the generator output during the pre-training phase is input into the conditional encoder to obtain the predicted conditional feature vector.

[0024] Based on the third loss function, the network parameters corresponding to the generator in the first generative adversarial network are updated until the iteration termination condition is met, and the first generator is obtained.

[0025] The third loss function is obtained by linearly weighting the first loss function and the conditional loss function. The conditional loss function is the square of the L2 norm between the predicted conditional feature vector and the real conditional feature vector corresponding to the generated image.

[0026] In some embodiments, the first loss function is obtained by linearly weighting the generator loss function and the instance diversity loss function. The generator loss function is obtained by linearly weighting the adversarial loss based on the generated image, the gradient norm penalty corresponding to the real image, and the gradient norm penalty corresponding to the generated image. The instance diversity loss function is the negative of the sum of the mean squared errors of the parameters between instances of different paths.

[0027] Secondly, embodiments of the present invention also provide a test image generation apparatus, comprising:

[0028] The first acquisition module is used to acquire random noise and first test requirement information, wherein the first test requirement information includes at least one of character content, character length, character type, and interference type;

[0029] An image generation module is used to input the random noise and the first test requirement information into a first generator to obtain a first test image that meets the test requirements. The first generator is trained based on a generative adversarial network. The generator in the generative adversarial network includes a geometric structure layer, a semantic feature layer, and a detail generation layer connected in series. The character length of the generated image output by the geometric structure layer, the character content and character type of the generated image output by the semantic feature layer, and the detail texture of the generated image output by the detail generation layer are all controlled by conditional feature vectors related to image generation.

[0030] Thirdly, embodiments of the present invention also provide a test image generation device, including a processor and a transceiver, wherein the transceiver receives and transmits data under the control of the processor, and the processor is configured to perform the following operations:

[0031] Obtain random noise and first test requirement information, wherein the first test requirement information includes at least one of character content, character length, character type, and interference type;

[0032] The random noise and the first test requirement information are input into the first generator to obtain a first test image that meets the test requirements. The first generator is trained based on a generative adversarial network. The generator in the generative adversarial network includes a geometric structure layer, a semantic feature layer and a detail generation layer connected in series. The character length of the generated image output by the geometric structure layer, the character content and character type of the generated image output by the semantic feature layer, and the detail texture of the generated image output by the detail generation layer are all controlled by conditional feature vectors related to image generation.

[0033] Fourthly, embodiments of the present invention also provide a test image generation device, including a memory, a processor, and a program stored in the memory and executable on the processor; when the processor executes the program, it implements the test image generation method as described in the first aspect.

[0034] Fifthly, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the test image generation method as described in the first aspect.

[0035] In a sixth aspect, embodiments of the present invention also provide a computer program product, including computer instructions, which, when executed by a processor, implement the steps in the test image generation method as described in the first aspect.

[0036] The above-described technical solution of the present invention has at least the following beneficial effects:

[0037] In this embodiment of the invention, random noise and first test requirement information are obtained, the first test requirement information including at least one of character content, character length, character type, and interference type; the random noise and the first test requirement information are input into a first generator to obtain a first test image that meets the test requirements; wherein, the first generator is trained based on a generative adversarial network, the generator in the generative adversarial network includes a geometric structure layer, a semantic feature layer and a detail generation layer connected in series, the character length of the generated image output by the geometric structure layer, the character content and character type of the generated image output by the semantic feature layer, and the detail texture of the generated image output by the detail generation layer are all controlled by conditional feature vectors related to image generation. In this way, by training a first generator with conditional control of the generated image, the obtained test image can meet the test requirements, improving the generation efficiency and quality of the test image. Attached Figure Description

[0038] Figure 1 A flowchart illustrating the test image generation method according to an embodiment of the present invention;

[0039] Figure 2 This diagram illustrates the architecture of the generator in an embodiment of the present invention.

[0040] Figure 3 A schematic diagram showing the structure of the generation block in an embodiment of the present invention;

[0041] Figure 4 A schematic diagram showing the structure of the discrimination block in an embodiment of the present invention;

[0042] Figure 5 A schematic diagram showing the structure of the residual block according to an embodiment of the present invention;

[0043] Figure 6 A schematic diagram of the test image generation apparatus according to an embodiment of the present invention;

[0044] Figure 7 This is a schematic diagram of the hardware structure of the test image generation device according to an embodiment of the present invention. Detailed Implementation

[0045] To make the technical problems, technical solutions and advantages of the present invention clearer, a detailed description will be given below in conjunction with the accompanying drawings and specific embodiments.

[0046] To facilitate understanding of the present invention, the relevant content involved in the present invention will be introduced first.

[0047] In related technologies, the main methods for generating web test images include manual generation, traditional generation based on Generative Adversarial Networks (GANs), and diffusion model generation.

[0048] Among these methods, manually generating test images is the most basic and intuitive. Testers manually draw, modify, or synthesize images as needed (e.g., to test specific types of violation images, CAPTCHAs of specific sizes, or images with specific defects), or select images from existing image libraries. This method is suitable for small-scale testing. However, as web applications grow in scale and complexity, the efficiency and quality issues of manually generated test images become more prominent.

[0049] GAN-based test data generation technology utilizes a game-like mechanism between a generator and a discriminator to generate test data. The generator simulates real data distributions to generate samples, while the discriminator distinguishes between the generator's data and real data. Through continuous competition and optimization, the generator's data becomes increasingly closer to reality. GANs demonstrate unique advantages in generating complex CAPTCHA images. However, while traditional GANs have applications in test image generation, their use in CAPTCHA generation is not yet widespread. The training process of traditional GANs is often unstable and prone to pattern collapse; that is, the generator can only generate a few similar data samples, failing to construct diverse test images and thus struggling to meet the diverse CAPTCHA requirements of web applications. Furthermore, the quality and detail of the generated test images are low, affecting test performance.

[0050] Diffusion modeling is a generative artificial intelligence (AI) technique. Its core involves training the model through a combination of "diffusion" (the process of progressively adding noise to destroy the original image) and "inverse process" (retraining a neural network to learn how to "de-noise" and reconstruct the original image from the noise). During generation, the model starts with random noise and iteratively denoises through multiple steps to generate entirely new, high-quality images. This technique, guided by text prompts or conditional instructions, allows for precise control over the content, style, and attributes of the generated images, typically producing images of higher quality, richer detail, and greater diversity than GANs, covering a wider range of visual scenes. However, diffusion-based generation schemes usually require massive datasets and powerful computing resources for model training, resulting in high training costs and long training cycles. Furthermore, the diffusion model is slow during the inference phase, making it unable to quickly generate large amounts of test data, thus failing to meet the demands of rapid iteration and frequent testing in web applications. In addition, while diffusion models (especially text-to-image models) possess powerful high-level semantic control capabilities thanks to text prompts, their performance lags behind GAN methods in terms of the extremely fine-grained, specific, and non-semantic control required for generating CAPTCHAs.

[0051] To address the aforementioned technical problems, this invention provides a method, apparatus, device, storage medium, and program product for generating test images. The method and apparatus are based on the same concept as described in the application. Since the methods and apparatus solve problems based on similar principles, their implementations can be mutually referenced, and repeated details will not be elaborated further.

[0052] like Figure 1 The diagram shown is a flowchart illustrating a test image generation method provided in an embodiment of the present invention. This method may include:

[0053] Step 101: Obtain random noise and first test requirement information, wherein the first test requirement information includes at least one of character content, character length, character type, and interference type;

[0054] Here, the first test requirement information refers to the test requirement information corresponding to the test image to be generated. For example, what is the character content of the test image to be generated, how many characters are the character length, what is the character type, and what is the interference type.

[0055] The character types include numbers, letters, and symbols; the interference types include arc interference, grid background, and character distortion.

[0056] Optionally, the random noise follows a normal distribution. For example, it could follow a standard normal distribution with a mean of 0 and a variance of 1.

[0057] Step 102: Input the random noise and the first test requirement information into the first generator to obtain a first test image that meets the test requirements; wherein, the first generator is trained based on a generative adversarial network, and the generator in the generative adversarial network includes a geometric structure layer, a semantic feature layer and a detail generation layer connected in sequence. The character length of the generated image output by the geometric structure layer, the character content and character type of the generated image output by the semantic feature layer, and the detail texture of the generated image output by the detail generation layer are all controlled by conditional feature vectors related to image generation.

[0058] Here, the first test image that meets the test requirements refers to the test image that meets the test requirements corresponding to the first test requirement information.

[0059] It should be noted that the first generator in this embodiment of the invention is obtained based on a generative adversarial network (GAN). Before training the GAN, it is necessary to construct it. Specifically, the GAN includes a generator and a discriminator. The generator generates fake images based on random noise, and the discriminator distinguishes between real and fake images based on real images and the fake images.

[0060] Among them, such as Figure 2 As shown, the generator comprises a geometric structure layer, a semantic feature layer, and a detail generation layer connected in series. The character length of the generated image output by the geometric structure layer, the character content and type of the generated image output by the semantic feature layer, and the detail texture of the generated image output by the detail generation layer are all controlled by conditional feature vectors related to image generation. This can be understood as the generator's image generation being controlled by conditional feature vectors; that is, the character length, character content, character type, and detail texture of the generated image are determined by the conditional feature vectors related to image generation. Thus, by training a generative adversarial network with conditional control over image generation, the resulting first generator ensures that the test images generated by this first generator meet the testing requirements, improving the generation efficiency and quality of the test images.

[0061] The test image generation method of this invention obtains random noise and first test requirement information, which includes at least one of character content, character length, character type, and interference type. The random noise and the first test requirement information are input into a first generator to obtain a first test image that meets the test requirements. The first generator is trained based on a generative adversarial network (GAN). The generator in the GAN includes a geometric structure layer, a semantic feature layer, and a detail generation layer connected in series. The character length of the generated image output by the geometric structure layer, the character content and character type of the generated image output by the semantic feature layer, and the detail texture of the generated image output by the detail generation layer are all controlled by conditional feature vectors related to image generation. Thus, by training a first generator with added conditional control over image generation, the obtained test image can meet the test requirements, improving the generation efficiency and quality of the test image.

[0062] In some embodiments, each level of the generator comprises multiple parallel instances consisting of generation blocks. For example, Figure 3 As shown, each of the generated blocks includes a convolutional layer, a bilinear interpolation upsampling layer, and a residual block connected in series.

[0063] like Figure 4 As shown, the discriminator of the generative adversarial network includes multiple cascaded discriminator blocks, each of which includes a residual block, a bilinear interpolation downsampling layer, and a convolutional layer connected in series.

[0064] It should be noted that each residual block includes a convolutional unit connected to the input feature map. The output of the convolutional unit is added to the input feature map to obtain the output feature map. The input feature map comes from the output of the previous residual block or generator block.

[0065] See here. Figure 5 The convolutional unit consists of a series of 1×1, 3×3, and 1×1 convolutional layers. Specifically, the 1×1 convolutional layer at the input is used to adjust the number of channels and contains a series of 1×1 convolutions, a bias function, and a LeakyReLU activation function. The 3×3 convolutional layer is used for feature extraction and spatial information processing and contains a series of 3×3 convolutions, a bias function, and a LeakyReLU activation function. The 1×1 convolutional layer at the output is used to restore the number of channels and contains a 1×1 convolution.

[0066] For the generative adversarial network of this invention, its input data is (x, s, l, t, d), which is divided into a target image branch {x} and a conditional control branch {s, l, t, d}. Here, x represents an image (such as an image containing a character verification code), s represents the character content corresponding to the image, l represents the character length corresponding to the image, t represents the character type corresponding to the image, and d represents the interference type corresponding to the image.

[0067] In the conditional control branch, each character of s is first converted to ASCII code, and then mapped to a fixed 128-dimensional feature vector through a pre-trained embedding layer Word2Vec. To adapt to character sequences of different lengths, a dynamic padding method is used to finally generate a uniform dimension vector independent of character length. The character length l∈{4,5,6} (e.g., l=5 is encoded as [0,1,0]); the character type l∈{number, character, symbol} is defined (e.g., number type is encoded as [1,0,0]); for the interference type d∈{arc interference, grid background, character distortion} (e.g., character distortion is encoded as [0,0,1]), the encoded feature vectors are finally concatenated to obtain a 137-dimensional conditional control vector.

[0068] In generator construction, the parallel instances (buckets) of each level path (or route) are generated by generator blocks. In discriminator construction, the discriminator is composed of multiple discriminator blocks connected in series, and finally works with a fully connected layer to output the predicted probabilities of real and fake samples.

[0069] Optionally, the conditional feature vector includes a character length feature vector, a character content feature vector, a character type feature vector, and an interference type feature vector; the character length feature vector is used to control the geometric structure layer, the character content feature vector and the character type feature vector are used to control the semantic feature layer, and the interference type feature vector is used to control the detail generation layer.

[0070] See Figure 2 The generator D takes fixed noise z and conditional feature vector c as input, where the probability distribution of z follows a standard normal distribution p. z ~N(0,1). Unlike traditional GAN ​​text graph generation tasks, CAPTCHA generation tasks require more diverse and specific CAPTCHA requirements. This invention employs a hierarchical random routing mechanism to ensure the diversity of generated CAPTCHAs, and a conditional injection module and a two-stage training mode to ensure their conditional specificity.

[0071] The generator adopts a hierarchical random routing mechanism and is divided into three concatenated layers: the bottom layer B1 (geometric structure layer), the middle layer B2 (semantic feature layer), and the top layer B3 (detail generation layer).

[0072] Each level is controlled by a conditional feature vector c related to image generation. Following the general rule of the generation process from coarse to fine, the geometric structure (character length) of the generated image (such as a verification code) is determined first, then the semantic features (character content, character type) of the generated image are optimized, and finally the detailed texture of the image (interference type) is generated.

[0073] The construction process of the conditional control vector c is as follows: the character length feature vector c[128:130] controls the geometric structure layer, the character content feature vector c[0:127] and the character type feature vector c[131:133] control the semantic feature layer, and the interference type feature vector c[134:136] controls the detail generation layer.

[0074] See Figure 2 Let f B1 f B2 f B3 For each parallel instance, r1∈[1:m1], r2∈[1:m2], and r3∈[1:m3] are specific instance numbers. The final process of generating image y is as follows:

[0075] f B1 =B 1, r1 (z,c[128:130]) (1)

[0076] f B2 =B 2, r2 (f B1 ,c[0:127],c[131:133]) (2)

[0077] f B3 =B 3, r3 (f B2 , c[134:136]) (3)

[0078] y = f B3 =G(z,c) (4)

[0079] Formulas (1) to (4) above describe the process of the generator generating images in the generative adversarial network of the present invention, and also describe the process of the first generator generating images after training.

[0080] It should be noted that during the training phase, all routes (or paths) at each level are traversed to generate images, while during the inference phase, instances at each level are randomly selected to construct output paths. This ensures that each path during the training phase generates images that meet the requirements (such as CAPTCHAs), and also makes the images output during the inference phase (such as CAPTCHAs) more diverse. The conditional injection process designed in this invention is embedded in each layer of the generator based on the hierarchical routing mechanism, providing more detailed guidance.

[0081] Optionally, the discriminator uses ResNet152 (a deep residual network with 152 layers). The input is a conditional feature vector (or conditional code) c and the generated image y. The output is the generation probability (0 for real, 1 for generated). The process is as follows:

[0082] (5)

[0083] The training process of generative adversarial networks will be explained below.

[0084] In some embodiments, the method of the present invention further includes:

[0085] Obtain a training dataset, which includes multiple training data sets, each of which includes an image sample and a conditional feature vector corresponding to the image sample;

[0086] This invention collects a large number of real image samples (such as a large number of real character verification code images) and classifies them according to character length, character type, and interference type. The character length is set to 4-6 characters, the character type includes numbers, letters, and symbols, and the interference types include curved interference, grid background, and character distortion. To ensure the construction of a high-quality training dataset, this invention uses Optical Character Recognition (OCR) tools to filter blurry or unrecognizable images (such as verification code images), retaining 50,000 clear and annotated images. Finally, each training dataset contains an image sample x and the corresponding conditional feature vector.

[0087] The conditional feature vectors include the character length l feature vector, the character content s feature vector, the character type t feature vector, and the interference type d feature vector.

[0088] The generative adversarial network is pre-trained unsupervised based on the training dataset and random noise that follows a normal distribution to obtain a first generative adversarial network.

[0089] Here, the pre-training phase initializes the generative adversarial network in an unsupervised manner. The first phase (i.e., the pre-training phase) learns the basic distribution of real images to generate random images (such as random CAPTCHAs).

[0090] Based on the generated image output by the generator in the pre-training phase, the first generative adversarial network is trained in a supervised manner using a conditional encoder to obtain the first generator.

[0091] It should be noted that the supervised training phase (i.e., the conditional fine-tuning phase) generates conditional images (such as CAPTCHAs) through supervised training. Here, while the images generated in the pre-training phase possess diversity and universal characteristics, they are not constrained by the input conditions, making it difficult to accurately generate the desired images. In the second phase (i.e., the supervised training phase), conditional constraints on the images are introduced, using the conditional constraint loss L (described later). condition Achieve controllable generation.

[0092] The conditional encoder is pre-trained.

[0093] The generator in this embodiment of the invention adopts a hierarchical random routing partitioning mechanism, controls the output through conditional feature vectors, and accurately generates images that meet the conditions (such as CAPTCHAs) by combining a two-stage training mode.

[0094] As an optional implementation, the generative adversarial network is unsupervisedly pre-trained based on the training dataset and normally distributed random noise to obtain a first generative adversarial network, including:

[0095] The generative adversarial network is iteratively trained based on the training dataset and random noise that follows a normal distribution.

[0096] For each training iteration, the input to the generative adversarial network includes an image sample and random noise that follows a normal distribution.

[0097] That is, the input is an image sample (such as a real CAPTCHA image) x ~ data (selecting sample x from image sample data), and the generator generates an image y ~ p. z (Using input noise z as the "seed" for generating the image, and the distribution follows p) z ~N(0,1), after being transformed layer by layer by the generator's neural network, is finally transformed into the generated image y. Essentially, the generator attempts to learn a mapping relationship from a "simple noise distribution" z to a "complex image distribution" y, and to make the generated image y as close as possible to the real image x.

[0098] Based on the first loss function, the network parameters corresponding to the generator in the generative adversarial network are updated. Based on the second loss function, the network parameters corresponding to the discriminator in the generative adversarial network are updated until the iteration termination condition is met, thus obtaining the first generative adversarial network.

[0099] The first loss function is obtained by linearly weighting the generator loss function and the instance diversity loss function. The generator loss function is obtained by linearly weighting the adversarial loss based on the generated image, the gradient norm penalty corresponding to the real image, and the gradient norm penalty corresponding to the generated image. The instance diversity loss function is the negative of the sum of the mean square errors of the parameters between instances of different paths.

[0100] The second loss function is the sum of the discriminator's loss on the real image and the discriminator's loss on the generated image.

[0101] Specifically, the first loss function L1=aL GAN + bL diversity , where L GAN L represents the generator loss function. diversity This represents the instance diversity loss function, where a and b are constants. Optional, a = b = 1.

[0102] (6)

[0103] Where E is the expectation operator, and the subscripts describe the distribution of the random variable, indicating the probability distribution on which the expectation calculation is based. The above equation represents the process during the training of a Generative Adversarial Network (GAN), where the generator G generates fake samples (fake images) G(z) based on noise z, and then calculates the discriminator's output for the fake samples. Logarithmic expectation (take) The goal is to make the fake samples generated by the generator appear real to the discriminator, i.e., to "fool" the discriminator. Among these... This represents the adversarial loss based on the generated image. This represents the gradient norm penalty corresponding to the real image. R1 and R2 represent the gradient norm penalty for the corresponding generated image. R1 and R2 are zero-center gradient penalties, which force the gradient norm of the discriminator to be stable on the real / generated images.

[0104] To ensure that different route (or path) instances are distinct in the hierarchical random routing partitioning mechanism and to avoid generating images with a single pattern, an instance diversity loss L is set. diversity To optimize generator diversity:

[0105] (7)

[0106] Where W represents all learnable parameters of the generator, and i and j represent distinct instances. The standard deviation of the parameters is calculated. The sum of the mean squared errors (MSEs) of different instances represents the parameter similarity between the different instances. By taking its negative value, the generator is forced to construct diverse generation paths in the geometric structure layer, semantic feature layer, and detail generation layer by maximizing the parameter differences between different routing instances, making the generated images under different output paths more diverse.

[0107] It should be noted that the discriminator's loss function, i.e., the second loss function, remains unchanged during the two-stage training (pre-training stage and conditional fine-tuning stage), namely, distinguishing real samples and generating samples. The second loss function L... Dis The design is as follows:

[0108] (8)

[0109] in, This represents the loss of the discriminator in relation to the real image. This represents the loss of the discriminator in generating the image.

[0110] During the pre-training phase, the difference between the generated image and the real image is maximized by adversarial loss, the zero-center gradient penalty is used to ensure the stability of the discriminator, and an instance diversity loss function is set to avoid the problem of the generator outputting images with a single pattern.

[0111] Based on this, in an optional embodiment, the conditional feature vector includes a character length feature vector, a character content feature vector, a character type feature vector, and an interference type feature vector.

[0112] Accordingly, the iterative training of the generative adversarial network based on the training dataset and normally distributed random noise includes:

[0113] Based on the conditional feature vector and the random noise, traverse all generation paths constructed by each layer instance in the generator to obtain the generated image output by each generation path;

[0114] During the training process for each generation path, the geometric structure layer is controlled by the character length feature vector, the semantic feature layer is controlled by the character content feature vector and the character type feature vector, and the detail generation layer is controlled by the interference type feature vector.

[0115] In other words, during the training phase, all paths (or routes) at each level of the generator will be traversed to generate images, using the instance diversity loss L set as described above. diversity To maximize the parameter differences between different path instances, the generator is forced to construct diverse generation paths in the geometric structure layer, semantic feature layer, and detail generation layer, making the generated images under different output paths more diverse.

[0116] As an optional implementation, the first generator is obtained by supervising the first generative adversarial network using a conditional encoder based on the generated image output by the generator in the pre-training phase, including:

[0117] For each training iteration, the generated image based on the generator output from the pre-training phase is input into the conditional encoder to obtain the predicted conditional feature vector.

[0118] During the supervised training phase (i.e., the conditional fine-tuning phase), based on the pre-trained conditional encoder, for the input generated image (i.e., the generated image output by the generator in the pre-training phase) y, the predicted conditional feature vector is obtained. .

[0119] It should be noted that the conditional encoder architecture is pre-trained on the dataset in this paper using a lightweight ResNet34 (a 34-layer deep residual network), and the training process assigns labels as... Image I is encoded as a conditional feature vector The ability to map images back to the conditional space; the training loss of the conditional encoder during pre-training is as follows:

[0120] (9)

[0121] (10)

[0122] Under the supervision of the conditional encoder, it is possible to detect whether the generator follows the conditions during training. The generated image is the conditional feature vector of the conditional encoder. Is it related to the conditional eigenvector at the time of generation? Consistent.

[0123] Based on the third loss function, the network parameters corresponding to the generator in the first generative adversarial network are updated until the iteration termination condition is met, thus obtaining the first generator.

[0124] The third loss function is obtained by linearly weighting the first loss function and the conditional loss function. The conditional loss function is the square of the L2 norm between the predicted conditional feature vector and the real conditional feature vector corresponding to the generated image.

[0125] The first loss function is obtained by linearly weighting the generator loss function and the instance diversity loss function. The generator loss function is obtained by linearly weighting the adversarial loss based on the generated image, the gradient norm penalty corresponding to the real image, and the gradient norm penalty corresponding to the generated image. The instance diversity loss function is the negative of the sum of the mean square errors of the parameters between instances of different paths.

[0126] It should be noted that during the conditional fine-tuning stage, under the hierarchical random routing mechanism, the conditional injection module proposed in this invention will finely control the output of each level, and the final generated result is also supervised by the conditional encoder. By controlling the conditional generation in both generation and supervision aspects, the generated image is highly controllable.

[0127] The first loss function is specifically expressed as: L1 = aL GAN + bL diversity Among them, L GAN The specific expression, L diversity For a detailed explanation of the specific implementation method, please refer to the above section on implementation methods. It will not be repeated here.

[0128] In this implementation, the third loss function L2 = aL GAN + bL diversity +cL condition , where L GAN L represents the generator loss function. diversity L represents the instance diversity loss function. condition This represents the conditional loss function, where a, b, and c are constants. Optional, a = b = c = 1.

[0129] Specifically, the conditional loss function L condition The design is as follows:

[0130]

[0131]

[0132] (11)

[0133] Ultimately, L GAN To ensure that the generated image has a similar distribution to the real image, L diversity To ensure diversity, L condition Constrain each instance by inputting conditional feature vectors This generates an image y, and under the supervision of a conditional encoder, determines the predicted conditional feature vector. With input condition vector Consistent, meaning the generated image meets the condition {s,l,t,d}.

[0134] In this implementation, during the conditional fine-tuning stage, a conditional constraint loss function is used to ensure that the generated image accurately meets the input character content, character length, character type, and interference type conditions while satisfying general features. This achieves a smooth transition from unsupervised to supervised learning, improving the quality and diversity of the generated image.

[0135] The network training method of this invention employs a two-stage training model: first, unsupervised training, followed by supervised fine-tuning. This reduces reliance on large-scale datasets and lowers training costs. During the inference phase, the generator selects a subset of instances from a large number of instances to activate certain routes, enabling rapid generation of images that meet the criteria. This improves generation speed and allows for timely responses to the rapid iteration and frequent testing requirements of web applications, providing strong support for the testing process.

[0136] After completing network training, this invention conducts multi-dimensional verification: During internal verification, an independent test set is divided from the training dataset (the training set and test set are divided in a 7:3 ratio at the initial stage of dataset construction). Various combinations of input conditions (different character content s, character length l, character type t, and interference type d) are used to generate images (such as CAPTCHAs). The recognizability and matching degree of the generated images are checked using tools such as OCR. At the same time, FID is calculated to evaluate the realism of the images, ensuring that the generation quality and diversity meet the standards.

[0137] Furthermore, it is deployed in a real-world web application testing environment and integrated into the web testing workflow: the model is encapsulated as an automated interface, supporting the rapid generation of images according to test requirements (specifying character content s, character length l, character type t, and interference type d). After deployment, it continuously provides diverse test data for scenarios such as web application feature iteration and security auditing. By batch generating images of extreme scenarios (such as CAPTCHAs), it efficiently exposes potential system defects, contributing to the stable iteration of web applications.

[0138] This invention employs a unique generator and discriminator architecture, along with a meticulously designed two-stage training mode. The pre-training stage learns the distribution of real images, introduces zero-center gradient penalty to effectively avoid the mode collapse problem in traditional GAN ​​training, and utilizes a conditional constraint loss function in the conditional fine-tuning stage to achieve controllable image generation. This effectively solves the mode collapse problem of traditional GANs and ensures generation stability.

[0139] The training dataset constructed in this invention covers different character lengths, types, and interference types, providing rich material for the generator. Through precise control of conditional feature vectors, the generator can generate images with rich diversity in character shape, arrangement, and background interference. In addition, the use of hierarchical random routing mechanism and instance diversity loss further enhances the diversity of generated images, fully meeting the needs of web applications for diverse test images (such as CAPTCHAs).

[0140] like Figure 6 As shown, embodiments of the present invention also provide a test image generation apparatus, which may include:

[0141] The first acquisition module 601 is used to acquire random noise and first test requirement information, wherein the first test requirement information includes at least one of character content, character length, character type, and interference type;

[0142] Image generation module 602 is used to input the random noise and the first test requirement information into a first generator to obtain a first test image that meets the test requirements; wherein, the first generator is trained based on a generative adversarial network, and the generator in the generative adversarial network includes a geometric structure layer, a semantic feature layer and a detail generation layer connected in sequence. The character length of the generated image output by the geometric structure layer, the character content and character type of the generated image output by the semantic feature layer, and the detail texture of the generated image output by the detail generation layer are all controlled by conditional feature vectors related to image generation.

[0143] Optionally, each level of the generator includes multiple parallel instances consisting of generation blocks, each generation block comprising a concatenated convolutional layer, a bilinear interpolation upsampling layer, and a residual block.

[0144] The discriminator of the generative adversarial network comprises multiple cascaded discriminator blocks, each of which includes a residual block, a bilinear interpolation downsampling layer, and a convolutional layer, which are cascaded in sequence.

[0145] In some embodiments, the apparatus of the present invention further includes:

[0146] The second acquisition module is used to acquire a training dataset, which includes multiple training data, each of which includes an image sample and a conditional feature vector corresponding to the image sample.

[0147] The first training module is used to perform unsupervised pre-training on the generative adversarial network based on the training dataset and random noise that follows a normal distribution, so as to obtain the first generative adversarial network.

[0148] The second training module is used to supervise the first generative adversarial network by using a conditional encoder based on the generated image output by the generator in the pre-training phase, so as to obtain the first generator.

[0149] In some embodiments, the first training module includes:

[0150] The first training unit is used to iteratively train the generative adversarial network based on the training dataset and random noise that follows a normal distribution.

[0151] The first parameter update unit is used to update the network parameters corresponding to the generator in the generative adversarial network based on the first loss function, and to update the network parameters corresponding to the discriminator in the generative adversarial network based on the second loss function, until the iteration termination condition is met, so as to obtain the first generative adversarial network.

[0152] The second loss function is the sum of the discriminator's loss on the real image and the discriminator's loss on the generated image.

[0153] In some embodiments, the conditional feature vector includes a character length feature vector, a character content feature vector, a character type feature vector, and an interference type feature vector; the first training unit is specifically used for:

[0154] Based on the conditional feature vector and the random noise, traverse all generation paths constructed by each layer instance in the generator to obtain the generated image output by each generation path;

[0155] During the training process for each generation path, the geometric structure layer is controlled by the character length feature vector, the semantic feature layer is controlled by the character content feature vector and the character type feature vector, and the detail generation layer is controlled by the interference type feature vector.

[0156] In some embodiments, the second training module includes:

[0157] The processing unit is used to input the generated image based on the generator output in the pre-training phase into the conditional encoder for each training session to obtain the predicted conditional feature vector.

[0158] The second parameter update unit is used to update the network parameters corresponding to the generator in the first generative adversarial network based on the third loss function until the iteration termination condition is met, so as to obtain the first generator.

[0159] The third loss function is obtained by linearly weighting the first loss function and the conditional loss function. The conditional loss function is the square of the L2 norm between the predicted conditional feature vector and the real conditional feature vector corresponding to the generated image.

[0160] Optionally, the first loss function is obtained by linearly weighting the generator loss function and the instance diversity loss function. The generator loss function is obtained by linearly weighting the adversarial loss based on the generated image, the gradient norm penalty corresponding to the real image, and the gradient norm penalty corresponding to the generated image. The instance diversity loss function is the negative of the sum of the mean squared errors of the parameters between instances of different paths.

[0161] The test image generation module of this invention acquires random noise and first test requirement information, which includes at least one of character content, character length, character type, and interference type. The random noise and the first test requirement information are input into a first generator to obtain a first test image that meets the test requirements. The first generator is trained based on a generative adversarial network (GAN). The generator in the GAN includes a geometric structure layer, a semantic feature layer, and a detail generation layer connected in series. The character length of the generated image output by the geometric structure layer, the character content and character type of the generated image output by the semantic feature layer, and the detail texture of the generated image output by the detail generation layer are all controlled by conditional feature vectors related to image generation. Thus, by training a first generator with conditional control over image generation, the obtained test image meets the test requirements, improving the generation efficiency and quality of the test image.

[0162] To better achieve the above objectives, such as Figure 7 As shown, this embodiment of the invention also provides a test image generation device, including a processor 700 and a transceiver 710. The transceiver 710 receives and transmits data under the control of the processor 700, and the processor 700 is used to perform the following process:

[0163] Obtain random noise and first test requirement information, wherein the first test requirement information includes at least one of character content, character length, character type, and interference type;

[0164] The random noise and the first test requirement information are input into the first generator to obtain a first test image that meets the test requirements. The first generator is trained based on a generative adversarial network. The generator in the generative adversarial network includes a geometric structure layer, a semantic feature layer and a detail generation layer connected in series. The character length of the generated image output by the geometric structure layer, the character content and character type of the generated image output by the semantic feature layer, and the detail texture of the generated image output by the detail generation layer are all controlled by conditional feature vectors related to image generation.

[0165] Optionally, each level of the generator includes multiple parallel instances consisting of generation blocks, each generation block comprising a concatenated convolutional layer, a bilinear interpolation upsampling layer, and a residual block.

[0166] The discriminator of the generative adversarial network comprises multiple cascaded discriminator blocks, each of which includes a residual block, a bilinear interpolation downsampling layer, and a convolutional layer, which are cascaded in sequence.

[0167] In some embodiments, the processor 700 is further configured to:

[0168] Obtain a training dataset, which includes multiple training data sets, each of which includes an image sample and a conditional feature vector corresponding to the image sample;

[0169] The generative adversarial network is pre-trained unsupervised based on the training dataset and random noise that follows a normal distribution to obtain a first generative adversarial network.

[0170] Based on the generated image output by the generator in the pre-training phase, the first generative adversarial network is trained in a supervised manner using a conditional encoder to obtain the first generator.

[0171] In some embodiments, the processor 700 is further configured to:

[0172] The generative adversarial network is iteratively trained based on the training dataset and random noise that follows a normal distribution.

[0173] Based on the first loss function, the network parameters corresponding to the generator in the generative adversarial network are updated, and based on the second loss function, the network parameters corresponding to the discriminator in the generative adversarial network are updated until the iteration termination condition is met, thus obtaining the first generative adversarial network.

[0174] The second loss function is the sum of the discriminator's loss on the real image and the discriminator's loss on the generated image.

[0175] In some embodiments, the conditional feature vector includes a character length feature vector, a character content feature vector, a character type feature vector, and a interference type feature vector; correspondingly, the processor 700 is further configured to:

[0176] Based on the conditional feature vector and the random noise, traverse all generation paths constructed by each layer instance in the generator to obtain the generated image output by each generation path;

[0177] During the training process for each generation path, the geometric structure layer is controlled by the character length feature vector, the semantic feature layer is controlled by the character content feature vector and the character type feature vector, and the detail generation layer is controlled by the interference type feature vector.

[0178] In some embodiments, the processor 700 is further configured to:

[0179] For each training iteration, the generated image based on the generator output during the pre-training phase is input into the conditional encoder to obtain the predicted conditional feature vector.

[0180] Based on the third loss function, the network parameters corresponding to the generator in the first generative adversarial network are updated until the iteration termination condition is met, and the first generator is obtained.

[0181] The third loss function is obtained by linearly weighting the first loss function and the conditional loss function. The conditional loss function is the square of the L2 norm between the predicted conditional feature vector and the real conditional feature vector corresponding to the generated image.

[0182] Optionally, the first loss function is obtained by linearly weighting the generator loss function and the instance diversity loss function. The generator loss function is obtained by linearly weighting the adversarial loss based on the generated image, the gradient norm penalty corresponding to the real image, and the gradient norm penalty corresponding to the generated image. The instance diversity loss function is the negative of the sum of the mean squared errors of the parameters between instances of different paths.

[0183] The test image generation device of this invention acquires random noise and first test requirement information, the first test requirement information including at least one of character content, character length, character type, and interference type; inputs the random noise and the first test requirement information into a first generator to obtain a first test image that meets the test requirements; wherein, the first generator is trained based on a generative adversarial network, the generator in the generative adversarial network includes a geometric structure layer, a semantic feature layer, and a detail generation layer connected in series, the character length of the generated image output by the geometric structure layer, the character content and character type of the generated image output by the semantic feature layer, and the detail texture of the generated image output by the detail generation layer are all controlled by conditional feature vectors related to image generation. In this way, by training a first generator with conditional control of the generated image, the obtained test image can meet the test requirements, improving the generation efficiency and quality of the test image.

[0184] This invention also provides a test image generation device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the various processes in the test image generation method embodiments described above and achieves the same technical effect. To avoid repetition, it will not be described again here.

[0185] This invention also provides a computer-readable storage medium storing a computer program. When executed by a processor, this program implements the various processes described above in the test image generation method embodiments, achieving the same technical effects. To avoid repetition, further details are omitted here. The computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0186] The invention also provides a computer program product, including computer instructions. When the computer instructions are executed by a processor, they implement the various processes in the test image generation method embodiments described above and achieve the same technical effect. To avoid repetition, they will not be described again here.

[0187] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-readable storage media (including, but not limited to, disk storage and optical storage) containing computer-usable program code.

[0188] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 A device for one or more processes and / or the functions specified in one or more boxes.

[0189] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce a paper article including an instruction means, the instruction means being implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0190] These computer program instructions can also be loaded onto a computer or other programmable data processing equipment, causing the computer or other programmable equipment to perform a series of operational steps to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0191] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A method for generating test images, characterized in that, include: Obtain random noise and first test requirement information, wherein the first test requirement information includes at least one of character content, character length, character type, and interference type; The random noise and the first test requirement information are input into the first generator to obtain a first test image that meets the test requirements. The first generator is trained based on a generative adversarial network. The generator in the generative adversarial network includes a geometric structure layer, a semantic feature layer, and a detail generation layer connected in series. The character length of the generated image output by the geometric structure layer, the character content and character type of the generated image output by the semantic feature layer, and the detail texture of the generated image output by the detail generation layer are all controlled by conditional feature vectors related to image generation.

2. The method according to claim 1, characterized in that, Each level of the generator includes multiple parallel instances consisting of generation blocks, each generation block comprising a concatenated convolutional layer, a bilinear interpolation upsampling layer, and a residual block. The discriminator of the generative adversarial network comprises multiple cascaded discriminator blocks, each of which includes a residual block, a bilinear interpolation downsampling layer, and a convolutional layer, which are cascaded in sequence.

3. The method according to claim 2, characterized in that, The method further includes: Obtain a training dataset, which includes multiple training data sets, each of which includes an image sample and a conditional feature vector corresponding to the image sample; The generative adversarial network is pre-trained unsupervised based on the training dataset and random noise that follows a normal distribution to obtain a first generative adversarial network. Based on the generated image output by the generator in the pre-training phase, the first generative adversarial network is trained in a supervised manner using a conditional encoder to obtain the first generator.

4. The method according to claim 3, characterized in that, The step of unsupervised pre-training the generative adversarial network based on the training dataset and normally distributed random noise to obtain a first generative adversarial network includes: The generative adversarial network is iteratively trained based on the training dataset and random noise that follows a normal distribution. Based on the first loss function, the network parameters corresponding to the generator in the generative adversarial network are updated, and based on the second loss function, the network parameters corresponding to the discriminator in the generative adversarial network are updated until the iteration termination condition is met, thus obtaining the first generative adversarial network. The second loss function is the sum of the discriminator's loss on the real image and the discriminator's loss on the generated image.

5. The method according to claim 4, characterized in that, The conditional feature vector includes a character length feature vector, a character content feature vector, a character type feature vector, and an interference type feature vector; The iterative training of the generative adversarial network based on the training dataset and normally distributed random noise includes: Based on the conditional feature vector and the random noise, traverse all generation paths constructed by each layer instance in the generator to obtain the generated image output by each generation path; During the training process for each generation path, the geometric structure layer is controlled by the character length feature vector, the semantic feature layer is controlled by the character content feature vector and the character type feature vector, and the detail generation layer is controlled by the interference type feature vector.

6. The method according to claim 3, characterized in that, The first generator is obtained by supervising the first generative adversarial network using a conditional encoder based on the generated image output from the generator in the pre-training phase, including: For each training iteration, the generated image based on the generator output during the pre-training phase is input into the conditional encoder to obtain the predicted conditional feature vector. Based on the third loss function, the network parameters corresponding to the generator in the first generative adversarial network are updated until the iteration termination condition is met, and the first generator is obtained. The third loss function is obtained by linearly weighting the first loss function and the conditional loss function. The conditional loss function is the square of the L2 norm between the predicted conditional feature vector and the real conditional feature vector corresponding to the generated image.

7. The method according to claim 4 or 6, characterized in that, The first loss function is obtained by linearly weighting the generator loss function and the instance diversity loss function. The generator loss function is obtained by linearly weighting the adversarial loss based on the generated image, the gradient norm penalty corresponding to the real image, and the gradient norm penalty corresponding to the generated image. The instance diversity loss function is the negative of the sum of the mean square errors of the parameters between instances of different paths.

8. A test image generation apparatus, characterized in that, include: The first acquisition module is used to acquire random noise and first test requirement information, wherein the first test requirement information includes at least one of character content, character length, character type, and interference type; An image generation module is used to input the random noise and the first test requirement information into a first generator to obtain a first test image that meets the test requirements. The first generator is trained based on a generative adversarial network. The generator in the generative adversarial network includes a geometric structure layer, a semantic feature layer, and a detail generation layer connected in series. The character length of the generated image output by the geometric structure layer, the character content and character type of the generated image output by the semantic feature layer, and the detail texture of the generated image output by the detail generation layer are all controlled by conditional feature vectors related to image generation.

9. A test image generation device, characterized in that, It includes a processor and a transceiver, the transceiver receiving and transmitting data under the control of the processor, characterized in that the processor is configured to perform the following operations: Obtain random noise and first test requirement information, wherein the first test requirement information includes at least one of character content, character length, character type, and interference type; The random noise and the first test requirement information are input into the first generator to obtain a first test image that meets the test requirements. The first generator is trained based on a generative adversarial network. The generator in the generative adversarial network includes a geometric structure layer, a semantic feature layer and a detail generation layer connected in series. The character length of the generated image output by the geometric structure layer, the character content and character type of the generated image output by the semantic feature layer, and the detail texture of the generated image output by the detail generation layer are all controlled by conditional feature vectors related to image generation.

10. A test image generation device, comprising a memory, a processor, and a computer program stored in the memory and running thereon, characterized in that, When the processor executes the program, it implements the test image generation method as described in any one of claims 1 to 7.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the program implements the steps of the test image generation method as described in any one of claims 1 to 7.

12. A computer program product, characterized in that, It includes computer instructions that, when executed by a processor, implement the steps in the test image generation method as described in any one of claims 1 to 7.