Facial image processing method, device, and computer program
The use of a generative adversarial network to predict and process texture and shape differences in facial images enhances the flexibility and accuracy of age-altered facial images, achieving natural and smooth transitions.
Patent Information
- Application Number
- JP2023513667
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2020-11-02
- Filing Date
- 2021-10-08
- Publication Date
- 2024-10-08
- Estimated Expiration
- 2041-10-08
AI Technical Summary
Existing facial image processing methods lack flexibility and accuracy when altering the age of facial images, primarily due to the limitations in simulating age changes that result in unnatural or inaccurate transformations.
A method involving a generative adversarial network (GAN) to predict a texture difference map based on a specified age, followed by image processing to generate a second facial image with enhanced accuracy and natural transitions, utilizing a condition generation network, texture synthesis network, and deformation network to adjust facial features and hair color.
The method improves flexibility and accuracy in age-altered facial images by generating clear, natural, and smooth transitions across various age groups, ensuring realistic changes in facial texture and hair color.
Smart Images

Figure 0007562927000003 
Figure 0007562927000004 
Figure 0007562927000005
Abstract
Description
[Technical field]
[0001] This application claims priority from a Chinese patent application bearing application number 202011203504.5 and entitled "Facial image processing method, display method, device and apparatus" filed with the China Patent Office on November 2, 2020, the entire contents of which are incorporated herein by reference.
[0002] The present application relates to the technical field of image processing, and in particular to a facial image processing method, display method, device and computer program. [Background technology]
[0003] As machine learning technology continues to mature, more and more types of services based on machine learning technology are being developed. For example, a computer device can process a first face (human face) image through machine learning technology to obtain a second face image, in which a first age corresponding to a face in the first face image is different from a second age corresponding to a face in the second face image, but both correspond to the same identity (ID).
[0004] The computer device typically processes a first face image inputted by the computer through a machine learning model to obtain a second face image based on a first face image and a user's face age changing operation, in which the face age changing operation is used to instruct the computer device to make the face in the second face image younger or older.
[0005] However, when processing face images with the above-mentioned methods, it can only simply make face images younger or make face images older, so the flexibility and accuracy are relatively low when processing face images in the age dimension. Summary of the Invention [Problem to be solved by the invention]
[0006] An object of the present application is to provide a facial image processing method, display method, device, and computer program that can improve flexibility and accuracy when processing facial images in the age dimension. [Means for solving the problem]
[0007] According to one aspect of the present application, there is provided a method for processing a face image, the method comprising: Obtain a first face image; Invoke an age modification model to predict a texture difference map for the first facial image at a specified age, the texture difference map being used to reflect (indicate) a texture difference between the facial texture in the first facial image and the facial texture at the specified age; performing image processing on the first face image based on the texture difference map to obtain a second face image, the second face image being a face image of the face in the first face image under the specified age; and The method includes the step of outputting the second facial image.
[0008] According to another aspect of the present application, there is provided a method for displaying a face image, the method comprising: displaying a first facial image and an age change control, the age change control being a control for inputting a specified age; In response to a trigger operation on the age change control, an age change model is invoked to process the first face image based on the specified age corresponding to the trigger operation to obtain a second face image, the second face image being a face image of a face in the first face image under the specified age; and Displaying the second facial image is included.
[0009] According to another aspect of the present application, there is provided a method for training an age modification model, the method comprising: obtaining a sample image set, the sample image set including sample images and sample age labels for the sample images; determining a designated age, said designated age being a random age or said sample age label; Invoke a generator in a generative adversarial network to perform prediction on the sample image based on the specified age to obtain a predicted face image; Invoke a classifier in the generative adversarial network to calculate an adversarial loss for the predicted face image, and the adversarial loss is used to represent the loss of whether the predicted face image is a true face image; Invoke an age prediction model to predict a predicted age of the predicted face image, and calculate an age loss between the predicted age and the specified age; training the generator based on the adversarial loss and the age loss; and When a training end condition is satisfied, determining the generator as an age-modified model.
[0010] According to another aspect of the present application, there is provided an apparatus for processing a face image, the apparatus comprising: an acquisition module for obtaining a first facial image; a prediction module for invoking an age modification model to predict a texture difference map under a specified age of the first facial image, the texture difference map being used to reflect a texture difference between a facial texture in the first facial image and a facial texture of the specified age; The first processing module includes a first processing module for performing image processing on the first facial image based on the texture difference map to obtain a second facial image, the second facial image being a facial image of the face in the first facial image under the specified age.
[0011] Optionally, the age modification model includes a condition generation network layer and a texture synthesis network layer; The prediction module is used to call the condition generation network layer to make a prediction on the first face image based on the designated age, and output a texture difference map, the texture difference map is used to reflect a texture difference between a facial texture in the first face image and a facial texture of the designated age; The first processing module is used to call the texture synthesis network layer to register the texture disparity map with the first facial image to obtain the second facial image.
[0012] Optionally, the condition generating network layer is further adapted to output an attention map, the attention map being adapted to reflect weighting factors of the texture disparities corresponding to pixel points in the first face image; The first processing module is used to call the texture synthesis network layer to register the texture disparity map with the first facial image based on the attention map to obtain the second facial image.
[0013] Optionally, the age modification model further comprises a transformation network layer; The apparatus further includes a second processing module for invoking the deformation network layer to perform a deformation process on a face in the second face image.
[0014] Optionally, the condition generating network layer is further used to output a deformation information map, and the deformation information map is used to predict a shape change (face shape change) between the face in the first face image and the face at the specified age; The second processing module is used to call the deformation network layer to perform deformation processing on the face in the second face image based on the deformation information map.
[0015] Optionally, the deformation information map comprises corresponding displacement information of pixel points in a first direction and a second direction, the first direction and the second direction being perpendicular to each other; The second processing module is used for calling the deformation network layer to perform a bilinear displacement on the pixel point in the second face image according to the displacement information on the first direction and the second direction.
[0016] Optionally, the apparatus further comprises: a third processing module for performing image semantic segmentation on the second facial image to obtain a hair region in the second facial image; a calculation module for calculating, based on original color values of pixel points in the hair region, corresponding target color values of pixel points in the hair region under the specified age through mapping; and A replacement module is included for replacing the original color values of pixel points in the hair region with the target color values.
[0017] Optionally, the apparatus further comprises: a fourth processing module adapted to input the first face image into a face detection model to output face registration points in the first face image; and A fifth processing module is included for performing matting on the first face image through an affine transformation based on the face alignment points to obtain an aligned first face image.
[0018] Optionally, the apparatus further comprises a training module, and the age modification model is obtained by employing and training the training module; The training module includes: obtaining a sample image set, the sample image set including sample images and sample age labels for the sample images; determining a designated age, said designated age being a random age or said sample age label; Invoke a generator in a generative adversarial network to perform prediction on the sample image based on the specified age to obtain a predicted face image; Invoke a classifier in the generative adversarial network to calculate an adversarial loss for the predicted face image, the adversarial loss being used to represent the loss of whether the predicted face image is a true face image; Invoke an age prediction model to predict a predicted age of the predicted face image, and calculate an age loss between the predicted age and the specified age; training the generator based on the adversarial loss and the age loss; and When a training end condition is satisfied, the generator is used to determine the age-modified model.
[0019] Optionally, the training module further comprises: Invoke the age prediction model to perform age prediction on the sample image to obtain a sample age label for the sample image; and The sample images and sample age labels of the sample images are used to determine the sample image set.
[0020] Optionally, the training module further comprises: inputting the sample image into a face detection model to output face alignment points in the sample image; and This is used to perform matting on the sample image by affine transformation based on the face alignment points to obtain a post-alignment sample image.
[0021] Optionally, the generator comprises a conditional generative network layer and a texture synthesis network layer; The training module includes: Invoke the condition generating network layer to make predictions for the sample images based on the designated age and output the texture difference map, the texture difference map being used to reflect texture differences between faces in the sample images and faces at the designated age; and The texture synthesis network layer is used to invoke the registration of the texture disparity map with the sample image to obtain the predicted face image.
[0022] Optionally, the conditional generative network layer is further adapted to output an attention map, the attention map being adapted to reflect weighting factors of the texture disparities corresponding to pixel points in the sample image; The training module is used to invoke the texture synthesis network layer to register the texture disparity map with the sample image based on the attention map to obtain the predicted face image.
[0023] Optionally, the generator further comprises a transformation network layer; The training module is used to invoke the deformation network layer to perform deformation processing on the face in the predicted face image.
[0024] Optionally, the condition generating network layer is further adapted to output a deformation information map, the deformation information map being adapted to predict shape changes between a face in the sample image and a face at the specified age; The training module is used to call the deformation network layer to perform deformation processing on the face in the predicted face image based on the deformation information map.
[0025] Optionally, the deformation information map comprises corresponding displacement information of pixel points in a first direction and a second direction, the first direction and the second direction being perpendicular to each other; The training module is used to invoke the deformation network layer to perform bilinear displacement on the pixel points in the predicted face image based on the displacement information on the first direction and the second direction.
[0026] According to another aspect of the present application there is provided a display device for a face image, said device comprising: a display module for displaying a first facial image and an age change control, the age change control being a control for inputting a specified age; and a processing module for calling an age change model in response to a trigger operation on the age change control, and processing the first face image based on the designated age corresponding to the trigger operation to obtain a second face image, the second face image being a face image of a face in the first face image under the designated age; A display module is used for displaying the second facial image.
[0027] Optionally, the display module is adapted to display the second facial image and the designated age.
[0028] According to another aspect of the present application, there is provided an age modification model training device, the device comprising: an acquisition module for acquiring a set of sample images, the set of sample images including sample images and sample age labels for the sample images; a first determination module for determining a designated age, the designated age being a random age or the sample age label; a prediction module for invoking a generator in a generative adversarial network to perform prediction on the sample image based on the specified age to obtain a predicted face image; a first calculation module for calling a classifier in the generative adversarial network to calculate an adversarial loss for the predicted face image, the adversarial loss being used to represent a loss as to whether the predicted face image is a true face image; a second calculation module used for invoking an age prediction model to predict a predicted age of the predicted face image, and calculating an age loss between the predicted age and the specified age; a training module for training the generator based on the adversarial loss and the age loss; and A second determination module for determining the generator as an age-modified model when a training end condition is satisfied.
[0029] According to another aspect of the present application, there is provided a computer device, the computer device including a processor and a memory, the memory storing at least one instruction, at least one program, code set or instruction set, the at least one instruction, the at least one program, code set or instruction set being loaded and executed by the processor to realize the method for processing facial images, the method for displaying facial images or the method for training an age modification model as described in the above aspect.
[0030] According to another aspect of the present application, there is provided a computer-readable storage medium having at least one program code stored therein, the program code being loaded and executed by a processor to realize the method for processing a facial image, the method for displaying a facial image, or the method for training an age modification model as described in the above aspect.
[0031] According to another aspect of the present application, there is provided a computer program product or computer program, the computer program product or computer program comprising computer instructions, the computer instructions being written on a computer-readable storage medium, a processor of a computer device reading the computer instructions from the computer-readable storage medium, and the processor executing the computer instructions, thereby causing the computer device to perform the method for processing a facial image, the method for displaying a facial image, or the method for training an age modification model, as provided in various possible implementations of the above-mentioned aspects. Effect of the Invention
[0032] The technical solutions provided by the embodiments of the present application at least have the following advantageous effects:
[0033] The first face image can be processed by the age modification model to generate and output a second face image based on a designated age, the second face image being a face image of the face in the first face image under the designated age, that is, the face image can be changed based on a user-defined designated age or a system-predefined designated age, so that the flexibility and accuracy of processing face images in the age dimension can be improved, and a clear, natural and smooth transition video for all age groups can be realized. [Brief description of the drawings]
[0034] [Figure 1] FIG. 2 illustrates the configuration of an age change model provided by one exemplary embodiment of the present application. [Diagram 2] 1 is a flowchart of a face image processing method provided by an embodiment of the present application. [Diagram 3] 1 is a flowchart of a face image processing method provided by an embodiment of the present application. [Figure 4] FIG. 13 illustrates an implementation process of processing a first face image based on a designated age provided by an embodiment of the present application. [Diagram 5] FIG. 2 illustrates a process of processing a first face image provided by an embodiment of the present application. [Figure 6] 4 is a flowchart of a face image display method provided by an embodiment of the present application. [Figure 7] FIG. 2 illustrates a user interface displaying a first facial image and an age change control provided by an embodiment of the present application. [Figure 8] FIG. 2 illustrates a user interface displaying a first facial image and an age change control provided by an embodiment of the present application. [Figure 9] FIG. 2 is a diagram showing a second face image provided by an embodiment of the present application. [Figure 10] FIG. 13 is a diagram illustrating a user interface for displaying a second face image provided by an embodiment of the present application. [Figure 11]1 is a flowchart of a method for training an age modification model provided by an embodiment of the present application. [Figure 12] 1 is a flowchart of another age modification model training method provided by an embodiment of the present application. [Figure 13] FIG. 1 illustrates a realization process of making predictions on sample images provided by an embodiment of the present application. [Figure 14] FIG. 2 is a diagram showing an implementation process of pre-processing a face image provided by an embodiment of the present application. [Figure 15] FIG. 13 illustrates an implementation process of age modification for face images provided by an embodiment of the present application. [Figure 16] FIG. 1 is a diagram showing the configuration of a face image processing device provided by an embodiment of the present application. [Figure 17] FIG. 1 is a diagram showing the configuration of a face image processing device provided by an embodiment of the present application. [Figure 18] FIG. 1 is a diagram showing the configuration of a face image processing device provided by an embodiment of the present application. [Figure 19] FIG. 1 is a diagram showing the configuration of a face image processing device provided by an embodiment of the present application. [Figure 20] FIG. 1 is a diagram showing the configuration of a face image processing device provided by an embodiment of the present application. [Figure 21] FIG. 2 is a diagram showing the configuration of a face image display device provided by an embodiment of the present application. [Figure 22] FIG. 2 is a diagram showing the configuration of a training device for an age change model provided by an embodiment of the present application. [Figure 23] FIG. 13 is a diagram showing the configuration of another age change model training device provided by an embodiment of the present application. [Figure 24] FIG. 2 is a diagram showing the configuration of a terminal provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0035] First, terms (nouns) related to the embodiments of the present application will be introduced.
[0036] Generative Adversarial Networks: Generative Adversarial Networks (GANs) usually include one generator (G) and one discriminator (D). The generator and discriminator compete with each other to realize unsupervised learning. The generator randomly takes samples from the latent space as input, and the output must mimic the true samples (also called real samples or actual samples) in the training set as much as possible. The input of the discriminator is the true sample or the output of the generator, and its goal is to use the output of the generator as an input sample and distinguish it as much as possible from all input samples including the true sample. Meanwhile, the generator needs to deceive the discriminator as much as possible. By forming an adversarial relationship between the generator and the discriminator, the parameters are continuously adjusted, and finally a picture that is indistinguishable from the real one is generated, completing the training of the model.
[0037] Image Semantic Segmentation: Image semantic segmentation is a very important area of computer vision, which refers to identifying input images at pixel level and labeling each pixel in the image with the target category (class) it belongs to. For example, using a neural network to distinguish each element in a picture containing a face (including hair, face, five senses, glasses, neck, clothes, background, etc.).
[0038] Color Lookup Table: A Color Lookup Table (LUT) allows you to find the corresponding color of another color based on the actual color you get.
[0039] Artificial intelligence cloud service: This is the so-called artificial intelligence cloud service, commonly referred to as AIaaS (AI as a Service). This is the current mainstream service mode of artificial intelligence platforms. Specifically, the AIaaS platform divides some common AI services and provides independent or packaged services on the cloud. Such a service model is similar to opening an AI-themed mall, where all developers can access and use one or more artificial intelligence services (e.g., face image processing based on a specified age) provided by the platform in the form of an application programming interface (API), and some advanced developers can even use the AI framework and AI infrastructure provided by the platform to deploy and maintain their own cloud artificial intelligence services.
[0040] 1 is a diagram illustrating the configuration of an age change model 101 provided by one exemplary embodiment of the present application. As shown in FIG. 1, the age change model 101 includes a condition generation network layer 1011, a texture synthesis network layer 1012, and a transformation network layer 1013.
[0041] The terminal or client can output a texture difference map 105, an attention map 106, and a deformation information map 107 based on the input first face image 104 and the specified age through the condition generation network layer 1011. The terminal or client is used to provide a function of changing the face image based on the specified age, and the age change model 101 can be called by the terminal or client. The age change model 101 may be provided in the terminal, in the server, or implemented as a cloud service. The terminal and the server may be collectively referred to as a computing device.
[0042] The texture difference map 105 is used to reflect the texture difference between the face texture in the first face image 104 and the face texture of the designated age, the attention map 106 is used to reflect the weight coefficient of the texture difference corresponding to the pixel point in the first face image 104, and the deformation information map 107 includes the corresponding displacement information of the pixel point in the first face image 104 in the first direction and the second direction, the first direction and the second direction are perpendicular to each other (for example, horizontal and vertical). Then, the terminal or client calls the texture synthesis network layer 1012 to superimpose the texture difference map 105 and the first face image 104 according to the attention map 106 to obtain a second face image. Then, the deformation network layer 1013 is called to perform bilinear displacement on the pixel point in the second face image according to the displacement information in the first direction and the second direction to perform deformation on the face in the second face image, to obtain the output second face image 108. The terminal or client can output face images 109 under different designated ages of the first face image 104 based on the first face image 104 according to different designated ages.
[0043] Optionally, the terminal or client may further perform pre-processing on the first face image 104 before inputting the first face image 104 to the age change model 101. The pre-processing includes inputting the first face image 104 to a face detection model to output face alignment points in the first face image. Then, based on the face alignment points, matting is performed on the first face image 104 by affine transformation to obtain an aligned first face image. The terminal or client further performs image semantic segmentation on the second face image 108 to be outputted, thereby obtaining a hair region in the second face image to be outputted. Then, based on the original color values of the pixel points in the hair region, the terminal or client calculates the corresponding target color values of the pixel points in the hair region under the specified age by mapping, and replaces the original color values of the pixel points in the hair region with the target color values to obtain a second face image whose hair color is dynamically changed based on the second face image 108 to be outputted. When extracting features of the first face image 104 by the condition generating network layer 1011 , the terminal or client can incorporate the specified age into the features extracted by the multiple feature extraction layers in the condition generating network layer 1011 .
[0044] The age modification model 101 and the classifier 102 can form a generative adversarial network, and at this time, the age modification model 101 may be called a generator in the generative adversarial network. When training the generator, the computer device obtains a sample image, and also randomly generates a designated age, or the age corresponding to the sample image predicted by the age prediction model 103 is set as the designated age. Then, the generator (age modification model 101) is called to perform prediction on the sample image based on the designated age to obtain a predicted face image, and the predicted face image is a face image of the face in the sample image under the designated age. Note that the process of predicting a predicted face image corresponding to the sample image based on the designated age can be referred to the process of outputting the second face image 108 by the age modification model 101 described above, and a detailed description thereof will be omitted here. Then, the computer device calls the classifier 102 to calculate the adversarial loss of the predicted face image, and the adversarial loss is used to represent the loss of whether the predicted face image is a true face image. Then, the age prediction model 103 is called to predict the predicted age of the predicted face image, and the age loss between the predicted age and the designated age is calculated. Thereby, a generator is trained based on the adversarial loss and the age loss. Then, when the training end condition is satisfied (e.g., the generator is stable and converged), the generator is determined as the age modification model 101. Wherein, the computer device can call the age modification model 101, the discriminator 102 and the age prediction model 103. The above-mentioned client can be installed in the computer device, and the computer device can send the age prediction model 103 after training to the client, or the client can call the age modification model 101 by the computer device. Optionally, the computer device may further pre-process the sample image before inputting the sample image into the generator. The pre-processing includes inputting the sample image into a face detection model to have the face alignment points in the sample image output. Then, the sample image is matted by affine transformation based on the face alignment points to obtain an aligned sample image.This pre-processing of the sample image is the same as the pre-processing performed on the first facial image 104 before processing the first facial image 104 using the age modification model 101, which can improve the accuracy of the model output and reduce the difficulty of training.
[0045] The first facial image can be processed by the age modification model to generate a second facial image based on a designated age, the second facial image being a facial image of the face in the first facial image under the designated age, so that the facial image can be modified based on a user self-defined designated age or a system pre-set designated age, thereby improving flexibility and accuracy when processing facial images in the age dimension.
[0046] 2 is a flowchart of a face image processing method provided by an embodiment of the present application. The method can be applied to a computer device or a client on a computer device. As shown in FIG. 2, the method includes the following steps:
[0047] Step 201: Obtain a first face image.
[0048] The first face image is derived from a photo or a video frame in a video. The first face image may be any image containing face information. Optionally, the first face image includes the five senses of the face, and the resolution of the first face image is 720P, 1080P, 4K, etc. The first face image is a photo uploaded by a user on a client or a video frame uploaded by a user on a video upload, or a photo taken by a computer device where the client is located or a video frame in a photo or video acquired by a client through another computer device.
[0049] The client is used to provide a function of processing face images based on a designated age. Illustratively, the client is a short video client, a song client, a live broadcast client, a social client, a game client, an applet, and a web client. A user can use the function by installing the client, or by accessing a website corresponding to the client.
[0050] The client obtains the first face image by taking a picture, or by reading a photo or video in a photo album, or receives the first face image transmitted by another device. Optionally, the client displays the first face image after obtaining the first face image.
[0051] Step 202: Invoke the age modification model to predict the texture difference map under the specified age of the first face image.
[0052] The designated age may be determined by the client based on a user's input of the designated age or may be generated by the client, and optionally the client obtains the designated age based on the user's triggering of an age change control displayed in a user interface displaying the first facial image, and invokes an age change model to process the first facial image based on the designated age.
[0053] The texture difference map is used to reflect the texture difference between the face texture in the first face image and the face texture of the specified age. The texture difference includes at least a facial skin texture feature difference, a hair color feature difference, and a beard feature difference. When the specified age is smaller than the age corresponding to the face in the sample image, the facial skin texture feature difference is used to make the facial skin smoother and more delicate, the hair color feature difference is used to darken the hair color, and the beard feature difference is used to remove the beard. When the specified age is larger than the age corresponding to the face in the sample image, the facial skin texture feature difference is used to increase the wrinkles on the face, the hair color feature difference is used to whiten the hair color, and the beard feature difference is used to whiten the beard. For example, when the age corresponding to the face in the first face image is 21 years old and the specified age is 50 years old, the texture difference map includes texture information corresponding to increasing wrinkles, texture information corresponding to whitening the hair color, and texture information corresponding to whitening the beard.
[0054] Step 203: Perform image processing on the first face image based on the texture difference map to obtain a second face image.
[0055] The second face image is a face image of the face in the first face image under the designated age. The age corresponding to the face in the first face image is the same as or different from the designated age. For example, a user uploads a photo of himself / herself at age 21 in a client, and inputs age 50 through an age change control. The client calls an age change model to process the photo at age 21, thereby obtaining a corresponding photo of the user at age 51 of the photo at age 21.
[0056] Optionally, the second face image is obtained by the client performing image processing on the first face image based on the texture difference map using an age modification model. The client further predicts a shape change between the face in the first face image and a face at a specified age using an age modification model, and processes the first face image based on the face shape change to obtain a more accurate second face image. Illustratively, the age modification model is based on Convolutional Neural Networks (CNN).
[0057] The age modification model is deployed in a client or in a computer device connected to the client. The computer device is a server, which may be an independent physical server, a server group consisting of multiple physical servers, or a distributed system, and may be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, Content Delivery Network (CDN), big data, and artificial intelligence platforms. When the age modification model is deployed in a computer device connected to the client, the client calls the age modification model to process the first face image based on the specified age through an interface provided by the computer device for calling the age modification model. Alternatively, the client sends the first face image and the specified age to the computer device, and the computer device calls the age modification model to process the first face image based on the specified age, and then sends the obtained second face image to the client.
[0058] Step 204: Output the second face image.
[0059] After the client processes the first face image to obtain a second face image, the client can output the second face image, for example, display the second face image. Optionally, the client displays the first face image and the second face image in different user interfaces, or displays the first face image and the second face image in the same user interface. For example, the client displays the first face image and the second face image superimposed on the same display area in the user interface, and a display dividing line is further displayed in the display area. The client displays the first face image on one side of the display dividing line, and the second face image on the other side. In response to a moving operation on the display dividing line, the display areas of the first face image and the second face image displayed by the client in the display area can be changed. This allows the client to realize the display of a user interface for comparing the difference between the first face image and the second face image.
[0060] Optionally, the client further displays the specified age when displaying the second facial image.
[0061] In summary, the method provided by the embodiment of the present application is to process a first face image according to an age modification model to generate and display a second face image based on a designated age, the second face image being a face image of the face in the first face image under the designated age, that is, the face image can be changed based on a user self-defined designated age or a system pre-set designated age, so that the flexibility and accuracy of processing face images in the age dimension can be improved, and furthermore, a clear, natural and smooth transition animation for all age groups can be realized.
[0062] 3 is a flowchart of another face image processing method provided by an embodiment of the present application. The method can be applied to a computer device or a client on a computer device. As shown in FIG. 3, the method includes the following steps:
[0063] Step 301: Obtain a first face image.
[0064] The first face image is derived from a video frame in a photo or video, for example, a photo or video frame in a video uploaded by a user at a client, or a video frame in a photo or video taken by a computer device where the client is located, or a video frame in a photo or video acquired by the client through another computer device. The client is used to provide a function of processing the face image based on a designated age.
[0065] Step 302: Invoke the age modification model to perform prediction on the first face image based on the specified age to obtain a second face image.
[0066] The second face image is a face image of the face in the first face image under the designated age. The client calls the age modification model to predict the texture difference map of the first face image under the designated age, and performs image processing on the first face image based on the texture difference map to obtain the second face image. Alternatively, the client calls the age modification model to predict the texture difference map of the first face image under the designated age and the shape change between the face in the first face image and the face at the designated age, and processes the first face image based on the texture difference map and the face shape change to obtain the second face image. Among them, the texture difference map is used to reflect the texture difference between the face texture in the first face image and the face texture at the designated age.
[0067] Optionally, when the client processes the first face image, the client can further perform pre-processing on the first face image, where the pre-processing includes inputting the first face image into a face detection model to output face alignment points in the first face image. Then, the client performs matting on the first face image by affine transformation based on the face alignment points to obtain an aligned first face image. The face detection model is the same as the model for performing pre-processing on the sample image when training the age modification model. The client uses a warpAffine function (a public function interface for realizing image rotation and translation) to realize matting on the first face image by affine transformation. Then, the client calls the age modification model to process the first face image after matting based on the specified age to obtain a second face image corresponding to the first face image after matting. Then, the client performs an inverse transformation of the affine transformation on the second face image to obtain a second face image for output.
[0068] The age-altering model integrates an efficient network structure module (e.g., MobileNet, CBAM module), and adopts model compression and pruning technology and optimization methods to optimize the performance of the age-altering model, thus reducing the memory space occupied by the age-altering model and improving the speed at which the age-altering model processes the first face image.
[0069] Optionally, the age modification model includes a condition generation network layer and a texture synthesis network layer. The age modification model may further include a deformation network layer. As shown in FIG. 4, the realization process of step 302 includes steps 3021 to 3023 as follows.
[0070] In step 3021, a condition generating network layer is invoked to make a prediction for the first face image based on the specified age, and output a texture disparity map.
[0071] The texture difference map is used to reflect the texture difference between the facial texture in the first facial image and the facial texture of the specified age. The texture difference includes at least one of facial skin texture feature difference, hair color feature difference, and beard feature difference. In the process of extracting features of the first facial image by the condition generating network layer and obtaining the texture difference map by prediction, the client can fuse the specified age with the features extracted by multiple feature extraction layers in the condition generating network layer. This can improve the accuracy of the output texture difference.
[0072] In step 3022, a texture synthesis network layer is invoked to register the texture disparity map with the first facial image to obtain a second facial image.
[0073] Optionally, the condition generating network layer is further used to output an attention map, and the attention map is used to reflect the weighting coefficients of the texture disparity corresponding to the pixel points in the first face image. The client calls the texture synthesis network layer to obtain a second face image by overlapping the texture disparity map with the first face image based on the attention map. Optionally, when overlapping the texture disparity map with the sample image based on the attention map, the weighting coefficients determined based on the pixel points in the texture disparity map, the pixel points in the first face image, the pixel points in the second face image, and the attention map are:
[0074]
number
[0075] In step 3023, a deformation network layer is called to perform deformation processing on the face in the second face image.
[0076] Optionally, the condition generation network layer is further used to output a deformation information map, which is used to predict the shape change between the face in the first face image and the face at the specified age. The client can call the deformation network layer to perform deformation processing on the face in the second face image according to the deformation information map.
[0077] Optionally, the deformation information map includes corresponding displacement information of the pixel points in a first direction and a second direction, the first direction and the second direction being perpendicular to each other, and the client can realize the deformation process for the second face image by invoking the deformation network layer to perform bilinear displacement on the pixel points in the second face image according to the displacement information in the first direction and the second direction.
[0078] For example, the first face image is an RGB image, in which the first face image includes three channels (red, green and blue). The texture difference map output by the texture generation network layer based on the first face image also includes three channels (red, green and blue), the attention map includes one channel (weight coefficient), and the deformation information map includes two channels (first direction displacement information and second direction displacement information).
[0079] For example, FIG. 5 is a diagram showing a process of processing a first face image provided by an embodiment of the present application. As shown in FIG. 5, the client can call a condition generation network layer in the age change model to process a first face image 501 based on a specified age, thereby obtaining a texture difference map 502, a deformation information map 504, and an attention map. The client can obtain a second face image 503 whose texture is changed by superimposing the first face image 501 and the texture difference map 502 based on the attention map through a texture synthesis network layer. Then, the deformation network layer can perform a deformation process on the second face image 503 whose texture is changed based on the deformation information map 504, thereby obtaining a second face image 505 after deformation.
[0080] In addition, the client can process the first face image through the age modification model to output a second face image obtained by changing only the texture, or can output the second face image obtained by changing the texture and performing deformation.
[0081] Step 303: Process the color of the hair region in the second face image.
[0082] The second face image is a second face image obtained by changing texture, or a second face image obtained by changing texture and deformation. In order to ensure that the facial hair color in the output second face image is more realistic, the client can further process the color of the hair area in the second face image. Specifically, the following is included:
[0083] The second face image is subjected to image semantic segmentation to obtain a hair region in the second face image. The client can obtain an image mask corresponding to the hair region by performing image semantic segmentation on the second face image. In the image mask, the pixel points in the hair region in the second face image have a value of 1, and the pixel points in the region other than the hair region have a value of 0. The hair region can be obtained by multiplying the image mask by the second face image. Then, the client can calculate a corresponding target color value of the pixel points in the hair region under a specified age by mapping based on the original color value of the pixel points in the hair region. Then, the second face image after hair color replacement can be obtained by replacing the original color value of the pixel points in the hair region with the target color value. Optionally, the client can realize the calculation of the target color value by mapping based on the original color value and the specified age by a conditional color lookup table (Conditional LUT). The condition refers to that the original color value corresponds to different target color values for different ages.
[0084] Step 304: Output the second face image.
[0085] The client outputs a second facial image. For example, the client displays the second facial image in a user interface displaying the first facial image and an age change control, i.e., the client displays the first and second facial images in the same user interface. Alternatively, the client displays the first and second facial images, respectively, in different user interfaces. Optionally, the client further displays a specified age corresponding to the second facial image in the user interface displaying the second facial image.
[0086] In summary, the method provided by the embodiment of the present application can process a first face image according to an age modification model to generate and display a second face image based on a designated age, the second face image being a face image of the face in the first face image under the designated age, that is, the face image can be changed based on a user self-defined designated age or a system pre-set designated age, thus improving the flexibility and accuracy when processing face images in the age dimension.
[0087] Furthermore, by performing texture modification and deformation processing on the first face image and superimposing the texture difference map on the input original image, the clarity of the output face image can be maintained. By further performing hair color processing on the face image after the texture modification and deformation processing, the hair color of the final output face image can be made more realistic, so that the hair color of the face image can match the specified age.
[0088] 6 is a flowchart of a face image display method provided by an embodiment of the present application. The method can be applied to a computer device or a client on a computer device. As shown in FIG. 6, the method includes the following steps:
[0089] Step 601: Display a first face image and an age change control.
[0090] The first facial image is derived from a photo or a video frame in a video. The first facial image may be any image containing facial information, such as a photo or a video frame in a video uploaded by a user at a client, a video frame in a photo or a video captured by a computer device where the client is located, or a video frame in a photo or video acquired by the client through another computer device. The client is used to provide a function of processing the facial image based on a designated age.
[0091] The age change control is a control for inputting a specified age. For example, the age change control includes an age input frame, the age control includes an age selection frame, or the age control includes an age display bar and an element for indicating the specified age superimposed on the age display bar.
[0092] The client displays the first facial image and an age change control in the same user interface, which is used to provide a function for processing the first facial image based on a specified age, and further displays an image upload control in the user interface, which is used to upload the first facial image.
[0093] For example, Fig. 7 is a diagram showing a user interface displaying a first face image and an age change control provided by an embodiment of the present application. As shown in Fig. 7, a first user interface 701 displays a first face image 702 uploaded by a user with an image upload button 704. The first user interface 701 is a user interface for providing a function of processing a face image based on a designated age at a client. The first user interface 701 further displays an age input box 703. According to an input operation in the age input box 703, the client can obtain the designated age.
[0094] 8 is a diagram showing another user interface displaying a first face image and an age change control provided by an embodiment of the present application. As shown in FIG. 8, in the second user interface 801, a video frame 802 in a video captured in real time by a computer device where a client is located is displayed, and the video frame 802 includes a face image. The second user interface 801 is a user interface for processing a video captured in real time in a client. When the client receives a click operation on a button 803 of an age change function in the second user interface 801, the client may display an age drag bar 804. Then, in response to a slide operation on an element on the age drag bar 804 for indicating a selected designated age, the client can obtain the designated age and display the designated age on the element.
[0095] Step 602: In response to a trigger operation on the age change control, process the first facial image to obtain a second facial image based on a specified age corresponding to the trigger operation.
[0096] The second face image is a face image of the face in the first face image under the designated age. When the client receives a trigger operation on the age change control, the client can adopt the method in the above embodiment to call the age change model to process the first face image according to the designated age to obtain the second face image. The age change model can be the age change model mentioned in the above embodiment.
[0097] Optionally, when the age change control includes an age input frame, the age change control further includes a decision (confirmation) control. When the client receives a touch operation on the decision control, the client can obtain the designated age input in the input frame and determine that the trigger operation has been received. When the age control includes an age selection frame, the age change control also includes a decision control. When the client receives a touch operation on the decision control, the client can receive the designated age selected by the selection frame and determine that the trigger operation has been received. Alternatively, when the age control includes an age display bar and an element for indicating the designated age superimposed on the age display bar, the client can receive a touch operation on the element for indicating the designated age (e.g., dragging to slide left or right), the client can receive the designated age indicated by the element and determine that the trigger operation has been received.
[0098] For example, continue to refer to Fig. 7. When the client receives an input operation on the age input box 703, the client receives the designated age input in the input operation, and calls the age change model to process the first face image according to the designated age.
[0099] For example, still referring to Fig. 8, when the client receives a slide operation on an element for indicating a selected designated age on the age drag bar, the client receives the designated age currently indicated by the element, and calls the age change model to process the first face image based on the designated age.
[0100] Step 603: The second face image is displayed.
[0101] The client displays the second facial image in a user interface displaying the first facial image and an age change control, i.e., the client displays the first and second facial images in the same user interface. Alternatively, the client displays the first and second facial images, respectively, in different user interfaces. Optionally, the client may further display a specified age corresponding to the second facial image in the user interface displaying the second facial image.
[0102] For example, Fig. 9 is a diagram showing the display of a second face image provided by an embodiment of the present application. As shown in Fig. 9, based on a first face image 901 uploaded by a user, the client invokes an age change model to process the first face image 901 according to a plurality of predetermined designated ages respectively, and obtains face images 902 under a plurality of different designated ages of the first face image 901. In addition, the client can further display on each displayed face image an age 903 corresponding to the face in the face image.
[0103] 10 is a diagram showing a user interface for displaying a second face image provided by an embodiment of the present application. As shown in FIG. 10, in the second user interface 801, a video frame 802 in a video captured in real time by a computer device where a client is located is displayed, and the video frame 802 includes a face image. The client calls an age change model to process the video frame 802 based on a specified age obtained by an age drag bar 804, to obtain a target video frame 805, and then performs superimposition display of the video frame 802 and the target video frame 805. The target video frame 805 includes a face image obtained by processing the face image in the video frame 802. A display dividing line 806 is further displayed in the second user interface 801. The client displays the video frame 802 on the left side of the display dividing line 806, and displays the target video frame 805 on the other side. Depending on a slide operation on the display dividing line 806, the display areas of the video frame 802 and the target video frame 805 displayed by the client may change. For example, when the display division line 806 is slid to the left, the area of the video frame 802 displayed by the client decreases, and the area of the target video frame 805 displayed increases. When the display division line 806 is slid to the right, the area of the video frame 802 displayed by the client increases, and the area of the target video frame 805 displayed decreases.
[0104] In summary, the method provided by the embodiment of the present application can process a first face image based on a designated age through an age change model according to a trigger operation on an age change control, thereby obtaining and displaying a second face image of the face in the first face image under the designated age. That is, the face image can be changed based on a user-defined designated age or a system-predefined designated age, thereby improving the flexibility and accuracy when processing face images in the age dimension.
[0105] 11 is a flow chart of a method for training an age modification model provided by an embodiment of the present application. The method can be applied to a computer device or a client on a computer device. As shown in FIG. 11, the method includes the following steps:
[0106] Step 1101: Get a sample image set.
[0107] The sample image set includes sample images and sample age labels for the sample images. Optionally, the sample image set includes sample images of different faces. The sample image set is determined by an administrator providing a face image processing service. A computer device trains an age-alteration model based on the sample image set, the computer device is configured with the age-alteration model, or the computer device can remotely invoke the age-alteration model.
[0108] The computer device obtains the sample age label by predicting the age of the sample image with an age prediction model based on CNN and trained with samples of face images of different ages and different identities and known ages corresponding to the face images.
[0109] Step 1102: Determine a designated age, where the designated age is a random age or a sample age label.
[0110] When the designated age is a random age, the designated age is randomly generated by the computer device, for example, the computer device randomly generates a number between 10 and 80 and determines it as the designated age. Optionally, the computer device can further obtain an age selected by an administrator to be the designated age.
[0111] Step 1103: A generator in the generative adversarial network is called to perform prediction on the sample image based on the specified age to obtain a predicted face image.
[0112] The predicted face image is a face image of the face in the sample image under the specified age. The generator in the adversarial network is an age modification model. Optionally, the computer device calls the generator to predict a texture difference map under the specified age of the sample image, and performs image processing on the sample image based on the texture difference map to obtain a predicted face image. Alternatively, the computer device calls the generator to predict a texture difference map under the specified age of the sample image and a shape change between the face in the sample image and the face at the specified age, and processes the sample image based on the texture difference map and the face shape change to obtain the predicted face image. Wherein, the texture difference map is used to reflect the texture difference between the face texture in the sample image and the texture of the face at the specified age. The generator is based on CNN.
[0113] Step 1104: Invoke a classifier in the generative adversarial network to calculate the adversarial loss of the predicted face image.
[0114] The generator and the classifier constitute a generative adversarial network. The classifier is used to determine whether an input image is an image generated by the generator or a true image, thereby generating an adversarial relationship between the generator and the classifier. The computer device can input a predicted face image to the classifier and calculate the adversarial loss by obtaining a judgment of whether the predicted face image is a true image, which is predicted by the classifier. The adversarial loss is used to represent the loss of whether the predicted face image is a true face image. The computer device can further input a sample image to the classifier and train the classifier based on the judgment of whether the sample image is a true image, which is output by the classifier. The classifier is based on CNN.
[0115] Step 1105: Invoke the age prediction model to predict the predicted age of the predicted face image, and calculate the age loss between the predicted age and the specified age.
[0116] The age prediction model may be the same as or different from the age prediction model for predicting the sample age label. The computer device inputs a predicted face image into the age prediction model, which outputs a predicted age for the face in the predicted face image, and calculates an age loss based on the predicted age and the assigned age. The age loss can reflect the difference between the predicted age and the assigned age.
[0117] Step 1106: Train a generator based on the adversarial loss and the age loss.
[0118] The computer device adopts gradient backpropagation based on the adversarial loss to train the generator, and adopts gradient backpropagation based on the age loss to train the generator. The computer device alternately trains the generator based on the adversarial loss and the age loss, or trains the generator simultaneously. Wherein, the adversarial loss can make the generator generate an image closer to the real face image, and the age loss can make the difference between the age reflected by the face in the face image generated by the generator and the specified age smaller.
[0119] Step 1107: When the training end condition is satisfied, determine the generator as the age-modified model.
[0120] The training end condition includes that the parameters of the generator obtained by adjusting according to backpropagation based on the adversarial loss and the age loss can make the generator stable and converge. Alternatively, the training end condition may be determined by the manager who trains the generator. The above-mentioned discriminator and age prediction model are mainly used by a computer device to train the generator. When completing the training of the generator, the computer device obtains the trained generator and determines it as the age modification model.
[0121] After the computer device has completed training the age modification model, the computer device can embed the age modification model in a client or provide an interface for calling the age modification model to the outside, thereby providing a service of processing face images according to a specified age to the outside. Optionally, the computer device is a server, specifically, it can be an independent physical server, a server group consisting of multiple physical servers, or a distributed system, and further it can be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDNs, big data, and artificial intelligence platforms. The computer device that trains the age modification model is the same as or different from the computer device that installs the client.
[0122] In summary, the method provided by the embodiment of the present application can obtain an age modification model by training a generator with a sample image set and a designated age. The age modification model is trained based on adversarial loss and age loss, so that the face image can be modified based on a user self-defined designated age or a system pre-set designated age, and the flexibility and accuracy can be improved when processing face images in the age dimension.
[0123] Figure 12 is a flow chart of another method for training an age modification model provided by an embodiment of the present application. The method can be applied to a computer device or a client on a computer device. As shown in Figure 12, the method includes the following steps:
[0124] Step 1201: Obtain a sample image set.
[0125] The sample image set includes sample images and sample age labels for the sample images. Optionally, the sample image set includes sample images of different faces. The sample image set is determined by an administrator providing a face image processing service. A computing device trains an age-altering model based on the sample image set, and the computing device can deploy the age-altering model or remotely invoke the age-altering model on the computing device.
[0126] The computer device calls the age prediction model to perform age prediction on the sample images to obtain sample age labels for the sample images, and then determines the sample images and sample age labels for the sample images as the sample image set. The age prediction model is based on CNN and can be obtained by training with samples of face images of different ages and different identities and the known ages corresponding to the face images.
[0127] Step 1202: Pre-processing is performed on the sample image set.
[0128] The computer device inputs the sample image into a face detection model to output face alignment points in the sample image. Then, the sample image is matted based on the face alignment points by affine transformation to obtain an aligned sample image. The face detection model is used to determine facial features contained in the sample image to obtain face alignment points that can reflect the facial features. The face detection model is obtained by training with training samples including facial five senses features. The face alignment points include pixel points in the sample image for indicating the facial five senses. The computer device can use a warpAffine function to realize matting the sample image by affine transformation.
[0129] Step 1203: Determine a designated age, where the designated age is a random age or a sample age label.
[0130] When the designated age is a random age, the designated age is randomly generated by the computer device, for example, the computer device randomly generates a number between 10 and 80 and determines it as the designated age. Optionally, the computer device can further obtain an age selected by an administrator as the designated age.
[0131] Step 1204: A generator in the generative adversarial network is called to make a prediction on the sample image based on the specified age to obtain a predicted face image.
[0132] The generator in the generative adversarial network is an age modification model. The computer device calls the generator to predict the texture difference between the face texture in the sample image and the face texture of the specified age, and performs image processing on the sample image based on the face texture difference to obtain a predicted face image. Alternatively, the computer device calls the generator to predict the texture difference between the face texture in the sample image and the face texture of the specified age, and the shape change between the face in the sample image and the face of the specified age, and processes the sample image based on the face texture difference and the face shape change to obtain the predicted face image.
[0133] Optionally, the generator includes a conditional generation network layer and a texture synthesis network layer. The generator may further include a deformation network layer. As shown in FIG. 13, the realization process of step 1204 includes steps 12041 to 12043 as follows.
[0134] In step 12041, a conditional generative network layer is invoked to make predictions on the sample images based on the specified age and output a texture disparity map.
[0135] The texture difference map is used to reflect texture differences between the face texture in the sample image and the face texture of a specified age. The texture difference includes at least one of a facial skin texture feature difference, a hair color feature difference, and a facial hair feature difference. When the specified age is smaller than the age corresponding to the face in the sample image, the facial skin texture feature difference is used to make the facial skin smoother and more delicate, the hair color feature difference is used to darken the hair color, and the facial hair feature difference is used to remove the facial hair. When the specified age is larger than the age corresponding to the face in the sample image, the facial skin texture feature difference is used to make the facial wrinkles more, the hair color feature difference is used to lighten the hair color, and the facial hair feature difference is used to lighten the facial hair.
[0136] In step 12042, a texture synthesis network layer is invoked to register the texture disparity map with the sample image to obtain a predicted face image.
[0137] Optionally, the conditional generative network layer is further used to output an Attention Map, which is used to reflect a weighting factor of a texture difference corresponding to a pixel point in the sample image, which is used to reflect the importance of the texture difference corresponding to the pixel point in the sample image in comparison with the texture difference corresponding to other pixel points.
[0138] The computer device may call a texture synthesis network layer to perform overlapping of the texture disparity map and the sample image based on the attention map to obtain a predicted face image. Optionally, when performing overlapping of the texture disparity map and the sample image based on the attention map, the weighting coefficients determined based on the pixel points in the texture disparity map, the pixel points in the sample image, the pixel points in the predicted face image, and the attention map are:
[0139]
number
[0140] In step 12043, a deformation network layer is called to perform deformation processing on the face in the predicted face image.
[0141] Optionally, the condition generating network layer is further used to output a deformation information map, which is used to predict the shape change between the face in the sample image and the face at the specified age. The computer device can call the deformation network layer to perform deformation processing on the face in the face image according to the deformation information map.
[0142] Optionally, the deformation information map includes corresponding displacement information of pixel points in the sample image in a first direction and a second direction. A predicted face image is obtained based on the sample image, and the deformation information map can also reflect corresponding displacement information of pixel points in the predicted face image in a first direction and a second direction. Wherein, the first direction and the second direction are perpendicular to each other. For example, the first direction is a vertical direction in the predicted sample image, and the second direction is a horizontal direction in the predicted sample image. The computer device can call a deformation network layer to perform row bilinear displacement on pixel points in the predicted face image according to the displacement information in the first direction and the second direction, thereby realizing deformation processing on the predicted face image.
[0143] For example, the sample image is an RGB image, in which the sample image includes three channels (red, green and blue). The texture difference map output by the condition generation network layer based on the sample image also includes three channels (red, green and blue), the attention map includes one channel (weight coefficient), and the deformation information map includes two channels (first direction displacement information and second direction displacement information).
[0144] Step 1205: Invoke a classifier in the generative adversarial network to calculate the adversarial loss of the predicted face image.
[0145] The computer device inputs a predicted face image to a classifier and calculates the adversarial loss by obtaining a judgment of whether the predicted face image is a true image, which is predicted by the classifier. The adversarial loss is used to represent the loss of whether the predicted face image is a true face image. The computer device can further input a sample image to the classifier and train the classifier based on the judgment of whether the sample image is a true image, which is output by the classifier.
[0146] Step 1206: Invoke the age prediction model to predict the predicted age of the predicted face image, and calculate the age loss between the predicted age and the specified age.
[0147] The age prediction model may be the same as or different from the age prediction model for predicting the sample age label. The computer device inputs the predicted face image into the age prediction model to output a predicted age for the face in the predicted face image, and calculates an age loss based on the predicted age and the assigned age. The age loss can reflect the difference between the predicted age and the assigned age.
[0148] Step 1207: Train a generator based on the adversarial loss and the age loss.
[0149] The computer device trains the generator using gradient backpropagation based on the adversarial loss, and trains the generator using gradient backpropagation based on the age loss. The computer device trains the generator alternately based on the adversarial loss and the age loss, or trains the generator simultaneously. Wherein, the adversarial loss can make the generator generate an image closer to the real face image, and the age loss can make the difference between the age reflected by the face in the face image generated by the generator and the specified age smaller.
[0150] Step 1208: When the training end condition is satisfied, determine the generator as the age-modified model.
[0151] The training end condition includes that the parameters of the generator obtained by adjusting by backpropagation based on the adversarial loss and the age loss can make the generator stable and converge. Alternatively, the training end condition is determined by the manager who trains the generator. The above-mentioned classifier and age prediction model are mainly used by a computer device to train the generator. After completing the training of the generator, the computer device obtains the trained generator and determines it as the age modification model.
[0152] It should be noted that the computer device can train only the condition generation network layer and the texture synthesis network layer, i.e., train the generator based on the output predicted face image without deformation processing. Alternatively, the computer device can train the condition generation network layer, the texture synthesis network layer, and the texture synthesis network layer, i.e., train the generator based on the output predicted face image after deformation processing. After completing the training of the age modification model, the computer device can embed the age modification model in a client or provide an interface to the outside for calling the age modification model. In this way, a service of processing face images based on a specified age can be provided to the outside.
[0153] In summary, the method provided by the embodiment of the present application can obtain an age modification model by training a generator with a sample image set and a designated age. The age modification model is trained based on adversarial loss and age loss, so that the face image can be modified based on a user self-defined designated age or a system pre-set designated age, and the flexibility and accuracy can be improved when processing face images in the age dimension.
[0154] In addition, by training the age modification model based on the generative adversarial network, the generated second face image can be made more natural. By training the age modification model based on the age prediction model, the face in the generated second face image can be made closer to the face of the specified age. In addition, by performing preprocessing on the sample image, the difficulty of training the age modification model can be reduced and the training efficiency can be improved.
[0155] In addition, the order of steps in the methods provided by the embodiments of the present application may be appropriately adjusted, and some steps may be added or removed. Furthermore, all methods that a person skilled in the art can easily come up with within the technical scope disclosed in the present application fall within the scope of protection of the present application, so a comprehensive description will be omitted here.
[0156] As a specific example, FIG. 14 is a diagram showing an implementation process of performing pre-processing on a face image provided by an embodiment of the present application. As shown in FIG. 14, a client obtains a face image based on a picture or video frame, and determines face alignment points in the face image using a face detection model to realize alignment for detection of a face in the face image. Then, using a warpAffine function, matting is performed on the face image through affine transformation based on the face alignment points to obtain an aligned face image. Then, an age prediction model predicts the age of the face image to obtain a combination of the face image and the predicted age. The face image and the predicted age can be used as a sample image and a sample age label to train an age modification model.
[0157] FIG. 15 is a diagram showing the implementation process of age modification for a face image provided by an embodiment of the present application. As shown in FIG. 15, a client obtains a face image based on a picture or video frame. In the pre-processing stage, the client performs face alignment pre-processing for the face image. After that, a designated age is obtained, and in the processing stage according to the age modification model, the client calls a condition generation network layer to process the face image based on the designated age, thereby obtaining a texture difference map, an attention map and a deformation information map. Then, the texture synthesis network layer performs superposition on the texture difference map and the face image based on the attention map, and the deformation network layer performs deformation processing on the output texture-modified face image based on the deformation information map. In the hair color processing stage, the client performs face semantic segmentation on the texture-modified and deformation-processed face image to obtain a hair region, and then uses a dynamic hair color algorithm (i.e., a conditional color lookup table) to replace the color of the pixel points in the hair region to output the final result diagram.
[0158] FIG. 16 is a diagram showing the configuration of a face image processing device provided by an embodiment of the present application. The device can be applied to a computer device or a client on a computer device. As shown in FIG. 16, the device 160 includes:
[0159] Acquisition module 1601: Used to acquire a first face image.
[0160] Prediction module 1602: Used to invoke an age modification model to predict a texture difference map under a specified age of the first facial image, and the texture difference map is used to reflect the texture difference between the facial texture in the first facial image and the facial texture at the specified age.
[0161] A first processing module 1603 is used to perform image processing on the first face image based on the texture difference map to obtain a second face image, where the second face image is a face image under a specified age of the face in the first face image.
[0162] Optionally, the age modification model includes a condition generation network layer and a texture synthesis network layer. The prediction module 1602 is used to call the condition generation network layer to make a prediction for the first face image based on the specified age, and output a texture difference map. The texture difference map is used to reflect the texture difference between the face texture in the first face image and the face texture of the specified age.
[0163] The first processing module 1603 is used to obtain a second facial image by invoking a texture synthesis network layer to register the texture disparity map with the first facial image.
[0164] Optionally, the condition generating network layer is further used to output an attention map, and the attention map is used to reflect the weight coefficient of the texture disparity corresponding to the pixel point in the first face image. The first processing module 1603 is used to call a texture synthesis network layer to obtain a second face image by overlapping the texture disparity map with the first face image based on the attention map.
[0165] Optionally, the age modification model further includes a transformation network layer. As shown in FIG.
[0166] A second processing module 1604: is used to call the deformation network layer to perform deformation processing on the face in the second face image.
[0167] Optionally, the condition generating network layer is further used to output a deformation information map, and the deformation information map is used to predict the shape change between the face in the first face image and the face at the specified age. The second processing module 1604 is used to call the deformation network layer to perform deformation processing on the face in the second face image based on the deformation information map.
[0168] Optionally, the deformation information map includes corresponding displacement information of the pixel points in a first direction and a second direction, where the first direction and the second direction are perpendicular to each other. The second processing module 1604 is used to call a deformation network layer to perform bilinear displacement for the pixel points in the second face image according to the displacement information in the first direction and the second direction.
[0169] Optionally, as shown in FIG. 18, the device 160 further includes:
[0170] A third processing module 1605 is used to perform image semantic segmentation on the second face image to obtain hair regions in the second face image.
[0171] Calculation module 1606: Used to calculate the corresponding target color value under a specified age of the pixel point in the hair region through mapping based on the original color value of the pixel point in the hair region.
[0172] Replacement module 1607: Used to replace the original color values of pixel points in the hair region with the target color values.
[0173] Optionally, as shown in FIG. 19, the device 160 further includes:
[0174] A fourth processing module 1608 is used to input the first face image into a face detection model to output face alignment points in the first face image.
[0175] A fifth processing module 1609 is used to perform matting on the first face image through affine transformation based on the face alignment points to obtain an aligned first face image.
[0176] Optionally, as shown in FIG. 20 , the apparatus 160 further includes a training module 1610, where the age change model is obtained by training of the training module 1610, and the training module 1610 is used to do the following: obtain a sample image set, where the sample image set includes sample images and sample age labels of the sample images; determine a specified age, where the specified age is a random age or a sample age label; invoke a generator in the generative adversarial network to make predictions on the sample images based on the specified age to obtain a predicted face image; invoke a classifier in the generative adversarial network to calculate an adversarial loss for the predicted face image, where the adversarial loss is used to represent the loss of whether the predicted face image is a true face image; invoke an age prediction model to predict a predicted age for the predicted face image, and calculate an age loss between the predicted age and the specified age; train a generator based on the adversarial loss and the age loss; and determine the generator as an age change model when a training termination condition is satisfied.
[0177] Optionally, the training module 1610 is used to invoke an age prediction model to perform age prediction on the sample images to obtain sample age labels for the sample images, and to determine the sample images and sample age labels for the sample images as a set of sample images.
[0178] Optionally, the training module 1610 is used to input a sample image to the face detection model to output face alignment points in the sample image, and then perform matting on the sample image using an affine transformation based on the face alignment points to obtain an aligned sample image.
[0179] Optionally, the generator includes a conditional generation network layer and a texture synthesis network layer. The training module 1610 calls the conditional generation network layer to make a prediction on the sample image based on the specified age and output a texture difference map, which is used to reflect the texture difference between the face texture in the sample image and the face texture of the specified age, and calls the texture synthesis network layer to overlap the texture difference map with the sample image to obtain a predicted face image.
[0180] Optionally, the condition generating network layer is further used to output an attention map, which is used to reflect the weighting coefficient of the texture disparity corresponding to the pixel point in the sample image. The training module 1610 is used to call the texture synthesis network layer to overlap the texture disparity map and the sample image based on the attention map to obtain a predicted face image.
[0181] Optionally, the generator further includes a deformation network layer, which is used by the training module 1610 to invoke the deformation network layer to perform deformation processing on the face in the predicted face image.
[0182] Optionally, the condition generation network layer is further used to output a deformation information map, and the deformation information map is used to predict the shape change between the face in the sample image and the face at the specified age. The training module 1610 is used to call the deformation network layer to perform deformation processing on the face in the predicted face image based on the deformation information map.
[0183] Optionally, the deformation information map includes corresponding displacement information of the pixel points in a first direction and a second direction, where the first direction and the second direction are perpendicular to each other. The training module 1610 is used to call the deformation network layer to perform bilinear displacement for the pixel points in the predicted face image based on the displacement information in the first direction and the second direction.
[0184] FIG. 21 is a diagram showing the configuration of a face image display device provided by an embodiment of the present application. The device can be applied to a computer device or a client on a computer device. As shown in FIG. 21, the device 210 includes:
[0185] A display module 2101 is used to display a first face image and an age change control, and the age change control is a control for inputting a specified age.
[0186] Processing module 2102: Used in response to a trigger operation on an age change control to process a first facial image based on a specified age corresponding to the trigger operation to obtain a second facial image, where the second facial image is a facial image of the face in the first facial image under the specified age.
[0187] The processing module 2102 is used to call the age change model according to the trigger operation on the age change control, and process the first face image according to the designated age corresponding to the trigger operation to obtain a second face image, where the second face image is a face image under the designated age of the face in the first face image. The age change model is the age change model mentioned in the above embodiment.
[0188] The display module 2101 is used to display the second face image.
[0189] Optionally, the display module 2101 is used to display the second facial image and the designated age.
[0190] Fig. 22 is a diagram showing the configuration of an age change model training device provided by an embodiment of the present application. The device can be applied to a computer device or a client on a computer device. As shown in Fig. 22, the device 220 includes:
[0191] Acquiring module 2201: used to obtain a sample image set, which includes sample images and sample age labels of the sample images.
[0192] A first determination module 2202: is used to determine a designated age, where the designated age is a random age or a sample age label.
[0193] Prediction module 2203: Used to call a generator in a generative adversarial network to make predictions on a sample image based on a specified age to obtain a predicted face image.
[0194] First calculation module 2204: Used to call a classifier in the generative adversarial network to calculate the adversarial loss of the predicted face image, where the adversarial loss is used to represent the loss of whether the predicted face image is a true face image.
[0195] A second calculation module 2205: is used to call the age prediction model to predict the predicted age of the predicted face image, and calculate the age loss between the predicted age and the specified age.
[0196] Training module 2206: Used to train the generator based on the adversarial loss and the age loss.
[0197] A second determination module 2207: is used to determine the generator as the age-modified model when the training end condition is satisfied.
[0198] Optionally, the acquisition module 2201 is used to invoke an age prediction model to perform age prediction on the sample image, obtain sample age labels for the sample images, and determine the sample images and sample age labels for the sample images as a sample image set.
[0199] Optionally, as shown in FIG. 23, the device 220 further includes:
[0200] First processing module 2208: Used to input a sample image into the face detection model to output face alignment points in the sample image.
[0201] A second processing module 2209 is used to perform matting on the sample image through affine transformation based on the face alignment points to obtain an aligned sample image.
[0202] Optionally, the generator includes a conditional generation network layer and a texture synthesis network layer. The prediction module 2203 is used to: call the conditional generation network layer to make a prediction on the sample image according to the designated age, output a texture difference map, which is used to reflect the texture difference between the face texture in the sample image and the face texture of the designated age, and call the texture synthesis network layer to overlap the texture difference map with the sample image to obtain a predicted face image.
[0203] Optionally, the condition generating network layer is further used to output an attention map, which is used to reflect the weight coefficient of the texture disparity corresponding to the pixel point in the sample image. The prediction module 2203 is used to call the texture synthesis network layer to overlap the texture disparity map and the sample image based on the attention map to obtain a predicted face image.
[0204] Optionally, the generator further includes a deformation network layer, and the prediction module 2203 is used to call the deformation network layer to perform deformation processing on the face in the predicted face image.
[0205] Optionally, the condition generation network layer is further used to output a deformation information map, and the deformation information map is used to predict the shape change between the face in the sample image and the face at the specified age. The prediction module 2203 is used to call the deformation network layer to perform deformation processing on the face in the predicted face image based on the deformation information map.
[0206] Optionally, the deformation information map includes corresponding displacement information of the pixel point in a first direction and a second direction, the first direction and the second direction being perpendicular to each other. The prediction module 2203 is used to call a deformation network layer to perform bilinear displacement for the pixel point in the predicted face image according to the displacement information in the first direction and the second direction.
[0207] In addition, the face image processing device provided by the above embodiment is described only by dividing each of the above-mentioned functional modules, but in actual application, the above-mentioned functions can be assigned to different functional modules to be completed according to needs, that is, the internal configuration of the device can be divided into different functional modules to complete all or part of the above-mentioned functions. In addition, since the face image processing device provided by the above embodiment belongs to the same concept as the embodiment of the face image processing method, the specific implementation process can be referred to the embodiment of the method, and the detailed description thereof will be omitted here.
[0208] Similarly, the face image display device provided by the above embodiment is described only by taking the division of each of the above-mentioned functional modules as an example, but in actual application, the above-mentioned functions can be assigned to different functional modules to be completed according to needs, that is, the internal configuration of the device can be divided into different functional modules to complete all or part of the above-mentioned functions.In addition, since the face image display device provided by the above embodiment belongs to the same concept as the embodiment of the face image display method, the specific realization process can be referred to the embodiment of the method, and the detailed description thereof will be omitted here.
[0209] Similarly, the training device for age change model provided by the above embodiment is described only by dividing each of the above-mentioned functional modules, but in actual application, the above-mentioned functions can be assigned to different functional modules to be completed according to needs, that is, the internal configuration of the device can be divided into different functional modules to complete all or part of the above-mentioned functions.In addition, the training device for age change model provided by the above embodiment belongs to the same concept as the embodiment of the training method for age change model, so the specific implementation process can be referred to the embodiment of the method, and the detailed description thereof will be omitted here.
[0210] In a further embodiment of the present application, a computer device is provided, the computer device including a processor and a memory, the memory including at least one instruction, at least one program, code set or instruction set, the at least one instruction, at least one program, code set or instruction set may be loaded and executed by the processor to realize the method for processing a facial image, the method for displaying a facial image or the method for training an age modification model provided by the embodiments of each of the above-mentioned methods.
[0211] Optionally, the computing device is a terminal. Exemplarily, Figure 24 is a diagram showing the configuration of a terminal provided by an embodiment of the present application.
[0212] The terminal 2400 typically includes a processor 2401 and a memory unit 2402 .
[0213] The processor 2401 may include one or more processing cores, for example, a 4-core processor, an 8-core processor, etc. The processor 2401 may be implemented by adopting at least one hardware of a digital signal processing (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). The processor 2401 may include a main processor and a coprocessor, where the main processor is a processor for processing data in a wake-up state, also referred to as a central processing unit (CPU), and the coprocessor is a low-power processor for processing data in a standby state. In some embodiments, the processor 2401 may further integrate a graphics processing unit (GPU), which is used to render and draw content that needs to be displayed on a display screen. In some embodiments, the processor 2401 may further include an artificial intelligence (AI) processor, which is configured to process computational operations related to machine learning.
[0214] The storage 2402 may include one or more computer readable storage media, which may be non-transitory. The storage 2402 may further include high speed random access memory, and non-volatile memory, such as one or more magnetic disks, flash memory, etc. In some embodiments, the non-transitory computer readable storage media in the storage 2402 is used to store at least one instruction that can be executed by the processor 2401 to implement the method provided by the method embodiments described above.
[0215] In further embodiments of the present application, a computer-readable storage medium is provided, which stores at least one program code, and when the program code is loaded and executed by a processor of a computer device, the method for processing a facial image, the method for displaying a facial image, or the method for training an age modification model provided by the embodiments of the above-mentioned methods can be realized.
[0216] The present application further provides a computer program product or a computer program, the computer program product or the computer program including computer instructions (programs), the computer instructions being stored in a computer-readable storage medium, a processor of a computer device reading the computer instructions from the computer-readable storage medium and executing the computer instructions, thereby causing the computer device to perform the method for processing a face image, the method for displaying a face image or the method for training an age modification model provided by each of the above method embodiments.
[0217] Although the preferred embodiment of the present application has been described above, the present application is not limited to this embodiment, and any modification to the present application falls within the technical scope of the present application as long as it does not depart from the spirit of the present application.
Claims
1. 1. A computer device implemented method for processing facial images, comprising: obtaining a first face image; Invoking an age modification model to predict a texture difference map under a specified age of the first facial image, the texture difference map being used to indicate texture difference between a facial texture in the first facial image and a facial texture of the specified age; and performing image processing on the first face image based on the texture difference map to obtain a second face image, the second face image being a face image of the face in the first face image under the specified age; The age modification model includes a condition generation network layer and a texture synthesis network layer; Invoking the age modification model to predict a texture difference map under a specified age of the first facial image, calling the condition generating network layer to make a prediction on the first face image based on the designated age and outputting the texture disparity map; performing image processing on the first face image based on the texture difference map to obtain a second face image, calling the texture synthesis network layer to register the texture disparity map with the first facial image to obtain the second facial image; The age modification model further includes a transformation network layer; The method comprises: The method further includes invoking the deformation network layer to perform a deformation process on the face in the second face image.
2. 2. The method of claim 1 , The condition generating network layer is further used to output an attention map, the attention map being used to indicate weighting coefficients of the texture disparities corresponding to pixel points in the first face image; Invoking the texture synthesis network layer to register the texture disparity map with the first facial image to obtain the second facial image, invoking the texture synthesis network layer to register the texture disparity map with the first facial image based on the attention map to obtain the second facial image.
3. 2. The method of claim 1 , The condition generating network layer is further used to output a deformation information map, and the deformation information map is used to predict a face shape change between the face in the first face image and the face at the specified age; The step of calling the transformation network layer to perform a transformation process on the face in the second face image includes: The method includes a step of invoking the deformation network layer to perform a deformation process on the face in the second face image based on the deformation information map.
4. 4. The method of claim 3, the deformation information map includes corresponding displacement information of pixel points in a first direction and a second direction, the first direction and the second direction being perpendicular to each other; The step of calling the transformation network layer and performing a transformation process on the face in the second face image based on the transformation information map includes: The method includes invoking the deformation network layer to perform a bilinear displacement on the pixel point in the second face image based on the displacement information in the first direction and the second direction.
5. A method according to any one of claims 1 to 4, comprising the steps of: performing image semantic segmentation on the second face image to obtain a hair region in the second face image; Calculating, based on the original color values of the pixel points in the hair region, corresponding target color values of the pixel points in the hair region under the specified age through mapping; and The method further comprising replacing the original color values of pixel points in the hair region with the target color values.
6. 1. A computer device implemented method for training an age modification model, comprising: obtaining a sample image set, the sample image set including sample images and sample age labels for the sample images; determining a designated age, the designated age being a random age or the sample age label; Invoking a generator in a generative adversarial network to perform prediction on the sample image based on the specified age to obtain a predicted face image; A step of calculating an adversarial loss of the predicted face image by invoking a classifier in the generative adversarial network, the adversarial loss being used to represent a loss of whether the predicted face image is a true face image; invoking an age prediction model to predict a predicted age of the predicted face image, and calculating an age loss between the predicted age and the specified age; training the generator based on the adversarial loss and the age loss; and determining the generator as the age-modified model when a training end condition is satisfied; the generator includes a conditional generative network layer and a texture synthesis network layer; The step of calling a generator in the generative adversarial network to perform prediction on the sample image based on the specified age to obtain a predicted face image includes: calling the condition generating network layer to make predictions on the sample images based on the designated age and output a texture difference map, the texture difference map being used to indicate texture differences between faces in the sample images and faces at the designated age; and calling the texture synthesis network layer to register the texture disparity map with the sample image to obtain the predicted face image; The generator further includes a transformation network layer; The method comprises: The method further includes invoking the deformation network layer to perform deformation processing on a face in the predicted face image.
7. 7. The method of claim 6, The step of obtaining a sample image set comprises: calling the age prediction model to perform age prediction on the sample image to obtain a sample age label for the sample image; and determining the sample images and sample age labels for the sample images as the set of sample images.
8. 8. The method of claim 7, inputting the sample image into a face detection model and outputting face alignment points in the sample image; and The method further comprises performing matting on the sample image through an affine transformation based on the face alignment points to obtain an aligned sample image.
9. 7. The method of claim 6, The conditional generative network layer is further adapted to output an attention map, the attention map being adapted to indicate weighting factors of the texture disparities corresponding to pixel points in the sample image; Invoking the texture synthesis network layer to register the texture disparity map with the sample image to obtain the predicted face image, invoking the texture synthesis network layer to register the texture disparity map with the sample image based on the attention map to obtain the predicted face image.
10. An apparatus for processing face images, comprising: an acquisition module for displaying a first facial image; a prediction module for invoking an age modification model to predict a texture difference map under a designated age of the first facial image, the texture difference map being used to indicate a texture difference between a facial texture in the first facial image and a facial texture of the designated age; and a first processing module for performing image processing on the first face image based on the texture difference map to obtain a second face image, the second face image being a face image of a face in the first face image under the specified age; The age modification model includes a condition generation network layer and a texture synthesis network layer; Invoking the age modification model to predict a texture difference map under a specified age of the first facial image, calling the condition generating network layer to make a prediction for the first face image based on the designated age and outputting the texture disparity map; performing image processing on the first face image based on the texture difference map to obtain a second face image, invoking the texture synthesis network layer to register the texture disparity map with the first facial image to obtain the second facial image; The age modification model further includes a transformation network layer; The apparatus comprises: The apparatus further includes a second processing module for invoking the deformation network layer to perform deformation processing on a face in the second facial image.
11. 1. An apparatus for training an age modification model, comprising: an acquisition module for obtaining a sample image set, the sample image set including sample images and sample age labels for the sample images; a first determination module for determining a designated age, the designated age being a random age or the sample age label; a prediction module for invoking a generator in a generative adversarial network to perform a prediction on the sample image based on the specified age to obtain a predicted face image; a first calculation module for calling a classifier in the generative adversarial network to calculate an adversarial loss for the predicted face image, the adversarial loss being used to represent a loss as to whether the predicted face image is a true face image; a second calculation module for invoking an age prediction model to predict a predicted age of the predicted face image and calculating an age loss between the predicted age and the specified age; a training module for training the generator based on the adversarial loss and the age loss; and a second determination module for determining the generator as an age-modified model when a training end condition is satisfied; the generator includes a conditional generative network layer and a texture synthesis network layer; Invoking a generator in the generative adversarial network to perform prediction on the sample image based on the specified age to obtain a predicted face image, calling the condition generating network layer to make predictions on the sample images based on the designated age and output a texture difference map, the texture difference map being used to indicate texture differences between faces in the sample images and faces at the designated age; and invoking the texture synthesis network layer to register the texture disparity map with the sample image to obtain the predicted face image; The generator further includes a transformation network layer; The training module further comprises: An apparatus that is used to invoke the deformation network layer to perform deformation processing on a face in the predicted face image.
12. A computer device including a processor and a memory coupled to the processor, A computer apparatus, the storage device storing a computer program, the processor configured to execute the computer program to cause the computer apparatus to perform a method according to any one of claims 1 to 5 or a method according to any one of claims 6 to 9.
13. A program for causing a computer to execute the method according to any one of claims 1 to 5 or the method according to any one of claims 6 to 9.
Citation Information
Patent Citations
Method for generating image of varying age and method for generating image of smoothed skin
JP2005063078A
Method for aging appearance simulation
JP2020515952A
