Method and system for beautifying facial image, and storage medium
By performing feature combination and preprocessing on the face image, and using the generator network and multi-task prediction network, the style transfer of specific parts of the face image is realized, which solves the problem of the inability to realize the style transfer of specific parts in the existing technology and improves the efficiency of the face image. User satisfaction.
Patent Information
- Application Number
- PCT/CN2023/095558
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-04-18
- Filing Date
- 2023-05-22
- Publication Date
- 2024-10-24
AI Technical Summary
Existing facial image beautification methods cannot achieve style transfer of specific parts, resulting in reduced user satisfaction.
By collecting dynamic images, screening diverse facial feature sets, combining images and features for preprocessing, inputting into the generator network for style transfer, and using multi-task prediction networks to evaluate beautiful feature values and recommend beautification solutions.
It realizes the style transfer of specific parts of the face image, improves user satisfaction, and provides users with satisfactory beautification recommendations.
Smart Images

Figure CN2023095558_24102024_PF_FP_ABST
Abstract
Description
Facial image beautification method, system and storage medium Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a facial image beautification method, system and storage medium. Background Art
[0002] With the continuous development and technological innovation in the field of image processing, computers' ability to perceive the aesthetic processing of facial images has been continuously enhanced. Most facial image beautification methods are based on deep neural networks, which can beautify facial images in combination with image processing and recommend beautification plans. Currently, facial image beautification methods have been widely used in technical fields such as cosmetic surgery recommendations, orthodontics, and makeup evaluation.
[0003] In related technologies, the focus is more on the overall migration of facial image styles, but it is impossible to achieve regional changes in multiple specific locations, which reduces user satisfaction. How to achieve style migration of specific parts of facial images is an issue that urgently needs to be discussed and solved.
[0004] Summary of the Invention
[0005] This application aims to solve at least one of the technical problems existing in the prior art. To this end, this application proposes a facial image beautification method, system, and storage medium that can achieve style transfer of specific parts of facial images, meet the beautification needs of users, and improve user satisfaction.
[0006] In order to solve the above technical problems, the present invention proposes the following technical solutions:
[0007] The first embodiment of the present application provides a method for beautifying a facial image, comprising:
[0008] Collecting a plurality of source images, positioning and cropping the source images to obtain a plurality of image sets, wherein the source images are dynamic images including human faces;
[0009] Screening a preset face database to obtain a plurality of feature sets, wherein the feature sets include a plurality of different explicit face features;
[0010] Combining the image set and the feature set to obtain a plurality of feature combinations, and preprocessing the feature combinations to obtain a style feature function;
[0011] Inputting the style feature function into a preset generator network to obtain a high-definition image set;
[0012] Inputting the high-definition image set into a preset multi-task prediction network to obtain a beauty feature value of each high-definition image in the high-definition image set, wherein the beauty feature value includes a beauty prediction score;
[0013] The beauty prediction scores are screened, and the high-definition image with the highest beauty prediction score is selected as a beautification recommendation solution.
[0014] The facial image beautification method according to the first embodiment of the present application has at least the following beneficial effects: the facial image beautification method of the present application can collect dynamic images of users with slight facial changes as source image input to obtain a source image domain, and at the same time screen multiple different sets of explicit facial features from a face database with diverse features to obtain a reference image domain, which contains features of different parts of the face. The present application combines the image set and the feature set to obtain several feature combinations, pre-processes the feature combinations to obtain a style feature function, and inputs the style feature function into the generator network, thereby achieving style transfer of specific parts of the user's source image, obtaining a high-definition image set, and improving user satisfaction. Moreover, the present application can also input the high-definition image set into a preset multi-task prediction network to obtain the beauty feature value of each high-definition image in the high-definition image set, and screen the beauty prediction score to recommend a suitable beautification recommendation plan to the user, thereby meeting the user's beautification needs.
[0015] According to some embodiments of the first aspect of the present application, preprocessing the feature combination to obtain a style feature function includes:
[0016] Performing semantic segmentation on the feature combination to obtain a face segmentation mask and a feature segmentation mask;
[0017] The face segmentation mask and the feature segmentation mask are synthesized according to preset requirements to obtain a style feature function.
[0018] According to some embodiments of the first aspect of the present application, performing semantic segmentation on the feature combination to obtain a face segmentation mask and a feature segmentation mask includes:
[0019] Extracting features of the feature combination to obtain a feature image;
[0020] Performing a normalization transformation on the feature image by a bilinear interpolation method to obtain a scaled feature map;
[0021] The scaled feature map is classified by a preset fully convolutional network to obtain a face segmentation mask and a feature segmentation mask.
[0022] According to some embodiments of the first aspect of the present application, synthesizing the face segmentation mask and the feature segmentation mask according to preset requirements to obtain a style feature function includes:
[0023] Synthesizing the face segmentation mask and the feature segmentation mask according to preset requirements to obtain a face mask;
[0024] The face mask is subjected to sampling processing, full connection layer processing, and affine transformation processing to obtain a style feature function.
[0025] According to some embodiments of the first aspect of the present application, the generator network includes a preset multidimensional constant tensor, multiple upsampling layers, and multiple adaptive instance normalization layers, and inputting the style feature function into the preset generator network to obtain a high-definition image set includes:
[0026] sequentially inputting the multidimensional constant tensor, the preset Gaussian noise, and the style feature function into the adaptive instance normalization layer to obtain a first style transferred image;
[0027] Inputting the first style transfer image into the upsampling layer to obtain a first filtered image;
[0028] sequentially inputting the first filtered image, the Gaussian noise, and the style feature function into the adaptive instance normalization layer to obtain a second style transferred image;
[0029] Repeat the process of inputting the second style transfer image into the upsampling layer and the adaptive instance normalization layer in sequence until a high-definition image set is obtained.
[0030] According to some embodiments of the first aspect of the present application, the multi-task prediction network includes multiple convolutional layers and at least three fully connected layers, and inputting the high-definition image set into a preset multi-task prediction network to obtain the beauty feature value of each high-definition image in the high-definition image set includes:
[0031] Performing convolution calculation on the high-definition image set through the convolution layer to obtain at least three subtasks, wherein the number of the fully connected layers is the same as the number of the subtasks;
[0032] Classifying and calculating the subtasks through the fully connected layer to obtain comprehensive results of the subtasks;
[0033] The comprehensive results of the subtasks are trained respectively according to preset weights to obtain the beauty feature value of each high-definition image in the high-definition image set.
[0034] According to some embodiments of the first aspect of the present application, the subtasks include a face beauty prediction task, a gender task, and a race task, the beauty feature value also includes a gender score and a race classification score, and the comprehensive results of the subtasks are trained according to preset weights to obtain the beauty feature value of each high-definition image in the high-definition image set, including:
[0035] assigning different weights to the face beauty prediction task, the gender task, and the race task, wherein the weight of the face beauty prediction task is greater than the weight of the gender task and the weight of the race task;
[0036] training an image set with known beauty feature values in the source image domain according to the weight of the face beauty prediction task, the weight of the gender task, and the weight of the race task to obtain a beauty degree model;
[0037] The comprehensive results of the subtasks are input into the beauty degree model to obtain the beauty prediction score, gender score and race classification score of each high-definition image in the high-definition image set.
[0038] According to some embodiments of the first aspect of the present application, inputting the comprehensive results of the subtasks into the beauty degree model to obtain a beauty prediction score, a gender score, and a race classification score for each high-definition image in the high-definition image set further includes:
[0039] Calculating based on a preset true beauty score and the beauty prediction score to obtain a face beauty prediction loss;
[0040] The gender classification loss is calculated based on the first label of the preset gender task and the probability of the first label generated by the preset multi-task prediction network;
[0041] The racial classification loss is calculated based on the second label of the preset racial task and the probability of the second label generated by the preset multi-task prediction network.
[0042] Calculating the overall loss of the multi-task prediction network based on the face beauty prediction loss, the gender classification loss, the race classification loss, the weight of the face beauty prediction task, the weight of the gender task, and the weight of the race task;
[0043] The beauty model is optimized according to the overall loss of the multi-task prediction network.
[0044] A second embodiment of the present application provides a facial image beautification system, including:
[0045] at least one memory;
[0046] at least one processor;
[0047] at least one program;
[0048] The programs are stored in the memory, and the processor executes at least one of the programs to implement:
[0049] A facial image beautification method as described in any one of the first aspects of this application.
[0050] A third aspect of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer-executable signal, wherein the computer-executable signal is used to execute:
[0051] A facial image beautification method as described in any one of the first aspects of this application.
[0052] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become obvious from the description below, or will be learned through practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Additional aspects and advantages of the present application will become apparent and readily understood from the following description of the embodiments with reference to the accompanying drawings, in which:
[0054] FIG1 is a main flow chart of a facial image beautification method provided by some embodiments of the present application;
[0055] FIG2 is a sub-flowchart of a facial image beautification method provided in some embodiments of the present application;
[0056] FIG3 is a sub-flowchart of a facial image beautification method provided in some embodiments of the present application;
[0057] FIG4 is a sub-flowchart of a facial image beautification method provided in some embodiments of the present application;
[0058] FIG5 is a sub-flowchart of a facial image beautification method provided in some embodiments of the present application;
[0059] FIG6 is a sub-flowchart of a facial image beautification method provided in some embodiments of the present application;
[0060] FIG7 is a sub-flowchart of a facial image beautification method provided in some embodiments of the present application;
[0061] FIG8 is a sub-flowchart of a facial image beautification method provided in some embodiments of the present application;
[0062] FIG9 is a main flow chart of a facial image beautification method provided in some other embodiments of the present application;
[0063] FIG10 is a module block diagram of a facial image beautification system provided in some embodiments of the present application. DETAILED DESCRIPTION
[0064] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0065] It should be noted that although a logical order is shown in the flowcharts, in some cases, the steps shown or described may be performed in a different order than that shown in the flowcharts. Terms used in the specification, claims, and drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0066] In the description of this application, if there is a description of first or second, it is only for the purpose of distinguishing technical features, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.
[0067] In the description of this application, unless otherwise clearly defined, terms such as setting, installing, and connecting should be understood in a broad sense, and technicians in the relevant technical field can reasonably determine the specific meanings of the above terms in this application based on the specific content of the technical solution.
[0068] With the continuous development and technological innovation of image processing, computers are increasingly capable of aesthetically processing and perceiving facial images. Most facial image beautification methods are based on deep neural networks, combining image processing with artificial intelligence to beautify and recommend facial images. Currently, facial image beautification methods are widely used in fields such as cosmetic surgery recommendations, orthodontics, and makeup evaluation. Related technologies focus on the overall transfer of facial image style, but are unable to modify specific areas, reducing user satisfaction. Therefore, achieving style transfer for specific facial areas is a pressing issue that needs to be discussed and addressed.
[0069] Based on this, the facial image beautification method of the present application can utilize a semantic segmentation algorithm and a generative adversarial neural network to obtain a facial segmentation mask and an image with random changes only in specific areas. It predicts facial beauty through an aesthetic information processing network based on multi-task learning, and obtains the optimal solution for facial modification in the process of continuously generating virtual portraits and judging beauty. It is understandable that the present application can retain the original biological characteristics of the person and randomly modify and select specified external facial features (such as the person's hairstyle, glasses, earrings, hats and other accessories), which is closest to the public's pursuit of facial beauty and has great practical value and significance.
[0070] 1 , in a first aspect, an embodiment of the present application provides a facial image beautification method, including but not limited to step S110 , step S120 , step S130 , step S140 , step S150 , and step S160 .
[0071] Step S110, collecting a plurality of source images, positioning and cropping the source images to obtain a plurality of image sets, wherein the source images are dynamic images including human faces;
[0072] Step S120, screening a preset face database to obtain a plurality of feature sets, wherein the feature sets include a plurality of different explicit facial features;
[0073] Step S130, combining the image set and the feature set to obtain a plurality of feature combinations, preprocessing the feature combinations to obtain a style feature function;
[0074] Step S140: inputting the style feature function into a preset generator network to obtain a high-definition image set;
[0075] Step S150: Inputting the high-definition image set into a preset multi-task prediction network to obtain a beauty feature value of each high-definition image in the high-definition image set, wherein the beauty feature value includes a beauty prediction score;
[0076] Step S160 , screening the beauty prediction scores, and selecting the high-definition image with the highest beauty prediction score as the beautification recommendation solution.
[0077] It should be noted that, in the present application, multiple image sets are stored in the source image domain, and multiple feature sets are stored in the reference image domain. The main purpose of the present application is to transfer different external facial features (such as hairstyle, glasses, earrings, hats, etc.) in the reference image domain to the image set in the source image domain according to the specific needs of the user, and then generate a high-definition image set including multiple high-definition images through detailed evaluation, and then screen the high-definition images to obtain the most beautiful beautification recommendation scheme. Referring to Figure 9, Figure 9 is the main flow chart of the facial image beautification method provided by other embodiments of the present application; it can be understood that, first, the present application will shoot a group of dynamic images with slight expression changes in each volunteer, that is, collect several source images. After obtaining the source images of multiple different volunteers, in order to facilitate the subsequent processing of the source images, it is also necessary to locate and crop the collected source images to obtain the source image domain Y, which includes multiple image sets Y i At the same time, the present application also needs to screen out a plurality of different explicit facial features from a preset face database with diverse features to serve as a reference image domain X, and the reference image domain includes a plurality of feature sets.
[0078] According to one embodiment of the present application, feature set 1 includes several different hairstyles, feature set 2 includes different glasses, feature set 3 includes different earrings, and feature set 4 includes different hats. After obtaining the source image domain Y and the reference image domain X, the present application will further combine different image sets and feature sets in the source image domain Y and the reference image domain X to obtain different combinations of image sets and different feature sets, namely, feature combination f(X i , Y i), such as combining the source image of volunteer A with hairstyle B in feature set 1, or combining the source image of volunteer B with glasses C in feature set 2. After obtaining different feature combinations, the feature combinations need to be preprocessed, such as semantic segmentation and face segmentation mask, to obtain a style feature function to facilitate subsequent generator network processing. The style feature function is expressed as y = (y s ,y b ). After obtaining the style feature function, the style feature function and the preset Gaussian noise need to be input into the preset generator network. The style feature function is trained through the generator network to extract the features of the image set and feature set contained in the style feature function, and generate a high-definition image set including multiple high-definition images layer by layer. The high-definition image here is the image generated by modifying the specific position of the image set in the source image domain in combination with the feature set. The generated high-definition image set will be used as input and input into the preset multi-task prediction network. The multi-task prediction network is a deep convolutional network including multiple convolutional layers. The convolutional layer will decompose the high-definition image set into three different sub-tasks, and subsequently assign different weights to different sub-tasks for calculation to obtain the beauty feature value of each high-definition image in the high-definition image set. The beauty feature value includes a beauty prediction score, a gender score, and a racial classification score. The beauty prediction score refers to the beauty score of the modified source image.
[0079] Finally, this application will also screen the beauty prediction scores, select the high-definition images with the highest beauty prediction scores as beautification recommendations, and recommend the beauty prediction scores, gender scores, and ethnicity classification scores to the user. The beauty recommendation solutions can be images with single-feature modifications to the source image, or images with multiple-feature modifications to the source image. The facial image beautification method of this application is not restricted by pose and expression changes, and the more diverse the poses, expressions, and overt facial features in the source image domain X and the reference image domain Y, the better the training effect, the more realistic the beautification recommendation solutions obtained, and have greater practical value.
[0080] It should be noted that the facial image beautification method of the present application can collect dynamic images of users with slight facial changes as source image input to obtain a source image domain. At the same time, it screens multiple different sets of explicit facial features from a face database with diverse features to obtain a reference image domain. The reference image domain contains features of different parts of the face. The present application combines the image set and the feature set to obtain several feature combinations, preprocesses the feature combinations to obtain a style feature function, and inputs the style feature function into the generator network to achieve style transfer of specific parts of the user's source image, obtain a high-definition image set, and improve user satisfaction. Moreover, the present application can also input the high-definition image set into a preset multi-task prediction network to obtain the beauty feature value of each high-definition image in the high-definition image set, and screen the beauty prediction score to recommend a suitable beautification recommendation plan for the user, thereby meeting the user's beautification needs.
[0081] 2 , in a first aspect, an embodiment of the present application provides a facial image beautification method, including but not limited to step S210 and step S220 .
[0082] Step S210, performing semantic segmentation on the feature combination to obtain a face segmentation mask and a feature segmentation mask;
[0083] Step S220 , synthesizing the face segmentation mask and the feature segmentation mask according to preset requirements to obtain a style feature function.
[0084] According to one embodiment of the present application, the present application will also combine different image sets and feature sets in the source image domain Y and the reference image domain X to obtain combinations of different image sets and different feature sets, namely feature combinations, such as combining the source image of volunteer A with hairstyle B in feature set 1, or combining the source image of volunteer B with glasses C in feature set 2. After obtaining the feature combination, it is necessary to first perform semantic segmentation on the feature combination. Semantic segmentation is a relatively important step in the preprocessing stage. It can identify the content and location in the image of the feature combination and convert the raw data in the image of the feature combination into a mask with a highlighted region of interest. The present application obtains a face segmentation mask and a feature segmentation mask by performing semantic segmentation on the image of the feature combination. The face segmentation mask is a mask of the face area, and the feature segmentation mask is a mask of the explicit face feature area. After obtaining the face segmentation mask and the feature segmentation mask, it is also necessary to synthesize the face mask and the feature segmentation mask, that is, synthesize the mask of the face area and the mask of the explicit face feature area to obtain a style feature function. Specifically, the style feature function can be expressed as a composite image obtained by synthesizing the source image of volunteer A and the hairstyle B in feature set 1, or as a composite image obtained by synthesizing the source image of volunteer B and the glasses C in feature set 2.
[0085] 3 , in a first aspect, an embodiment of the present application provides a facial image beautification method, including but not limited to step S310 , step S320 , and step S330 .
[0086] Step S310, extracting features of the feature combination to obtain a feature image;
[0087] Step S320, performing a normalization transformation on the feature image by a bilinear interpolation method to obtain a scaled feature map;
[0088] Step S330: Classify the scaled feature map through a preset fully convolutional network to obtain a face segmentation mask and a feature segmentation mask.
[0089] According to one embodiment of the present application, the step of semantic segmentation includes: extracting features from the feature combination to obtain a feature image; secondly, performing a normalization transformation on the feature image to achieve image scaling to obtain a scaled feature map; finally, performing pixel-level classification on the scaled feature map through a preset fully convolutional network to distinguish between faces and explicit facial features in the scaled feature map to obtain a face segmentation mask and a feature segmentation mask.
[0090] Specifically, the present application performs semantic segmentation on the input feature combination through a preset semantic segmentation network, and outputs a face segmentation mask and a feature segmentation mask. The semantic segmentation network includes a Residual Network (ResNet) backbone network, the Region of Interest Align (RoIAlign) layer, and a fully convolutional network. In the process of semantic segmentation, the ResNet backbone network first extracts features from the input feature combination image and outputs a feature image; the feature image is used as input and input to the RoIAlign layer, which performs a normalized transformation on the feature image to achieve image scaling and outputs a scaled feature map. The scaled feature map is used as input and input to the fully convolutional network, which performs pixel-level classification on the scaled feature map and outputs a face segmentation mask and a feature segmentation mask.
[0091] More specifically, the RoIAlign layer implements a standard transformation of the feature image through a two-line interpolation method. The two-line interpolation method consists of two steps. The first step is to interpolate in the x-axis direction, which is specifically expressed as follows:
[0092] Where, f(R1) and f(R2) represent the values obtained by interpolation in the x-axis direction; f(Q 11 )、f(Q 21 )、f(Q 12 ) and f(Q 22) represents the four pixel points Q near the sampling point P in the region of interest (RoI) in the corresponding feature map 11 =(x1,y1),Q 21 =(x2,y1),f(Q 12 )=(x1,y2),f(Q 22 )=(x2,y2).
[0093] The second step is to interpolate in the y-axis direction, which is as follows:
[0094] Here, f(R1) and f(R2) represent values obtained by interpolation in the x-axis direction; f(P) and f(x,y) represent the values of the sampling point P.
[0095] It is understandable that using bilinear interpolation to scale images for semantic segmentation can largely preserve the features of the original image, generating more realistic images. This can also avoid the problem of misalignment and misalignment between RoIs and extracted features in the semantic segmentation network.
[0096] 4 , in a first aspect, an embodiment of the present application provides a facial image beautification method, including but not limited to step S410 and step S420 .
[0097] Step S410, synthesizing the face segmentation mask and the feature segmentation mask according to preset requirements to obtain a face mask;
[0098] Step S420 , performing sampling processing, fully connected layer processing, and affine transformation processing on the face mask to obtain a style feature function.
[0099] According to one embodiment of the present application, after obtaining the mask of the face area and the mask of the external facial feature area, that is, after obtaining the face segmentation mask and the feature segmentation mask, it is necessary to synthesize the face segmentation mask and the feature segmentation mask according to preset requirements, synthesizing the features of the specific part in the reference image domain and the face in the source image domain to obtain a face mask. Furthermore, after synthesizing the face mask, it is necessary to sample the face mask, perform fully connected layer processing, and perform affine transformation processing to obtain a style feature function, and then input the style feature function as input to the adaptive instance normalization (AdaIN) layer of the generator network.
[0100] 9, according to an embodiment of the present application, the image set Y in the source image domain Y can be converted into kThe hairstyle in feature set 1 and the earrings in feature set 3 of the reference image domain X are synthesized to obtain the synthesized style feature function.
[0101] 5 , in a first aspect, an embodiment of the present application provides a facial image beautification method, including but not limited to step S510 , step S520 , step S530 , and step S540 .
[0102] Step S510: sequentially inputting the multidimensional constant tensor, the preset Gaussian noise, and the style feature function into the adaptive instance normalization layer to obtain a first style transferred image;
[0103] Step S520: input the first style transfer image to the upsampling layer to obtain a first filtered image;
[0104] Step S530 , sequentially inputting the first filtered image, Gaussian noise, and style feature function into an adaptive instance normalization layer to obtain a second style transferred image;
[0105] Step S540 : Repeat the process of inputting the second style transfer image into the upsampling layer and the adaptive instance normalization layer in sequence until a high-definition image set is obtained.
[0106] It should be noted that the generator network includes a preset multidimensional constant tensor, multiple upsampling layers, and multiple adaptive instance normalization layers. Specifically, the generator network includes a block consisting of a multidimensional constant tensor and an adaptive instance normalization layer, and a block consisting of multiple upsampling layers and an adaptive instance normalization layer. The multidimensional constant tensor represents multiple low-resolution original images. Specifically, the multidimensional constant tensor is 512 4*4 images, but the pixel level is the same random constant.
[0107] Referring to Figure 9, it can be understood that the generator network has three different inputs. First, a multidimensional constant tensor is input as the first input to the first AdaIN layer. Preset Gaussian noise is input as the second input to each AdaIN layer before the style feature function is input to the AdaIN layer. The style feature function is input as the third input to each AdaIN layer in the generator network, allowing the AdaIN layer to perform style transfer based on the style feature function. As the generator network trains, the features of the source image domain Y and the reference image domain X contained in the style feature function are extracted, and multiple high-definition images, i.e., a high-definition image set, are generated layer by layer.
[0108] Specifically, during operation, after receiving the style feature function, the generator network of the present application sequentially inputs a multidimensional constant tensor, preset Gaussian noise, and style feature function into an adaptive instance normalization layer to obtain a first style transferred image. The first style transferred image is then input into a block consisting of an upsampling layer and an adaptive instance normalization layer. The upsampling layer outputs a first filtered image, which is then used as input into the adaptive instance normalization layer. Specifically, the first filtered image, Gaussian noise, and style feature function are sequentially input into the adaptive instance normalization layer to obtain a second style transferred image. After obtaining the second style transferred image, the above steps are repeated, with the second style transferred image being input into a block consisting of an upsampling layer and an adaptive instance normalization layer. The upsampling layer outputs a second filtered image, which is then used as input into the adaptive instance normalization layer. Specifically, the second filtered image, Gaussian noise, and style feature function are sequentially input into the adaptive instance normalization layer to obtain a third style transferred image. This step is then repeated until multiple high-definition images, i.e., a high-definition image set, are obtained.
[0109] More specifically, the style feature function y=(y s ,y b ) as input, the operation input to the AdaIN layer can be defined as:
[0110] Among them, x i Represents the i-th feature map, which comes from a multidimensional constant tensor; μ(x i ) and σ(x i ) represents x i The mean and standard deviation of y s,i and y b,i Represents the style feature function y=(y s ,y b )’s scaling factor and bias factor; AdaIN(x i ,y) represents the value obtained after the AdaIN layer operation, that is, the style transfer image.
[0111] It can be understood that by designing the generator module as a stack of multiple upsampling layers and adaptive instance normalization layers, this helps output multiple high-definition images without altering the facial biometrics. Adding Gaussian noise before the adaptive instance normalization layer can randomly alter more microscopic features, such as hair texture, making the generated images more realistic.
[0112] 6 , in a first aspect, an embodiment of the present application provides a facial image beautification method, including but not limited to step S610 , step S620 , and step S630 .
[0113] Step S610: performing convolution calculation on the high-definition image set through a convolution layer to obtain at least three subtasks, wherein the number of fully connected layers is the same as the number of subtasks;
[0114] Step S620: classify and calculate the subtasks through the fully connected layer to obtain the comprehensive results of the subtasks;
[0115] Step S630 : training the comprehensive results of the subtasks according to preset weights to obtain a beauty feature value for each high-definition image in the high-definition image set.
[0116] It should be noted that the multi-task prediction network includes multiple convolutional layers and at least three fully connected layers.
[0117] According to one embodiment of the present application, a high-definition image set will be used as input and input into a convolutional layer, so that the convolutional layer performs convolution calculations on multiple high-definition images and converts them into at least three subtask outputs. Multiple subtasks will be used as input and input into a fully connected layer corresponding to each subtask, so that the fully connected layer classifies and calculates the subtasks to obtain a comprehensive result of the subtasks. Specifically, the present application includes multiple fully connected layers corresponding to the subtasks, and each fully connected layer processes one subtask. Furthermore, after obtaining the comprehensive results of different subtasks, the multi-task prediction network of the present application will also train the comprehensive results of the subtasks according to preset weights to obtain the beauty feature value of each high-definition image in the high-definition image set. The beauty feature value includes a beauty prediction score, a gender score, and a racial classification score.
[0118] It can be understood that this application obtains comprehensive results of different subtasks by classifying and calculating subtasks, which facilitates the evaluation of beauty feature values from different dimensions.
[0119] 7 , in a first aspect, an embodiment of the present application provides a facial image beautification method, including but not limited to step S710 , step S720 , and step S730 .
[0120] Step S710, assigning different weights to the face beauty prediction task, the gender task, and the race task, wherein the weight of the face beauty prediction task is greater than the weight of the gender task and the weight of the race task;
[0121] Step S720, training a set of images with known beauty feature values in the source image domain according to the weight of the face beauty prediction task, the weight of the gender task, and the weight of the race task to obtain a beauty degree model;
[0122] Step S730 : Input the comprehensive results of the subtasks into the beauty degree model to obtain the beauty prediction score, gender score, and race classification score of each high-definition image in the high-definition image set.
[0123] According to one embodiment of the present application, starting from the fully connected layer, the multi-task prediction network is divided into three branches, corresponding to three different subtasks: facial beauty prediction, gender prediction, and ethnicity prediction. The facial beauty prediction task is the primary task, considered a regression problem, while the gender and ethnicity tasks are auxiliary tasks, considered a binary classification problem and a multi-classification problem, respectively.
[0124] Specifically, to make the facial image beautification method of this application more universal, this application also takes into account the race and gender of different users, assigning different weights to the facial beauty prediction task, gender task, and race task. The weight of the facial beauty prediction task is greater than the weights of the gender task and the race task. Furthermore, the multi-task prediction network learns and trains images in the source image domain Y that have been annotated with beauty feature values based on the weights of the facial beauty prediction task, the gender task, and the race task. It learns features related to beauty and builds a model that associates facial images with beauty, namely the beauty model. When the combined results of the subtasks are input to the beauty model, the beauty model outputs a beauty prediction score, a gender score, and a race classification score for each high-definition image in the current high-definition image set. This application uses the beauty prediction score to select beautification recommendation solutions. The solution with the highest beauty prediction score is the beautification recommendation solution. The beautification recommendation solution also includes a gender score and a race classification score, which are output simultaneously with the beauty prediction score.
[0125] More specifically, after obtaining the beauty feature values, the beauty degree model will annotate the HD images corresponding to the combined results of the subtasks based on the beauty feature values. The images annotated with beauty feature values used to train the beauty degree model can be pre-annotated by the operator or HD images annotated with beauty feature values obtained during subsequent beauty degree model training. The true beauty score is annotated within the annotated HD images.
[0126] 8 , in a first aspect, an embodiment of the present application provides a facial image beautification method, including but not limited to step S810 , step S820 , step S830 , step S840 , and step S850 .
[0127] Step S810, calculating based on the preset true beauty score and beauty prediction score to obtain the face beauty prediction loss;
[0128] Step S820, calculating the gender classification loss based on the first label of the preset gender task and the probability of the first label generated by the preset multi-task prediction network;
[0129] Step S830, calculating the race classification loss based on the second label of the preset race task and the probability of the second label generated by the preset multi-task prediction network;
[0130] Step S840, calculating the overall loss of the multi-task prediction network based on the face beauty prediction loss, the gender classification loss, the race classification loss, the weight of the face beauty prediction task, the weight of the gender task, and the weight of the race task;
[0131] Step S850: Optimize the beauty degree model based on the overall loss of the multi-task prediction network.
[0132] According to one embodiment of the present application, during the training process, the present application will also optimize the beauty degree model using the mean square error loss function, the binary cross entropy loss function, and the multi-class cross entropy loss function. First, based on the true beauty score and the beauty prediction score, the face beauty prediction loss is calculated. The face beauty prediction loss is specifically:
[0133] Among them, loss B represents the face beauty prediction loss; y i Indicates the beauty truth score; represents the beauty prediction score.
[0134] The second step is to calculate the gender classification loss based on the first label of the preset gender task and the probability of the first label generated by the preset multi-task prediction network; loss G =-(1-g)log(1-p g )-glog(p g );
[0135] Among them, loss G represents the gender classification loss; g represents the first label of the preset gender task; p g Indicates the probability of the first label generated by the preset multi-task prediction network.
[0136] At the same time, the racial classification loss is calculated based on the second label of the preset racial task and the probability of the second label generated by the preset multi-task prediction network. The racial classification loss is:
[0137] Among them, loss E represents the racial classification loss; e i The second tag indicating the preset racial mission; p e,i Indicates the probability of the second label generated by the preset multi-task prediction network.
[0138] Finally, the overall loss of the multi-task prediction network is calculated based on the face beauty prediction loss, gender classification loss, race classification loss, the weight of the face beauty prediction task, the weight of the gender task, and the weight of the race task. The beauty degree model is optimized based on the overall loss of the multi-task prediction network. The overall loss of the multi-task prediction network is:
[0139] Among them, lossprediction represents the overall loss of the multi-task prediction network; loss t and λ t Represents the face beauty prediction loss loss B Weights and gender classification loss corresponding to the face beauty prediction task G Weights corresponding to gender tasks and racial classification loss E The weight corresponding to the racial mission.
[0140] Specifically, in a multi-task prediction network, this application treats ethnicity classification as a multi-classification problem and replaces the common binary cross-entropy loss function with a multi-classification cross-entropy loss function. By refining the ethnicity classification task, the accuracy of facial beauty prediction is improved.
[0141] In a second aspect, referring to FIG. 10 , an embodiment of the present application provides a facial image beautification system, including:
[0142] at least one memory 200;
[0143] at least one processor 100;
[0144] at least one program;
[0145] Programs are stored in the memory 200, and the processor 100 executes at least one program to implement:
[0146] A facial image beautification method as in any embodiment of the first aspect of the present application.
[0147] The processor 100 and the memory 200 may be connected via a bus or other means.
[0148] The memory 200 is a non-transitory readable storage medium that can be used to store non-transitory software instructions and non-transitory instructions. In addition, the memory 200 may include a high-speed random access memory 200, and may also include a non-transitory memory 200, such as at least one disk storage device 200, a flash memory device, or other non-transitory solid-state storage device 200. It is understood that the memory 200 optionally includes a memory 200 remotely located relative to the processor 100, and these remote memories 200 can be connected to the processor 100 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0149] The processor 100 executes non-transitory software instructions, commands, and signals stored in the memory 200, thereby performing various functional applications and data processing, thereby realizing the facial image beautification method of the first embodiment described above.
[0150] The non-transient software instructions and instructions required to implement the facial image beautification method of the above-mentioned embodiment are stored in the memory 200. When executed by the processor 100, the facial image beautification method of the first aspect embodiment of the present application is executed, for example, the method steps S110 to S160 in Figure 1, the method steps S210 to S220 in Figure 2, the method steps S310 to S330 in Figure 3, the method steps S410 to S420 in Figure 4, the method steps S510 to S540 in Figure 5, the method steps S610 to S630 in Figure 6, the method steps S710 to S730 in Figure 7, and the method steps S810 to S850 in Figure 8 described above are executed.
[0151] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer-executable signal, and the computer-executable signal is used to execute:
[0152] A facial image beautification method according to any embodiment of the first aspect of the application.
[0153] For example, execute the method steps S110 to S160 in Figure 1, the method steps S210 to S220 in Figure 2, the method steps S310 to S330 in Figure 3, the method steps S410 to S420 in Figure 4, the method steps S510 to S540 in Figure 5, the method steps S610 to S630 in Figure 6, the method steps S710 to S730 in Figure 7, and the method steps S810 to S850 in Figure 8 described above.
[0154] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected based on actual needs to achieve the objectives of this embodiment.
[0155] By the description of the above embodiments, it will be appreciated by those skilled in the art that all or some of the steps and systems in the method disclosed above can be implemented as software, firmware, hardware and appropriate combinations thereof. Some physical components or all physical components can be implemented as software executed by a processor, such as a central processing unit, a digital signal processor or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a readable medium, and the readable medium can include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those skilled in the art, the term computer storage medium is included in any method or technology for storing information (such as a computer-readable signal, a data structure, an instruction module or other data) and is volatile and non-volatile, removable and non-removable. Computer storage media includes but is not limited to RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cassette, magnetic tape, disk storage or other magnetic storage device, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, as is well known to those skilled in the art, communication media typically embodies computer-readable signals, data structures, instruction modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0156] The embodiments of the present application are described in detail above in conjunction with the accompanying drawings, but the present application is not limited to the above embodiments. Various changes can be made within the scope of knowledge possessed by ordinary technicians in the relevant technical field without departing from the purpose of the present application.
Claims
1. A facial image beautification method, It is characterized in that include: Collecting a plurality of source images, positioning and cropping the source images to obtain a plurality of image sets, wherein the source images are dynamic images including human faces; Screening a preset face database to obtain a plurality of feature sets, wherein the feature sets include a plurality of different external face features; Combining the image set and the feature set to obtain a plurality of feature combinations, and preprocessing the feature combinations to obtain a style feature function; Inputting the style feature function into a preset generator network to obtain a high-definition image set; Inputting the high-definition image set into a preset multi-task prediction network to obtain a beauty feature value of each high-definition image in the high-definition image set, wherein the beauty feature value includes a beauty prediction score; The beauty prediction scores are screened, and the high-definition image with the highest beauty prediction score is selected as a beautification recommendation scheme.
2. The facial image beautification method according to claim 1, It is characterized in that The preprocessing of the feature combination to obtain a style feature function includes: Performing semantic segmentation on the feature combination to obtain a face segmentation mask and a feature segmentation mask; The face segmentation mask and the feature segmentation mask are synthesized according to preset requirements to obtain a style feature function.
3. The facial image beautification method according to claim 2, It is characterized in that The semantic segmentation of the feature combination to obtain a face segmentation mask and a feature segmentation mask includes: Extracting features of the feature combination to obtain a feature image; Performing a standard transformation on the feature image by a bilinear interpolation method to obtain a scaled feature map; The scaled feature map is classified through a preset full convolutional network to obtain a face segmentation mask and a feature segmentation mask.
4. The facial image beautification method according to claim 2, It is characterized in that The face segmentation mask and the feature segmentation mask are synthesized according to preset requirements to obtain a style feature function, including: The face segmentation mask and the feature segmentation mask are synthesized according to preset requirements to obtain a face mask; The face mask is subjected to sampling processing, full connection layer processing and affine transformation processing to obtain a style feature function.
5. The facial image beautification method according to claim 1, It is characterized in that The generator network includes a preset multi-dimensional constant tensor, multiple upsampling layers and multiple adaptive instance normalization layers, and the style feature function is input into the preset generator network to obtain a high-definition image set, including: Inputting the multidimensional constant tensor, the preset Gaussian noise and the style feature function into the adaptive instance normalization layer in sequence to obtain a first style transfer image; Inputting the first style transfer image into the upsampling layer to obtain a first filtered image; sequentially inputting the first filtered image, the Gaussian noise and the style feature function into the adaptive instance normalization layer to obtain a second style transfer image; Repeat the process of sequentially inputting the second style transfer image into the upsampling layer and the adaptive instance normalization layer until a high-definition image set is obtained.
6. The facial image beautification method according to claim 1, It is characterized in that The multi-task prediction network includes a plurality of convolutional layers and at least three fully connected layers. The inputting the high-definition image set into the preset multi-task prediction network to obtain the beauty feature value of each high-definition image in the high-definition image set includes: Performing convolution calculation on the high-definition image set through the convolution layer to obtain at least three subtasks, wherein the number of the fully connected layers is the same as the number of the subtasks; Classifying and calculating the subtasks through the fully connected layer to obtain comprehensive results of the subtasks; The comprehensive results of the subtasks are trained respectively according to preset weights to obtain the beauty feature value of each high-definition image in the high-definition image set.
7. The facial image beautification method according to claim 6, It is characterized in that The subtasks include a face beauty prediction task, a gender task, and a race task, and the beauty feature value also includes a gender score and a race classification score. The comprehensive results of the subtasks are trained according to preset weights to obtain the beauty feature value of each high-definition image in the high-definition image set, including: Assigning different weights to the face beauty prediction task, the gender task, and the race task, wherein the weight of the face beauty prediction task is greater than the weight of the gender task and the weight of the race task; Training an image set with known beauty feature values in the source image domain according to the weight of the face beauty prediction task, the weight of the gender task, and the weight of the race task to obtain a beauty degree model; The comprehensive results of the subtasks are input into the beauty degree model to obtain the beauty prediction score, gender score and race classification score of each high-definition image in the high-definition image set.
8. The facial image beautification method according to claim 7, It is characterized in that The step of inputting the comprehensive results of the subtasks into the beauty degree model to obtain a beauty prediction score, a gender score and a race classification score for each high-definition image in the high-definition image set further includes: Calculating according to a preset true beauty score and the beauty prediction score to obtain a face beauty prediction loss; The gender classification loss is calculated based on the first label of the preset gender task and the probability of the first label generated by the preset multi-task prediction network; The probability of generating the second label of the preset race task and the preset multi-task prediction network is calculated. Get racial classification loss; Calculating according to the face beauty prediction loss, the gender classification loss, the race classification loss, the weight of the face beauty prediction task, the weight of the gender task, and the weight of the race task, to obtain an overall loss of the multi-task prediction network; The beauty model is optimized according to the overall loss of the multi-task prediction network.
9. A facial image beautification system, It is characterized in that include: at least one memory; at least one processor; at least one program; The program is stored in the memory, and the processor executes at least one of the programs to implement: A facial image beautification method as claimed in any one of claims 1 to 8.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer-executable signal, wherein the computer-executable signal is used to execute: A facial image beautification method as claimed in any one of claims 1 to 8.
Citation Information
Patent Citations
Image processing method and device, computer equipment and storage medium
CN111127378A
Multi-dimensional task face beauty prediction method and system and storage medium
CN111695602A
Face image generation method based on content features and style features
CN112861805A
Makeup migration method based on adaptive instance normalization
CN114742693A
