Method for training a face image generation model and related apparatus

By constructing facial image samples of the same individual at different ages and training an image generation network, the problem of inaccurate individual age change characteristics in existing technologies is solved. This enables the generation of age change images that conform to individual characteristics, thereby improving prediction accuracy and the model's generalization ability.

CN122493500APending Publication Date: 2026-07-31SHENZHEN SHULIAN TIANXIA INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN SHULIAN TIANXIA INTELLIGENT TECH CO LTD
Filing Date
2026-01-20
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing machine learning models, when generating images of age changes, tend to produce aging or youthful images that do not match the individual's true condition and fail to accurately reflect the individual's age change characteristics.

Method used

By constructing image samples including facial images of the same individual at different ages, training samples are built and an image generation network is used for iterative training to learn the age change characteristics of the individual. The model is optimized using the SoftMask-Guided PatchGAN network structure and the total variation regularized loss function to generate age change images that conform to the individual characteristics.

Benefits of technology

It improves the generation accuracy of age-related images, enabling more accurate prediction of aging or tracing back to younger images, thus enhancing the model's prediction accuracy and generalization ability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122493500A_ABST
    Figure CN122493500A_ABST
Patent Text Reader

Abstract

A method for training a face image generation model includes: acquiring several image samples, including an original face image, a target face image, the age corresponding to the original face image, and the age corresponding to the target face image, wherein the original face image and the target face image belong to the same individual; constructing several training samples based on the image samples; the training samples include the original face image, the age features of the original face image, and the age features of the target face image, with the target face image as the ground truth label for the training samples; and iteratively training an image generation network using the training samples until the image generation network converges to obtain the face image generation model. This allows the image generation network to learn the age change features of the same individual, which helps the trained face image generation model generate age-change images that match individual characteristics, more accurately predicting aging images or tracing the origin of youthful images.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to a method and related apparatus for training a face image generation model. Background Technology

[0002] As machine learning technology matures, the types of services based on it are also increasing. For example, computer devices can use machine learning to process facial images and obtain age-related images. The initial age of a face in the original image differs from the second age in the age-related image, but both represent the same person. This service is widely needed in various scenarios. For instance, in film and television production, when actors play older roles, their current appearance can be used to predict their future appearance, making it easier for makeup artists to create the desired look. Another example is during leisure time, where people want to use current images to recall photos from their childhood.

[0003] Currently, computer devices typically use machine learning models to process the input facial image and the expected age to obtain an age change image, which is expected to reflect a person's age in a way that matches the expected age.

[0004] However, some machine learning models known to the inventors of this application learn different facial images of different age groups. Such age-based aging prediction or youth tracing is prone to generating aging or youth images that do not match the individual's actual situation. Summary of the Invention

[0005] In view of this, this application provides a method and related apparatus for training a face image generation model, which enables the trained face image generation model to generate age change images that conform to individual characteristics, and can more accurately predict aging images or trace the origin of youthful images.

[0006] In a first aspect, embodiments of this application provide a method for training a face image generation model, comprising: acquiring a plurality of image samples, the image samples including an original face image, a target face image, the age corresponding to the original face image, and the age corresponding to the target face image, wherein the original face image and the target face image belong to the same person; constructing a plurality of training samples based on the plurality of image samples; the training samples including the original face image, the age features of the original face image, and the age features of the target face image, the true label of the training samples being the target face image; and iteratively training the image generation network using the plurality of training samples until the image generation network converges to obtain a face image generation model.

[0007] In some embodiments, the aforementioned acquisition of several image samples includes: acquiring multiple face images, the multiple face images including face images of multiple individuals at multiple age groups; identifying the age of the multiple face images; taking any two face images from the multiple face images of the same individual as an image pair, the image pair including the original face image and the target face image; and taking the image pair and the age of the face images in the image pair as image samples.

[0008] In some embodiments, the aforementioned construction of several training samples based on several image samples includes: segmenting the facial region of the original face image, fusing the facial region of the face image with the age of the original face image to obtain the age feature of the original face image; segmenting the facial region of the target face image, fusing the facial region of the target face image with the age of the target face image to obtain the age feature of the target face image; using the original face image, the age feature of the original face image, and the age feature of the target face image as training samples, and using the target face image as the true label of the training samples.

[0009] In some embodiments, the aforementioned method of iteratively training an image generation network using several training samples until the image generation network converges to obtain a face image generation model includes: inputting training samples into the image generation network for computational processing, and the image generation network outputting predicted age feature differences; fusing the predicted age feature differences with the original face image to obtain a predicted face image; calculating the difference between the predicted face image and the target face image using a loss function, and adjusting the model parameters of the image generation network based on the differences corresponding to several training samples until the image generation network converges to obtain a face image generation model.

[0010] In some embodiments, the image generation network includes a generator and a discriminator, wherein the discriminator includes a SoftMask-Guided PatchGAN network structure.

[0011] In some embodiments, the loss function includes total variation regularization loss, which is used to calculate the sum of the absolute values ​​of the differences between adjacent pixel values ​​in the horizontal and vertical directions of the predicted face image.

[0012] In some embodiments, the method further includes: performing random color enhancement or brightness enhancement processing on the original face images in the training samples before inputting the image generation network.

[0013] Secondly, this application provides a method for generating an age change image, comprising: acquiring a test face image, the age of the test face image, and the expected age; acquiring age features of the test face image and the expected age features based on the test face image, the age of the test face image, and the expected age; inputting the test face image, the age features of the test face image, and the expected age features into a face image generation model to obtain an age change image, wherein the age of the individual in the age change image is adapted to the expected age; wherein the face image generation model is trained using the method for training a face image generation model in the first aspect.

[0014] Thirdly, this application provides an electronic device, including: At least one processor, and A memory that is communicatively connected to at least one processor, wherein, The memory stores instructions that can be executed by at least one processor, such that the at least one processor is able to perform the methods described in the first or second aspect above.

[0015] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions for causing a computer device to perform the methods described in the first or second aspect above.

[0016] The beneficial effects of this application's embodiments are as follows: Unlike existing technologies, the method for training a face image generation model provided in this application first acquires several image samples, including an original face image, a target face image, the age corresponding to the original face image, and the age corresponding to the target face image, wherein the original face image and the target face image belong to the same individual. Based on these image samples, several training samples are constructed; the training samples include the original face image, the age features of the original face image, and the age features of the target face image, with the target face image serving as the ground truth label for each training sample. The image generation network is iteratively trained using these training samples until it converges, resulting in a face image generation model.

[0017] Thus, since the original face image and the target face image in the image sample belong to the same person but are of different ages, the image generation network can learn the age change features of the same person. This helps the trained face image generation model generate age change images that conform to individual characteristics. On the other hand, by constructing age features based on the age of the face images in the image sample, and using the original face image, the age features of the original face image, and the age features of the target face image as training samples, the image generation network can not only learn the image features corresponding to age changes but also the age features corresponding to age changes. This helps improve the prediction accuracy of the face image generation model, thereby enabling more accurate prediction of aging images or tracing back to younger images. Attached Figure Description

[0018] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.

[0019] Figure 1 This is a flowchart illustrating the method for training a face image generation model in an embodiment of this application; Figure 2 yes Figure 1 A schematic diagram of the sub-process of step S10; Figure 3 yes Figure 1 A schematic diagram of the sub-process of step S20; Figure 4 This is a schematic diagram of the structure of the face image generation network in the embodiments of this application; Figure 5 This is a flowchart illustrating the method for generating age-changing images in an embodiment of this application; Figure 6 This is a schematic diagram of the structure of the electronic device in the embodiments of this application. Detailed Implementation

[0020] The present application will now be described in detail with reference to specific embodiments. These embodiments will help those skilled in the art to further understand the present application, but do not limit the present application in any way. It should be noted that those skilled in the art can make several modifications and improvements without departing from the concept of the present application. These all fall within the protection scope of the present application.

[0021] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0022] It should be noted that, unless there is a conflict, the various features in the embodiments of this application can be combined with each other, all of which are within the protection scope of this application. Furthermore, although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than the module division in the device or the order in the flowchart. In addition, the terms "first," "second," and "third" used herein do not limit the data or execution order, but only distinguish identical or similar items with essentially the same function and effect.

[0023] Unless otherwise defined, all technical and scientific terms used in this specification have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The term "and / or" as used in this specification includes any and all combinations of one or more of the associated listed items.

[0024] Furthermore, the technical features involved in the various embodiments of this application described below can be combined with each other as long as they do not conflict with each other.

[0025] As people age, facial features gradually show signs of aging such as wrinkles, sagging, and pigmentation. Poor lifestyle habits and lack of daily skincare can accelerate this process. Facial aging prediction algorithms simulate and analyze facial images to help users intuitively understand future appearance changes, and are widely used in entertainment and health management. For example, in film special effects and beauty consultations, they can provide users with personalized visual references. Similar to aging prediction scenarios, some users also hope to use current images to trace back to photos from their childhood.

[0026] Taking aging prediction as an example, most current facial aging prediction methods rely primarily on data-driven training of facial images, using Generative Adversarial Networks (GANs) or other image generation models to directly synthesize aging effects. Facial image data mainly comes from two sources: real-world images of different individuals of different ages, which are very difficult to obtain; and images generated using existing generative techniques, which significantly reduces the data cost during model training.

[0027] Other approaches use multiple images labeled with different ages as a training set to train a Conditional Generative Adversarial Network (GAN). This GAN includes an image generator (G), an image discriminator (D), an age estimation network (AEN), and an identity recognition network (FRN). G is trained to generate aged images; specifically, it automatically and effectively generates aged images by inputting young images and preset age conditions. D is used to verify whether the generated aged images are genuine, ensuring their deceptiveness. AEN reduces the discrepancy between the age of the generated aged images and the preset value, while FRN ensures consistency in the identity of the person during generation. During model training, the training set is grouped according to age groups, allowing the GAN to learn the aging features corresponding to each age group, thus realizing the aging changes in the face.

[0028] However, in this approach, aging features are learned from each set of images, making them determined solely by age group and ensuring that individual aging features are identical. Thus, for each set of test data, the feature changes are the same. However, in real life, each person's aging feature changes are influenced by individual factors and are specific. Therefore, this approach does not consider individual differences and cannot accurately generate images showing signs of aging.

[0029] To address the aforementioned issues, this application provides a method for training a face image generation model. By constructing a dataset of face images of different individuals at different age stages and incorporating the individuals' age values, the face image generation network can learn the age characteristics exhibited by individuals at various age stages based on their own age features. Consequently, the trained face image generation model can generate age-changing images that conform to the individual's characteristics, enabling more accurate prediction of aging images or tracing back to youthful images.

[0030] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.

[0031] Please see Figure 1 , Figure 1 A flowchart illustrating a training method for a model provided in an embodiment of this application is shown. Method S100 may specifically include the following steps: S10: Obtain several image samples.

[0032] The image sample includes the original face image, the target face image, the age corresponding to the original face image, and the age corresponding to the target face image. That is, the data structure of the image sample is (Image_1, age_1, Image_2, age_2), where Image_1 is the original face image, age_1 is the age of the individual in the original face image, Image_2 is the target face image, and age_2 is the age of the individual in the target face image. age_1 can be greater than or less than age_2.

[0033] In this context, the original face image and the target face image belong to the same individual. That is, the individual in Image_1 and the individual in Image_2 have the same identity.

[0034] For example, the original face image and the target face image are both photos of the same person "Chen" at different ages. In the original face image, Chen's age is 25 years old, and in the target face image, Chen's age is 32 years old. Therefore, the age corresponding to the original face image is 25 years old, and the age corresponding to the target face image is 32 years old.

[0035] For example, the original face image and the target face image are both photos of the same person "Zhang" at different ages. In the original face image, Zhang's age is 51 years old, and in the target face image, Zhang's age is 30 years old. Therefore, the age corresponding to the original face image is 51 years old, and the age corresponding to the target face image is 30 years old.

[0036] This approach allows the image samples to include two facial images of the same individual at different ages, with one image serving as the source face and the other as the target face. Thus, the image generation network can learn the facial features of the same individual at different ages, specifically learning the age-related changes in the face from age_1 to age_2. Since age-related changes vary from person to person, if the image generation network learns these features from different individuals at different ages, the model's predictions might not match the individual's characteristics. In this approach, the image generation network learns the age-related changes of the same individual at different ages, which helps the trained face image generation model generate age-related images that match the individual's characteristics. Furthermore, age_1 can be greater than or less than age_2, allowing the trained face image generation model to predict aging or trace the origin of age.

[0037] In some embodiments, please refer to Figure 2 The aforementioned step S10 specifically includes: S11: Acquire multiple face images, which include face images of multiple individuals at different age groups.

[0038] For example, the multiple face images include 10,000 individual face images at different age groups. The age groups can be divided into (0, 10 years old), [10 years old, 20 years old), [20 years old, 30 years old), [30 years old, 40 years old), [40 years old, 50 years old), [50 years old, 60 years old), [60 years old, 70 years old), [70 years old, 80 years old), [80 years old, 90 years old), [90 years old, 100 years old). Thus, 10,000 × 10 = 100,000 face images are obtained. Optionally, the resolution of the face images is 1024*1024.

[0039] In some possible implementations, the StyleGAN2 model is used to randomly generate 10,000 individual face images with a resolution of 1024*1024. For each face image, an age editor is used to generate 10 face images belonging to the aforementioned age groups. For example, for a randomly generated face image A, whose age belongs to the age group [20 years old, 30 years old], the age editor is used to edit face image A, resulting in 9 face images belonging to another 9 age groups. Thus, the individual in face image A has 10 face images belonging to the aforementioned age groups.

[0040] Specifically, optionally, for the 10,000 randomly generated face images by the stylegan2 model, the trained age detection model is first used to detect the age of the face images, and face images falling within the aforementioned 10 age ranges are selected. The face images are then input into a pre-trained SVM classifier to obtain the corresponding age orientation vector. The `coeff` parameter, which controls the shift along the age direction, is used to control the generation of face images for each age group. The face image can be represented by the following formula:

[0041] in, Based on the face vector, Let the age direction vector be... The magnitude of the shift along the age direction, when When the value is positive, the facial image appears aged; when... When the value is negative, the face image appears younger. For example, setting coeffs to -25, -21, -17, -13, -9, -5, -2, 0, 5, 10 controls the generation of vectors for different age groups, thus obtaining face images of the same individual belonging to the above 10 age groups.

[0042] S12: Identify the age of multiple face images.

[0043] For example, a trained age detection model can be used to detect the age of these facial images. Thus, each facial image corresponds to an age value.

[0044] S13: Take any two face images from multiple face images of the same person as an image pair, where the image pair includes the original face image and the target face image.

[0045] As described above, a single individual has 10 facial images, representing the aforementioned 10 age groups. From these 10 images, any two facial images are selected as an image pair. One image in the pair serves as the original facial image, and the other as the target facial image. Thus, a single individual corresponds to multiple image pairs, thereby enriching the image sample.

[0046] S14: Use the image pair and the age of the face image in the image pair as image samples.

[0047] Understandably, an image pair includes the original face image and the target face image, with the original face image and its age, and the target face image and its age used as image samples.

[0048] In this way, the image samples contain facial images of multiple individuals across all age groups, enabling the image generation network to learn the age change characteristics of multiple individuals across all age groups. This helps the trained facial image generation model generate age change images that match individual characteristics, thus achieving accurate prediction of aging or tracing the origin of youth.

[0049] S20: Construct several training samples based on several image samples.

[0050] The training samples include the original face image, the age features of the original face image, and the age features of the target face image. The true label of the training samples is the target face image.

[0051] As mentioned above, the data structure of the image sample is (Image_1, age_1, Image_2, age_2), where Image_1 is the original face image, age_1 is the age of the individual in the original face image, Image_2 is the target face image, and age_2 is the age of the individual in the target face image. age_1 can be greater than or less than age_2.

[0052] Each image sample is used to construct a training sample. For example, (Image_1, age_1, age_2) is used as the training sample, and Image_2 is used as the true label of the training sample.

[0053] In this embodiment, in order for the image generation network to learn the age features corresponding to age changes, age features are constructed based on ages_1 and age_2 respectively.

[0054] In some embodiments, please refer to Figure 3 The aforementioned step S20 specifically includes: S21: Segment the facial region of the original face image, and fuse the facial region of the face image with the age of the original face image to obtain the age features of the original face image.

[0055] For example, a face segmentation algorithm is used to segment the original face image, resulting in facial and non-facial regions. The facial region includes facial skin, hair, eyebrows, eyes, nose, ears, mouth, lips, and neck skin. The non-facial region is the remaining area in the face image after excluding the facial region. Optionally, the face segmentation algorithm is a pre-trained BiSeNetV2 model.

[0056] In some possible approaches, the facial region is represented by a mask matrix, the number of rows and columns of which is the same as the resolution of the face image. Each element in the mask corresponds to a pixel in the face image; an element value of 1 indicates that the corresponding pixel belongs to the facial region; an element value of 0 indicates that the corresponding pixel belongs to a non-facial region.

[0057] The mask matrix of the original face image is fused with the age of the original face image to obtain the age feature of the original face image. In this way, the age value is represented in the form of image data, which makes it easier for the subsequent image generation network to learn the image features of the original face image, while also learning the age feature of the original face image, which helps to improve the prediction accuracy of the model.

[0058] In some possible ways, the mask matrix of the original face image is fused with the age of the original face image using the following formula:

[0059] in, The mask matrix is ​​the original face image. The age value is the original face image. The age characteristics of the original face image.

[0060] That is, the age value of the original face image is divided by 100, normalized to between 0 and 1, and then multiplied by the mask matrix representing the facial region. .

[0061] This allows the age value of the original face image to be represented in the form of image data, making it convenient for the subsequent image generation network to learn the image features of the original face image while also learning the age features of the original face image.

[0062] S22: Segment the facial region of the target face image, and fuse the facial region of the target face image with the age of the target face image to obtain the age feature of the target face image.

[0063] For example, a face segmentation algorithm is used to segment the target face image, obtaining facial regions and non-facial regions. The facial regions include facial skin, hair, eyebrows, eyes, nose, ears, mouth, lips, and neck skin, while the non-facial regions are the remaining areas in the face image after excluding the facial regions. Optionally, the face segmentation algorithm is a pre-trained BiSeNetV2 model.

[0064] In some possible approaches, the facial region is represented by a mask matrix, the number of rows and columns of which is the same as the resolution of the face image. Each element in the mask corresponds to a pixel in the face image; an element value of 1 indicates that the corresponding pixel belongs to the facial region; an element value of 0 indicates that the corresponding pixel belongs to a non-facial region.

[0065] The mask matrix of the target face image is fused with the age of the target face image to obtain the age feature of the target face image. In this way, the age value is represented in the form of image data, which facilitates the subsequent image generation network in learning the image features of the target face image while simultaneously learning the age feature, thus improving the prediction accuracy of the model.

[0066] In some possible approaches, the mask matrix of the target face image is fused with the age of the target face image using the following formula:

[0067] in, The mask matrix is ​​the target face image. The age value of the target face image. Age characteristics of the target face image.

[0068] That is, the age value of the target face image is divided by 100, normalized to between 0 and 1, and then multiplied by the mask matrix representing the facial region. .

[0069] This allows the age value of the target face image to be represented in the form of image data, making it convenient for the subsequent image generation network to learn the age characteristics of the target face image while learning its image features.

[0070] S23: Use the original face image, the age features of the original face image, and the age features of the target face image as training samples, and use the target face image as the true label of the training samples.

[0071] For example, the original face image Image_1, the above and the above As training samples, the data structure of the training samples is (Image_1, ... , The actual label is Image_2.

[0072] In this embodiment, the age values ​​of the original face image and the target face image are represented in the form of image data, so that the subsequent image generation network can learn the age features of the original face image and the target face image at the same time when learning the image features of the original face image, which is beneficial to improving the prediction accuracy of the model.

[0073] S30: Iteratively train the image generation network using several training samples until the image generation network converges to obtain a face image generation model.

[0074] The original face image, its age features, and the target face image in the training sample are concatenated using multiple channels to obtain a 5-channel training sample. The original face image is a 3-channel image data set, while the age features of both the original and target face images are 1-channel matrices with the same resolution as the images.

[0075] The image generation network is iteratively trained using these 5-channel training samples until it converges, resulting in a face image generation model.

[0076] The image generation network is a pre-defined neural network with neural network components (convolutional layers, deconvolutional layers, pooling layers, or activation functions, etc.). In some embodiments, the image generation network includes a generator and a discriminator. The generator outputs predicted face images based on training samples, and the discriminator calculates the probability of the predicted face images being real or fake.

[0077] Based on the sum of differences and true / false probabilities between multiple predicted face images and multiple target face images, the model parameters of the image generation network are adjusted inversely until a convergence condition is met. The model parameters that meet the convergence condition are then configured in the image generation network to obtain the face image generation model. In some training methods, the convergence condition includes the sum of differences between multiple predicted face images and multiple target face images being less than or equal to a threshold, fluctuating within a certain range, or reaching a certain number of training epochs.

[0078] In some embodiments, the aforementioned step S30 specifically includes: S31: Input the training samples into the image generation network for computation and processing. The image generation network outputs the predicted age feature differences.

[0079] Understandably, the computation method for generating the network is the same for each training sample input image. Here, we will use the computation method of one training sample as an example for illustration.

[0080] Please see Figure 4 The image generation network consists of a generator and a discriminator. Training samples are first input into the generator, and the generator outputs the predicted aging delta.

[0081] Optionally, the generator uses a function If the difference in predicted age features output by the generator is expressed as follows: ,in, Original face image The age characteristics of the original face image. Age characteristics of the target face image.

[0082] In some implementations, the network structure of the generator is shown in the table below.

[0083]

[0084] Among them, ReflectionPad2d is a two-dimensional reflection filling module used to perform boundary filling operations on two-dimensional image tensors; ConvBlock1, ConvBlock2, and ConvBlock3 are three convolutional modules used to sample features from the input image; AOTBlock*8 is an adaptive octave transform block used to transform low-resolution feature maps into high-resolution, high-fidelity image features; and the decoding and upconvolutional module UpConv*4 is used to gradually enlarge and restore the resolution of the image.

[0085] Please see Figure 4 Finally, the predicted age feature difference output by the generator has the same resolution as the original face image.

[0086] S32: The predicted age feature difference is fused with the original face image to obtain the predicted face image.

[0087] like Figure 4 As shown, the predicted aging delta is fused with the original face image to obtain the generated face image. In some embodiments, the fusion process can be performed using the following formula:

[0088] in, Original face image It is the mask matrix of the original face image. It represents the age characteristics of the original facial image. It refers to the age characteristics of the target facial image. It predicts human face images.

[0089] S33: The difference between the predicted face image and the target face image is calculated using a loss function. Based on the difference corresponding to several training samples, the model parameters of the image generation network are adjusted in reverse until the image generation network converges, thus obtaining the face image generation model.

[0090] like Figure 4 As shown, the loss function calculates the difference between the predicted face image and the target face image. Each training sample corresponds to a difference, and the differences of several training samples are summed to obtain the difference sum. Based on the difference sum, the model parameters of the image generation network are adjusted inversely to complete one round of training. After several rounds of training, the image generation network converges, and the model parameters at convergence are configured to obtain the face image generation model.

[0091] In some embodiments, the Adam algorithm is used to optimize the model parameters. For example, the number of iterations is set to 100,000, the initial learning rate is set to 0.001, the learning rate weight decay is set to 0.0005, and the learning rate decays to 1 / 10 of its original value every 1,000 iterations. The learning rate, loss, and input can be fed into the Adam algorithm to obtain the adjusted model parameters output by the Adam algorithm. These adjusted model parameters are used for the next training iteration until training is complete. Then, the converged model parameters of the image generation network are output, thus obtaining the image generation model.

[0092] In some embodiments, the discriminator includes a Soft Mask-Guided PatchGAN network structure. For example... Figure 4 As shown, the predicted face image is input into the discriminator, and the discriminator outputs a probability map of true and false faces.

[0093] The loss function includes adversarial loss and generative loss. Adversarial loss is expressed by the following formula:

[0094] The generation loss is expressed by the following formula:

[0095] in, It is to combat losses. It is the generation loss. This indicates that the discriminator analyzes a single original face image. The output of the discriminator aims to make this value as close as possible to 1, i.e., "determine it as true". This represents the discriminator's output for predicting face images. The discriminator's goal is to make this value as close as possible to 0, or a specific target value, as shown here. That is, "determined to be false". This represents the input mask matrix. It is a function consisting of downsampling and Gaussian filtering. The overall meaning is: a soft label for a "known area" that has been blurred and smoothed.

[0096] This represents the average of the expression following it, calculated over all images generated by the generator. In actual training, this is typically approximated by calculating the average loss of a mini-batch of generated samples.

[0097] This represents the average of the expression calculated over all real images. Similarly, it is approximated by the average loss of a mini-batch of real samples. This average reflects the difference in realism or credibility between the generated images and aims to narrow the gap between the distributions of generated and real sample data, resulting in clearer, more realistic images.

[0098] In this embodiment, the generator is optimized using predictions of image patches synthesized from mask regions (i.e., facial regions). This optimization encourages the discriminator to distinguish image patches synthesized from mask regions from real-world background image patches outside the mask regions. Thus, the enhanced discriminator, in turn, helps the generator synthesize more realistic textures.

[0099] In some embodiments, in order to ensure the detail fidelity of the generated image, the accuracy of pixel-level reconstruction, and the visual fidelity of the restored image, the loss function also includes reconstruction loss, perceptual loss, style loss, and total variation regularization loss.

[0100] The reconstruction loss can be described by the following formula:

[0101] in, It is a reconstruction loss. It is the original face image. It represents the age characteristics of the original facial image. It refers to the age characteristics of the target facial image. It predicts human face images.

[0102] The reconstruction loss aims to minimize the L1 distance between the predicted face image and the target face image.

[0103] The perceived loss can be described by the following formula:

[0104] in, It is perceived loss. It is the feature map of the i-th layer after feature extraction from the original face image using the VGG19 network. It is the feature map of the i-th layer after feature extraction of the target face image through the VGG19 network. yes The number of elements.

[0105] Perceptual loss aims to minimize the L1 distance between the feature maps of the predicted face image and the target face image.

[0106] The style loss can be described by the following formula:

[0107] in, It's a loss of style. It is the Lagm matrix for predicting the i-th layer features of a face image. It is the Lagm matrix of the i-th layer features of the target face image.

[0108] Style loss aims to minimize the L1 distance between the Gram matrices of deep features of the predicted face image and the target face image.

[0109] The total variation regularization loss can be described by the following formula:

[0110] in, It is the total variation regularized loss. It predicts the pixel value in the i-th row and j-th column of a face image. It predicts the pixel value in the (i+1)th row and jth column of a face image. It predicts the pixel value in the i-th row and j+1-th column of a face image.

[0111] The total variation regularization loss aims to calculate the sum of the absolute values ​​of the differences between adjacent pixel values ​​in the horizontal and vertical directions of a predicted face image.

[0112] Considering that the differences in the predicted age features output by the generator can easily lead to unexplained color shifts, such as a bluish, reddish, or grayish tint, or the appearance of strange high-frequency noise, introducing total variation regularization loss can make the predicted face image smoother and suppress noise points.

[0113] Thus, the total loss function of the configuration can be described by the following formula:

[0114] in, For the total loss function, It is the generation loss. These are the weights used to generate the loss. It is a reconstruction loss. It is the weight of reconstruction loss. It is perceived loss. It is the weight of perceived loss. It's a loss of style. It is the weight of style loss. It is the total variation regularized loss. It is the weight of the total variation regularization loss.

[0115] Thus, through the aforementioned total loss function, the face image generation network is constrained to move towards reducing the difference between the predicted face image and the target face image, the L1 distance, and smoothing the pixels of the predicted face image. As a result, the trained face image generation model has accurate and realistic prediction results.

[0116] In some embodiments, the method S100 further includes: S40: Before generating the network from the input image, perform random color enhancement or brightness enhancement on the original face images in the training samples.

[0117] In this way, the model learns to ignore irrelevant color and brightness fluctuations during training and focus on facial age features rather than relying on fixed color information. As a result, it can stably output high-quality images when faced with various colors and brightness inputs in real-world scenes, and its generalization ability is significantly improved.

[0118] After training a face image generation model using the method provided in this application, the model can be used to generate age-changing images of an individual. The method for generating age-changing images provided in this application can be implemented by various types of electronic devices with computing capabilities, such as smart terminals and servers.

[0119] The method for generating age-changing images provided in this application is described below with reference to exemplary applications and implementations of the terminal provided in the embodiments of this application. See also Figure 5 , Figure 5 This is a schematic flowchart of a method for generating images showing age changes provided in an embodiment of this application. Method S200 includes the following steps: S201: Obtain the test face image, the age of the test face image, and the expected age.

[0120] A smart terminal (such as a smartphone) with a built-in aging prediction assistant or youth-tracking assistant (application software) acquires a test subject's facial image, corresponding real age, and expected age. This test facial image can be captured by the smart terminal or input by the user. It is understood that the test facial image includes a face. The real age and expected age can be input by the user, for example, a real age of 20 and an expected age of 30, or a real age of 50 and an expected age of 30.

[0121] S202: Based on the test face image, the age of the test face image, and the expected age, obtain the age features and expected age features of the test face image.

[0122] The methods for obtaining the age features and expected age features of the test face image can refer to the methods described in step S20 and sub-steps S21 to S23 above, and will not be repeated here. The difference is that the mask matrix used for the expected age feature is the mask matrix of the test face image.

[0123] S203: Input the test face image, the age features of the test face image, and the expected age features into the face image generation model to obtain an age change image, in which the age of the individual is adapted to the expected age.

[0124] After acquiring the test face image, its age features, and expected age features, the terminal inputs them into the face image generation model. After processing, the model outputs an age change image. This age change image reflects a person's age in a way that matches their expected age. When the expected age is greater than the actual age, the age change image is a prediction of aging; when the expected age is less than the actual age, the age change image is a youthful-looking photo.

[0125] The face image generation model is trained using the method described in any of the above training method embodiments.

[0126] This application also provides an electronic device, see [link to document]. Figure 6 , Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device 300 includes a processor 301 and a memory 302. The processor 301 is connected to the memory 302, for example, the processor 301 can be connected to the memory 302 via a bus.

[0127] Processor 301 is configured to support the execution of electronic device 300. Figures 1-4 The method shown is for training a face image generation model or Figure 5The corresponding steps in the method for generating images of age changes are shown. The processor 301 can be a central processing unit (CPU), a network processor (NP), a hardware chip, or any combination thereof. The aforementioned hardware chip can be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The aforementioned PLD can be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), generic array logic (GAL), or any combination thereof.

[0128] Memory 302 is used to store program code, etc. Memory 302 may include volatile memory (VM), such as random access memory (RAM); memory 1002 may also include non-volatile memory (NVM), such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (SSD); memory 302 may also include combinations of the above types of memory.

[0129] In some possible cases, processor 301 may call the program code to perform the following operations: Acquire several image samples, including the original face image, the target face image, the age corresponding to the original face image, and the age corresponding to the target face image, wherein the original face image and the target face image belong to the same person; Several training samples are constructed based on several image samples. The training samples include the original face image, the age features of the original face image, and the age features of the target face image. The true label of the training samples is the target face image. The image generation network is iteratively trained using several training samples until it converges, resulting in a face image generation model.

[0130] In other possible scenarios, processor 301 may call program code to perform the following operations: Obtain the test face image, the age of the test face image, and the expected age; Based on the test face image, the age of the test face image, and the expected age, obtain the age features and expected age features of the test face image; The test face image, the age features of the test face image, and the expected age features are input into the face image generation model to obtain an age change image, in which the age of the individual is adapted to the expected age. The face image generation model is trained using the method described in the above embodiments.

[0131] This application also provides a computer-readable storage medium storing a computer program, the computer program including program instructions, which, when executed by a computer, cause the computer to perform the method for training a face image generation model or the method for generating age change images as described in the foregoing embodiments.

[0132] It should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0133] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software and a general-purpose hardware platform, or of course, using hardware. Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.

[0134] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and not to limit them; under the concept of this application, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of different aspects of this application as described above, which are not provided in detail for the sake of brevity; although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A method for training a face image generation model, characterized in that, include: Acquire several image samples, including an original face image, a target face image, the age corresponding to the original face image, and the age corresponding to the target face image, wherein the original face image and the target face image belong to the same person; Based on the aforementioned image samples, several training samples are constructed; the training samples include the original face image, the age features of the original face image, and the age features of the target face image, and the true label of the training samples is the target face image; The image generation network is iteratively trained using the aforementioned training samples until it converges, thus obtaining the face image generation model.

2. The method according to claim 1, characterized in that, The acquisition of several image samples includes: Acquire multiple facial images, wherein the multiple facial images include facial images of multiple individuals at multiple age groups; Identify the age of the multiple facial images; Take any two face images from multiple face images of the same individual as an image pair, wherein the image pair includes the original face image and the target face image; The image pair and the age of the face image in the image pair are used as the image sample.

3. The method according to claim 1, characterized in that, The construction of several training samples based on the aforementioned image samples includes: The facial region of the original face image is segmented, and the facial region of the face image and the age of the original face image are fused to obtain the age feature of the original face image. The facial region of the target face image is segmented, and the facial region of the target face image and the age of the target face image are fused to obtain the age feature of the target face image; The original face image, the age features of the original face image, and the age features of the target face image are used as the training samples, and the target face image is used as the true label of the training samples.

4. The method according to claim 1, characterized in that, The step of iteratively training the image generation network using the aforementioned training samples until the image generation network converges to obtain the face image generation model includes: The training samples are input into the image generation network for computation and processing, and the image generation network outputs a predicted age feature difference. The predicted age feature difference is fused with the original face image to obtain the predicted face image; The difference between the predicted face image and the target face image is calculated using a loss function. Based on the differences corresponding to several training samples, the model parameters of the image generation network are adjusted in reverse until the image generation network converges, thus obtaining the face image generation model.

5. The method according to claim 4, characterized in that, The image generation network includes a generator and a discriminator, wherein the discriminator includes a Soft Mask-Guided PatchGAN network structure.

6. The method according to claim 4, characterized in that, The loss function includes total variation regularization loss, which is used to calculate the sum of the absolute values ​​of the differences between adjacent pixel values ​​in the horizontal and vertical directions of the predicted face image.

7. The method according to any one of claims 1-6, characterized in that, Also includes: Before being input into the image generation network, the original face images in the training samples are subjected to random color enhancement or brightness enhancement processing.

8. A method for generating images showing changes in age, characterized in that, include: Obtain the test face image, the age of the test face image, and the expected age; Based on the test face image, the age of the test face image, and the expected age, obtain the age features and expected age features of the test face image; The test face image, the age features of the test face image, and the expected age features are input into the face image generation model to obtain the age change image, wherein the age of the individual in the age change image is adapted to the expected age; The face image generation model is trained using the method described in any one of claims 1-7.

9. An electronic device, characterized in that, include: At least one processor, and The memory communicatively connected to the at least one processor, wherein, The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the method according to any one of claims 1-8.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions for causing a computer device to perform the method as described in any one of claims 1-8.