A face image restoration method based on latent feature reconstruction and mask perception
Through the two-stage model of latent feature reconstruction and mask awareness, the problem of excessive boundary smoothing and texture artifacts in face image repair is solved, efficient image repair is achieved, the complexity and iterative optimization time are reduced, and the repair time is improved. Effects and detail quality.
Patent Information
- Application Number
- CN202111655736.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-30
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2041-12-30
AI Technical Summary
Existing technologies are prone to problems such as excessive smoothing of boundaries or texture artifacts during face image repair, and the repair process is time-consuming and lacks practicality.
A two-stage image repair model based on latent feature reconstruction and mask perception is adopted. Through the structure reconstructor and texture generator, combined with the cosine similarity loss and the improved mask perception module, arbitrary image generation is completed in one training, reducing complexity. degree and iterative optimization time.
It achieves better repair effects, reduces artifacts, and improves the details of face images. Both subjective visual quality and objective quantitative measurement are superior to advanced methods, and is suitable for areas such as intelligent photo processing.
Smart Images

Figure CN114331894B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image processing, and more specifically, relates to a face image restoration method based on latent feature reconstruction and mask perception. Background Art
[0002] Image inpainting refers to generating replaceable structures and textures for missing regions of a corrupted input image and obtaining visually realistic results. It has a wide range of applications. For example, users can remove unwanted objects or edit the content of an image by using inpainting techniques. A major challenge in the image inpainting task is to generate correct structures and realistic textures. Some early patch-based works attempted to fill in missing regions with image patches from existing regions. Through nearest neighbor search and copying related patches, these methods can synthesize realistic textures for background inpainting tasks. However, since these methods cannot capture high-level semantics, it is difficult to generate realistic structures for images with non-repeating patterns (such as faces).
[0003] With the advent of deep neural network technology, some recent works have modeled the inpainting task as a conditional generation problem that learns a mapping function between the input damaged image and the real image. These methods are able to learn meaningful semantics and thus can generate coherent structures for the missing regions. However, since these methods cannot effectively separate structure and texture information, they often suffer from boundary over-smoothing or texture artifacts.
[0004] To solve this problem, some scholars have proposed some two-stage networks. These methods repair the lost structure in the first stage and use the reconstructed information to generate the final result in the second stage. Some methods use real images as labels for structure recovery. However, real images contain high-frequency textures. These irrelevant details may mislead structure reconstruction. SPG-Net predicts semantic segmentation labels for missing areas as structural information. However, areas with similar semantic labels may have different textures (for example, windows and walls of the same building), which brings difficulties to the final restoration. Using edge images as structural guidance, EdgeConnect has also achieved good results in some highly structured scenes. However, the distribution of edge images is very different from that of the target image. In other words, the edge extractor discards too much useful information, such as image color, so it is difficult to generate vivid textures.
[0005] After searching, there are many solutions for image restoration in the prior art, such as patent application No. 202110701430.6, filed on June 24, 2021. The application discloses a facial image restoration method based on facial style, which constructs a generative adversarial network based on facial style, including a generative network based on facial style and a PatchGAN discriminator network; the generative network based on facial style includes a backbone restoration subnetwork composed of an encoder-decoder, and a facial style extraction subnetwork that can extract local facial area styles and global facial styles of each facial area according to a facial analysis graph; all local facial area styles and global facial styles constitute a style matrix to generate affine parameters of each facial area; there are jump connections between the corresponding network layers in the encoder and decoder, and a facial area restoration module is embedded in each jump connection. This application can overcome the problems of visual artifacts, blurred facial structure details and inconsistent facial semantics in the facial images restored by the prior art to a certain extent, and achieve a more accurate restoration effect. However, the image restoration process of this application is relatively time-consuming, and its practicality needs to be strengthened in actual application scenarios.
[0006] Based on the above analysis, the prior art requires a method for face image restoration that can avoid excessive boundary smoothing or texture artifacts. Summary of the invention
[0007] 1. Technical problem to be solved by the invention
[0008] In order to overcome the problem of excessive boundary smoothing or texture artifacts in the above-mentioned prior art, the repaired image in reality is prone to the problem of excessive boundary smoothing or texture artifacts; the present invention proposes a face image repair method based on latent feature reconstruction and mask perception; the present invention proposes a two-stage image repair model, which can achieve better repair effect, and the present invention can complete arbitrary image generation after one training, without time-consuming iterative optimization, and meets the requirement of low complexity in reality.
[0009] 2. Technical solution
[0010] In order to achieve the above object, the technical solution provided by the present invention is:
[0011] A facial image restoration method based on latent feature reconstruction and mask perception of the present invention comprises the following steps:
[0012] Step 1: Obtain a face image dataset and preprocess the images in the dataset;
[0013] Step 2: Build a structure reconstructor based on latent feature reconstruction and a mask-aware texture generator for model training;
[0014] Step 3: Based on the data set preprocessed in step 1 and the network constructed in step 2, adjust the network parameters and perform network training;
[0015] Step 4: Take a defective face image as the input of the network, and use the parameters learned in step 3 to obtain a complete face image as the output.
[0016] Furthermore, the method for obtaining the face dataset in step 1 is: entering the official download interface and selecting the dataset for downloading. The method for preprocessing the image in step 1 is: using a computer to generate a mask of any size and shape, performing pixel-level multiplication of the mask with any image in the training set to obtain a damaged image.
[0017] Furthermore, the structure reconstructor constructed in step 2 first passes through a 3×3 convolution layer, a normalization layer, and a PReLU layer, and then uses 50 identical bottleneck modules to extract three feature maps of different sizes from the 6th, 20th, and 23rd layers, respectively, denoted as c1, c2, and c3. The feature map obtained by c2 through 1×1 convolution is upsampled and added to c3 to obtain p2, and the feature map obtained by p2 through 1×1 convolution is upsampled and added to c1 to obtain p1. c3 generates style vector 0, style feature vector 1, and style feature vector 2 through 16 gradient style modules, p2 generates style feature vector 3, style feature vector 4, style feature vector 5, and style feature vector 6 through 32 gradient style modules, and p1 generates 11 style vectors such as style feature vector 7, ..., style feature vector 17 through 64 gradient style modules. Finally, the generated 18 style feature vectors are sent to StyleGAN to obtain the repaired rough image.
[0018] The texture generator constructed in step 2 is divided into three modules, namely, the encoder, which encodes the rough restored image with the mask into a feature map; the restoration decoder, which is used to refine the feature map; and two refinement decoders of the same structure, which are used to continue to refine the feature map and decode the feature map back to pixels. Specifically, in the encoder, the mask image is first passed through the convolution layer and the Relu activation layer, and then through the convolution to generate the convolution kernel, which is used to convolve the restored rough image to obtain the feature map and pass it into the restoration decoder. In the restoration decoder, it first passes through the transposed convolution, and then cascades it with the feature map obtained in the previous layer. After the cascade, it passes through the convolution layer and the activation layer to obtain the refined feature map, which is then passed into the two refinement decoders of the same structure in series to finally obtain the restored image. In the refinement decoder, the feature map passes through the transposed convolution layer, and then is normalized to finally obtain a more refined feature map.
[0019] The deep network will learn the mapping relationship from the defective image to the corresponding position of the repaired complete image, as shown in the formula:
[0020] x=F(y,φ)
[0021] Among them, y, x represent the defective image and the complete image after restoration, respectively, and φ is the model parameter learned by the restoration network, which is used for subsequent image restoration.
[0022] Furthermore, the loss function of the network training in step 2 adopts different methods in the structure reconstructor and the texture generator. In the structure reconstructor, the loss function is mainly divided into six types, namely pixel reconstruction loss, perceptual loss, identity loss, potential similarity loss, pixel reconstruction loss within the mask, and pixel reconstruction loss outside the mask, as shown below:
[0023] L Gs =L2+0.8*L s-prec +0.1*L ID +L latent +6*L s-hole +L s-vaild
[0024] Among them, given the output result of the structure reconstructor I r and the real image I gt , the pixel reconstruction loss is expressed as follows:
[0025] L2=||I gt -I r ||2
[0026] The perceptual loss is expressed as follows, where F represents the feature extractor:
[0027] L s-perc =||F(I gt )-F(I r )||2
[0028] Identity loss, where R is a pre-trained ArcFace network for face recognition.
[0029] L ID =1- <R(I gt ),R(I r )>
[0030] The latent cosine similarity loss is expressed as follows: the cosine similarity loss is performed on the 18 latent feature vectors of the reconstructed image and the real image. The 18 latent feature vectors obtained from the image are divided into three groups according to the following rules, and the mathematical expectation is calculated as the cosine similarity loss of the model:
[0031]
[0032]
[0033]
[0034] L Latent =0.5*L coarse +L middle +0.5*L fine
[0035] We define the L1 loss of masked and masked pixels as L s-hole and L s-valid , where M represents the given mask:
[0036] L s-hole =||(1-M)θ(I r -I gt )||1
[0037] L s-valid =||MΘ(I r -I gt )||1
[0038] In the texture generator, the loss functions are mainly divided into five types, namely perceptual loss, style loss, total variation loss, pixel reconstruction loss within the mask, and pixel reconstruction loss outside the mask:
[0039] L Gt =L t-vaild +6L t-hole +0.05L t-prec +120L style +0.1L tv
[0040] Among them, given the mask M, the result I out And real pictures I gt , we define the L1 loss of the masked and masked pixels as L t-hole and L t-valid :
[0041]
[0042]
[0043] Where N Igt Represents real picture I gt The number of pixels in .
[0044] Perceptual loss, the formula is as follows:
[0045]
[0046] I com is from the output image I outThe image is composed of mask pixels and non-masked pixels from the real image. It is the feature map obtained at the pth layer of the vgg layer for a given input image I*. is the eigenvector The number of pixels.
[0047] Style loss. The formula is as follows:
[0048]
[0049] Here, (C p ,H p ,W p )express The shape of K p Equal to 1 / (C p H p W p ).
[0050] Total variation loss. The formula is as follows:
[0051]
[0052] Where R represents the mask area.
[0053] Furthermore, in step 2, in the structure reconstructor, the feature pyramid structure uses 50 identical bottleneck modules, which include shortcut layer and res layer. The shortcut layer includes 1×1 convolution layer, normalization layer, res layer includes normalization layer, 3×3 convolution layer, PReLU activation function layer, 3×3 convolution layer, normalization layer, pooling layer, 1×1 convolution layer, ReLU activation function layer, 1×1 convolution layer, sigmoid activation function layer. The gradient style module includes 3×3 convolution layer and LeakyReLU activation function layer.
[0054] In the texture generator, there are 7 layers of networks in total. The processing operations of each layer of the network are the same, but the sizes of the convolution kernels of some convolution layers are different, as shown in the following table. In the encoder, the mask image is first passed through the convolution layer (denoted as Conv1) and the Relu activation layer, and then through the 3×3 convolution layer and the 1×1 convolution layer to generate the convolution kernel. The convolution kernel is used to convolve the repaired rough image (denoted as FConv), and then through the normalization layer, ReLU activation function layer, 3×3 convolution layer, 1×1 convolution layer, ReLU activation function layer, and the feature map is passed to the recovery decoder. In the recovery decoder, it first passes through the transposed convolution layer (denoted as Dconv), normalization layer, LeakyReLU activation function layer, and then cascades it with the feature map obtained in the previous layer. After the cascade, it passes through the 5×5 convolution layer, 3×3 convolution layer, and LeakyReLU activation function layer to obtain the feature map. In the refinement decoder, the feature map passes through the transposed convolution layer and the normalization layer, and the obtained feature map is denoted as f1; the feature map obtained in the previous layer passes through a 4×4 convolution layer, a 3×3 convolution layer, a ReLU activation function layer, and a 3×3 convolution layer, and the obtained feature map is denoted as f2; the two feature maps f1 and f2 are multiplied pixel by pixel, and the obtained feature map and f2 are added pixel by pixel, and finally pass through a LeakyReLU activation function layer.
[0055] Conv1 FConv DConv Layer1 7*7 7*7 6*6 Layer2 7*7 7*7 5*5 Layer3 5*5 5*5 4*4 Layer4 5*5 5*5 4*4 Layer5 3*3 3*3 4*4 Layer6 3*3 3*3 3*3 Layer7 1*1 1*1 2*2
[0056] Furthermore, in the structure reconstructor, the number of feature maps of p1 is 512, the number of feature maps of p2 is 512, the number of feature maps of c3 is 512, and the number of feature maps of the style vector is 18;
[0057] In the texture generator, the number of feature maps output by the first layer of the network is 3, the number of feature maps output by the second layer of the network is 64, the number of feature maps output by the third layer of the network is 128, the number of feature maps output by the fourth layer of the network is 256, and the number of feature maps output by the fifth, sixth, and seventh layers of the network are all 512.
[0058] Furthermore, step 3 uses the pytorch deep learning platform to train the network, uses the Adam optimization algorithm to optimize the network model, uses the learning rate decay strategy, and optimizes by minimizing the overall loss function, which is expressed as follows:
[0059]
[0060] Where N is the number of samples in the training set obtained in step 1, represents the i-th defective image sample, represents the i-th complete image sample, Ф represents the learned neural network parameters, and L is the calculated overall loss value;
[0061] During the training process, the network parameters are updated by specifying the number of iterations.
[0062] 3. Beneficial effects
[0063] Compared with the existing known technologies, the technical solution provided by the present invention has the following significant effects:
[0064] (1) The face image restoration method based on latent feature reconstruction and mask perception of the present invention takes into account the needs of actual scenes and does not require time-consuming iterative optimization. Any image generation can be completed after one training. This method meets the requirement of low complexity in reality.
[0065] (2) The present invention proposes a face image restoration method based on latent feature reconstruction and mask perception, and proposes a two-stage image restoration model. The two parts of the model not only introduce a cosine similarity loss to supervise the style feature vector, but also propose an improved mask-based perception module to effectively improve the restoration performance.
[0066] (3) The face image restoration method based on latent feature reconstruction and mask perception of the present invention not only enhances the details of the face image, but also greatly reduces the artifact phenomenon by combining a structure reconstructor and a texture generator with excellent performance. It is superior to the current advanced methods in terms of subjective visual quality and objective quantitative measurement, and has broad application prospects in the fields of intelligent photo processing and so on. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] Figure 1 It is a flow chart of a method for facial image restoration based on latent feature reconstruction and mask perception of the present invention;
[0068] Figure 2 It is a structural diagram of the overall network model constructed by the present invention. DETAILED DESCRIPTION
[0069] In order to further understand the content of the present invention, the present invention is described in detail in conjunction with the accompanying drawings and embodiments.
[0070] Example 1
[0071] Combination Figure 1 and Figure 2 , a face image restoration method based on latent feature reconstruction and mask perception in this embodiment specifically includes the following steps:
[0072] Step 1: First, you need to deploy the corresponding pytorch environment to facilitate subsequent model building, training, and testing; use commonly used data sets, such as the CelebA-HQ face data set.
[0073] Step 2: Build a deep neural network based on latent feature reconstruction and a mask-aware deep neural network for model training;
[0074] 2-1. The constructed structure reconstructor first uses the standard feature pyramid on the ResNet backbone to extract three feature maps of different sizes from the 6th, 20th and 23rd layers, respectively, denoted as c1, c2, and c3. The feature map obtained by 1×1 convolution of c2 is upsampled and added to c3 to obtain p2, and the feature map obtained by 1×1 convolution of p2 is upsampled and added to c1 to obtain p1. c3 generates style vector 1 and style vector 2 through 16 gradient style modules, p2 generates style vector 3, style vector 4, style vector 5 and style vector 6 through 32 gradient style modules, and p1 generates 12 style vectors such as style vector 7, ..., style vector 18 through 64 gradient style modules. Finally, the generated 18 style vectors are sent to StyleGAN to obtain the repaired rough image.
[0075] The texture generator constructed in step 2 is divided into three modules, namely the encoder, which encodes the rough restored image with mask into a feature map; the restoration decoder, which is used to refine the feature map; and two refinement decoders with the same structure, which are used to continue to refine the feature map and decode the feature map back to pixels. Specifically, in the decoder, the mask image is first passed through the convolution layer and the Relu activation layer, and then through the convolution to generate the convolution kernel, which is used to convolve the repaired rough image to obtain the feature map and pass it into the decoder. In the restoration decoder, it first passes through the transposed convolution, and then cascades it with the feature map obtained in the previous layer. After the cascade, it passes through the convolution layer and the activation layer to obtain the refined feature map. In the refinement decoder, the feature map passes through the transposed convolution layer, and then is normalized to finally obtain the restored image.
[0076] 2-2. In the structure reconstructor, the feature pyramid structure uses 50 identical bottleneck modules, which include shortcut layer and res layer. The shortcut layer includes 1×1 convolution layer, normalization layer, res layer includes normalization layer, 3×3 convolution layer, PReLU activation function layer, 3×3 convolution layer, normalization layer, pooling layer, 1×1 convolution layer, ReLU activation function layer, 1×1 convolution layer, sigmoid activation function layer. The gradient style module includes 3×3 convolution layer and LeakyReLU activation function layer.
[0077] In the texture generator, there are 7 layers of networks in total. The processing operations of each layer of the network are the same, but the sizes of the convolution kernels of some convolution layers are different, as shown in the following table. In the decoder, the mask image is first passed through the convolution layer (denoted as Conv1) and the Relu activation layer, and then through the 3×3 convolution layer and the 1×1 convolution layer to generate the convolution kernel. The convolution kernel is used to convolve the repaired rough image (denoted as FConv), and then through the normalization layer, ReLU activation function layer, 3×3 convolution layer, 1×1 convolution layer, ReLU activation function layer, and the feature map is passed into the decoder. In the restoration decoder, it first passes through the transposed convolution layer (denoted as Dconv), normalization layer, LeakyReLU activation function layer, and then cascades it with the feature map obtained in the previous layer. After the cascade, it passes through the 5×5 convolution layer, 3×3 convolution layer, and LeakyReLU activation function layer to obtain the feature map. In the refinement decoder, the feature map passes through the transposed convolution layer and the normalization layer, denoted as f1; the feature map obtained in the previous layer passes through a 4×4 convolution layer, a 3×3 convolution layer, a ReLU activation function layer, and a 3×3 convolution layer, denoted as f2; the two feature maps f1 and f2 are multiplied pixel by pixel, the obtained feature map and f2 are added pixel by pixel, and finally pass through a LeakyReLU activation function layer.
[0078] Conv1 FConv DConv Layer1 7*7 7*7 6*6 Layer2 7*7 7*7 5*5 Layer3 5*5 5*5 4*4 Layer4 5*5 5*5 4*4 Layer5 3*3 3*3 4*4 Layer6 3*3 3*3 3*3 Layer 1*1 1*1 2*2
[0079] 2-2. In the structure reconstructor, the number of feature maps of p1 is 512, the number of feature maps of p2 is 512, the number of feature maps of c3 is 512, and the number of feature maps of the style vector is 18;
[0080] In the texture generator, the number of feature maps output by the first layer of the network is 3, the number of feature maps output by the second layer of the network is 64, the number of feature maps output by the third layer of the network is 128, the number of feature maps output by the fourth layer of the network is 256, and the number of feature maps output by the fifth, sixth, and seventh layers of the network are all 512.
[0081] The activation function of the ReLU activation layer is expressed as follows:
[0082] f(x)=max(0,x)
[0083] Where x is the input of the ReLU activation function, and f(x) is the output of the ReLU activation function;
[0084] The activation function of the Sigmoid activation layer is expressed as follows:
[0085]
[0086] Among them, x is the input of the Sigmoid activation function, and f(x) is the output of the Sigmoid activation function.
[0087] The activation function of the LeakyReLU activation layer is expressed as follows:
[0088] f(x)=max(ax,x)
[0089] Among them, x is the input of the LeakyReLU activation function, f(x) is the output of the LeakyReLU activation function, and a is a fixed parameter.
[0090] The activation function of the PReLU activation layer is expressed as follows:
[0091] f(x)=max(ax,x)
[0092] Among them, x is the input of the PReLU activation function, f(x) is the output of the PReLU activation function, and a is the parameter to be learned.
[0093] Step 3: Based on the training set prepared in step 1 and the network constructed in step 2, adjust the network parameters and perform network training, as follows:
[0094] 3-1. Adopt Adam optimization algorithm to optimize the network model, use learning rate decay strategy, and optimize by minimizing the overall loss function, which can be expressed as follows:
[0095]
[0096] Where N is the number of samples in the training set obtained in step 1, represents the i-th defect image sample, represents the i-th complete image sample, Ф represents the learned neural network parameters, and L is the calculated overall loss value.
[0097] 3-2. During the training process, the network parameters are updated by specifying the number of iterations.
[0098] Step 4: After the training is completed, a defective face image is used as the input of the network, and the parameters learned in step 3 are used to reconstruct a complete face image as the output.
[0099] The face image restoration method based on latent feature reconstruction and mask perception of this embodiment not only enhances the details of the face image, but also greatly reduces the artifact phenomenon by combining a structure reconstructor and a texture generator with excellent performance. It is superior to the current advanced methods in terms of subjective visual quality and objective quantitative measurement, and has broad application prospects in fields such as intelligent photo processing.
[0100] The present invention and its embodiments are described schematically above, and the description is not restrictive. The drawings show only one embodiment of the present invention, and the actual structure is not limited thereto. Therefore, if a person skilled in the art is inspired by it and designs a structural method and an embodiment similar to the technical solution without creativity without departing from the purpose of the invention, they shall all fall within the protection scope of the present invention.
Claims
1. A face image restoration method based on latent feature reconstruction and mask perception, characterized in that: The steps are: Step 1: Obtain a face image dataset and preprocess the images in the dataset; Step 2: construct a structure reconstructor based on latent feature reconstruction and a mask-aware texture generator for network model training; wherein: The structure reconstructor first passes through a 3×3 convolution layer, a normalization layer, and a PReLU layer, and then uses 50 identical bottleneck modules to extract three feature maps of different sizes from the 6th, 20th, and 23rd layers, respectively, denoted as c1, c2, and c3; the feature map obtained by 1×1 convolution of c2 is upsampled and added to c3 to obtain p2, and the feature map obtained by 1×1 convolution of p2 is upsampled and added to c1 to obtain p1; c3 generates style feature vector 0, style feature vector 1, and style feature vector 2 through 16 gradient style modules, p2 generates style feature vector 3, style feature vector 4, style feature vector 5, and style feature vector 6 through 32 gradient style modules, and p1 generates style feature vector 7 to style feature vector 17 through 64 gradient style modules; finally, the generated 18 style feature vectors are sent to StyleGAN to obtain the repaired rough image; The texture generator is divided into three modules: Texture encoder, which encodes the rough restored image with mask into a feature map; Recovery decoder, used to refine the feature map; and two refinement decoders with the same structure, used to continue refining the feature map and decoding the feature map back to pixels; In the texture generator, there are a total of 7 layers of networks. The processing operations of each layer of the network are the same, but the sizes of the convolution kernels of some convolution layers are different. In the encoder, the mask image is first passed through the convolution layer Conv1 and the Relu activation layer, and then through the 3×3 convolution layer and the 1×1 convolution layer to generate the convolution kernel. The convolution kernel is used to convolve the repaired rough image, and then through the normalization layer, ReLU activation function layer, 3×3 convolution layer, 1×1 convolution layer, ReLU activation function layer, the feature map is obtained and passed into the recovery decoder. In the recovery decoder, it first passes through the transposed convolution layer Dconv, the normalization layer, the LeakyReLU The activation function layer is then cascaded with the feature map obtained in the previous layer. After the cascade, it passes through a 5×5 convolution layer, a 3×3 convolution layer, and a LeakyReLU activation function layer to obtain a feature map; in the refinement decoder, the feature map passes through a transposed convolution layer and a normalization layer, and the obtained feature map is denoted as f1; the feature map obtained in the previous layer passes through a 4×4 convolution layer, a 3×3 convolution layer, a ReLU activation function layer, and a 3×3 convolution layer, and the obtained feature map is denoted as f2; the two feature maps f1 and f2 are multiplied pixel by pixel, and the obtained feature map and f2 are added pixel by pixel, and finally pass through a LeakyReLU activation function layer; Step 3: Based on the data set preprocessed in step 1 and the model constructed in step 2, adjust the model parameters and perform model training; Step 4: Take a defective face image as the input of the network, and use the parameters learned in step 3 to obtain a complete face image as the output.
2. The method for facial image restoration based on latent feature reconstruction and mask perception according to claim 1, characterized in that: The process of image preprocessing in step 1 is: using a computer to generate a mask of any size and shape, multiplying the mask by any image in the training set pixel by pixel, and obtaining a damaged image.
3. The method for facial image restoration based on latent feature reconstruction and mask perception according to claim 2, characterized in that: The loss function of the network training in step 2 is divided into six types in the structure reconstructor, namely pixel reconstruction loss L2, perceptual loss L s-prec , identity loss L ID , potential similarity loss L lalent , the reconstruction loss of pixels within the mask L s-hole and the reconstruction loss L for pixels outside the mask s-valid , as shown below: L Gs =L2+0.8*L s-prec +0.1*L ID +L latent +6*L s-hole +L s-vaild There are five types of loss functions in the texture generator: perceptual loss L t-prec , style loss L style , total variation loss L tv , the reconstruction loss of pixels within the mask L t-hole and the reconstruction loss L for pixels outside the mask t-valid : L Gt =L t-vaild +6L t-hole +0.05L t-prec +120L style +0.1L tv 。 4. The method for facial image restoration based on latent feature reconstruction and mask perception according to claim 3, characterized in that: In the structure reconstructor, the bottleneck module contains a shortcut layer and a res layer; the shortcut layer contains a 1×1 convolution layer and a normalization layer in sequence, and the res layer contains a normalization layer, a 3×3 convolution layer, a PReLU activation function layer, a 3×3 convolution layer, a normalization layer, a pooling layer, a 1×1 convolution layer, a ReLU activation function layer, a 1×1 convolution layer, and a sigmoid activation function layer in sequence; the gradient style module contains a 3×3 convolution layer and a LeakyReLU activation function layer in sequence.
5. The method for facial image restoration based on latent feature reconstruction and mask perception according to claim 4, characterized in that: In the structure reconstructor, the number of feature maps of p1 is 512, the number of feature maps of p2 is 512, the number of feature maps of c3 is 512, and the number of feature maps of the style vector is 18.
6. The method for facial image restoration based on latent feature reconstruction and mask perception according to claim 5, characterized in that: In the texture generator, the number of feature maps output by the first layer of the network is 3, the number of feature maps output by the second layer of the network is 64, the number of feature maps output by the third layer of the network is 128, the number of feature maps output by the fourth layer of the network is 256, and the number of feature maps output by the fifth, sixth, and seventh layers of the network are all 512.
7. The method for facial image restoration based on latent feature reconstruction and mask perception according to claim 6, characterized in that: The Adam optimization algorithm is used to optimize the network model, using the learning rate decay strategy and optimizing by minimizing the overall loss function, which can be expressed as follows: Where N is the number of samples in the training set obtained in step 1, represents the i-th defect image sample, represents the i-th complete image sample, Ф represents the learned neural network parameters, and L is the calculated overall loss value; During the training process, the network parameters are updated by specifying the number of iterations.
