Face texture generation method and device, electronic equipment and storage medium
Through vertex visibility detection, spatial mapping and reconstruction, combined with the style transfer model, the problem of low efficiency in face texture generation is solved, high-fidelity face texture is generated, and the generation efficiency and accuracy are improved.
Patent Information
- Application Number
- CN202311544075.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-20
- Publication Date
- 2024-10-18
AI Technical Summary
The existing technology is inefficient when generating face textures, and the accuracy of the generated face textures is low. It is limited by differences in face models and data spaces, resulting in high resource consumption.
By obtaining the face image to be processed, perform vertex visibility detection, spatial mapping and reconstruction to obtain the visibility mask image, style image and content image, and perform style migration through the style transfer model, using the visibility mask image to supplement the face Visible texture,generates high-fidelity face texture images.
The efficiency of face texture generation is improved. The generated face texture is closer to the real face. There is no need for a large number of real and complete face texture images or face images in the image space to train the neural network, which reduces resource consumption.
Smart Images

Figure CN118799472A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a method, device, electronic device and storage medium for generating facial texture. Background Art
[0002] Face texture reconstruction technology based on a single image. The input of this technology is a single face image (both frontal and side face), and the output is a complete face texture coordinate image (also called UV image). Among them, it can be divided into supervised methods and unsupervised methods. Supervised methods usually use a large number of high-quality complete high-quality face UV images to train the Generative Adversarial Network (GAN), so that the generator of GAN can complete the corresponding task. Unsupervised methods usually use data in the prior model to reduce the dependence on real complete face texture data. However, the above supervised and unsupervised methods require a large number of real complete face texture images or face images in image space to train the neural network, and the reconstructed face texture is limited by the face model, which will be very rough or limited by the data space and the real input image. There may be differences in image details, image structure and identity information, resulting in large resources consumed in face texture generation and low accuracy of the generated face texture, which in turn leads to low efficiency in the current face texture generation. Summary of the invention
[0003] The embodiments of the present application provide a facial texture generation method, device, electronic device and storage medium to solve the problem of low efficiency in the current facial texture generation.
[0004] In a first aspect, an embodiment of the present application provides a method for generating facial texture, comprising:
[0005] Obtain the face image to be processed;
[0006] Performing face vertex visibility detection based on the face image to be processed to obtain a visibility mask image;
[0007] Performing spatial mapping of facial texture based on the facial image to be processed to obtain a style image;
[0008] Performing face reconstruction based on the face image to be processed to obtain a content image;
[0009] Style migration is performed based on the visibility mask image, the style image and the content image to obtain a facial texture image; the visibility mask image is used to supplement the visible texture of the face in the migration image based on the style image and the content image.
[0010] In one embodiment, performing style migration based on the visibility mask image, the style image and the content image to obtain a face texture image includes:
[0011] The visibility mask image, the style image and the content image are input into a style transfer model to obtain a target face texture image output by the style transfer model; the total loss function of the style transfer model includes a content loss function, a style loss function and a reconstruction loss function; the reconstruction loss function is used to supplement the visible texture of the face in a transfer image based on the style image and the content image based on the visibility mask image.
[0012] In one embodiment, the style transfer model is determined by the following steps:
[0013] Get a sample face image;
[0014] Extracting features from the sample face image to obtain feature information;
[0015] The loss function of the initial style transfer model is improved to obtain an improved style transfer model; wherein the initial style transfer model includes a content loss function and a style loss function; the improved style transfer model includes a content loss function, a style loss function and a reconstruction loss function;
[0016] Based on the feature information, the improved style transfer model is trained to obtain a trained style transfer model.
[0017] In one embodiment, performing face vertex visibility detection based on the face image to be processed to obtain a visibility mask image includes:
[0018] Mapping the facial texture of the facial image to be processed from the image space to the texture space to obtain a three-dimensional facial image;
[0019] Performing face vertex visibility detection on the three-dimensional face image to obtain a visibility detection result;
[0020] A visibility mask image is generated based on the visibility detection result and the three-dimensional face image.
[0021] In one embodiment, generating a visibility mask image based on the visibility detection result and the three-dimensional face image includes:
[0022] Adjusting the texture value of the three-dimensional face image based on the visibility detection result to obtain a texture value adjusted image;
[0023] A morphological opening and closing operation is performed on the texture value adjusted image to obtain a visibility mask image.
[0024] In one embodiment, performing spatial mapping of facial texture based on the face image to be processed to obtain a style image includes:
[0025] Acquire facial geometry information of the facial image to be processed;
[0026] Determine a first mapping between each vertex in the face geometry information and the image space;
[0027] Determining a second mapping between each vertex in the face geometry information and a texture space;
[0028] Determining a target mapping from image space to texture space based on the first mapping and the second mapping;
[0029] Based on the target mapping, the face image to be processed is mapped from the image space to the texture space to obtain a style image.
[0030] In one embodiment, the step of performing face reconstruction based on the face image to be processed to obtain a content image includes:
[0031] Determining the average facial texture in the face image to be processed;
[0032] Determining adjustment parameters of the average facial texture;
[0033] Adjusting the average facial texture based on the adjustment parameter to obtain an adjusted texture;
[0034] The adjusted texture is projected from the image space to the texture space to obtain a content image.
[0035] In a second aspect, an embodiment of the present application provides a facial texture generating device, comprising:
[0036] An acquisition module, used for acquiring a face image to be processed;
[0037] A detection module, used for performing face vertex visibility detection based on the face image to be processed to obtain a visibility mask image;
[0038] A mapping module, used for performing spatial mapping of facial texture based on the facial image to be processed to obtain a style image;
[0039] A reconstruction module, used for performing face reconstruction based on the face image to be processed to obtain a content image;
[0040] A migration module is used to perform style migration based on the visibility mask image, the style image and the content image to obtain a facial texture image; the visibility mask image is used to supplement the visible texture of the face in the migration image based on the style image and the content image.
[0041] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory storing a computer program, wherein when the processor executes the program, the method for generating facial texture described in the first aspect is implemented.
[0042] In a fourth aspect, an embodiment of the present application provides a storage medium, which is a computer-readable storage medium and includes a computer program. When the computer program is executed by a processor, the method for generating facial texture described in the first aspect is implemented.
[0043] The facial texture generation method, device, electronic device and storage medium provided in the embodiments of the present application can respectively obtain corresponding visibility mask images, style images and content images by performing face vertex visibility detection, spatial mapping of facial texture and face reconstruction based on the face image to be processed. The style of the content image can be transferred through the style image, and the visible texture of the face can be supplemented in the transferred image through the visibility mask image, so that the facial texture image obtained by style transfer is closer to the real face. A high-fidelity facial texture image can be obtained without a large number of real and complete facial texture images or facial images in image space to train the neural network, thereby improving the efficiency of facial texture generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the present application or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0045] Figure 1 It is a flowchart of a method for generating facial texture provided in an embodiment of the present application;
[0046] Figure 2 It is a scene schematic diagram of the face texture generation method provided in the embodiment of the present application;
[0047] Figure 3 This is a functional module diagram of an embodiment of the face texture generating device of the present applicant;
[0048] Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0050] Below is a combination of the embodiments and Figure 1-Figure 4 The facial texture generation method, device, electronic device and storage medium provided by the present invention are described in detail.
[0051] in, Figure 1 A schematic diagram of a process for generating facial texture according to an embodiment of the present application; Figure 2 A schematic diagram of a scene of a facial texture generation method provided in an embodiment of the present application.
[0052] Specifically, refer to Figure 1 and Figure 2 , the embodiment of the present application provides a method for generating facial texture, which may include:
[0053] Step 100, obtaining a face image to be processed;
[0054] It should be noted that the execution subject of the device identification method provided in the embodiment of the present application may be a server, a computer device, etc., such as a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a personal digital assistant (PDA), etc. The server or computer device of the present application may be provided with or connected to a face texture generation device, and the face texture generation method of the present application may be completed by controlling the face texture generation device.
[0055] The face image to be processed in the present application may be an image acquired by an image acquisition device, which may include but is not limited to a surveillance camera, a still camera, and the like.
[0056] In the present application, a camera can be used to photograph a designated area and collect facial images.
[0057] Furthermore, the camera can send the collected facial image to the facial texture generating device.
[0058] Therefore, the facial texture generating device can receive the facial image sent by the camera and use it as the facial image to be processed, so as to facilitate facial texture generation based on the received facial image to be processed.
[0059] Step 200, performing face vertex visibility detection based on the face image to be processed to obtain a visibility mask image;
[0060] The present application can first obtain the facial texture in the face image to be processed, and map the obtained facial texture from the image space to the texture space, thereby obtaining a three-dimensional face image.
[0061] Furthermore, due to the self-occlusion phenomenon of the human face, the visibility of each vertex of the three-dimensional face in the three-dimensional face image can be calculated, the texture value of each vertex can be adjusted according to the visibility calculation result, and each vertex can be projected into the texture space, and the visibility mask image can be obtained after performing morphological operations.
[0062] Step 300, performing spatial mapping of facial texture based on the face image to be processed to obtain a style image;
[0063] The present application can also obtain facial geometry information of the facial image to be processed, and then respectively determine the mapping between each vertex in the facial geometry information and the image space and the mapping between each vertex in the facial geometry information and the texture space.
[0064] Further, the target mapping from the image space to the texture space may be determined according to the mapping between each vertex and the image space and the mapping between each vertex and the texture space.
[0065] Furthermore, the face image to be processed can be mapped from the image space to the texture space through target mapping to obtain a style image.
[0066] Step 400, performing face reconstruction based on the face image to be processed to obtain a content image;
[0067] The present application can also reconstruct the face of the face image to be processed through a three-dimensional face reconstruction algorithm to obtain an accurate three-dimensional face geometry model and a complete but rough face texture map.
[0068] Furthermore, the rough texture in the face texture map is projected from the image space to the texture space to obtain the content image.
[0069] Step 500, performing style transfer based on the visibility mask image, the style image and the content image to obtain a face texture image.
[0070] After obtaining the visibility mask image, the style image and the content image, the high-quality facial texture information in the style image can be transferred to the content image as much as possible while ensuring the structure of the content image. It should be noted that in this application, when performing style transfer, the visible texture of the face can be supplemented by the visibility mask image to the transfer image based on the style image and the content image, and the texture of the visible part of the face can be constrained at the pixel level, and finally the facial texture image is obtained after completing the style transfer.
[0071] In one embodiment, the present application can perform multiple texture migrations based on the style image, the content image, and the visibility mask image, and obtain a final face texture image after completing multiple texture migrations.
[0072] The facial texture generation method provided in the embodiment of the present application can obtain corresponding visibility mask images, style images and content images respectively by performing vertex visibility detection, spatial mapping of facial texture and facial reconstruction based on the face image to be processed. The style of the content image can be transferred through the style image, and the visible texture of the face can be supplemented in the transferred image through the visibility mask image, so that the facial texture image obtained by style transfer is closer to the real face. A high-fidelity facial texture image can be obtained without the need for a large number of real and complete facial texture images or facial images in image space to train the neural network, thereby improving the efficiency of facial texture generation.
[0073] In one embodiment, performing face vertex visibility detection based on the face image to be processed to obtain a visibility mask image includes:
[0074] Step 201, mapping the face texture of the face image to be processed from the image space to the texture space to obtain a three-dimensional face image;
[0075] Step 202, performing face vertex visibility detection on the three-dimensional face image to obtain a visibility detection result;
[0076] Step 203: Generate a visibility mask image based on the visibility detection result and the three-dimensional face image.
[0077] In the present application, a face detection algorithm can be used to locate the face area in the face image to be processed. The face detection algorithm can be a cascade classifier based on Haar features, a convolutional neural network based on deep learning, etc.
[0078] After detecting a face, a key point detection algorithm can be used to determine specific key points on the face, such as the location of the eyes, nose, mouth, etc. The detection of these key points can help with subsequent texture mapping and transformation.
[0079] After the face is detected and the key points are located, the information can be used to map the face texture in the face image to be processed from the image space to the texture space to obtain a three-dimensional face image.
[0080] Furthermore, the depth buffer (Z_buffer) algorithm is used to calculate the visibility of each vertex of the three-dimensional face in the three-dimensional face image, thereby obtaining the visibility detection result. The Z_buffer algorithm first calculates the coordinates of each vertex of the three-dimensional figure projected onto the target image. For all vertices projected to the same coordinate, the point closest to the target image is taken as the visible point, and the other points are invisible.
[0081] Furthermore, each vertex in the three-dimensional face image can be projected into the texture space according to the visibility detection result, and a visibility mask image can be obtained after a morphological opening and closing operation.
[0082] Furthermore, based on the visibility detection result and the three-dimensional face image, a visibility mask image is generated, including:
[0083] Step 2031, adjusting the texture value of the 3D face image based on the visibility detection result to obtain a texture value adjusted image;
[0084] Step 2032: Perform morphological opening and closing operations on the texture value adjusted image to obtain a visibility mask image.
[0085] After obtaining the visibility detection result, the texture value of the visible vertices in the 3D face image can be set to 255, and the texture value of the invisible vertices can be set to 0, and then each vertex is projected into the UV space (ie, the texture space) to obtain a texture value adjusted image.
[0086] It should be noted that the mask obtained by the Z_buffer algorithm is sparse, that is, the obtained mask may have many tiny holes and the edges are not smooth enough.
[0087] Therefore, the present application can use morphological opening and closing operations to eliminate these small holes while smoothing the edges.
[0088] Specifically, the present application can first perform a morphological opening operation on the texture value adjustment image, and then perform a morphological closing operation. Among them, the morphological opening operation is a process of first performing erosion and then dilation, and the morphological closing operation is a process of first dilation and then erosion. The erosion operation can eliminate small holes in the mask and shrink the mask as a whole. Performing an erosion operation on the texture value in the UV space can remove small holes. The dilation operation can fill the holes in the mask and expand the mask as a whole. Performing a dilation operation on the texture value in the UV space can make the edges smoother.
[0089] After completing the morphological opening and closing operations, the visibility mask image can be obtained.
[0090] This embodiment maps the facial texture of the input facial photo from the image space to the texture space, and calculates the visibility of each vertex of the three-dimensional face to obtain a visibility mask of the face, wherein morphological opening and closing operations are performed to eliminate small holes in the mask and smooth the edges, so as to accurately supplement the visible texture of the face of the migration image through the visibility mask image, so that the facial texture image obtained through style transfer is closer to the real face, and a high-fidelity facial texture image can be obtained without a large number of real and complete facial texture images or facial images in the image space to train the neural network, thereby improving the efficiency of facial texture generation.
[0091] Furthermore, a spatial mapping of the facial texture is performed based on the face image to be processed to obtain a style image, including:
[0092] Step 301, obtaining face geometry information of the face image to be processed;
[0093] Step 302, determining a first mapping between each vertex in the face geometry information and the image space;
[0094] Step 303, determining a second mapping between each vertex in the face geometry information and the texture space;
[0095] Step 304, determining a target mapping from the image space to the texture space based on the first mapping and the second mapping;
[0096] Step 305 , based on the target mapping, the face image to be processed is mapped from the image space to the texture space to obtain a style image.
[0097] In this application, Deep3DFace can be used to obtain the facial geometry information of the face image to be processed.
[0098] Deep3DFace is an unsupervised 3D face reconstruction method, which mainly relies on a priori linear parameterized face model, the Basel Face Model (BFM). Deep3DFace uses a neural network to regress the BFM parameters (including texture and shape) of the input image, and can reconstruct accurate 3D face shape and rough 3D face texture through BFM based on the regressed parameters.
[0099] It can be understood that through Deep3DFace, the pixel coordinates corresponding to each vertex of the face geometry in the original image can also be obtained, thereby establishing a mapping g1 from the three-dimensional space to the image space.
[0100] In addition, the mapping g2 between each vertex of the face geometry and the texture space can be obtained through BFM. BFM is a classic three-dimensional deformation model that describes the average shape and texture information of the face and provides a corresponding statistical model. This model is obtained by statistical analysis of a large amount of face data and can describe the range of changes in the shape and texture of the face. The BFM model is usually used in the fields of face reconstruction, face animation, virtual makeup, etc. By adjusting its parameters, faces of different shapes and textures can be generated.
[0101] Furthermore, the three-dimensional face geometry can be used as a bridge to obtain the mapping g from the image space to the UV space through mapping g1 and mapping g2. The mapping g makes each point of the face part in the input image correspond to the point in the texture space one by one. By using triangulation, the input image and texture space can be divided into many small triangular patches, and each triangular patch in the triangular patch set of the input image and texture space also corresponds one to one. Finally, through affine transformation, the face parts in the image space can be projected one by one to the texture space to obtain the face texture image as the style image.
[0102] In the above process, mapping g1 does not take into account the self-occlusion of the face in the input image. For example, the right face part of the input image is not visible due to self-occlusion, but mapping g1 will still find a part of pixels in the input image. The projection of these pixels into the texture space will cause distortion and distortion. These distorted parts can be eliminated by using the visibility mask M in the subsequent process of this application, and finally a texture map of the visible part of the face containing rich details is obtained.
[0103] This embodiment can obtain a corresponding style image by performing spatial mapping of facial texture based on the face image to be processed, and then perform style transfer on the content image through the style image, and supplement the migration image with the visible texture of the face through the visibility mask image, so that the facial texture image obtained by style transfer is closer to the real face, and a high-fidelity facial texture image can be obtained without a large number of real and complete facial texture images or facial images in image space to train the neural network, thereby improving the efficiency of facial texture generation.
[0104] In one embodiment, face reconstruction is performed based on the face image to be processed to obtain a content image, including:
[0105] Step 401, determining the average face texture in the face image to be processed;
[0106] Step 402, determining adjustment parameters of average facial texture;
[0107] Step 403, adjusting the average face texture based on the adjustment parameter to obtain an adjusted texture;
[0108] Step 404: Project the adjusted texture from the image space to the texture space to obtain a content image.
[0109] This application can use the 3D face reconstruction algorithm Deep3DFace to obtain accurate 3D face geometry and complete but rough face texture maps.
[0110] Specifically, Deep3DFace can be used to obtain the average face shape and the average face texture through BFM, and then a neural network can be used to obtain parameters for adjusting the average face shape and the average face texture. The average face shape and the average face texture are adjusted according to these adjustment parameters, so as to obtain a unique face geometry and face texture corresponding to the input face as an adjusted texture.
[0111] Furthermore, since the rough texture obtained by Deep3DFace is in the image space, and the data required by this application is in the texture space, it is necessary to project the rough adjusted texture from the image space to the texture space to obtain the content image.
[0112] More specifically, in this application, the vertex set of face geometry can be defined as V, and the set of face texture color can be defined as T. Each element v in V i (i=1,2,…,n, n is the number of geometric vertices of the face) is the coordinate (x i ,y i ,z i ), each vertex corresponds to a texture color value t i , so there is a one-to-one mapping relationship f1 between set V and set T. BFM provides the coordinates of each vertex of the face in the texture space, and defines the coordinate set as U. There is a mapping relationship f2 between set V and set U. Combining the mapping relationships f1 and f2, the mapping relationship f from set T to set U can be obtained, that is, the coordinates of the color values of each vertex of the face in the image space in the texture space are obtained, thereby obtaining a complete texture map. This application defines this image as the content image C in the texture migration stage.
[0113] This embodiment can obtain a corresponding content image by performing face reconstruction based on the face image to be processed, and then perform style transfer on the content image through the style image, and supplement the visible texture of the face in the transferred image through the visibility mask image, so that the face texture image obtained by style transfer is closer to the real face, and a high-fidelity face texture image can be obtained without a large number of real and complete face texture images or face images in image space to train the neural network, thereby improving the efficiency of face texture generation.
[0114] In one embodiment, the present application may determine the style transfer model in advance through the following steps:
[0115] Step 1, obtaining a sample face image;
[0116] Step 2, extracting features from the sample face image to obtain feature information;
[0117] Step 3, improving the loss function of the initial style transfer model to obtain an improved style transfer model; wherein the initial style transfer model includes a content loss function and a style loss function; the improved style transfer model includes a content loss function, a style loss function and a reconstruction loss function;
[0118] Step 4: Based on the feature information, the improved style transfer model is trained to obtain the trained style transfer model.
[0119] In this application, a certain number of face images can be obtained as sample face images.
[0120] Furthermore, a convolutional neural network may be used to extract features from the sample face images to obtain feature information in each sample face image.
[0121] Furthermore, an initial style transfer model can be obtained. In the present application, the STROTSS style transfer model can be specifically obtained as the initial style transfer model. It should be noted that the style transfer algorithm in the STROTSS style transfer model is the same as other style transfer algorithms, and the total loss function includes content loss and style loss. Since the STROTSS style transfer model is a basic style transfer model, this application does not describe it in detail.
[0122] It should be noted that there is no pixel-level loss function in the loss function of the initial style transfer model. However, in the face generation / repair task, a very important part is to ensure that the generated image is as consistent as possible with the original image in the visible part of the face. Therefore, this application improves on the content loss and style loss of STROTSS and adds pixel-level reconstruction loss, so that the improved style transfer model of this application includes content loss function, style loss function and reconstruction loss function.
[0123] Furthermore, the present application can perform unsupervised training on the improved style transfer model based on feature information to obtain a trained style transfer model.
[0124] Furthermore, style transfer is performed based on the visibility mask image, the style image and the content image to obtain a face texture image, including:
[0125] Step 501, input the visibility mask image, the style image and the content image into the style transfer model to obtain the target face texture image output by the style transfer model; the total loss function of the style transfer model includes the content loss function, the style loss function and the reconstruction loss function; the reconstruction loss function is used to supplement the visible texture of the face in the transfer image based on the style image and the content image based on the visibility mask image.
[0126] Therefore, after obtaining the trained style transfer model, the present application can input the visibility mask image, style image and content image into the style transfer model, and the style transfer model performs style transfer through the visibility mask image, style image and content image, and obtains the target face texture image output by the style transfer model after the transfer is completed.
[0127] It should be noted that before texture migration, the resolutions of the three images need to be unified, for example, in one embodiment, the resolutions can be unified to 512×512.
[0128] In the texture migration stage, this application uses VGG16 to extract the features of the content image C and the style image S, and then transfers the rich facial details of S to C through the style migration model to obtain the output image X (0) In order to make the final generated image as good as possible, this application will use the output image as the new content image and perform multiple texture migrations. (i) is the output of the i-th texture migration, and the output of the i-1-th texture migration will be used as the content image of the i-th texture migration. In all texture migration processes, the style image and the visible mask of the face are the same. Usually, good results can be obtained after 5 texture migrations.
[0129] In one embodiment, the present application performs a total of 5 texture migrations, and the output of each migration is X (i) , where X (5) is the final output result. Before starting texture migration, this application takes the Laplacian pyramid of the content image C as the parameter to be optimized. During each texture migration process, this method optimizes at three scales of 128×128, 256×256, and 512×512 in turn. When optimizing at the 128×128 scale, the style image S, content image C, and face visibility mask M are all downsampled to 128×128 to calculate the loss. In particular, L contentThe hyperparameter α decreases dynamically as the scale increases. This method uses a stochastic gradient descent optimizer for optimization with a learning rate of 0.3 and a momentum of 0.9. Each scale performs 150 iterations to update the parameters. After the optimization of the 128×128 scale is completed, the optimized parameters are upsampled to 256×256 as part of the initial value of the next scale optimization. The texture migration process is exactly the same for each scale. In order to reduce information loss during downsampling and upsampling, this application uses bilinear interpolation for sampling.
[0130] The migration algorithm of this application is based on STROTSS, and the feature extraction method used is the same as STROTSS: using hypercolumns captured from the 10 sublayers of VGG16 trained on ImageNet. After the input image passes through the convolutional neural network, a series of feature maps can be obtained. Each feature map represents an extracted feature. The shallow feature maps focus more on pixel-level features, and the deep feature maps focus more on structural features. Using hypercolumns to represent the features of style images and content images can simultaneously include low-level edge and color features, mid-level texture features, and high-level semantic features. The ImageNet project is a large visualization database used for research on visual object recognition software.
[0131] Among them, VGG (Visual Geometry Group) is a deep convolutional neural network architecture proposed by a visual geometry group in 2014. The VGG network uses continuous small convolution kernels (3x3) and pooling layers to build a deep neural network, and the network depth can reach 16 layers, namely VGG16.
[0132] The total loss function of the trained style transfer model in the present application includes a content loss function, a style loss function and a reconstruction loss function, wherein the reconstruction loss function is used to supplement the visible texture of the face in the transfer image based on the style image and the content image based on the visibility mask image.
[0133] The reconstruction loss function in this application may be an L1 loss function, and in some cases a perceptual loss function, an L2 loss function, etc. may also be used.
[0134] The total loss function can be specifically:
[0135] L total =αL content +L style +γL reconstruction ;
[0136] Among them, α and γ are hyperparameters, which can be set according to actual needs; L content is the content loss function; L style is the style loss function; γL reconstructionis the reconstruction loss function.
[0137] It should be noted that, inspired by self-similarity, STROTSS uses L content It is defined as the absolute error between the normalized cosine distances of pairwise feature vectors extracted from the content image and the output image, respectively:
[0138]
[0139] Where X is the output image in each texture migration process, D X is the cosine distance matrix of the pairwise feature vectors of the output image X, D C The definition is similar to that of , where n is the number of rows and columns of the feature matrix. X and D C , with D C For example: This application defines the features of the content image extracted by the network in the form of hypercolumns. If n pixels are selected, there will be n hypercolumns. Arranging the n hypercolumns in rows will give an n×m feature matrix, where m is the length of the hypercolumn. For this feature matrix, this application calculates the cosine distance between it and its transposed matrix, and then normalizes the result to obtain the matrix D C This loss function mainly ensures that the output image and the content image are similar in spatial structure without directly restricting the pixels, because D C The geometric meaning of is the cosine distance between all hypercolumns of the input image, and the cosine distance represents the spatial difference ignoring the size, i is the i-th row of the image, and j is the j-th column of the image.
[0140] As follows, L style It consists of three parts:
[0141]
[0142] Among them, l r is the Relaxed EarthMover's Distance between the output image X and the input style image in each optimization process. r It can transfer the structure of the style image to the output image well, but because the distance in RelaxedEarth Mover's Distance is a cosine distance, the relationship between the lengths of the feature vectors is ignored, which may cause artifacts in the output image. To solve this problem, it is necessary to introduce a loss function l m , l m is the moment matching loss. Finally, in order to ensure that the output image is as similar to the style image as possible in color, the color matching loss l is introduced p , hyperparameters α and Lcontent The hyperparameters are the same.
[0143] L content and L style All of them constrain the output image at a higher level based on hypercolumns, which will result in a large difference between the final output image and the face of the input image. In order to improve the quality of the final result, this application uses a reconstruction loss function for the visible part of the face, thereby constraining the output image at the pixel level. The reconstruction loss function is as follows:
[0144]
[0145] Among them, w, h and c are the length, width and number of channels of the image respectively; X is the output image in each texture migration process (also called migration image); S is the style image; M is the visibility mask image.
[0146] Reference Figure 2 In one embodiment, the present application can obtain an input face image, perform face vertex visibility detection, face texture spatial mapping, face reconstruction and other data processing based on the input face image, and obtain a visibility mask image, a style image and a content image respectively. Furthermore, texture migration can be performed n times according to the visibility mask image, the style image and the content image, and finally an output face texture image is obtained. By adding multi-stage style migration, the generated face map can be guaranteed to retain identity feature information to the greatest extent.
[0147] Furthermore, the present application also provides a facial texture generating device.
[0148] Reference Figure 3 , Figure 3 This is a schematic diagram of the functional modules of an embodiment of the facial texture generation device of the present applicant.
[0149] The face texture generating device comprises:
[0150] An acquisition module 310 is used to acquire a face image to be processed;
[0151] A detection module 320, configured to perform face vertex visibility detection based on the face image to be processed to obtain a visibility mask image;
[0152] A mapping module 330 is used to perform spatial mapping of facial texture based on the facial image to be processed to obtain a style image;
[0153] A reconstruction module 340, configured to perform face reconstruction based on the face image to be processed to obtain a content image;
[0154] The migration module 350 is used to perform style migration based on the visibility mask image, the style image and the content image to obtain a facial texture image; the visibility mask image is used to supplement the visible texture of the face in the migration image based on the style image and the content image.
[0155] The facial texture generation device provided in the embodiment of the present application can obtain corresponding visibility mask images, style images and content images respectively by performing vertex visibility detection, spatial mapping of facial texture and facial reconstruction based on the facial image to be processed. The style of the content image can be transferred through the style image, and the visible texture of the face can be supplemented in the transferred image through the visibility mask image, so that the facial texture image obtained by style transfer is closer to the real face. A high-fidelity facial texture image can be obtained without the need for a large number of real and complete facial texture images or facial images in image space to train the neural network, thereby improving the efficiency of facial texture generation.
[0156] In one embodiment, the detection module 320 is specifically used to:
[0157] Mapping the facial texture of the facial image to be processed from the image space to the texture space to obtain a three-dimensional facial image;
[0158] Performing face vertex visibility detection on the three-dimensional face image to obtain a visibility detection result;
[0159] A visibility mask image is generated based on the visibility detection result and the three-dimensional face image.
[0160] In one embodiment, the detection module 320 includes a generation unit, the generation unit being configured to:
[0161] Adjusting the texture value of the three-dimensional face image based on the visibility detection result to obtain a texture value adjusted image;
[0162] A morphological opening and closing operation is performed on the texture value adjusted image to obtain a visibility mask image.
[0163] In one embodiment, the mapping module 330 is specifically used to:
[0164] Acquire facial geometry information of the facial image to be processed;
[0165] Determine a first mapping between each vertex in the face geometry information and the image space;
[0166] Determining a second mapping between each vertex in the face geometry information and a texture space;
[0167] Determining a target mapping from image space to texture space based on the first mapping and the second mapping;
[0168] Based on the target mapping, the face image to be processed is mapped from the image space to the texture space to obtain a style image.
[0169] In one embodiment, the reconstruction module 340 is specifically configured to:
[0170] Determining the average facial texture in the face image to be processed;
[0171] Determining adjustment parameters of the average facial texture;
[0172] Adjusting the average facial texture based on the adjustment parameter to obtain an adjusted texture;
[0173] The adjusted texture is projected from the image space to the texture space to obtain a content image.
[0174] In one embodiment, the migration module 350 is specifically configured to:
[0175] The visibility mask image, the style image and the content image are input into a style transfer model to obtain a target face texture image output by the style transfer model; the total loss function of the style transfer model includes a content loss function, a style loss function and a reconstruction loss function; the reconstruction loss function is used to supplement the visible texture of the face in a transfer image based on the style image and the content image based on the visibility mask image.
[0176] Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call a computer program in the memory 430 to execute the steps of the method for generating facial texture, for example, including:
[0177] Obtain the face image to be processed;
[0178] Performing face vertex visibility detection based on the face image to be processed to obtain a visibility mask image;
[0179] Performing spatial mapping of facial texture based on the facial image to be processed to obtain a style image;
[0180] Performing face reconstruction based on the face image to be processed to obtain a content image;
[0181] Style migration is performed based on the visibility mask image, the style image and the content image to obtain a facial texture image; the visibility mask image is used to supplement the visible texture of the face in the migration image based on the style image and the content image.
[0182] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk.
[0183] On the other hand, an embodiment of the present application further provides a storage medium, wherein the storage medium is a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program is used to enable a processor to execute the steps of the methods provided in the above embodiments, for example, including:
[0184] Obtain the face image to be processed;
[0185] Performing face vertex visibility detection based on the face image to be processed to obtain a visibility mask image;
[0186] Performing spatial mapping of facial texture based on the facial image to be processed to obtain a style image;
[0187] Performing face reconstruction based on the face image to be processed to obtain a content image;
[0188] Style migration is performed based on the visibility mask image, the style image and the content image to obtain a facial texture image; the visibility mask image is used to supplement the visible texture of the face in the migration image based on the style image and the content image.
[0189] The computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc.), optical storage (such as CD, DVD, BD, HVD, etc.), and semiconductor storage (such as ROM, EPROM, EEPROM, non-volatile memory (NANDFLASH), solid-state drive (SSD)), etc.
[0190] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0191] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0192] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for generating facial texture, characterized in that: include: Obtain the face image to be processed; Performing face vertex visibility detection based on the face image to be processed to obtain a visibility mask image; Performing spatial mapping of facial texture based on the facial image to be processed to obtain a style image; Performing face reconstruction based on the face image to be processed to obtain a content image; Style migration is performed based on the visibility mask image, the style image and the content image to obtain a facial texture image; the visibility mask image is used to supplement the visible texture of the face in the migration image based on the style image and the content image.
2. The method for generating facial texture according to claim 1, characterized in that: The performing style migration based on the visibility mask image, the style image and the content image to obtain a face texture image includes: The visibility mask image, the style image and the content image are input into a style transfer model to obtain a target face texture image output by the style transfer model; the total loss function of the style transfer model includes a content loss function, a style loss function and a reconstruction loss function; the reconstruction loss function is used to supplement the visible texture of the face in a transfer image based on the style image and the content image based on the visibility mask image.
3. The method for generating facial texture according to claim 2, characterized in that: The style transfer model is determined by the following steps: Get a sample face image; Extracting features from the sample face image to obtain feature information; The loss function of the initial style transfer model is improved to obtain an improved style transfer model; wherein the initial style transfer model includes a content loss function and a style loss function; the improved style transfer model includes a content loss function, a style loss function and a reconstruction loss function; Based on the feature information, the improved style transfer model is trained to obtain a trained style transfer model.
4. The method for generating facial texture according to claim 1, characterized in that: The step of performing face vertex visibility detection based on the face image to be processed to obtain a visibility mask image includes: Mapping the facial texture of the facial image to be processed from the image space to the texture space to obtain a three-dimensional facial image; Performing face vertex visibility detection on the three-dimensional face image to obtain a visibility detection result; A visibility mask image is generated based on the visibility detection result and the three-dimensional face image.
5. The method for generating facial texture according to claim 4, characterized in that: The generating a visibility mask image based on the visibility detection result and the three-dimensional face image includes: Adjusting the texture value of the three-dimensional face image based on the visibility detection result to obtain a texture value adjusted image; A morphological opening and closing operation is performed on the texture value adjusted image to obtain a visibility mask image.
6. The method for generating facial texture according to claim 1, characterized in that: The performing spatial mapping of facial texture based on the face image to be processed to obtain a style image includes: Acquire facial geometry information of the facial image to be processed; Determine a first mapping between each vertex in the face geometry information and the image space; Determining a second mapping between each vertex in the face geometry information and a texture space; Determining a target mapping from image space to texture space based on the first mapping and the second mapping; Based on the target mapping, the face image to be processed is mapped from the image space to the texture space to obtain a style image.
7. The method for generating facial texture according to claim 1, characterized in that: The step of performing face reconstruction based on the face image to be processed to obtain a content image includes: Determining the average facial texture in the face image to be processed; Determining adjustment parameters of the average facial texture; Adjusting the average facial texture based on the adjustment parameter to obtain an adjusted texture; The adjusted texture is projected from the image space to the texture space to obtain a content image.
8. A facial texture generating device, characterized in that: include: An acquisition module, used for acquiring a face image to be processed; A detection module, used for performing face vertex visibility detection based on the face image to be processed to obtain a visibility mask image; A mapping module, used for performing spatial mapping of facial texture based on the facial image to be processed to obtain a style image; A reconstruction module, used for performing face reconstruction based on the face image to be processed to obtain a content image; A migration module is used to perform style migration based on the visibility mask image, the style image and the content image to obtain a facial texture image; the visibility mask image is used to supplement the visible texture of the face in the migration image based on the style image and the content image.
9. An electronic device comprising a processor and a memory storing a computer program, characterized in that: When the processor executes the computer program, the method for generating facial texture according to any one of claims 1 to 7 is implemented.
10. A storage medium, the storage medium being a computer-readable storage medium, comprising a computer program, characterized in that: When the computer program is executed by a processor, the method for generating facial texture according to any one of claims 1 to 7 is implemented.
