A method for simultaneously generating and editing arbitrary facial attributes based on VAE and cGAN

By combining variational autoencoders and conditional adversarial neural networks, the complexity problem of face editing and generation in the existing technology is solved, and new face images with required attributes are generated and edited while retaining the face identity. , avoids mode collapse and improves the performance of image generation and editing.

CN114240736BActive Publication Date: 2024-09-20SHENYANG INST OF AUTOMATION - CHINESE ACAD OF SCI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111479737.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-06
Publication Date
2024-09-20
Estimated Expiration
2041-12-06

AI Technical Summary

Technical Problem

It is difficult for existing technologies to edit and generate new face images with required attributes while retaining face identity, and a single end-to-end network is prone to mode collapse problems when processing complex face images.

Method used

Using a combination method based on variational autoencoder (VAE) and conditional adversarial neural network (cGAN), through the combination of codec architecture and connection network, the relationship between the latent space and the real face image space is established, and the connection network is introduced to Control the trade-offs between decoupling and reconstruction, resulting in an end-to-end generation and editing model.

Benefits of technology

It realizes the generation and editing of new face images with required attributes on the basis of retaining the face identity, avoids the problem of pattern collapse, improves the performance of image generation and editing, can flexibly identify and control attribute subspaces, and supports multiple attributes. and changes in attribute strength.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114240736B
    Figure CN114240736B
Patent Text Reader

Abstract

The present invention relates to a method for simultaneously generating and editing arbitrary facial attributes based on variational autoencoders (VAE) and conditional adversarial neural networks (cGANs). The present invention focuses on the encoder-decoder architecture based on variational autoencoders (VAEs) and conditional adversarial neural networks (cGANs), and develops a bidirectional feedback generation network for simultaneously generating new faces and performing attribute editing. Attribute classification constraints are applied to the generated images to ensure the correct variation of the specified attributes, and face images with multiple attributes are generated by sampling attribute encodings from the latent space. The method includes modeling of attribute strengths to support attribute interpolation and flexible handling of multiple facial attributes. The method solves the problem of using an end-to-end model for face generation and attribute editing. The effectiveness and advancement of the method are verified through qualitative and quantitative evaluations, and experimental results show that it achieves performance comparable to the most advanced attribute editing techniques.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to an image generation and editing method, in particular to a method for simultaneously generating and editing arbitrary facial attributes based on a variational autoencoder (VAE) and a conditional generative adversarial neural network (cGAN). Background Art

[0002] Facial attribute generation and editing has been an important problem in computer vision and graphics for decades, aiming to generate diverse and realistic images by changing some latent parameters according to the underlying face image distribution. Moreover, if one wants to modify the attributes of a face (e.g., add a smile, change the hair color, or even the gender), this is a more complex and challenging modification. Therefore, the required model needs to capture the underlying data distribution, which is a challenging task as the collection of image samples may lie on a very complex manifold. The research on generative models such as variational autoencoders (VAE) and generative adversarial networks (GAN) has made great progress in facial attribute editing. However, it is difficult for a single end-to-end network to edit the desired attributes while preserving the face identity and generate new face images. Summary of the invention

[0003] In view of the above technical deficiencies, the purpose of the present invention is to provide a method for simultaneously generating and editing arbitrary facial attributes based on a variational autoencoder (VAE) and a conditional adversarial neural network (cGAN). This method can solve the problem of simultaneously modifying the facial attributes of an input face and generating a new face with the desired attributes. 1. The codec architecture is combined with a connection network to form an end-to-end network. 2. The encoder network is used to map the real image to a latent vector. In this way, we explicitly establish the relationship between the latent space and the real face image space, avoiding the problem of mode collapse when generating different samples. 3. A connection network is introduced to control the trade-off between decoupling and reconstruction in VAE, that is, an L1 loss is added between the connection network and the latent space. This improvement enables the encoder network to disentangle the entangled factors in the face image as much as possible, alleviating the trade-off between decoupling and reconstruction of the image in VAE.

[0004] The objective of the present invention is achieved through the following technical solutions:

[0005] The method for generating faces and editing attributes based on VAE and cGAN includes the following steps:

[0006] S1 Data collection steps: collect real face images, manually annotate the attributes of each face, and establish a pairing set of face images and labels;

[0007] S2 modeling step: Based on the VAE and cGAN method, a joint loss function is used to establish a generation and editing model for achieving the task of simultaneously generating new faces and editing faces; the model includes five modules:

[0008] The encoder module encodes the image to obtain the hidden coding features of the face image;

[0009] The decoder module generates the edited face image using hidden coded features and editable attributes;

[0010] The classifier module processes the edited face image and outputs the face features including the edited attributes, so as to further realize the recognition and classification of the edited attributes of the edited face image;

[0011] A discriminator module filters the editing attributes of the edited face image and outputs the face features that do not contain the editing attributes, so as to discriminate the authenticity of the edited face image; the authenticity is to discriminate whether the current edited face image is a face image;

[0012] The reverse connection module converts the output features of the classifier module and the discriminator module into hidden codes and outputs them to the decoder module;

[0013] S3 training step: input the collected image joint loss function, iteratively train the parameters of the network model, and optimize the network model;

[0014] S4 actual processing steps: collect the face image to be processed and input it into the optimized model, and input the editable attributes, and automatically output the face image that meets the editable attributes.

[0015] The manual annotation is to classify the face images and add face category labels; wherein the face category labels include: bald, bangs, black hair, blonde hair, brown hair, eyebrows, glasses, male, open mouth, beard, beard, pale skin, and young.

[0016] The editable attributes are edits and modifications made manually on the face image to be processed, including modifying the facial features or adding hairstyle features and accessories features to generate a desired face image.

[0017] The face image to be processed is a collected face image or a face image that conforms to a normal distribution and is generated by directly obtaining hidden coding from a reverse connection module.

[0018] The model is used to synthesize any facial image, edit known input images and newly created facial images, and overcome the problem that a single end-to-end model can only perform generation or editing operations.

[0019] The face image encoder module includes four convolutional layers and a fully connected layer, which are used to extract feature maps of face images in the training data set and convert them into hidden codes; each convolutional layer includes a convolution kernel, normalization, and an activation function; the normalization uses BatchNorm, and the activation function uses ReLU.

[0020] The upsampling layer of the face image decoder module includes four deconvolution layers, each of which includes a convolution kernel, normalization, and an activation function; the parameters of the deconvolution layer are: (d, k, s), where d is the dimension, k is the kernel size, and s is the step size; BatchNorm is used for normalization, and ReLU is used for activation function.

[0021] The discriminator module includes four convolutional layers and a fully connected layer, which are used to discriminate the authenticity of the original image, the newly generated face image, and the edited face image. Each convolutional layer includes a convolution kernel, normalization, and an activation function; the normalization adopts instance normalization IN, and the activation function adopts ReLU.

[0022] The face image classifier module includes four convolutional layers and a fully connected layer, which are used to determine whether the original image and the edited face image have the desired attributes. Each convolutional layer includes a convolution kernel, normalization, and an activation function; the normalization uses instance normalization IN, and the activation function uses ReLU.

[0023] The reverse connection module includes two convolutional layers and a fully connected layer, which converts the output features of the classifier and the discriminator into hidden codes, and at the same time limits the converted hidden codes to obey the normal distribution to support the generation of new face images from the distribution. Each convolutional layer includes a convolution kernel, normalization, and an activation function; the normalization uses BatchNorm and the activation function uses ReLU.

[0024] The present invention has the following beneficial effects and advantages:

[0025] 1. The method of the present invention proposes an end-to-end improved encoder-decoder network framework, which encodes the face image into a latent space through an encoder module, and performs editing and reconstruction of the face image through a decoder. The classifier and discriminator respectively determine whether it has the desired attributes and the authenticity of the image.

[0026] 2. The method of the present invention introduces a connection network and establishes a two-way feedback mechanism, which can generate both real arbitrary faces and input faces with ideal multi-attributes, solving the problem of simultaneously generating and editing arbitrary face attributes, increasing the performance of the method, and providing support for subsequent data enhancement.

[0027] 3. The proposed method uses attribute classification constraints on the generated images, and can easily identify a new attribute subspace to ensure the correct change of the specified attribute. It can also generate face images with multiple attributes by sampling latent representations, and flexibly model attribute intensity changes to achieve face interpolation. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 are real images and label instances in the training data;

[0029] Figure 2 is the network architecture of the method of the present invention;

[0030] Figure 3 It is a display diagram of various algorithms in editing specified attributes;

[0031] Figure 4 It is a demonstration of various algorithms in generating new faces;

[0032] Figure 5 It is a display diagram of various algorithms in controlling the intensity of attribute editing;

[0033] Figure 6 This is a comparison chart of the attribute editing accuracy of various algorithms;

[0034] Figure 7 This is a comparison chart of attribute editing error rates of various algorithms; DETAILED DESCRIPTION

[0035] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific implementation method of the present invention is described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the invention, so the present invention is not limited by the specific implementation disclosed below.

[0036] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in the specification of the invention herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention.

[0037] 1. Training Dataset: We use the public dataset CelebA to train the end-to-end network. CelebA is the abbreviation of CelebFaces Attribute, which is a celebrity face attribute dataset. It contains 202,599 face images of 10,177 celebrities. Each image is marked with features, including face bbox annotations, 5 facial feature point coordinates, and 40 attribute tags. It is widely used in computer vision training tasks related to faces, such as face attribute identification training, face detection training, and landmark marking. Figure 1 The face labels shown are glasses, bangs, pointed nose, oval face, wearing a hat, curly hair, beard, and smiling.

[0038] 2. Network architecture based on VAE and cGAN

[0039] 2.1. Model structure analysis

[0040] like Figure 2 As shown in the figure, our proposed method consists of five parts: 1) Encoder network G enc ; 2) Generate network G dec ; 3) Discriminant network D; 4) Classification network C; 5) Connection network CN. G enc and G dec The function of is the same as that of conditional variational autoencoder (cVAE). The encoder network G enc By learning the distribution P(z|x, c) from the real face image x to the hidden code z, where c is a label attribute of the real face image. Generative network G dec The generated face image x′.G is obtained by sampling the learned distribution P(x|z, c) dec The functions of and D are the same as GAN. Generator network G dec It attempts to learn the true data distribution through the gradient given by the discriminator network D, which learns to distinguish between real samples and fake samples. The function of the classifier network C is attribute classification, which is used to judge whether the generated image has the desired attributes. The connection network CN is a feedback network that estimates the latent encoding from the discriminator D and the classifier C, aiming to help VAE learn meaningful latent representations.

[0041] Encoder G enc Map the real image to the hidden code z, and then the generator G dec The hidden code z is mapped to the face image. The discriminator D and the classifier C take the samples in the generator as input and output the probability of a real or fake face image and the probability of whether the expected attribute exists in the face image. At the same time, the connection network estimates the hidden code z from the discriminator D and the classifier C. This hidden code z is input to the generator G dec, used for reconstruction or editing of new faces.

[0042] Encoding network G enc It is necessary to map the real face image space to the hidden space. Compared with the EdiGAN model, the invented method utilizes a bidirectional feedback connection network CN to convert the feature vectors of the discriminator D and the classifier C into hidden codes. In this way, it bypasses the use of the encoder-decoder architecture. However, the training of GAN will encounter the problem of gradient disappearance or instability, and the connection network does not have enough ability to transform the real image space into the hidden space. As a result, the generated network outputs the same image for different potential codes, and the gradient descent cannot separate these identical outputs, and eventually mode collapse occurs. To solve this problem, we introduced a bidirectional feedback encoder-decoder architecture. In this way, we explicitly establish the relationship between the real image space and the hidden space.

[0043] The connection network CN plays a crucial role in the attribute editing of the input image, which transforms the feature vector extracted from the discriminator D and the classifier C into a hidden code. Afterwards, the generator combines the hidden code z and the user-specific attribute c vector as input to generate the input image. In addition, the connection network is an effective tool to alleviate the image decoupling and reconstruction trade-off problem in VAEGAN, which helps to learn meaningful hidden codes z. Specifically, this is because the hidden code z is converted from the powerful discriminator D and classifier C. Finally, a bidirectional feedback generative adversarial network is constructed through the encoder-decoder architecture and the connection network.

[0044] After training the model, a hidden code z is extracted from the learning distribution and its binary attribute vector is set. Then, the generator combines the hidden code z with the user-specific attribute c to generate a face image with the specified attribute. It is worth mentioning that the encoder G dec An L1 loss is added between the concatenated network CN, which improves the performance of face image decoupling. This means that the hidden code z is more independent in each dimension, which allows us to operate on multiple attributes simultaneously.

[0045] 2.2. Loss Function of Bidirectional Feedback Model

[0046] 2.2.1 Adversarial Loss

[0047] In the standard cGAN, the generator G and the discriminator D are in a conditional two-person minimax game. The discriminator D tries to distinguish real images from the dataset and fake images from the generator, and the generator G tries to fool the discriminator D. Following WGAN, the adversarial loss of the generator G and the discriminator D is The formulas are as follows:

[0048]

[0049]

[0050] in, Indicates z~P z The mathematical expectation of Represents x~P data The mathematical expectation of

[0051] In practice, the distributions of real and fake images may not overlap, especially early in the training process. Therefore, the discriminator D can separate them well. That is, we always have D(x)→1 and D(x')→0, where x'=G(z,a) is the generated image. Therefore, when updating the network G enc When Therefore, G enc The training process of is unstable. To solve this problem, we propose a mean feature matching objective for the generator, which is effective for cVAE-GAN. The objective requires that the feature center of the synthetic sample matches the feature center of the real sample. Let f D (x) represents the features on the intermediate layer of the discriminator D, and the generator G tries to minimize the loss function:

[0052]

[0053] in, express The mathematical expectation of Indicates that from the distribution sampling The generated edited image with attribute a;

[0054] f D (x) is extracted from the last fully connected (FC) layer of the discriminator D. By combining multiple layers, the convergence speed is slightly improved. In the training stage, estimating the mean feature using small batch data is an effective way to alleviate the problem of training instability.

[0055] 2.2.2 Attribute Classification Loss

[0056] The discriminator D performs well in evaluating image quality, but it is not an effective tool for judging whether the desired attributes are present in the output image. This is because image quality reflects neither the presence nor the absence of an attribute. Therefore, we use an attribute classifier C to constrain the generated images to have the desired attributes. Similar to existing methods, the attribute vector is a binary multidimensional vector that serves as an input condition. However, the CelebA dataset has significant biases between different attributes, and the attribute classifier needs to deal with the class imbalance problem of the dataset. In order to control the bias on the dataset, we introduce weight regularization for both large and small attribute samples. More specifically, let w p is the weight of the positive sample, w n is the weight of the negative sample. For each attribute, w p is calculated by dividing the batch size by 2×N. Similarly, for each attribute, w n is calculated by dividing the batch size by 2×(MN), where N is the total number of labels and M is the batch size:

[0057]

[0058] Where C(x) represents the classification result of image x after passing through attribute classifier C, S(C(x)) represents the result after nonlinear activation of the classification result, S is the Sigmoid function, and y i is the i-th attribute of the input image.

[0059] The classifier C controls the relationship between the hidden code z and the attributes a / b in two aspects. On the one hand, the combination between z and b in the generator should produce a realistic image x' with the desired attributes. b On the other hand, the combination between z and a in the generator should produce an input x that is close to a The image x' a To this end, a property constraint is imposed on the classifier network, forcing the generated image x' b Has the desired property b:

[0060]

[0061] in, express The mathematical expectation of the joint distribution, Indicates that from the distribution sampling The generated edited image with attribute b, Indicates the edited image Weighted attribute classification loss of;

[0062] The classifier C is trained on the original images with its own attributes according to the following objectives:

[0063]

[0064] in, Indicates z~P z ,a~p attr The mathematical expectation of the joint distribution, G(z,a) represents the distribution from z to P z Sampling, the generated edited image with attribute a, represents the weighted attribute classification loss of the edited image G(z,a);

[0065] P data and P attr Represents the distribution of real images and the distribution of attributes. Represents the hidden code reconstructed by the connected network The distribution of P z represents the distribution of hidden codes z sampled from the prior distribution. a / b is the distribution of P attr A vector of attributes to sample from the distribution.

[0066] 2.2.3 Generator Loss

[0067] The loss of the generator consists of G enc and G dec Two parts. Although the use of mean feature matching can reduce the possibility of mode collapse, it cannot completely solve this problem. This is because although the generated image and the real image have the same feature center, they may have different distributions. In order to generate different samples, we add an encoder network to constrain the mapping from the real face image x to the hidden code z. Encoder G enc The mean μ and variance ∈ of the output hidden code z. We calculate the KL divergence to reduce the deviation between the prior distribution P(z) and the generated distribution P(z|x,c):

[0068]

[0069] Among them, sum(exp(∈)-∈-1) means forcing the generated distribution P(z|x,c) to conform to the prior normal distribution P(z);

[0070] After training, we can use z = μ + r⊙exp(∈), where r~N(0,I) is a normal distribution and ⊙ represents element-wise multiplication. Then, we a and x a Add L2 loss constraints between generators to reconstruct and pairwise feature matching losses:

[0071]

[0072] Where x represents the input image, x' represents any edited image, and f C (x) represents the output features of the input image x after passing through the fully connected layer of the classifier C, f C (x') represents the output features of the input image x' after passing through the fully connected layer of classifier C; f D and f C They are the features of the fully connected layers of the discriminator D and the classifier C respectively.

[0073] 2.2.4 Connection network loss

[0074] In order to correctly reflect the attribute information in the hidden feedback representation, the feature vectors of the attribute classifier and the discriminator are combined. c (G(z,a))-way hidden feedback coding Provides features related to attribute information, It is expected to have the attribute style on the reconstructed image. At the same time, f d (G(z,a)) maps various elements except attributes to a unique hidden feedback code expect Maintain high reconstruction quality.

[0075]

[0076]

[0077] Among them, f d (G(z,a) represents the output features of the image G(z,a) after the fully connected layer of the discriminator D, Represents the concatenated output feature f d (G(z,a) and f d (G(z,a)) and returns the hidden feedback code G(z,a) represents the distribution from z to P z Sampling, the generated edited image with attribute a;

[0078] z is the hidden code given to the generator, is the reconstruction hidden feedback encoding of the connection network a is the attribute of the real image given to the discriminator, classifier and generator.

[0079] 2.2.4 Global Loss

[0080] To simplify the loss function of the generator, we combine it as follows:

[0081]

[0082] The goal of our approach is to minimize the following joint function:

[0083]

[0084] Only with G dec It indicates whether the distribution of hidden codes is as expected. With G dec Related, including and They are minimized to indicate that the generated images are similar to the training images, real images, and other samples in the same category, respectively. Related to the classifier C, it represents the network's ability to classify images of different categories. Represents the performance of the network in distinguishing true and false images, which is related to the connection network represents the inverse generation process of the hidden feedback representation. All these goals complement each other and ultimately enable our algorithm to achieve better results.

[0085] 3 Experimental procedures

[0086] We evaluate the performance of bidirectional feedback GANs, we perform some tasks on the CelebA dataset and compare with some existing methods. Two different types of experiments are set up, including qualitative evaluation and quantitative evaluation.

[0087] 3.1 Experimental environment configuration

[0088] The hardware platform configuration of this experiment is Intel(R) Xeon(R) CPU E5-2640 v4@2.40GHz, 128G memory, Nvidia GeForce TITAN Xp graphics card, 12G video memory. The software environment is Ubuntu 20.04, deep learning framework Pytorch, version 1.7, CUDA version 11.0, and cuDNN version 10.2.

[0089] 3.2 Experimental parameter settings

[0090] Bidirectional feedback GAN is evaluated on the CelebA dataset, which contains 202,599 face images for training, validation, and testing, and annotated with 40 binary attributes. In our experiments, 13 attributes are selected whose visual features are different from other attributes and cover most of the attributes used in existing methods. enc , G dec The detailed architectures of D, C, and CN are shown in Tables 1-4. The model is trained by the RMSProp optimizer with a batch size of 32 and a learning rate of 0.0001. For the hyperparameters of the balanced loss in Eq. (12), we empirically set λ1 = 3, λ2 = 10-4 The weights of all networks are initialized from a zero-centered normal distribution with a standard deviation of 0.02.

[0091] Table 1 Encoder network

[0092]

[0093] Table 2 Decoder network

[0094]

[0095] Table 3 Discriminator and classifier networks

[0096]

[0097] Table 4 Bidirectional feedback network

[0098]

[0099] 3.3 Qualitative comparison results

[0100] 3.3.1 Property Editing Comparison

[0101] We select input images from the test set, which is not used for training and validation. Figure 3 Results of attribute editing using input images from AttGAN, STGAN, and bidirectional feedback GAN are shown, with face images from left to right being original, bald, bangs, black hair, blonde hair, brown hair, eyebrows, glasses, male, open mouth, beard, beard, pale skin, and younger. The results show that our method performs well compared to professional attribute editing methods. These Our method correctly separates the attribute space by using an encoder-decoder structure and introducing a connection network because we explicitly establish the relationship between the latent space and the real image space.

[0102] 3.3.2 Generate new face image comparison

[0103] Our method introduces attribute classifiers to handle face image generation with desired attributes and is compared with EdiGAN and IcGAN. In this experiment, multiple attributes are used for image generation, such as Figure 4As shown, the method of this application (top left: original image, reconstructed image, adding bangs, changing gender, beard, mouth closed and multi-attribute editing; top right: original image, reconstructed image, adding brown hair, changing gender, glasses, mouth closed and multi-attribute editing; bottom left: original image, reconstructed image, adding black hair, changing gender, smiling, mouth closed and multi-attribute editing; bottom right: original image, reconstructed image, adding gray hair, bangs, changing gender, mouth open and multi-attribute editing.) IcGAN method (from left to right: editing black hair, smiling, black hair, bangs, black hair, glasses; editing black hair, smiling, black hair, bangs, black hair, glasses.), EdiGAN (from left to right: editing golden hair, bangs, golden hair, glasses, golden hair, beard; editing golden hair, bangs, golden hair, glasses, golden hair, beard.), the experimental results can reflect the effect of each attribute, and can also successfully combine multiple attributes. In addition, our results retain the facial features under different attributes. It is noteworthy that our model can not only process multiple attributes simultaneously, but also maintain the structural information of face images. The reason why our model outperforms the baseline model is that it establishes an accurate bidirectional mapping from image space to latent space and fully disentangles the relationship between image vectors and attribute vectors.

[0104] 3.3.3 Attribute Strength Control

[0105] Performing latent interpolation between two faces is an effective tool to measure whether the latent space and attribute space make sense. In this experiment, we compare the interpolation results output by EdiGAN and our method. Figure 5 The effect of controlling the interpolation strength between two latent vectors and the attribute vector is shown, the method of this application (from top to bottom: interpolation of black hair, beard, gender), EdiGAN (from top to bottom: interpolation of black hair, beard, gender). From the results, we can conclude that the smooth transition between attribute vectors can lead to natural and meaningful changes in the image semantically. This shows that the latent space vectors and the attribute vectors are semantically meaningful. In addition, although the semantic relationship between adjacent images changes smoothly, each generated image is still clear and realistic. Due to the attributes of "black hair" and "beard", they can both transition naturally from the original face image by both methods. However, for the "male" attribute, our method is more advantageous. In Figure 5 In the third row of , we gradually increase the "male" attribute from 0 to 1. Comparing the results of the two experiments, it can be clearly seen that our method does not change other attribute information of the facial image, while EdiGAN changes the length of the hair. The experimental results strongly prove that our method can sort out the relationship between the latent space and the attribute space and produce meaningful representation vectors.

[0106] 3.4 Quantitative comparison results

[0107] 3.4.1 Face Image Generation Performance

[0108] To obtain image generation performance quality, we compare our method with VAE-GAN, IcGAN, AttGAN, STGAN, and EdiGAN using IS and FID scores. For fair comparison, we repeat the experiment 10 times and report the average and standard deviation of the IS and FID scores of each model, as shown in Table 4. Considering that larger IS values ​​and smaller FID values ​​indicate higher quality, our method outperforms other competitors; the performance gap is more significant than three standard deviations.

[0109] Table 4 Quantitative comparison of face generation quality

[0110]

[0111] 3.4.2 Image reconstruction performance

[0112] To confirm whether the input image can be faithfully reconstructed using each model, we evaluate the reconstruction accuracy by SSIM and PSNR using 19651 test samples on CelebA, and report the mean and standard deviation of some existing methods. Table 5 summarizes the accuracy of each model, and our method outperforms all other methods in terms of SSIM and PSNR.

[0113] Table 4 Quantitative comparison of image reconstruction quality

[0114]

[0115] 3.4.3 Attribute Editing Accuracy and Error Rate

[0116] We use an attribute classifier independent of all methods to judge the attributes of the generated faces. If the classifier predicts that the attribute of the generated image is the same as the desired attribute, it is considered a correct generation, otherwise it is considered an incorrect generation. In addition, we also estimate the average preservation error of other attributes when editing each attribute. In this experiment, we compare our method with EdiGAN, AttGAN, STGAN, because all of these methods have the best performance among other competitors in face image editing. Figure 6 and 7 The attribute editing accuracy and error of EdiGAN, AttGAN, STGAN and our method are shown. The 13 attributes are: bald, bangs, black hair, blonde hair, brown hair, eyebrows, glasses, male, open mouth, beard, beard, pale skin, and young age. All these methods use a single model for multi-attribute editing.

[0117] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should be regarded as within the scope of protection of the present invention.

Claims

1. A method for generating faces and editing attributes based on VAE and cGAN, characterized in that: The following steps are involved: S1 Data collection steps: collect real face images, manually annotate the attributes of each face, and establish a pairing set of face images and labels; S2 modeling step: Based on the VAE and cGAN method, a joint loss function is used to establish a generation and editing model for achieving the task of simultaneously generating new faces and editing faces; the model includes five modules: The encoder module encodes the image to obtain the hidden coding features of the face image; The decoder module generates the edited face image using hidden coded features and editable attributes; The classifier module processes the edited face image and outputs the face features including the edited attributes, so as to further realize the recognition and classification of the edited attributes of the edited face image; A discriminator module filters the editing attributes of the edited face image and outputs the face features that do not contain the editing attributes, so as to discriminate the authenticity of the edited face image; the authenticity is to discriminate whether the current edited face image is a face image; The reverse connection module converts the output features of the classifier module and the discriminator module into hidden codes and outputs them to the decoder module; S3 training step: input the collected image joint loss function, iteratively train the parameters of the network model, and optimize the network model; S4 actual processing steps: collect the face image to be processed and input it into the optimized model, and input the editable attributes, and automatically output the face image that meets the editable attributes.

2. The method for generating faces and editing attributes based on VAE and cGAN according to claim 1, characterized in that: The manual annotation is to classify the face images and add face category labels.

3. The method for generating faces and editing attributes based on VAE and cGAN according to claim 1, characterized in that: The editable attributes are edits and modifications made manually on the face image to be processed, including modifying the facial features or adding hairstyle features and accessories features to generate a desired face image.

4. The method for generating faces and editing attributes based on VAE and cGAN according to claim 1, characterized in that: The face image to be processed is a collected face image or a face image that conforms to a normal distribution and is generated by directly obtaining hidden coding from a reverse connection module.

5. The method for generating faces and editing attributes based on VAE and cGAN according to claim 2, characterized in that: The model is used to synthesize any facial image, edit known input images and newly created facial images, and overcome the problem that a single end-to-end model can only perform generation or editing operations.

6. The method for generating faces and editing attributes based on VAE and cGAN according to claim 1, characterized in that: The face image encoder module includes four convolutional layers and a fully connected layer, which is used to extract the feature maps of face images in the training data set and convert them into hidden codes; each convolutional layer includes a convolution kernel, normalization, and activation function; BatchNorm is used for normalization, and ReLU is used for activation function.

7. The method for generating faces and editing attributes based on VAE and cGAN according to claim 1, characterized in that: The upsampling layer of the face image decoder module includes four deconvolution layers, each of which includes a convolution kernel, normalization, and an activation function. The parameters of the deconvolution layer are: (d, k, s), where d is the dimension, k is the kernel size, and s is the step size. BatchNorm is used for normalization, and ReLU is used for activation function.

8. The method for generating faces and editing attributes based on VAE and cGAN according to claim 1, characterized in that: The discriminator module includes four convolutional layers and a fully connected layer, which are used to discriminate the authenticity of the original image, the newly generated face image, and the edited face image. Each convolutional layer includes a convolution kernel, normalization, and activation function. The normalization uses instance normalization IN and the activation function uses ReLU.

9. The method for generating faces and editing attributes based on VAE and cGAN according to claim 1 is characterized in that: The face image classifier module includes four convolutional layers and a fully connected layer, which is used to determine whether the original image and the edited face image have the desired attributes. Each convolutional layer includes a convolution kernel, normalization, and an activation function; the normalization uses instance normalization IN, and the activation function uses ReLU.

10. The method for generating faces and editing attributes based on VAE and cGAN according to claim 1 is characterized in that: The reverse connection module includes two convolutional layers and a fully connected layer, which converts the output features of the classifier and discriminator into hidden codes. At the same time, the converted hidden codes are limited to obey the normal distribution to support the generation of new face images from this distribution. Each convolutional layer includes a convolution kernel, normalization, and an activation function; BatchNorm is used for normalization and ReLU is used for activation function.