A text-controlled 3D face generation method based on StyleCLIP and 3DDFA
Through the combined network of StyleCLIP and 3DDFA, text and images are used for iterative training, which solves the difficulty of editing existing 3D face models, realizes the generation and editing of text-controlled 3D face models, and improves interactivity and convenience.
Patent Information
- Application Number
- CN202210710650.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-22
- Publication Date
- 2024-10-22
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing 3D face model generation methods lack interactive editing, making it difficult for users to adjust the generated 3D face model through manual adjustments.
Using a text control method based on StyleCLIP and 3DDFA, the input text and the original image are iteratively trained through a combined network to generate a three-dimensional face model that conforms to the text description. The image-text matching loss of StyleCLIP and the feature encoding loss of 3DDFA are used to achieve three-dimensional face modeling. Automatic adjustment of face models.
The 3D face model generated through direct text control is realized, which improves the interactivity and editing convenience of the 3D face model. There is no need to manually adjust features, and it does not rely on additional annotation attribute data.
Smart Images

Figure CN114998690B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of three-dimensional reconstruction, and in particular relates to a method for generating a text-controlled three-dimensional face model based on StyleCLIP and 3DDFA. Background Art
[0002] With the popularity of smart devices (mobile phones, iPads, etc.), more and more people like to record their daily lives and upload them to WeChat Moments, Weibo, Instagram, Facebook and other apps. According to statistics from the American Imaging Industry Association, more than 60% of the multimedia data currently collected by mobile devices, such as images and videos, contains facial information, which indirectly shows that faces account for a very high proportion of the information people come into contact with on a daily basis. 3D face reconstruction technology is widely used in film special effects, live broadcasting, security and other industries.
[0003] The existing face 3D reconstruction technology fits a two-dimensional face image with a three-dimensional deformable model to obtain a reconstructed three-dimensional face model. The local features of the face model can be adjusted by modifying the parameters of the three-dimensional deformable model. CN112002009A proposes an unsupervised 3D face reconstruction method based on a generative adversarial network. A generator is used to learn the 3DMM basis vector parameters in a two-dimensional face image, and the 3DMM parameters extracted by the generator are made to conform to the distribution of realistic face parameters through an adversarial generation process, thereby generating a realistic three-dimensional face. However, the three-dimensional face model generated by this method lacks interactive editing, and it is difficult for users to adjust the generated three-dimensional face model. Therefore, a method for generating a three-dimensional face model using other modal information is proposed, which can improve the interactivity of the three-dimensional face model and make the editing of the three-dimensional face model more convenient. Summary of the invention
[0004] The present invention aims to overcome the problem of difficulty in interactive editing of three-dimensional face models in the prior art, and provides a text-controlled three-dimensional face generation method based on StyleGAN and 3DDFA, which can input text content to make the generated face model conform to the text description.
[0005] In order to achieve the above-mentioned object of the invention, the present invention adopts the following technical solutions:
[0006] A method for generating a text-controlled three-dimensional face model based on StyleCLIP and 3DDFA, comprising the following steps:
[0007] Step S1, building a combined network based on the image editing network StyleCLIP and the three-dimensional reconstruction network 3DDFA;
[0008] Step S2, obtaining the original image and target text required for input;
[0009] Step S3: Input the original image and target text into the combined network, and then L Perform iterative training to obtain the parameters used in the 3D reconstruction network 3DDFA p ;
[0010] Step S4, use the trained parameters p , use the 3D reconstruction network 3DDFA to perform 3D reconstruction of the face.
[0011] Furthermore, the combined network in step S1 includes a pre-trained image encoding network e4e, a pre-trained image generation network G based on StyleGAN2, a multimodal pre-trained network CLIP, a pre-trained three-dimensional reconstruction network 3DDFA and a pre-trained recognition network ArcFace.
[0012] Furthermore, the image encoding network e4e and the image generation network G are both trained based on the face dataset FFHQ.
[0013] Furthermore, the deviation loss in step S3 L Specifically:
[0014]
[0015] in λ L2 , λ ID is a constant proportional value, L CLIP It is the image-text matching loss, specifically:
[0016]
[0017] in D CLIP is the output of the CLIP model, t To enter the target text, w For the generated image hidden code output by the image encoding network e4e, G (∙) represents the output of the image generation network, L L2 is the coding distance loss, specifically:
[0018]
[0019] in w s is the hidden code of the original image output by the image encoding network e4e, L ID is the feature encoding loss, specifically:
[0020]
[0021] in, R (∙) is the output of ArcFace network, F PAF (∙) is the feature map output of the 3DDFA network, and 〈∙〉 is the cosine similarity calculation.
[0022] Furthermore, the specific process of obtaining the image-text matching loss is as follows;
[0023] Use the image encoding network e4e to translate the original image into the input form of StyleGAN, that is, input the hidden code of each layer of the StyleGAN generator in turn. First, input the original image into the e4e encoding network to generate the original image hidden code of 1×1×512×18 w s , the hidden codes are arranged from small to large according to the level of the input features, and the image generated by the hidden code is consistent with the original image at all levels of features;
[0024] The hidden code is input into the generator G and the generated image is output. The generated image and the target text are input into the CLIP model. The CLIP model inputs the target text and the generated image into two encoders to generate two sets of feature vectors with the same dimension. Since the feature vectors belong to the feature spaces of two different modes, the cosine similarity is used to measure the similarity between the image and the text, that is, the image-text similarity L CLIP As the image-text matching loss.
[0025] Furthermore, the specific process of obtaining the coding distance loss is as follows;
[0026] Since the image features controlled by the hidden code are not completely decoupled, optimizing the hidden code of the generated image based only on the image-text similarity will cause some irrelevant features to be changed. Therefore, the coding distance loss is introduced, and the generated image is input into the e4e coding network to obtain the hidden code of the generated image. w , and the original image hidden code w s Calculate Euclidean distance as encoding distance loss L L2 , using the coding distance loss L L2 The latent code is constrained so that the generated image conforms to the semantic description of the text while the changes in irrelevant features are as small as possible.
[0027] Furthermore, the specific process of obtaining the feature encoding loss is as follows;
[0028] In order to ensure that the features of the generated 3D model are as consistent as possible with the features of the original image, the original image and the generated image are input into the 3DDFA model to obtain the feature map of the original image and the feature map of the generated image. The process of obtaining the feature map is as follows: The image is input into the 3D reconstruction network 3DDFA to obtain the parameters used to fit the 3DDFA face model p , based on the parameters output by 3DDFA p , use 3DMM to construct the three-dimensional shape and calculate the cylindrical coordinates of each point. Parameterize the three-dimensional face data according to the three-dimensional cylindrical coordinates. Take the center of the face as the Z axis, set the center of the face as the coordinate origin, the coordinate axis pointing to the front of the face as the X axis, and the axis perpendicular to the plane formed by the X and Z axes as the Y axis. Convert the three-dimensional rectangular coordinates of the face into cylindrical coordinates according to the following formula:
[0029]
[0030] Where X, Y, and Z are the XYZ axis coordinates of the three-dimensional face in the Cartesian coordinate system. h , r , ϕ is the transformed cylindrical coordinate;
[0031] Sample 64×64 three-dimensional feature anchor points based on the cylindrical coordinates of the face according to a fixed azimuth and height; project the three-dimensional feature anchor points to the image plane to obtain two 64×64 feature anchor points to represent the visible and invisible parts of the 2D image: crop a 3×3 block on each feature anchor point and connect it with the original image to form an extended two-dimensional image;
[0032] The original image feature map and the generated image feature map are input into the ArcFace network, and the cosine similarity between the generated vectors is calculated as the feature encoding loss L ID .
[0033] Furthermore, the parameters in step S3 p Specifically:
[0034]
[0035] in, f represents the scaling factor, R represents the rotation matrix, t 2d represents the translation vector, α id and α exp They represent the shape parameters and expression parameters of the 3DMM model respectively.
[0036] Furthermore, the specific implementation of step S4 is as follows:
[0037] The 3DDFA model selects and expands the 3D face deformation statistical model to perform parameterized modeling of the face shape. The 3D face deformation statistical model is a mathematical statistical model based on the facial laser scanning data set of several experimental subjects. It uses the principal component analysis technology to provide a set of position basis vectors and two sets of feature basis vectors. The face is represented as a linear combination of three sets of basis vectors through the following formula:
[0038]
[0039] in S Represents the Cartesian coordinate system position information of each vertex in the three-dimensional grid. is the average value of the position information of the three-dimensional grids of several experimental objects, A id , A exp They are the shape principal component vector and expression principal component vector obtained by principal component analysis technology, which can be obtained through the public 3DMM database Basel Face Model 2017;
[0040] In 3DDFA, facial feature point marking is regarded as a regression operation from image pixels to feature point positions. That is, the input image enters the 3DDFA network model, and the regression target parameters are calculated based on the weighted parameter distance cost function WPDC and the vertex distance cost function VDC. p , WPDC is calculated as follows:
[0041] in p 0 is the initial parameter, p g is a true value parameter, parameter w Calculated using the following process:
[0042]
[0043] in p de,i To replace the true value parameter with the current estimated parameter i Bit, V ( p ) is the conversion calculation between three-dimensional coordinates and two-dimensional plane coordinates, specifically:
[0044]
[0045] In the initial parameters pUnder the control of , through the projection from three dimensions to the plane, a two-dimensional plane image can be obtained from a three-dimensional model, and then the error with the input image is calculated, and then the correlation coefficient is adjusted by error back propagation, and the three-dimensional model is adjusted, and it is continuously iterated to achieve the fitting of 2D image face to 3D face;
[0046] After training 3DDFA according to the weighted parameter distance cost function, the model is fine-tuned using the vertex distance cost function, which is calculated as follows:
[0047]
[0048] After the image is input into 3DDFA, it passes through the final fully connected layer output parameters p The increment ∆ p ,parameter p Contains 12-dimensional posture parameters f,R , t 2d , 40-dimensional identity parameter α id And 10-dimensional expression parameters α exp ; By adding the parameters to the increment, the 3DMM parameters of the three-dimensional face that conforms to the input image are obtained, and the characteristic parameter α in the parameters is used id and expression parameters α exp Substitute into the formula The three-dimensional face in the image can be represented.
[0049] Compared with the prior art, the present invention has the following advantages: (1) the present invention achieves the goal of regulating the generated three-dimensional face model through text without manually adjusting the features of the three-dimensional face; (2) the present invention only requires the input of a set of image-text pairs for training when editing the three-dimensional face model, and does not rely on additional annotated attribute data. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 This is a main flow chart of a method for generating three-dimensional human faces by text control based on a deep learning algorithm according to the present invention;
[0051] Figure 2 A schematic diagram of the architecture of the combined model in the present invention;
[0052] Figure 3 A schematic diagram of the steps for calculating the image-text matching loss in the training process of the present invention;
[0053] Figure 4 Schematic diagram of the steps for calculating the coding distance loss in the training process of the present invention;
[0054] Figure 5 Schematic diagram of the feature encoding loss calculation steps in the training process of the present invention. DETAILED DESCRIPTION
[0055] In order to more clearly illustrate the embodiments of the present invention, the specific implementation methods of the present invention will be described below with reference to the accompanying drawings. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those of ordinary skill in the art, other accompanying drawings and other implementation methods can be obtained based on these accompanying drawings without creative work.
[0056] Embodiment 1:
[0057] like Figure 1 The method for generating three-dimensional faces controlled by text based on StyleCLIP and 3DDFA includes the following steps:
[0058] S1, build a combined network based on the image editing network StyleCLIP and the 3D reconstruction network 3DDFA;
[0059] like Figure 2 The combined network shown includes a pre-trained image editing network StyleCLIP, a pre-trained 3D reconstruction network 3DDFA and a pre-trained recognition network ArcFace. The pre-trained image editing network StyleCLIP includes a pre-trained image encoding network e4e, a pre-trained image generation network G based on StyleGAN2, and a multi-modal pre-trained network CLIP. The image encoding network e4e and the image generation network G are trained based on the face dataset FFHQ. The image editing network StyleCLIP mainly utilizes the image-text contrast pre-training model Contrastive Language-Image Pre-training (CLIP), combined with StyleGAN2 to edit the latent code through the user input language description, so as to achieve the purpose of editing the image. The CLIP model uses 400 million image-text pairs for training. The model can learn the embedding space of language modality and image modality to estimate the similarity between a given text and an image. 3DDFA uses a regression-based cascade convolutional neural network as the 3D reconstruction module in the model. It can extract useful information from pictures with large posture changes and fit a 3D dense face model instead of a sparse feature point shape to the face picture. By adding 3D information, the appearance change and self-occlusion problems caused by 3D transformation can be solved.
[0060] S2, obtains the original image and target text required for input. The original image is a face image containing a frontal angle, and the target text is a descriptive text of some facial features. In this case, the original image is a fake face randomly generated by StyleGAN, and the target text is a feature description of the eyes "Asian eyes". Based on the text description, the generated 3D face model should show smaller and softer eye features.
[0061] S3, input the original image and target text into the combined network according to the deviation loss L Specifically:
[0062]
[0063] in λ L2 , λ ID is a constant proportional value, L CLIP It is the image-text matching loss, specifically:
[0064]
[0065] in D CLIP is the output of the CLIP model, t To enter the target text, w For the generated image hidden code output by the image encoding network e4e, G (∙) represents the output of the image generation network, L L2 is the coding distance loss, specifically:
[0066]
[0067] in w s is the hidden code of the original image output by the image encoding network e4e, L ID is the feature encoding loss, specifically:
[0068]
[0069] in, R (∙) is the output of ArcFace network, F PAF (∙) is the feature map output of the 3DDFA network, and 〈∙〉 is the cosine similarity calculation.
[0070] According to the deviation loss LTo iterate the hidden code, the specific content is to minimize the difference between the generated image and the original image while maximizing the similarity between the generated image and the target text, and at the same time minimize the changes in the hidden code that are not related to the text features.
[0071] The process of calculating the image-text matching loss is as follows: Figure 3 As shown in the figure, since the generator G is a pre-trained StyleGAN generator, the image cannot be directly input as a noise feature. Therefore, the image encoding network e4e is needed to translate the original image into the input form of StyleGAN, that is, the hidden code of each layer of the StyleGAN generator is input in turn. First, the original image is input into the e4e encoding network to generate a 1×1×512×18 original image hidden code w s The hidden codes are arranged from small to large according to the level of the input features. The hidden codes at smaller levels control the rough information of the image (such as posture, skin color, etc.), and the hidden codes at higher levels control the detailed information of the image (such as wrinkles, makeup, etc.). The image generated by the hidden coding is consistent with the original image at all levels of features.
[0072] The hidden code is input into the generator G and the generated image is output. The generated image and the target text are input into the CLIP model. The CLIP model inputs the target text and the generated image into two encoders to generate two sets of feature vectors with the same dimension. Since the feature vectors belong to the feature spaces of two different modes, the cosine similarity is used to measure the similarity between the image and the text, that is, the image-text similarity L CLIP As the image-text matching loss;
[0073] Since the image features controlled by the latent code are not completely decoupled, optimizing the generated image latent code based only on the image-text similarity will cause some irrelevant features to be changed as well. Therefore, the coding distance loss is introduced, such as Figure 4 As shown, the generated image is input into the e4e encoding network to obtain the hidden code of the generated image w , and the original image hidden code w s Calculate Euclidean distance as encoding distance loss L L2 , using the coding distance loss L L2 The latent code is constrained so that the generated image conforms to the semantic description of the text while the changes in irrelevant features are as small as possible.
[0074] like Figure 5As shown, in order to ensure that the features of the generated 3D model are as consistent as possible with the features of the original image, the original image and the generated image are input into the 3DDFA model to obtain the feature map of the original image and the feature map of the generated image. The process of obtaining the feature map is as follows: the image is input into the 3D reconstruction network 3DDFA to obtain the parameters used to fit the 3DDFA face model p , based on the parameters output by 3DDFA p , use 3DMM to construct the three-dimensional shape and calculate the cylindrical coordinates of each point. Parameterize the three-dimensional face data according to the three-dimensional cylindrical coordinates. Take the center of the face as the Z axis, set the center of the face as the coordinate origin, the coordinate axis pointing to the front of the face as the X axis, and the axis perpendicular to the plane formed by the X and Z axes as the Y axis. Convert the three-dimensional rectangular coordinates of the face into cylindrical coordinates according to the following formula:
[0075]
[0076] Where X, Y, and Z are the XYZ axis coordinates of the three-dimensional face in the Cartesian coordinate system. h , r , ϕ is the transformed cylindrical coordinate;
[0077] Based on the cylindrical coordinates of the face, 64×64 three-dimensional feature anchor points are sampled at fixed azimuth and altitude. The three-dimensional feature anchor points are projected onto the image plane to obtain two 64×64 feature anchor points to represent the visible and invisible parts of the 2D image. A 3×3 block is cropped on each feature anchor point and connected to the original image to form an extended two-dimensional graph.
[0078] The original image feature map and the generated image feature map are input into the ArcFace network, and the cosine similarity between the generated vectors is calculated as the feature encoding loss L ID .
[0079] After 150-200 rounds of iterative training, the training is terminated and the parameters output by the 3DDFA model are used. p Perform three-dimensional reconstruction.
[0080] S4, using trained parameters p Perform 3D reconstruction of the face, parameters p Specifically:
[0081]
[0082] in, f represents the scaling factor, R represents the rotation matrix, t 2d represents the translation vector, α id and αexp They represent the shape parameters and expression parameters of the 3DMM model respectively.
[0083] The 3DDFA model chooses to extend the 3D face morphing statistical model (3DMM) to perform parametric modeling of the face shape. The 3D face morphing statistical model is a mathematical statistical model based on the facial laser scanning data set of 200 experimental subjects. It uses the principal component analysis technology (PCA) to provide a set of position basis vectors and two sets of feature basis vectors. The face is represented as a linear combination of three sets of basis vectors through the following formula:
[0084]
[0085] in S Represents the Cartesian coordinate system position information of each vertex in the three-dimensional grid. is the average value of the position information of the three-dimensional grids of several experimental objects, A id , A exp They are the shape principal component vector and expression principal component vector obtained by principal component analysis technology, which can be obtained through the public 3DMM database Basel Face Model 2017;
[0086] New parameters are obtained through 2D image feature points and corresponding 3D vertex indexes to achieve reconstruction of 2D images to 3D faces. In 3DDFA, facial feature point marking is regarded as a regression operation from image pixels to feature point positions, that is, the input image enters the 3DDFA network model, and the regression target parameters are calculated based on the weighted parameter distance cost function (WPDC) and the vertex distance cost function (VDC). p , WPDC is calculated as follows:
[0087] in p 0 is the initial parameter, p g is a true value parameter, parameter w Calculated using the following process:
[0088]
[0089] in p de,i To replace the true value parameter with the current estimated parameter i Bit, V ( p ) is the conversion calculation between three-dimensional coordinates and two-dimensional plane coordinates, specifically:
[0090]
[0091] In the initial parameters p Under the control of , a 2D plane image can be obtained from a 3D model through projection from 3D to plane, and then the error with the input image is calculated, and the correlation coefficient is adjusted by error back propagation, the 3D model is adjusted, and iteration is performed continuously to achieve the fitting of 2D image face to 3D face.
[0092] After training 3DDFA according to the weighted parameter distance cost function, the model is fine-tuned using the vertex distance cost function, which is calculated as follows:
[0093]
[0094] After the image is input into 3DDFA, it passes through the final fully connected layer output parameters p The increment ∆ p ,parameter p Contains 12-dimensional posture parameters f,R , t 2d , 40-dimensional identity parameter α id And 10-dimensional expression parameters α exp ; By adding the parameters to the increment, the 3DMM parameters of the three-dimensional face that conforms to the input image are obtained, and the characteristic parameter α in the parameters is used id and expression parameters α exp Substitute into the formula The three-dimensional face in the image can be represented.
[0095] The present invention can regulate the effect of the generated three-dimensional face model through text without manually adjusting the feature anchor points of the three-dimensional face; thanks to the training method of StyleCLIP model comparative learning, the training method used in the present invention does not need to introduce additional annotation attributes to realize the editing of the three-dimensional model.
[0096] The above description is only a detailed description of the preferred embodiments and principles of the present invention. For ordinary technicians in this field, according to the ideas provided by the present invention, there will be changes in the specific implementation methods, and these changes should also be regarded as the protection scope of the present invention.
Claims
1. A method for generating a text-controlled three-dimensional face model based on StyleCLIP and 3DDFA, characterized in that: The following steps are involved: Step S1, building a combined network based on the image editing network StyleCLIP and the three-dimensional reconstruction network 3DDFA; Step S2, obtaining the original image and target text required for input; Step S3, inputting the original image and the target text into the combined network, performing iterative training according to the deviation loss L, and obtaining the parameter p used in the three-dimensional reconstruction network 3DDFA; Step S4, using the trained parameter p to perform three-dimensional reconstruction of the face using the three-dimensional reconstruction network 3DDFA; The specific implementation of step S4 is as follows: The 3DDFA model selects and expands the 3D face deformation statistical model to perform parameterized modeling of the face shape. The 3D face deformation statistical model is a mathematical statistical model based on the facial laser scanning data set of several experimental subjects. It uses the principal component analysis technology to provide a set of position basis vectors and two sets of feature basis vectors. The face is represented as a linear combination of three sets of basis vectors through the following formula: Where S represents the Cartesian coordinate system position information of each vertex in the three-dimensional grid. is the average value of the position information of the three-dimensional grids of several experimental objects, A id , A exp They are the shape principal component vector and expression principal component vector obtained by principal component analysis technology, which can be obtained through the public 3DMM database Basel Face Model 2017; In 3DDFA, facial feature point marking is regarded as a regression operation from image pixels to feature point positions. That is, the input image enters the 3DDFA network model, and the regression target parameter p is calculated based on the weighted parameter distance cost function WPDC and the vertex distance cost function VDC. The WPDC calculation method is as follows: E WPDC =(Δp-(p g -p 0 )) T diag(w)(Δp-(p g -p 0 )) where p 0 is the initial parameter, p g is a true value parameter, and the parameter w is calculated by the following process: in=(in1,in2,…in i ,…In p ) where p de,i To replace the true value parameter to the i-th position of the current estimated parameter, V(p) is the conversion calculation between three-dimensional coordinates and two-dimensional plane coordinates, specifically: V(p)=f*Pr*R*S+t 2d Under the control of the initial parameter p, a 2D plane image can be obtained from a 3D model through projection from 3D to plane, and then the error with the input image is calculated, and the correlation coefficient is adjusted by error back propagation, and the 3D model is adjusted, and it is continuously iterated to achieve the fitting of 2D image face to 3D face; After training 3DDFA according to the weighted parameter distance cost function, the model is fine-tuned using the vertex distance cost function, which is calculated as follows: E vdc =||V(p+Δp)-V(p g )|| 2 After the image is input into 3DDFA, it passes through the final fully connected layer to output the increment Δp of parameter p, which contains 12-dimensional posture parameters f, R, t 2d , the shape parameter α of 40 dimensions id and the 10-dimensional expression parameter α exp , where f represents the scaling factor, R represents the rotation matrix, and t 2d Represents the translation vector; by adding the parameters to the increment, the 3DMM parameters of the three-dimensional face that conforms to the input image are obtained, and the shape parameter α in the parameters is used id and expression parameter α exp Substitute into the formula The three-dimensional face in the image can be represented.
2. The method for generating a text-controlled 3D face model based on a deep learning algorithm according to claim 1, characterized in that: The combined network in step S1 includes a pre-trained image encoding network e4e, a pre-trained image generation network G based on StyleGAN2, a multimodal pre-trained network CLIP, a pre-trained three-dimensional reconstruction network 3DDFA and a pre-trained recognition network ArcFace.
3. The method for generating a text-controlled 3D face model based on a deep learning algorithm according to claim 2, characterized in that: The image encoding network e4e and the image generation network G are both trained based on the face dataset FFHQ.
4. The method for generating a text-controlled 3D face model based on a deep learning algorithm according to claim 2, characterized in that: The deviation loss L in step S3 is specifically: L=L CLIP +λ L2 L L2 +λ ID L ID where λ L2 , ID is a constant proportional value, L CLIP It is the image-text matching loss, specifically: L CLIP =1-D CLIP (G(w),t) Where D CLIP is the output of the CLIP model, t is the input target text, w is the generated image hidden code output by the image encoding network e4e, G(·) represents the output of the image generation network, L L2 is the coding distance loss, specifically: L L2 =||w-w s ||2 where w s is the hidden code of the original image output by the image encoding network e4e, L ID is the feature encoding loss, specifically: L ID =1-<R(F PAF (G(w))),R(F PAF (G(w s )))> Among them, R(·) is the output of ArcFace network, F PAF (·) is the feature graph output of the 3DDFA network, and <·> is the cosine similarity calculation.
5. The method for generating a text-controlled 3D face model based on a deep learning algorithm according to claim 4, characterized in that: The specific process of obtaining the image-text matching loss is as follows: Use the image encoding network e4e to translate the original image into the input form of StyleGAN, that is, input the hidden code of each layer of the StyleGAN generator in turn. First, input the original image into the e4e encoding network to generate the original image hidden code w of 1×1×512×18 s , the hidden codes are arranged from small to large according to the level of the input features, and the image generated by the hidden code is consistent with the original image at all levels of features; The latent code is input into the generator G and the generated image is output. The generated image and the target text are input into the CLIP model. The CLIP model inputs the target text and the generated image into two encoders to generate two sets of feature vectors with the same dimension. Since the feature vectors belong to the feature spaces of two different modes, the cosine similarity is used to measure the similarity between the image and the text, that is, the image-text similarity L CLIP As the image-text matching loss.
6. The method for generating a text-controlled 3D face model based on a deep learning algorithm according to claim 4, characterized in that: The specific process of obtaining the coding distance loss is as follows; Since the image features controlled by the hidden code are not completely decoupled, optimizing the generated image hidden code based only on the image-text similarity will cause some irrelevant features to be changed. Therefore, the coding distance loss is introduced. The generated image is input into the e4e coding network to obtain the generated image hidden code w, which is compared with the original image hidden code w. s Calculate the Euclidean distance as the encoding distance loss L L2 , using the encoding distance loss L L2 The latent code is constrained so that the generated image conforms to the semantic description of the text while the changes in irrelevant features are as small as possible.
7. The method for generating a text-controlled 3D face model based on a deep learning algorithm according to claim 4, characterized in that: Feature Encoding The specific process of obtaining the loss is as follows; In order to ensure that the features of the generated three-dimensional model are as consistent as possible with the features of the original image, the original image and the generated image are input into the 3DDFA model to obtain the feature map of the original image and the feature map of the generated image. The process of obtaining the feature map is as follows: the image is input into the three-dimensional reconstruction network 3DDFA to obtain the parameter p used to fit the 3DDFA face model. Based on the parameter p output by 3DDFA, 3DMM is used to construct the three-dimensional shape and the cylindrical coordinates of each point are calculated. The three-dimensional data of the face is parameterized according to the three-dimensional cylindrical coordinates. The center of the face is regarded as the Z axis, the center of the face is set as the coordinate origin, the coordinate axis pointing to the front of the face is taken as the X axis, and the axis perpendicular to the plane formed by the X and Z axes is taken as the Y axis. The three-dimensional rectangular coordinates of the face are converted into cylindrical coordinates according to the following formula: Where X, Y, and Z are the XYZ axis coordinates of the three-dimensional face in the Cartesian coordinate system, and h, r, and φ are the transformed cylindrical coordinates; Based on the cylindrical coordinates of the face, sample 64×64 three-dimensional feature anchor points according to fixed azimuth and height; The 3D feature anchor points are projected onto the image plane, thereby obtaining two 64×64 feature anchor points to represent the visible and invisible parts of the 2D image; a 3×3 block is cropped on each feature anchor point and connected to the original image to form an extended 2D graph; The original image feature map and the generated image feature map are input into the ArcFace network, and the cosine similarity between the generated vectors is calculated as the feature encoding loss L ID .
8. The method for generating a text-controlled 3D face model based on a deep learning algorithm according to claim 1, characterized in that: The parameter p in step S3 is specifically: p=[f, R, t 2d ,a id ,a exp ] Where f represents the scaling factor, R represents the rotation matrix, and t 2d represents the translation vector, α id and α exp They represent the shape parameters and expression parameters of the 3DMM model respectively.
