Human face texture generation method, electronic device and computer storage medium
The face texture generation model is used to process bald face feature images and random noise images to generate more realistic and natural face texture images, which solves the problem of weak realism in face UV generation in the existing technology and achieves a wider range of application scenarios and efficient face texture generation.
Patent Information
- Application Number
- CN202311284572.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-28
- Publication Date
- 2024-09-06
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing face UV generation methods have the problem of inaccurate estimation, resulting in a weak sense of reality.
The face texture generation model is used to splice the bald face feature image and the random noise image, and the diffusion model is used for diffusion processing, and the decoder is used for decoding to generate a more realistic and natural face texture image.
The generated face texture image is more realistic and natural, has good versatility, avoids the estimation inaccuracy problem in the traditional face pose fitting method, and has a wide range of use scenarios.
Smart Images

Figure CN117115295B
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of visual processing technology, and in particular to a method for generating facial texture, an electronic device, and a computer storage medium. Background Art
[0002] With the development of artificial intelligence technology, more and more industries are using machine learning models to meet different business needs. Face modeling based on face UV is one of them.
[0003] UV is short for UVW, which means texture mapping coordinates, which are related to the XYZ coordinates of the model. UV defines the position information of each point on the image. Each model is composed of faces, and UV texture can be generally regarded as the "skin" of the model composed of all these faces. The face UV, or face texture, is the "skin" of the face. If you want to generate a 3D face model similar to a real face, the generation of face UV is crucial.
[0004] Existing facial UV generation mostly uses linearized deep learning models to fit facial postures, and then maps facial UV from 2D faces based on the correspondence between facial key points. However, due to the fitting of facial postures, there are problems such as inaccurate estimation, resulting in weak realism of facial UV generation. Summary of the invention
[0005] In view of this, an embodiment of the present application provides a solution for generating facial texture to at least partially solve the above-mentioned problem.
[0006] According to a first aspect of an embodiment of the present application, a facial texture generation method is provided, comprising: obtaining a bald facial feature image and a random noise image corresponding to a bald facial image with hair removed, splicing the bald facial feature image and the random noise image to obtain a spliced image; performing diffusion processing on the spliced image through a diffusion model in a facial texture generation model to obtain a denoised image corresponding to the bald facial image; and decoding the denoised image through a decoder in the facial texture generation model to obtain a corresponding facial texture image.
[0007] According to a second aspect of an embodiment of the present application, there is provided an electronic device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the method described in the first aspect.
[0008] According to a third aspect of an embodiment of the present application, a computer storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the method described in the first aspect is implemented.
[0009] According to the scheme provided in the embodiment of the present application, a face texture image is generated by a face texture generation model. On the one hand, the face texture generation model takes a spliced image generated by splicing a bald face feature image and a random noise image as input. Through diffusion and decoding processing, the generated face texture image can be made more realistic and natural, and has good versatility. It only needs to obtain a bald head image of the face image, and has a wide range of usage scenarios. On the other hand, the face texture generation model includes a diffusion model and a decoder. Through the diffusion model, an image corresponding to the input image that can meet the requirements of texture transformation can be obtained, and then converted into a face texture image through the decoder. In this way, the needs of face texture generation are met, and because face posture fitting is no longer required in this process, the problems of inaccurate estimation and weak sense of reality of face texture generation in traditional face posture fitting methods are avoided. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0011] Figure 1 is a schematic diagram of an exemplary diffusion model;
[0012] Figure 2 is a schematic diagram of an exemplary encoding and decoding model;
[0013] Figure 3 A schematic diagram of the structure of a face texture generation model according to an embodiment of the present application;
[0014] Figure 4 for Figure 3 A flowchart of the steps in the training process of the face texture generation model shown;
[0015] Figure 5 for Figure 4 A schematic diagram of the structure of a specific face texture generation model in the example shown;
[0016] Figure 6 A flowchart of a method for generating facial texture according to an embodiment of the present application;
[0017] Figure 7 It is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0018] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the embodiments of the present application should fall within the scope of protection of the embodiments of the present application.
[0019] The specific implementation of the embodiment of the present application is further explained below in conjunction with the accompanying drawings of the embodiment of the present application.
[0020] In order to facilitate understanding of the solution of the embodiment of the present application, the diffusion model is briefly described below. An exemplary diffusion model is as follows: Figure 1 shown.
[0021] The diffusion model is a type of image generation model that learns the information attenuation caused by noise and then uses the learned pattern to generate images. An example of the above process is as follows Figure 1 As shown in the figure, in the traditional method, the diffusion model uses the image denoising in the forward process and the image denoising in the reverse process, and the difference between the denoised image and the original image is used as the basis to realize the training of the model. In the inference stage of the model, the reverse process of the diffusion model can be directly used to realize the generation of the image.
[0022] For the diffusion model, Figure 1 As shown in , it can realize model training using image samples, including: in the forward process (such as Figure 1 In the forward process (from right to left in the figure), the image samples are denoised through multiple diffusion noise layers to generate noisy image samples; in the reverse process, the noisy image samples generated by the forward process are denoised to generate denoised images; then, based on the difference between the denoised images and the image samples, the diffusion model is trained. For example, in the training stage of the diffusion model, the forward process gradually denoises the data (such as clear image data) through diffusion noise to generate noisy data (such as a noisy image), as shown in FIG. Figure 1 As shown in , it is necessary to add noise to the image output by the previous diffusion noise layer according to the preset parameters to t-1 The output image is denoised to generate a diffusion noise layer X t The process is shown in the figure as q(x t |x t-1), through the forward process, the diffusion noise is used to generate the noisy image sample (as shown in the left image in the figure); then, based on the noisy image sample, the original image is gradually denoised and output through the reverse process (as shown in the right image in the figure), so as to t The output image denoising generates the denoising layer x t-1 The image is taken as an example, and the process is shown in the figure as p θ (x t-1 |x t ).
[0023] In the diffusion model, the number of steps in the forward process and the reverse process is defined by the subscript t, and there is a predefined total number of steps T (for example, 1000). When t = 0, it is a real image obtained by sampling, and when t = T, it is approximately a pure noise image. Through the diffusion model, effective image reconstruction can be achieved.
[0024] The following further describes the encoding and decoding model involved in the embodiments of the present application.
[0025] The codec model is a model composed of an encoder and a decoder. The codec model can encode and decode various types of data, including but not limited to text data, image data, audio data, etc. The embodiment of the present application mainly involves image data types. In the training stage, the vector representation of the input image is encoded by the encoder to obtain a coding vector; the coding vector is then decoded by the decoder to obtain a decoding vector, which represents the prediction map corresponding to the input image; then, based on the difference between the prediction map and the input image, the codec model is trained. In the inference stage, the decoder can be directly used to decode the vector representation of the image to obtain the desired image. In practical applications, the codec model can be implemented in any appropriate form as needed, including but not limited to a form based on a convolutional structure, a form based on a Transformer structure, a form based on a VAE (Variational AutoEncode) structure, and the like.
[0026] In the embodiment of the present application, a VAE structure encoding and decoding model is used. An exemplary VAE structure is as follows Figure 2 As shown, it includes an encoder and a decoder. In this model, the input data, in this example, the input image data such as the input UV image, is first encoded into a low-dimensional representation through the encoder; then, the low-dimensional representation is decoded back to the original space, that is, the original dimensional representation, through the decoder, thereby realizing the reconstruction of the input image data.
[0027] In the traditional way, the diffusion model and the codec model are used independently to achieve their own independent functions. However, the inventors of the present application have improved the diffusion model and the codec model based on their respective characteristics and constructed a face texture generation model in the embodiment of the present application. The face texture generation model in the embodiment of the present application is, for example, Figure 3 As shown, it includes a pixel space model and a latent space model. Among them, the pixel space model is implemented by the encoding and decoding model of the VAE structure, and the latent space model is implemented by the diffusion model. In the training stage, the pixel space model and the latent space model are trained separately. After the pixel space model and the latent space model are trained, in the inference stage, the output end of the reverse process of the trained diffusion model is connected to the input end of the decoder in the trained pixel space model to generate the final face texture generation model. When in use, the input image is processed through the reverse process of the diffusion model and the decoder to obtain the required face texture image, that is, the face UV image.
[0028] Based on the structure of the above-mentioned face texture generation model, the following first describes its training process, and then describes the process of applying the trained face texture generation model to face texture generation.
[0029] Reference Figure 4 , showing a flowchart of the steps of the training process of a face texture generation model according to an embodiment of the present application. As mentioned above, the face texture generation model in this embodiment includes a pixel space model and a latent space model. Among them, the pixel space model is implemented by a codec model, including an encoder and a decoder; the latent space model is implemented by a diffusion model, that is, including a diffusion model. The pixel space model and the latent space model are trained separately, regardless of the order of training, and can also be trained in parallel.
[0030] In which, in the training stage of the pixel space model, the vector representation of the face texture sample image of the first vector dimension is received by the encoder and encoded to obtain a coding vector of the second vector dimension, wherein the first vector dimension is higher than the second vector dimension; the coding vector is decoded by the decoder to predict and generate a face texture prediction map; based on the difference between the face texture prediction map and the face texture sample image, the encoder and decoder are trained.
[0031] The training of the latent space model is mainly for the training of its diffusion model. Unlike the training of the traditional diffusion model, which includes both the forward process and the reverse process, in the embodiment of the present application, the noise image is used for training only for the reverse process, without the forward process. Specifically, the random noise sample image is received through the diffusion model, and the input bald face sample image is used as the training condition, and the spliced sample image is denoised through the reverse process to obtain the corresponding denoised sample image, wherein the spliced sample image is an image generated by splicing the random noise sample image and the feature sample image corresponding to the bald face sample image; the diffusion model is trained according to the difference between the denoised sample image and the bald face sample image.
[0032] Based on this, the training process of the face texture generation model in this embodiment includes the following steps:
[0033] Step S402: training the pixel space model in the face texture generation model.
[0034] Compared with the method of uniformly training the face texture generation model as a whole, the method of training its pixel space model separately can make the training more targeted and the training effect of the pixel space model better. On the other hand, it can also greatly save the data processing burden of the model during training, improve training efficiency and reduce training costs.
[0035] In one feasible method, training the pixel space model may include: receiving a vector representation of a face texture sample image of a first vector dimension through an encoder and performing encoding processing to obtain a coding vector of a second vector dimension, wherein the first vector dimension is higher than the second vector dimension; decoding the coding vector through a decoder to predict and generate a face texture prediction map; and training the encoder and decoder based on the difference between the face texture prediction map and the face texture sample image.
[0036] In an embodiment of the present application, a pixel space model is used to realize image reconstruction, such as reconstruction of a face UV image. Exemplarily, the training of the pixel space model mainly includes the training of its encoder and decoder. The input and output of the model are both face UV images. Specifically, the input training sample can be a face texture sample image, i.e., a face UV sample image, and the output is a face UV prediction map. As mentioned above, the pixel space model of the encoder-decoder structure adopts a VAE architecture, and the network structure adopts a UNet structure. The dimension of the latent vector between the encoder and the decoder can be one eighth of the input image, i.e., the face texture sample image. For example, assuming that the dimension of the face UV sample image input to the encoder is B*3*512*512 (where B represents Batch Size), it is first encoded by the encoder and the encoding vector is output, and its dimension can be B*4*64*64. Then, the decoder receives the encoding vector of B*4*64*64 dimension from the encoder, decodes it, and obtains a face UV prediction map of dimension B*3*512*512. Then, the encoder-decoder training is performed based on the difference between the face UV prediction map and the face UV sample image through the predicted loss function. The above loss function can be flexibly set by those skilled in the art according to actual needs, and the embodiment of the present application does not limit this.
[0037] Among them, the encoder adopts the VAE structure in its specific implementation, and its training process can be simply divided into three parts:
[0038] 1) First, input the B*3*512*512 face UV sample image, pass it through the encoding network, such as the ResNetblock network, realize the encoding extraction of features, and obtain the B*8*64*64 dimension encoding vector;
[0039] 2) After passing through a quantization network, which may be a layer of convolutional network, the above-mentioned B*8*64*64 dimensional coding vector is convolved and the convolved coding vector with the dimension of B*8*64*64 is output;
[0040] 3) The last part is a sampling network, which splits the encoding vector of dimension B*8*64*64 into two parts, one part as the mean (mean) of the Gaussian distribution, and the other part as the std (standard error) of the Gaussian distribution. In this way, a Gaussian distribution is obtained, and then a latent vector with dimension B*4*64*64 is obtained by random sampling, which is used as the encoding vector output by the encoder.
[0041] For the decoder, the decoding process consists of two parts:
[0042] 1) Dequantize the encoding vector with a dimension of B*4*64*64 output by the encoder to obtain a feature vector with a dimension of B*8*64*64;
[0043] 2) The feature vector with a dimension of B*8*64*64 is passed through the decoding network to obtain a face UV prediction map with a dimension of B*3*512*512. The decoding network can also use a ResNetblock structure network.
[0044] The above training process is repeated repeatedly until the training termination condition is reached, such as reaching a preset number of training times, or the loss value reaches a preset threshold.
[0045] In a feasible manner, the facial texture sample images can be obtained by: acquiring real facial images with multiple perspectives collected synchronously by multiple groups of cameras; and obtaining facial texture sample images of the real facial images with multiple perspectives through a face reconstruction algorithm.
[0046] Exemplarily, a camera array can be built based on a 180-degree semicircle to collect multi-view upper body data for real people. Specifically, in an ideal scene with uniform light, a headgear is put on a person to ensure that the face and forehead are not blocked. Multiple groups of cameras synchronously collect photos of the person at a certain moment, and synchronously record a group of videos of the person. The main thing is that the head of the person rotates within a certain angle under different lighting to obtain real face images from multiple perspectives. Then, based on the real face images from multiple perspectives, a reconstruction algorithm is used to obtain the head mesh and face UV image of the person. Optionally, manual intervention can also be used for correction. In this way, a face UV image under ideal conditions and face images under different angles and light can be obtained. In this way, a large number of face images and corresponding face UV images can be obtained to form a training sample set. Then, any face UV image can be used as a face texture sample image when used for model training.
[0047] Step S404: training the diffusion model.
[0048] It should be noted that, in this embodiment, the pixel space model is trained first and then the diffusion model is trained as an example, but as mentioned above, the training of the two models can be performed in any order and can also be performed in parallel.
[0049] The training of the diffusion model includes: receiving a random noise sample image, and receiving an input bald face sample image, splicing the feature image corresponding to the bald face sample image and the random noise sample image to obtain a spliced sample image; using the bald face sample image as a training condition, denoising the spliced sample image through a reverse process to obtain a corresponding denoised sample image; and training the diffusion model based on the difference between the vector corresponding to the denoised sample image and the encoding vector. The feature image corresponding to the bald face sample image can be obtained by extracting features from the bald face sample image through any appropriate structure or model. For example, another encoder can be used to extract features from the bald face sample image in an encoded form to obtain the feature image.
[0050] Among them, the bald face sample image corresponding to the face texture sample image can be obtained in the following way: for each image in the multi-view real face image, face detection, face feature point detection, and hair segmentation processing are performed to obtain the hair mask corresponding to each image; according to each image and its corresponding hair mask, the bald face sample image corresponding to each image is obtained.
[0051] As mentioned above, the training sample set contains a large number of face images and corresponding face UV images. When obtaining a bald face image, the face image can be processed by face detection, face feature point detection, and hair segmentation, and the hair mask MASK of the face image can be obtained. On this basis, the corresponding neural network model can be used to process the face image and the corresponding hair mask MASK to obtain the corresponding bald face image. In this way, the face images in the training sample set are processed in this way. In the training sample set, each face image has a corresponding bald face image in addition to the corresponding face UV image.
[0052] Based on this, when the bald face sample image is used as the training condition, the spliced sample image is denoised through the reverse process to obtain the corresponding denoised sample image: for each denoising step in the reverse process, based on the feature map of the spliced sample image output by the previous denoising step, the feature map is guided by the image vector corresponding to the bald face sample image to output the guided feature map until the last denoising step is passed to obtain the denoised sample feature map. In each denoising step, the feature map generated by the denoising step is guided by the image vector of the bald face sample image, which can make the feature map closer to the bald face sample image, and thus make the final denoised sample image obtained after the reverse process of the diffusion model based on the noisy spliced sample image closer to the features of the bald face sample image. As a result, the training effect of the diffusion model is greatly improved.
[0053] After the pixel space model and the diffusion model are trained, the two are connected to form the face texture generation model in the embodiment of the present application. Specifically, the output end of the inverse process of the diffusion model can be connected to the input end of the decoder in the pixel space model.
[0054] However, the method is not limited to training the pixel space model and the diffusion model separately, and the two can also be trained jointly. The following is an example of a structure of a specific face texture generation model. Figure 5 shown.
[0055] Figure 5 In the figure, the left box represents the pixel space model including the encoder and decoder, the middle box represents the latent space model including the diffusion model, and the right box represents the conditional input of the diffusion model.
[0056] Depend on Figure 5 As can be seen from the figure, the encoder (denoted as ε in the figure) is connected to the input end of the forward process of the diffusion model, and the decoder (denoted as ) is connected to the output end of the reverse process of the diffusion model. In each denoising step of the reverse process of the diffusion model, the input feature data is subjected to cross attention processing (denoted as QKV in the figure), and the denoising process of each denoising step is guided by the feature image of the bald face sample image, so that the features obtained by the denoising step are closer to the features of the bald face sample image, including but not limited to texture features, posture features, etc.
[0057] based on Figure 5 The model structure shown in the figure has a training process that includes:
[0058] In the first stage, the pixel-space model including the encoder and decoder is pre-trained.
[0059] like Figure 5 As shown in the left box, the pixel space model includes an encoder and a decoder, which can be trained independently. When training this part, the input is a face UV sample image with a dimension of B*3*512*512, where B represents the batch size. First, the encoder encodes the latent vector with a dimension of B*4*64*64, and then decodes it with the decoder to obtain the face UV prediction image; then the loss is performed with the input original image, that is, the face UV sample image, to train the encoder and decoder.
[0060] Among them, the encoder adopts the VAE structure, which can be simply divided into three parts:
[0061] (1) First, input the B*3*512*512 face UV sample image, and obtain the B*8*64*64 feature vector through the encoding network. This part of the encoding network can use the ResNetblock structure network to realize feature encoding extraction;
[0062] (2) After passing through a quantization network, it can be implemented as a convolutional network, which inputs the above B*8*64*64 feature vector, performs convolution processing, and outputs the convolved B*8*64*64 feature vector;
[0063] (3) The last part is a sampling network, which splits the B*8*64*64 feature vector into two parts, one part as the mean of the Gaussian distribution and the other part as the std of the Gaussian distribution. This results in a Gaussian distribution, and then random sampling to obtain a latent vector with a dimension of B*4*64*64, which is the encoding vector output by the encoder.
[0064] The decoder is divided into two parts:
[0065] (1) Dequantize the encoding vector output by the encoder to obtain a B*8*64*64 feature vector;
[0066] (2) The B*8*64*64 feature vector is passed through a decoding network to obtain a face UV prediction map with a dimension of B*3*512*512, that is, a decoding vector output by the decoder. The decoding network can also adopt a ResNetblock structure network.
[0067] The second stage: Based on the trained pixel space model, the diffusion model is trained.
[0068] like Figure 5 As shown in the middle box in , the diffusion network can be a UNet network. For example, if the number of diffusion steps is T times, then the actual diffusion process is a UNet network that goes through T steps.
[0069] Combination Figure 5 , the training process of the diffusion model includes:
[0070] (1) Face UV sample image (such as Figure 5 The image in the upper left corner of the image) is first converted into an image vector ( Figure 5 The trained encoder ( Figure 5 The encoding process of the trained encoder is to obtain the encoding vector latent, which is input into the diffusion model ( Figure 5 Indicated in ), randomly select one step t from step 1 to step T, and then calculate the weight W according to the preset weight W. t , design the diffusion input for this step: It =laten*W t +noise*(1-W t ), the target output is noise, that is, a noise image Figure 5 Indicated in
[0071] (2) When obtaining noise After that, it will enter the reverse process of the diffusion model. In this example, the reverse process is performed based on the noise image and the conditional graph. Among them, the conditional graph input to the reverse process can be the feature image corresponding to the bald face sample image after the hair is removed corresponding to the face UV sample image input to the encoder. Specifically, the conditional graph will pass through an encoding network (such as an encoding network implemented by a 4-layer convolution, Figure 5 Indicated as “τ θ ”) to extract features and obtain feature images, the dimension will change from B*3*512*512 to B*3*64*64.
[0072] (3) On the one hand, the extracted feature image of the conditional graph will be concat (joined) with the noise image to obtain a new input feature, namely the concatenated sample image, whose feature dimension is B*7*64*64. Then, the concatenated sample image will be sent to the UNet network for denoising. In this process, Figure 5 As shown in , the characteristics of the conditional graph will also guide the denoising process at each step until the feature graph restored by the denoising process is obtained This feature map will be combined with the input diffusion model Use L1loss to guide the learning of the diffusion model.
[0073] Furthermore, the It will be input into the decoder for decoding and get the face UV prediction map. Figure 5 Indicated in
[0074] It should be noted that, during the training of the diffusion model, the model parameters of the encoder and decoder in the pixel space model can remain fixed, that is, no longer participate in the training. However, preferably, according to the training of the diffusion model, as part of the face texture generation model, its model parameters can be fine-tuned to better adapt to the overall model and achieve better UV generation effect.
[0075] In addition, in the inference stage of the model, the initial input of the face texture generation model can be pure noise, such as a pure noise image, which is combined with a bald face image as the conditional map of UNet (specifically, the feature image corresponding to the conditional map). At each step t, UNet predicts the noise of the current step t each time, and then inputs the feature map of step t and the predicted noise map to obtain the output feature map of step t. After T steps of this cycle, the result is the predicted latent vector, which can be processed by the decoder to obtain the predicted face UV prediction map.
[0076] Through the above training, a face texture generation model can be obtained which takes the face bald image as conditional input and the face UV image as output.
[0077] It can be seen that through the training process of this embodiment, there is no need to process the light and shadow, angle or posture of the face, and a face texture generation model that can generate a real and natural face UV image can be obtained. This model has higher versatility and a wider range of application scenarios, and greatly reduces the requirements for the input image, and the face texture processing is more accurate and efficient.
[0078] The following is an explanation of the facial texture generation method provided by the embodiment of the present application based on the facial texture generation model trained above. Figure 6 shown.
[0079] Reference Figure 6 The face texture generation method of this embodiment includes the following steps:
[0080] Step S602: Obtain a bald face feature image and a random noise image corresponding to the bald face image after hair removal.
[0081] When generating facial texture, the obtained image may be a bald face image, such as a real person is bald. However, in most cases, the obtained facial image may be an image with hair. In this case, the image needs to be processed to remove the hair.
[0082] Exemplarily, the hair mask corresponding to each image can be obtained by sequentially performing face detection, facial feature point detection, and hair segmentation processing on the image; then, based on each image and its corresponding hair mask, the bald face image corresponding to each image is obtained.
[0083] In a specific example, the above process may include:
[0084] (1) Face detection
[0085] Specifically, the face detection process may include:
[0086] In the first stage, the P-Net fully convolutional network is used to obtain the regression vector of the face and its bounding box in the face image, and the bounding box is used to regress the possible vector to calibrate the face candidate box. Finally, non-maximum suppression (NMS) is used to merge the highly overlapping face candidate boxes to obtain the final candidate detection box.
[0087] In the second stage, all candidate detection frames output from P-Net are input into another CNN network, such as R-Net. In the R-Net network, non-face candidate detection frames are filtered out, calibrated using bounding box regression, and merged using NMS to obtain the final face detection frame.
[0088] The third stage, O-net, outputs the location of the face detection frame and five facial key points.
[0089] (2) Facial feature point detection
[0090] A facial key point recognition model with ResNet18 as the backbone network can be used to detect and identify facial images to obtain a series of two-dimensional coordinates of facial feature points in the image, thereby locating the key information of the face.
[0091] (3) Hair segmentation
[0092] A hair segmentation model based on the deeplab v3+ network can be used to achieve hair-level segmentation and remove hair from face images. The input of this model is a face image, and the output is a mask of the hair.
[0093] (4) Bald model
[0094] A model based on the Pix2Pix network can be used, with the input being a face image and its corresponding hair mask MASK, and the output being the corresponding bald face image.
[0095] During the training phase, the model requires two parts of training samples: one part is to remove the hair from real face images. Although the cost of this part of training samples is high and the amount of data is small, the effect is more realistic and natural; the other part is to add hair to the collected real bald face images. This part of data has a large amount. In this way, the training effect of the model can be guaranteed and the number of training samples can be expanded.
[0096] Through the above process, a bald face image corresponding to the face image for which face UV needs to be generated can be obtained. On this basis, feature extraction is performed on the bald face image. Exemplarily, feature extraction can be performed by an encoder for feature extraction (different from the encoder in the pixel space model) to obtain a bald face feature image corresponding to the bald face image.
[0097] In addition, in this embodiment, a noise image is also needed, and a random noise image can be selected. The random noise image is easy to generate and has low implementation cost.
[0098] Step S604: stitching the bald face feature image and the random noise image to obtain a stitched image.
[0099] Specifically, the facial features corresponding to the bald face feature image and the noise features corresponding to the random noise image can be obtained respectively; the facial features and the noise features are spliced to obtain a spliced feature image.
[0100] Step S606: performing diffusion processing on the spliced image using the diffusion model in the face texture generation model to obtain a denoised image corresponding to the bald face image.
[0101] After the face texture generation model is trained, the inverse process part and the decoder part of the diffusion model can be used in the inference stage. Specifically, in this step, the image vector corresponding to the spliced image is output to the diffusion model, and denoised through the inverse process part to obtain the corresponding denoised image, which is a feature map carrying features such as face texture features and posture features.
[0102] In one feasible method, cross-attention processing can be performed on the features corresponding to the above-mentioned spliced feature image; diffusion processing can be performed based on the features after cross-attention processing to obtain a denoised image corresponding to the bald face image. Through cross-attention processing, various feature information of the face can be effectively integrated, and the facial features can be made more prominent, achieving a better diffusion processing effect.
[0103] Step S608: Decoding the denoised image through the decoder in the face texture generation model to obtain a corresponding face texture image.
[0104] After obtaining the denoised image, it is output to the decoder, and the corresponding face UV image can be obtained through decoding.
[0105] According to this embodiment, a face texture image is generated by a face texture generation model. On the one hand, the face texture generation model takes a spliced image generated by splicing a bald face feature image and a random noise image as input. Through diffusion and decoding processing, the generated face texture image can be made more realistic and natural, and has good versatility. It only needs to obtain a bald image of the face image, and has a wide range of usage scenarios. On the other hand, the face texture generation model includes a diffusion model and a decoder. Through the diffusion model, an image corresponding to the input image that can meet the requirements of texture transformation can be obtained, and then converted into a face texture image through the decoder. In this way, the needs of face texture generation are met, and because face posture fitting is no longer required in this process, the problems of inaccurate estimation and weak sense of reality of face texture generation in traditional face posture fitting methods are avoided.
[0106] It should be noted that the implementation description of some steps in this embodiment is relatively simple, and the relevant parts can refer to the description in the aforementioned model training embodiment.
[0107] Reference Figure 7 , shows a schematic diagram of the structure of an electronic device according to an embodiment of the present application. The specific embodiment of the present application does not limit the specific implementation of the electronic device.
[0108] like Figure 7 As shown, the electronic device may include: a processor (processor) 702 , a communication interface (Communications Interface) 704 , a memory (memory) 706 , and a communication bus 708 .
[0109] in:
[0110] The processor 702 , the communication interface 704 , and the memory 706 communicate with each other via a communication bus 708 .
[0111] The communication interface 704 is used to communicate with other electronic devices or servers.
[0112] The processor 702 is used to execute the program 710, and specifically can execute the relevant steps in the above method embodiment.
[0113] Specifically, the program 710 may include program codes, which include computer operation instructions.
[0114] The processor 702 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application. The one or more processors included in the smart device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0115] The memory 706 is used to store the program 710. The memory 706 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0116] The program 710 may be specifically used to enable the processor 702 to execute operations corresponding to the methods described in the above method embodiments.
[0117] The specific implementation of each step in program 710 can refer to the corresponding description of the corresponding steps and units in the above method embodiment, which will not be repeated here. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described devices and modules can refer to the corresponding process description in the above method embodiment, which will not be repeated here.
[0118] It should be pointed out that, according to the needs of implementation, the various components / steps described in the embodiments of the present application can be split into more components / steps, or two or more components / steps or partial operations of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present application.
[0119] The above-mentioned method according to the embodiment of the present application can be implemented in hardware, firmware, or implemented as software or computer code that can be stored in a recording medium (such as a CD ROM, RAM, floppy disk, hard disk or magneto-optical disk), or implemented as a computer code originally stored in a remote recording medium or a non-temporary machine-readable medium downloaded through a network and to be stored in a local recording medium, so that the method described herein can be stored in such software processing on a recording medium using a general-purpose computer, a special-purpose processor or programmable or special-purpose hardware (such as an ASIC or FPGA). It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component (e.g., RAM, ROM, flash memory, etc.) that can store or receive software or computer code, and when the software or computer code is accessed and executed by a computer, a processor or hardware, the method described herein is implemented. In addition, when a general-purpose computer accesses the code for implementing the method shown here, the execution of the code converts the general-purpose computer into a special-purpose computer for executing the method shown here.
[0120] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present application.
[0121] The above implementation methods are only used to illustrate the embodiments of the present application, and are not limitations on the embodiments of the present application. Ordinary technicians in the relevant technical field can make various changes and modifications without departing from the spirit and scope of the embodiments of the present application. Therefore, all equivalent technical solutions also belong to the scope of the embodiments of the present application. The scope of patent protection of the embodiments of the present application should be limited by the claims.
Claims
1. A method for generating facial texture, comprising: Acquire a bald face feature image and a random noise image corresponding to the bald face image after hair removal, and splice the bald face feature image and the random noise image to obtain a spliced image; Performing diffusion processing on the spliced image by using a diffusion model in a facial texture generation model to obtain a denoised image corresponding to the bald face image; Decoding the denoised image through a decoder in the face texture generation model to obtain a corresponding face texture image; The step of splicing the bald face feature image and the random noise image to obtain a spliced image includes: respectively obtaining facial features corresponding to the bald face feature image and noise features corresponding to the random noise image; splicing the facial features and the noise features to obtain a spliced feature image; The method of performing diffusion processing on the spliced image through the diffusion model in the face texture generation model to obtain a denoised image corresponding to the bald face image includes: performing cross-attention processing on the features corresponding to the spliced feature image; and performing diffusion processing based on the features after the cross-attention processing to obtain a denoised image corresponding to the bald face image.
2. The method according to claim 1, wherein: The face texture generation model includes a pixel space model and a latent space model; the pixel space model includes an encoder and a decoder, and the latent space model includes a diffusion model; the pixel space model and the latent space model are trained separately.
3. The method according to claim 2, wherein: The training of the latent space model includes: The random noise sample image is received through the diffusion model, and the input bald face sample image is used as a training condition, and the spliced sample image is denoised through the inverse process to obtain a corresponding denoised sample image, wherein the spliced sample image is an image generated by splicing the random noise sample image and the feature sample image corresponding to the bald face sample image; The diffusion model is trained according to the difference between the denoised sample image and the bald face sample image.
4. The method according to claim 3, wherein: The method uses the input bald face sample image as a training condition, performs denoising on the spliced sample image through a reverse process, and obtains a corresponding denoised sample image, including: For each denoising step in the reverse process, based on the feature map of the spliced sample image output by the previous denoising step, the image vector corresponding to the bald face sample image is used to guide the feature map, and the guided feature map is output until the last denoising step is passed to obtain the denoised sample feature map.
5. The method according to claim 2, wherein: The training of the pixel space model includes: Receiving, by means of the encoder, a vector representation of a facial texture sample image of a first vector dimension and performing encoding processing to obtain an encoding vector of a second vector dimension, wherein the first vector dimension is higher than the second vector dimension; Decoding the encoding vector by the decoder to predict and generate a facial texture prediction map; The encoder and the decoder are trained based on the difference between the face texture prediction map and the face texture sample image.
6. The method according to claim 2, wherein: The method further comprises: The output end of the inverse process of the trained diffusion model is connected to the input end of the decoder in the trained pixel space model.
7. The method according to claim 5, wherein: The facial texture sample images are obtained by: acquiring multi-perspective real facial images synchronously acquired by multiple groups of cameras; and obtaining facial texture sample images of the multi-perspective real facial images by using a face reconstruction algorithm. The bald face sample images corresponding to the face texture sample images are obtained by: performing face detection, face feature point detection, and hair segmentation processing on each of the multi-view real face images to obtain a hair mask corresponding to each image; According to each image and its corresponding hair mask, a bald face sample image corresponding to each image is obtained.
8. An electronic device comprising: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the method as described in any one of claims 1-7.
9. A computer storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Model head portrait creation method and device, electronic equipment and storage medium
CN112669447A
Portrait image hair removal method and device based on GAN network
CN114663274A
Face attribute editing model training and face attribute editing methods
WO2023072067A1
