A method, system and device for generating a few-sample image
By constructing a latent vector set and an initial generative adversarial network, and applying comparative learning ideas, the over-fitting problem in few-sample image generation is solved, the quality and diversity of images are improved, and the performance of existing technologies is surpassed.
Patent Information
- Application Number
- CN202311305967.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-10
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2043-10-10
AI Technical Summary
In a few-sample setting, it is difficult for existing techniques to generate high-quality and diverse images. Especially when the training set contains only a small number of samples, the generative model is prone to overfitting, resulting in low image diversity.
By constructing the first latent vector set and the second latent vector set, and constructing an initial few-sample image generation adversarial network, using the target image training sample set to optimize the network training, and using the idea of contrastive learning to effectively utilize the latent feature information between samples, we get Excellent few-shot image generator.
Even with a small number of samples, being able to train improves the quality and diversity of generated images, surpassing the performance of baseline methods.
Smart Images

Figure CN117372806B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image generation technology, and in particular to a method, system and device for generating a few-sample image. Background Art
[0002] At present, generative models have achieved remarkable results in various generative tasks, such as online makeup trial, AI painting, and natural image synthesis. However, the success of these generative models depends heavily on a large-scale available training set. When the size of the training set is limited, especially when the training set contains only a small number of training samples (for example, 10 images), the quality and diversity of the images generated by these generative models will be severely degraded. In fact, due to production costs, time cycles, geographical locations, and confidentiality, it is very difficult to obtain training sets for many specific generative tasks (for example, artists' works, medical images, and military combat scenes).
[0003] In order to solve the problem of image generation under limited sample conditions, some researchers have proposed several enhancement techniques and model architectures to improve the performance of generative models. In 2020, Karras et al. proposed an adaptive discriminator augmentation (ADA) mechanism, which can significantly stabilize the training process under limited sample conditions. In the same year, Zhao et al. proposed a differentiable data augmentation (DA) method, which avoids discriminator overfitting by performing differentiable augmentation on real / generated data. In 2021, Liu et al. achieved the image generation task under limited sample conditions by using a cross-layer channel excitation module and a self-supervised discriminator. This method is called FastGAN. In 2022, Cui et al. introduced multiple complementary discriminators to provide diversified supervision from multiple different angles, effectively alleviating the problem of discriminator overfitting. This method is called GenCo. In 2023, Chen Zheng et al. proposed a few-shot image generation method (DrawGAN) based on the painter's idea, established a more stable training framework and generator, and improved the quality of limited sample image generation. The above methods often only need hundreds of training samples to generate realistic fake images, which alleviates the problem of limited number of training set samples to a certain extent. However, for specific tasks of generating images with a small number of samples (for example, the training set contains only 10 training samples), the above methods often overfit during the training process because the discriminator easily remembers the training samples, resulting in low diversity of generated images.
[0004] In order to generate high-quality and diverse images in the few-shot setting, the Cross-domain Distance Consistency (CDC) method and the Dual Contrastive Learning (DCL) method require a source domain generation model pre-trained on a large-scale training set, and retrain the source domain generation model with a small number of target domain training samples to obtain a new target domain generation model adapted to the few-shot target domain. The success of the CDC and DCL methods in the few-shot image generation task lies in having a large-scale source domain generation model and requiring a significant semantic similarity relationship between the source domain and the target domain, which greatly limits the application and development of the few-shot image generation task.
[0005] In 2022, Kong et al. first challenged a real few-shot image generation task, called Mixup-based Distance Learning (MixDL) method. In other words, MixDL can train an excellent generative model from scratch with only 10 training samples, but the diversity of images generated by MixDL using the idea of relative semantic distance in the few-shot setting is generally low. Summary of the invention
[0006] The purpose of the present invention is to provide a method, system and device for generating a few-sample image, so as to solve the problem of generating high-quality and diversified images under a few-sample setting.
[0007] To achieve the above object, the present invention provides the following solutions:
[0008] In a first aspect, the present invention provides a method for generating a few-sample image, comprising:
[0009] Obtain a target image training sample set;
[0010] Constructing a first latent vector set and a second latent vector set; the i-th latent vector in the first latent vector set is independent of the i-th latent vector in the second latent vector set, and the i-th latent vector in the first latent vector set is related to other latent vectors in the second latent vector set;
[0011] Constructing an initial few-shot image generation adversarial network; the initial few-shot image generation adversarial network includes a generator and a discriminator; the generator is used to generate an image based on a latent vector in the first latent vector set or the second latent vector set;
[0012] Using the target image training sample set, the first latent vector set, and the second latent vector set, the initial few-shot image generative adversarial network is optimized and trained to obtain a few-shot image generator;
[0013] The latent vector to be processed is input into the few-sample image generator to obtain a final generated image.
[0014] In a second aspect, the present invention provides a few-sample image generation system, comprising:
[0015] An image sample acquisition module is used to acquire a target image training sample set;
[0016] A vector set construction module, used to construct a first potential vector set and a second potential vector set; the i-th potential vector in the first potential vector set is independent of the i-th potential vector in the second potential vector set, and the i-th potential vector in the first potential vector set is related to other potential vectors in the second potential vector set;
[0017] An image generation adversarial network construction module, used to construct an initial few-shot image generation adversarial network; the initial few-shot image generation adversarial network includes a generator and a discriminator; the generator is used to generate an image based on a latent vector in the first latent vector set or the second latent vector set;
[0018] An image generator determination module, configured to optimize and train the initial few-sample image generation adversarial network using the target image training sample set, the first latent vector set, and the second latent vector set to obtain a few-sample image generator;
[0019] The image generation module is used to input the potential vector to be processed into the few-sample image generator to obtain a final generated image.
[0020] In a third aspect, the present invention provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute a few-sample image generation method.
[0021] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:
[0022] The present invention discloses a method, system and device for generating a few-sample image, constructing a first latent vector set and a second latent vector set, wherein the i-th latent vector in the first latent vector set is independent of the i-th latent vector in the second latent vector set, and the i-th latent vector in the first latent vector set is related to other latent vectors in the second latent vector set; using a target image training sample set, a first latent vector set and a second latent vector set, an initial few-sample image generation adversarial network is optimized and trained to obtain a few-sample image generator, and then image generation is performed. The present invention trains an initial few-sample image generation adversarial network composed of a generator and a discriminator, and realizes effective use of potential feature information between samples based on the idea of contrastive learning (CL), so that even in the case of a small number of samples, an excellent few-sample image generator can still be trained for few-sample image generation, which can effectively improve the quality and diversity of generated images. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0024] Figure 1 Schematic diagram of the process of generating a few-sample image according to the present invention;
[0025] Figure 2 A schematic diagram of the network architecture of the method for generating a few-sample image according to the present invention;
[0026] Figure 3 A comparison chart of the generation results of the present invention and the baseline method on the Sketches and AFHQ-Cat datasets;
[0027] Figure 4 A comparison chart of the generation results of the present invention and the baseline method on the AFHQ-Wild dataset;
[0028] Figure 5 A comparison chart of the generation results of the present invention and the baseline method on the AFHQ-Dog dataset;
[0029] Figure 6 Schematic diagram of a system for generating a few-sample image according to the present invention. DETAILED DESCRIPTION
[0030] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0031] The present invention provides a few-sample image generation method, system and device, constructs a latent vector set and an initial generative adversarial network, the initial generative adversarial network includes a generator (Generator, G) and a discriminator (Discriminator, D); the generator is obtained by training the initial generative adversarial network using the latent vector set and the training set; the latent vector is input into the generator to obtain a generated image; the present invention effectively improves the quality and diversity of the generated images.
[0032] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0033] Embodiment 1
[0034] like Figure 1 As shown, the present invention provides a method for generating a few-sample image, comprising:
[0035] Step 100, obtaining a target image training sample set. Specifically, obtaining any number of target images to be generated, all of which are real images, such as 10 images of artists' works; then preprocessing the target images to unify the image size, thereby obtaining a target image training sample set of the same size.
[0036] Step 200, construct a first latent vector set and a second latent vector set, i.e., {Z, Z′}; the i-th latent vector in the first latent vector set is independent of the i-th latent vector in the second latent vector set, and the i-th latent vector in the first latent vector set is related to other latent vectors in the second latent vector set.
[0037] The latent vector set refers to a set of low-dimensional vectors, and each latent vector z is passed through the generator G to obtain the generated image G(z); specifically, each latent vector in the first latent vector set is a one-dimensional vector containing 512 elements, expressed as:
[0038]
[0039] Among them, z i represents the i-th latent vector in the first latent vector set, Denotes the latent vector z iThe nth element of , n = 1, 2, ..., 512, N represents the number of latent vectors in the first latent vector set. The first latent vector set is:
[0040]
[0041] Among them, Z represents the first potential vector set, z i ~p(z), p(z) represents a known prior distribution. In a specific practical application, p(z) is a standard normal distribution, expressed as N(0,1), that is, z i ~N(0,1).
[0042] The second potential vector set is:
[0043] Z′=Z(C-diag(C)).
[0044] Where Z′ represents the second latent vector set, C is the coefficient matrix, diag(C) is the diagonal matrix of C, And c ij ~Dir(α), Dir(α) represents a Dirichlet distribution with coefficient α, and in a specific example, α=1; [] T Represents the transpose of a matrix.
[0045] Step 300, constructing an initial few-shot image generative adversarial network; the initial few-shot image generative adversarial network includes a generator and a discriminator; the generator is used to generate an image based on the latent vectors in the first latent vector set or the second latent vector set.
[0046] Step 400, using the target image training sample set, the first latent vector set and the second latent vector set, the initial few-shot image generation adversarial network is optimized and trained to obtain a few-shot image generator. The discriminator in the few-shot image generation adversarial network needs to be trained, but only the generator is needed when the image is finally generated, and no discriminator is needed.
[0047] Step 400 specifically includes:
[0048] (1) Inputting the target image training sample set, the first latent vector set and the second latent vector set into the initial few-sample image generative adversarial network for optimization training, using a generator loss function to calculate a generator loss value, and using a discriminator loss function to calculate a discriminator loss value.
[0049] (2) Determine whether the generator loss value satisfies a first convergence condition; the first convergence condition is that the difference between two adjacent generator loss values is less than a first set threshold, or the generator loss value is within a first set range.
[0050] (3) When the generator loss value satisfies the first convergence condition, determine whether the discriminator loss value satisfies the second convergence condition; the second convergence condition is that the difference between two adjacent discriminator loss values is less than a second set threshold, or the discriminator loss value is within a second set range.
[0051] (4) When the discriminator loss value satisfies the second convergence condition, stop training; when the discriminator loss value does not satisfy the second convergence condition, return to the above step (1).
[0052] (5) When the generator loss value does not meet the first convergence condition, return to the above step (1).
[0053] (6) The initial few-shot image generation adversarial network after stopping training is marked as a few-shot image generator.
[0054] In another example, step 400 specifically includes:
[0055] (1) Inputting the target image training sample set, the first latent vector set, and the second latent vector set into the initial few-sample image generative adversarial network for optimization training, and increasing the number of iterations by one.
[0056] (2) Determine whether the current number of iterations is less than or equal to the preset number of training times.
[0057] (3) When the current number of iterations is less than or equal to the preset number of training times, the generator loss function is used to calculate the generator loss value, the discriminator loss function is used to calculate the discriminator loss value, and the Adam optimization algorithm is used to update the network parameters of the initial few-sample image generative adversarial network, and then return to the above step (1). The Adam optimization algorithm is the most commonly used optimization algorithm in deep learning algorithms. In the specific example, the learning rate lr is set to 0.0002, the first-order momentum is set to 0.5, and the second-order momentum is set to 0.999.
[0058] (4) When the current number of iterations is greater than the preset number of training times, stop training.
[0059] (5) The initial few-shot image generation adversarial network after stopping training is marked as a few-shot image generator.
[0060] Based on Figure 2 As shown, the generator loss function is:
[0061] This formula is specifically the generator loss optimization function.
[0062] L G =L g_adv +λ 1 ·Lg_CL . This formula is specifically the generator loss function.
[0063] L g_adv =E z~p(z) [log(1-D(G(z)))].
[0064]
[0065] f(a,b)=e (1-Cos Sim(a,b)) / τ .
[0066] Among them, L G Represents the generator loss value, represented by L g_adv and L g_CL The two parts of the loss value are calculated, lr represents the learning rate during the initial few-sample image generation adversarial network optimization training process, Indicates L G The gradient of 1 For L g_CL The coefficient of , specifically 1; E represents the expected value, z represents the latent vector in the first latent vector set or the second latent vector set, p(z) represents the known prior distribution, G(z) represents the generated image obtained by inputting a latent vector in the first latent vector set or the second latent vector set into the generator, D(G(z)) represents the identification probability value obtained by inputting the image G(z) into the discriminator; N represents the number of latent vectors in the first latent vector set, which is equal to the number of latent vectors in the second latent vector set; G l represents the lth layer of the generator, G l (z i ) represents the image feature information generated by the i-th potential vector in the first potential vector set after being input to the l-th layer of the generator, G l (z i ′) represents the image feature information generated by the i-th potential vector in the second potential vector set after being input to the l-th layer of the generator, G l (z′ j ) represents the image feature information generated by the jth potential vector in the second potential vector set after being input to the lth layer of the generator, G l (z j ) represents the image feature information generated by the jth latent vector in the first latent vector set after being input into the lth layer of the generator; f(a,b) is used to measure the correlation between a and b. The larger the f(a,b), the smaller the correlation between a and b; CosSim(a,b) represents the cosine similarity of a and b. τ is a hyperparameter with a specific value of 0.07; a is G l (z i ), G l (z j), b is G l (z′ i ), G l (z′ j ).
[0067] The discriminator loss function is:
[0068] This formula is specifically the discriminator loss optimization function.
[0069] L D =L d_adv +λ 2 ·L d_CL . This formula is specifically the discriminator loss function.
[0070] L d_adv =-E x~X [logD(x)]+E z~p(z) [logD(G(z))].
[0071]
[0072] Among them, L D Represents the discriminator loss value, represented by L d_adv and L d_CL The two parts of loss value are calculated. Indicates L D The gradient of 2 For L d_CL The coefficient of , the specific value is 1; x represents an image in the target image training sample set X, D(x) represents the identification probability value obtained after inputting image x into the discriminator, pl represents a linear projection layer; Indicates to d 1 The tensor obtained after inputting the image G(z) in the definition of the discriminator d 2 is the last fully connected layer of the discriminator, d 1 Divide d by the discriminator 2 In addition, Indicates that The tensor obtained after inputting into pl, Indicates that The tensor obtained after inputting into pl, Indicates that The tensor obtained after inputting into pl, Indicates that The tensor obtained after inputting into pl, a is also b is also
[0073] Step 500: input the latent vector to be processed into the few-sample image generator to obtain a final generated image.
[0074] In another specific example, the present invention is experimentally verified based on Sketches, AFHQ-Cat, AFHQ-Dog and AFHQ-Wild datasets. The above datasets contain 290-5152 images. During the training process, 10 training samples are randomly selected as the target image training sample set for training. In the process of comparing with the baseline method, the quality of the generated samples is mainly evaluated by measuring the FID. The lower the FID, the higher the quality of the generated result.
[0075] Specifically, the method of the present invention is compared with the current state-of-the-art few-shot image generation methods, such as ADA, CDC, DCL, FastGAN and MixDL. Figure 3 The generation results of the present invention and the baseline methods (ADA, CDC, DCL, FastGAN and MixDL) on the Sketches and AFHQ-Cat datasets are shown; Figure 4 and Figure 5 The generation results of the proposed method and the baseline methods (FastGAN and MixDL) on the AFHQ-Dog and AFHQ-Wild datasets are shown respectively. All experimental results show that the diversity of images generated by the proposed method is better than that of other methods.
[0076] In addition, the following Table 1 shows the evaluation results of the present invention and the baseline methods (ADA, CDC, DCL, FastGAN and MixDL) on four datasets: Sketches, AFHQ-Cat, AFHQ-Dog and AFHQ-Wild. All experimental results show that the quality of the images generated by the present invention is better than that of the baseline methods.
[0077] Table 1 shows the FID (↓) comparison results of the proposed method and the baseline methods (ADA, CDC, DCL, FastGAN and MixDL) on the few-shot training set. The best results are in black bold, and the suboptimal results are in black italics. The last column shows the average FID scores of different methods on the four datasets Sketches, AFHQ-Cat, AFHQ-Dog and AFHQ-Wild.
[0078] Table 1
[0079]
[0080] In summary, all experimental results show that the diversity and quality of the images generated by the present invention are better than those of the baseline method.
[0081] Embodiment 2
[0082] like Figure 6 As shown, in order to implement the technical solution in the first embodiment and achieve the corresponding functions and technical effects, this embodiment also provides a few-sample image generation system, including:
[0083] The image sample acquisition module is used to obtain the target image training sample set.
[0084] A vector set construction module is used to construct a first potential vector set and a second potential vector set; the i-th potential vector in the first potential vector set is independent of the i-th potential vector in the second potential vector set, and the i-th potential vector in the first potential vector set is related to other potential vectors in the second potential vector set.
[0085] An image generation adversarial network construction module is used to construct an initial few-sample image generation adversarial network; the initial few-sample image generation adversarial network includes a generator and a discriminator; the generator is used to generate an image based on the latent vectors in the first latent vector set or the second latent vector set.
[0086] An image generator determination module is used to optimize the training of the initial few-sample image generation adversarial network using the target image training sample set, the first latent vector set and the second latent vector set to obtain a few-sample image generator.
[0087] The image generation module is used to input the potential vector to be processed into the few-sample image generator to obtain a final generated image.
[0088] Embodiment 3
[0089] This embodiment provides an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to perform the few-sample image generation method of Embodiment 1. Optionally, the electronic device may be a server.
[0090] In addition, an embodiment of the present invention further provides a computer-readable storage medium storing a computer program, which implements the method for generating a few-sample image in the first embodiment when executed by a processor.
[0091] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0092] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of the present invention. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A method for generating a few-sample image, characterized in that the method include: Obtain a target image training sample set; Constructing a first latent vector set and a second latent vector set; The i-th latent vector in the first latent vector set is independent of the i-th latent vector in the second latent vector set, and the i-th latent vector in the first latent vector set is correlated with other latent vectors in the second latent vector set; The latent vector set refers to a set of low-dimensional vectors. Each latent vector z is passed through the generator G to obtain the generated image G(z); each latent vector in the first latent vector set is a one-dimensional vector containing 512 elements, expressed as: in, Denotes the latent vector z i The nth element of , n = 1, 2, ..., 512; the first potential vector set is: Among them, Z represents the first potential vector set, z i ~p(z), z i represents the i-th latent vector in the first latent vector set, p(z) represents the known prior distribution, and N represents the number of latent vectors in the first latent vector set; The second potential vector set is: Z′=Z(C-diag(C)); Where Z′ represents the second latent vector set, C is the coefficient matrix, diag(C) is the diagonal matrix of C, And c ij ~Dir(α), Dir(α) represents the Dirichlet distribution with coefficient α, [] T Represents the transpose of a matrix; Constructing an initial few-shot image generation adversarial network; the initial few-shot image generation adversarial network includes a generator and a discriminator; the generator is used to generate an image based on a latent vector in the first latent vector set or the second latent vector set; Using the target image training sample set, the first latent vector set, and the second latent vector set, the initial few-shot image generative adversarial network is optimized and trained to obtain a few-shot image generator; The latent vector to be processed is input into the few-sample image generator to obtain a final generated image.
2. The method for generating a few-sample image according to claim 1, characterized in that: The target image training sample set, the first latent vector set, and the second latent vector set are used to optimize the initial few-sample image generation adversarial network to obtain a few-sample image generator, specifically including: Inputting the target image training sample set, the first latent vector set and the second latent vector set into the initial few-sample image generative adversarial network for optimization training, using a generator loss function to calculate a generator loss value, and using a discriminator loss function to calculate a discriminator loss value; Determine whether the generator loss value satisfies a first convergence condition; the first convergence condition is that the difference between two adjacent generator loss values is less than a first set threshold, or the generator loss value is within a first set range; When the generator loss value satisfies the first convergence condition, determining whether the discriminator loss value satisfies the second convergence condition; the second convergence condition is that the difference between two adjacent discriminator loss values is less than a second set threshold, or the discriminator loss value is within a second set range; When the discriminator loss value satisfies the second convergence condition, the training is stopped; when the discriminator loss value does not satisfy the second convergence condition, the step of returning to the step of inputting the target image training sample set, the first latent vector set and the second latent vector set into the initial few-sample image generative adversarial network for optimization training is performed; When the generator loss value does not satisfy the first convergence condition, returning to the step of inputting the target image training sample set, the first latent vector set and the second latent vector set into the initial few-sample image generative adversarial network for optimization training; The initial few-shot image generation adversarial network after stopping training is marked as a few-shot image generator.
3. The method for generating a few-sample image according to claim 1, characterized in that: The target image training sample set, the first latent vector set, and the second latent vector set are used to optimize the initial few-sample image generation adversarial network to obtain a few-sample image generator, specifically including: Input the target image training sample set, the first latent vector set and the second latent vector set into the initial few-sample image generative adversarial network for optimization training, and increase the number of iterations by one; Determine whether the current number of iterations is less than or equal to the preset number of training times; When the current number of iterations is less than or equal to the preset number of training times, a generator loss function is used to calculate a generator loss value, a discriminator loss function is used to calculate a discriminator loss value, an Adam optimization algorithm is used to update network parameters of the initial few-sample image generation adversarial network, and then the target image training sample set, the first latent vector set, and the second latent vector set are returned to the step of inputting the target image training sample set, the first latent vector set, and the second latent vector set into the initial few-sample image generation adversarial network for optimization training; When the current number of iterations is greater than the preset number of training times, stop training; The initial few-shot image generation adversarial network after stopping training is marked as a few-shot image generator.
4. The method for generating a few-sample image according to claim 2 or 3, characterized in that: The generator loss function is: L G ←L G +lr·▽AdamL G ; L G =L g_adv +λ1·L g_CL ; L g_adv =E z~p(z) [log(1-D(G(z)))]; f(a,b)=e (1-CosSim(a,b)) / τ ; Among them, L G Represents the generator loss value, lr represents the learning rate during the initial few-sample image generation adversarial network optimization training process, ▽AdamL G Indicates L G The gradient of L g_CL ; E represents the expected value, z represents the latent vector in the first latent vector set or the second latent vector set, p(z) represents the known prior distribution, G(z) represents the generated image obtained by inputting a latent vector in the first latent vector set or the second latent vector set into the generator, and D(G(z)) represents the identification probability value obtained by inputting the image G(z) into the discriminator; N represents the number of latent vectors in the first latent vector set, which is equal to the number of latent vectors in the second latent vector set; G l represents the lth layer of the generator, G l (z i ) represents the image feature information generated by the i-th potential vector in the first potential vector set after being input into the l-th layer of the generator, G l (z i ′) represents the image feature information generated by the i-th potential vector in the second potential vector set after being input to the l-th layer of the generator, G l (z j ′) represents the image feature information generated by the jth potential vector in the second potential vector set after being input to the lth layer of the generator, G l (z j ) represents the image feature information generated by the jth latent vector in the first latent vector set after being input into the lth layer of the generator; f(a,b) is used to measure the correlation between a and b, CosSim(a,b) represents the cosine similarity between a and b, τ is a hyperparameter, a is G l (z i ), G l (z j ), b is G l (z′ i ), G l (z′ j ).
5. The method for generating a few-sample image according to claim 4, characterized in that: The discriminator loss function is: L D ←L D +lr·▽AdamL D ; L D =L d_adv +λ2·L d_CL ; L d_adv =-E x~X [log D(x)]+E z~p(z) [log D(G(z))]; Among them, L D represents the discriminator loss value, ▽AdamL D Indicates L D The gradient of L d_CL The coefficient of ; x represents an image in the target image training sample set X, D(x) represents the identification probability value obtained after inputting image x into the discriminator, and pl represents a linear projection layer; Indicates to d 1 The tensor obtained after inputting the image G(z) in the definition of the discriminator d 2 is the last fully connected layer of the discriminator, d 1 Divide d by the discriminator 2 In addition, Indicates that The tensor obtained after inputting into pl, Indicates that The tensor obtained after inputting into pl, Indicates that The tensor obtained after inputting into pl, Indicates that The tensor obtained after inputting into pl, a is also b is also 6. A few-sample image generation system, characterized in that: The system includes: An image sample acquisition module is used to acquire a target image training sample set; A vector set construction module, used to construct a first latent vector set and a second latent vector set; The i-th latent vector in the first latent vector set is independent of the i-th latent vector in the second latent vector set, and the i-th latent vector in the first latent vector set is correlated with other latent vectors in the second latent vector set; The latent vector set refers to a set of low-dimensional vectors. Each latent vector z is passed through the generator G to obtain the generated image G(z); each latent vector in the first latent vector set is a one-dimensional vector containing 512 elements, expressed as: in, Denotes the latent vector z i The nth element of , n = 1, 2, ..., 512; the first potential vector set is: Among them, Z represents the first potential vector set, z i ~p(z), z i represents the i-th latent vector in the first latent vector set, p(z) represents the known prior distribution, and N represents the number of latent vectors in the first latent vector set; The second potential vector set is: Z′=Z(C-diag(C)); Where Z′ represents the second latent vector set, C is the coefficient matrix, diag(C) is the diagonal matrix of C, And c ij ~Dir(α), Dir(α) represents the Dirichlet distribution with coefficient α, [] T Represents the transpose of a matrix; An image generation adversarial network construction module, used to construct an initial few-shot image generation adversarial network; the initial few-shot image generation adversarial network includes a generator and a discriminator; the generator is used to generate an image based on a latent vector in the first latent vector set or the second latent vector set; An image generator determination module, configured to optimize and train the initial few-sample image generation adversarial network using the target image training sample set, the first latent vector set, and the second latent vector set to obtain a few-sample image generator; The image generation module is used to input the potential vector to be processed into the few-sample image generator to obtain a final generated image.
7. An electronic device, characterized in that: The electronic device comprises a memory and a processor, wherein the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the method for generating a few-sample image according to any one of claims 1 to 5.
