Age estimation model training and estimation method, device, equipment and storage medium
Through adversarial training methods, combining age estimation and gender prediction, the impact of gender information on age estimation is weakened, and the robustness and accuracy of the age estimation model on different genders is improved.
Patent Information
- Application Number
- CN202210260388.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-16
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2042-03-16
AI Technical Summary
The existing age estimation models have large performance and are less robust when facing different genders.
By acquiring multiple face images in the training set, labeling age and gender labels, and using preset neural network models for adversarial training of age estimation and gender prediction, the impact of gender information on age estimation and improve the robustness of the model.
When facing different genders, the prediction accuracy and robustness of the age estimation model are improved, and the interference of gender classification on age estimation is reduced.
Smart Images

Figure CN114694215B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a method, apparatus, device, and storage medium for training and estimating an age estimation model. Background Art
[0002] Age, as an important facial attribute, has broad application prospects in fields such as human-computer interaction, smart commerce, security monitoring, and entertainment. Facial age estimation, as a key biometric recognition technology, has become a hot research topic in pattern recognition and computer vision. The facial age estimation problem is defined as automatically estimating a person's true age based on an input facial image using techniques such as computer vision. Although numerous researchers have devoted considerable effort to addressing age estimation, it is far from being solved and still faces many significant difficulties and challenges. Interference from factors such as gender is a typical example. Specifically, the age progression patterns of men and women differ, significantly increasing the difficulty of age estimation. Trained age estimation models can easily exhibit significant performance differences based on gender, resulting in poor algorithm robustness. Summary of the Invention
[0003] The present application provides a training and estimation method, apparatus, device and storage medium for an age estimation model, which is used to solve the problem of poor robustness of age estimation models in the prior art.
[0004] In a first aspect, an embodiment of the present application provides a method for training an age estimation model, comprising:
[0005] Obtaining a training set; wherein the training set includes: a plurality of face images, and each face image is annotated with an age label and a gender label;
[0006] Inputting each of the facial images into a preset neural network model to obtain facial image features and age estimation results corresponding to each of the facial images;
[0007] Obtaining a gender output result corresponding to each of the facial image features;
[0008] Based on the age estimation results, the gender output results, the age labels and the gender labels corresponding to each facial image, the preset neural network model is subjected to adversarial training between age estimation accuracy and gender prediction accuracy to obtain the age estimation model.
[0009] Optionally, the performing adversarial training on the preset neural network model between age estimation accuracy and gender prediction accuracy based on the age estimation result, the gender output result, the age label, and the gender label corresponding to each facial image to obtain the age estimation model includes:
[0010] The process of training the preset neural network model once using the age estimation result, the gender output result, the age label, and the gender label of each face image includes:
[0011] Calculating a gender accuracy parameter value based on the gender output result and the gender label; wherein the gender accuracy parameter value is used to characterize the accuracy of gender prediction;
[0012] Calculating the absolute value of the difference between the age estimation result and the age label as an age accuracy parameter value; wherein the age accuracy parameter value is used to characterize the accuracy of age estimation;
[0013] Performing adversarial training on the preset neural network model using the gender accuracy parameter value and the age accuracy parameter value to update a first parameter value of a first parameter in the preset neural network model;
[0014] If it is determined that the preset neural network model does not converge, executing the next training process according to the preset neural network model after updating the first parameter value;
[0015] Otherwise, the preset neural network model after updating the first parameter value is used as the age estimation model.
[0016] Optionally, the using the gender accuracy parameter value and the age accuracy parameter value to perform adversarial training on the preset neural network model to update a first parameter value of a first parameter in the preset neural network model includes:
[0017] Calculating a difference between the age accuracy parameter value and the gender accuracy parameter value, and using the difference as a loss function of the preset neural network model;
[0018] The first parameter value is updated using the loss function.
[0019] Optionally, the updating the first parameter value by using the loss function includes:
[0020] A derivative of the loss function with respect to the first parameter is obtained to obtain a first derivative result; and a first parameter value of the first parameter is updated based on the first derivative result.
[0021] Optionally, the calculating a gender accuracy parameter value based on the gender output result and the gender label includes:
[0022] Inputting the gender output result into a prediction function to obtain a gender prediction vector;
[0023] Based on the gender prediction vector and the gender label, a gender classification loss function value is calculated, and the gender classification loss function value is used as the gender accuracy parameter value.
[0024] Optionally, calculating the gender classification loss function value based on the gender prediction vector and the gender label includes:
[0025] Obtaining, from the gender prediction vector, a vector element value corresponding to the gender label;
[0026] Taking the negative logarithm of the vector element value to obtain the gender classification loss function value.
[0027] Optionally, obtaining the gender output result corresponding to each of the facial image features includes:
[0028] The discriminator determines the gender output result corresponding to each of the facial image features.
[0029] Optionally, after calculating the gender accuracy parameter value based on the gender output result and the gender label, the method further includes:
[0030] Calculate the second derivative of the age accuracy parameter value with respect to the second parameter in the discriminator to obtain a second derivative result, and update the second parameter value of the second parameter based on the second derivative result, so that in the next training process, the gender output result corresponding to the facial image feature is obtained through the updated discriminator.
[0031] Optionally, obtaining a training set includes:
[0032] Get multiple face images;
[0033] For each of the facial images, obtaining at least one labeling result for the age of the facial image, calculating an average of the at least one labeling result, and rounding down the average to obtain a rounded result; using the rounded result as the age label of the facial image, and obtaining a gender label for the facial image, thereby obtaining a labeled facial image;
[0034] Each of the labeled face images is used as the training set.
[0035] In a second aspect, an embodiment of the present application provides an age estimation method, comprising:
[0036] Obtain the target face image to be estimated;
[0037] The target face image is input into a pre-trained age estimation model to obtain an estimated target age; wherein the age estimation model is trained based on the age estimation model training method described in the first aspect.
[0038] In a third aspect, an embodiment of the present application provides a training device for an age estimation model, comprising:
[0039] A first acquisition module is configured to acquire a training set, wherein the training set includes: a plurality of face images, each of which is annotated with an age label and a gender label;
[0040] A processing module, configured to input each of the facial images into a preset neural network model to obtain facial image features and age estimation results corresponding to each of the facial images;
[0041] A second acquisition module is used to obtain the gender output result corresponding to each of the facial image features;
[0042] A training module is used to perform adversarial training between the age estimation accuracy and the gender prediction accuracy on the preset neural network model based on the age estimation results, the gender output results, the age labels and the gender labels corresponding to each facial image, to obtain the age estimation model.
[0043] In a fourth aspect, an embodiment of the present application provides an age estimation device, comprising:
[0044] The third acquisition module is used to acquire the target face image to be estimated;
[0045] An estimation module is used to input the target face image into a pre-trained age estimation model to obtain an estimated target age; wherein the age estimation model is trained based on the age estimation model training method described in the first aspect.
[0046] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a memory, and a communication bus, wherein the processor and the memory communicate with each other via the communication bus;
[0047] The memory is used to store computer programs;
[0048] The processor is configured to execute the program stored in the memory to implement the age estimation model training method described in the first aspect or the age estimation method described in the second aspect.
[0049] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the age estimation model training method described in the first aspect or the age estimation method described in the second aspect.
[0050] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the method provided by the embodiment of the present application obtains a training set; wherein the training set includes: multiple facial images, and each facial image is annotated with an age label and a gender label; each facial image is input into a preset neural network model to obtain the facial image features and age estimation results corresponding to each facial image; the gender output results corresponding to each facial image are obtained; based on the age estimation results, gender output results, age labels and gender labels corresponding to each facial image, the preset neural network model is subjected to adversarial training between age estimation accuracy and gender prediction accuracy to obtain an age estimation model. In the process of training the age estimation model, the gender output results corresponding to the facial images are introduced for model training, which takes into account the differences between the age patterns of men and women and improves the prediction robustness of the model when facing different genders. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0052] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0053] Figure 1 A flowchart of a method for training an age estimation model provided in an embodiment of the present application;
[0054] Figure 2 A schematic diagram of the network architecture of the training model provided in an embodiment of the present application;
[0055] Figure 3 A flowchart of a method for training the preset neural network model provided in an embodiment of the present application;
[0056] Figure 4 A flowchart of an age estimation method provided in an embodiment of the present application;
[0057] Figure 5 A schematic diagram of the structure of a training device for an age estimation model provided in an embodiment of the present application;
[0058] Figure 6 A schematic diagram of the structure of an age estimation device provided in an embodiment of the present application;
[0059] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0060] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0061] In order to solve the problem of poor robustness of age estimation models in the prior art, the present invention provides a training method for an age estimation model, such as Figure 1 As shown, the specific steps include:
[0062] Step 101: Obtain a training set; wherein the training set includes: multiple face images, and each face image is annotated with an age label and a gender label;
[0063] When obtaining a training set, multiple facial images can be first obtained, and then each facial image can be labeled to obtain a training set. Specifically, multiple facial images are obtained; for each facial image, at least one labeling result for the facial image's age is obtained, the at least one labeling result is averaged, and the average is rounded down to obtain a rounded result; the rounded result is used as the age label for the facial image, and the gender label for the facial image is obtained to obtain labeled facial images; and each labeled facial image is used as the training set.
[0064] For ease of understanding, here is an example to collect a large amount of face image data, each face image is represented by X, X∈R H×W×3 ; Among them, H represents height, W represents width, and 3 represents RGB channels.
[0065] For each face image X, obtain n people’s age annotations for the same face image, and obtain n annotation results Where n is a positive integer, and each annotation result is an integer between 0 and 100, representing 0 to 100 years old. The average value of , and the average value is rounded down as the final age labeling result of the face image X, that is, the age label a:
[0066]
[0067] in, Indicates the rounding down of *. During the annotation process, the gender j of the face image also needs to be annotated, where j∈{1,2}, where 1 represents male and 2 represents female.
[0068] In practice, all labeled face images can be divided into two parts, for example, in a 9:1 ratio. One part is used as training set Data1, and the other as test set Data2. Training set Data1 is used for model training, while test set Data2 is used to verify the quality of the trained model after it is completed.
[0069] Step 102: Input each facial image into a preset neural network model to obtain facial image features and age estimation results corresponding to each facial image;
[0070] like Figure 2 As shown, an embodiment of the present application provides a feasible preset neural network model, which mainly includes two parts: a feature extraction part and an age estimation part; the feature extraction part can be composed of two convolution blocks BLOCK (BLOCK1 and BLOCK2) and a fully connected layer FC1 cascaded, wherein each BLOCK contains a convolution layer and an activation function, for example: the convolution layer is 3 layers, and each convolution layer uses a 3*3 convolution kernel, and the activation function can use a ReLu function. Among them, the full name of the ReLu function is the Rectified Linear Unit (ReLU), also known as the rectified linear unit, which is an activation function commonly used in artificial neural networks. The age estimation part can be composed of two fully connected layers (FC3 and FC_a) cascaded.
[0071] In the specific implementation, each face image is input into the feature extraction part to obtain the face image features, and the face image features are input into the age estimation part to obtain the age estimation result.
[0072] Furthermore, it should be noted that the embodiments of this application only provide an exemplary embodiment of a feasible preset neural network model; preset neural network models with other structures may also be used. The number and size of convolutional layers and the number and size of fully connected layers in the convolutional block can be determined based on the speed and accuracy requirements of the specific application. Generally speaking, the greater the number, the deeper the network as a whole, the better the performance, but the slower the speed.
[0073] Step 103, obtaining the gender output result corresponding to each facial image feature;
[0074] Specifically, the facial image features can be input into the gender classification model to obtain the gender output result corresponding to the facial image features. In the specific implementation, a discriminator can be used to obtain the gender output results corresponding to the facial image features. The gender output contains two elements, which represent the probability of the face image being male or female respectively.
[0075] During the training phase, the discriminator can be cascaded after the feature extraction part and in parallel with the age estimation part, such as Figure 2 As shown, the discriminator can be implemented by two cascaded fully connected layers (FC2 and FC_g).
[0076] The input of the preset neural network model is a face image X of size H×W×3. The face image X is extracted through the feature extraction part, that is, the two blocks (Block1 and Block2) and a fully connected layer FC1 in the figure to obtain a face image feature (feature vector) f∈R with a length of c. c ,The face image feature f not only contains age information but also gender information, which is not conducive to gender-robust age estimation.,The following goal is to weaken the influence of gender information on,age estimation.
[0077] The facial image feature f is fed into the discriminator, whose purpose is to accurately classify gender. Specifically, the facial image feature f passes through the two fully connected layers (FC2 and FC_g) of the discriminator to obtain the gender output result.
[0078] The facial image feature f is sent to the age estimation part (which also contains two fully connected layers FC3 and FC_a) to obtain the age estimation result
[0079] For ease of description, the feature extraction and age estimation components of the neural network model are collectively referred to as N1, and the discriminator is referred to as N2. During the training phase, N1 is trained based on the gender output of discriminator N2. However, once the neural network model is trained, only N1 is used during recognition. N2 aims to accurately determine gender as much as possible using the shared facial image feature f, while N1 aims to minimize age estimation error while reducing N2's classification accuracy. Through adversarial training between N1 and N2, the gender information contained in the shared facial image feature f is weakened, resulting in a more robust neural network model N1 for age estimation.
[0080] Step 104 : Based on the age estimation results, gender output results, age labels, and gender labels corresponding to each facial image, adversarial training is performed on the preset neural network model between the accuracy of age estimation and the accuracy of gender prediction to obtain an age estimation model.
[0081] In an embodiment of the present application, a training set is obtained; wherein the training set includes: multiple facial images, each of which is annotated with an age label and a gender label; each facial image is input into a preset neural network model to obtain facial image features and age estimation results corresponding to each facial image; a gender output result corresponding to each facial image feature is obtained; based on the age estimation results, gender output results, age labels, and gender labels corresponding to each facial image, the preset neural network model is trained adversarially between age estimation accuracy and gender prediction accuracy to obtain an age estimation model. In the process of training the age estimation model, the gender output results corresponding to the facial images are introduced for model training, taking into account the differences between male and female age patterns and improving the model's prediction robustness when facing different genders.
[0082] In an optional embodiment, if Figure 3 As shown, based on the age estimation results, gender output results, age labels, and gender labels corresponding to each face image, the preset neural network model is trained on the adversarial between age estimation accuracy and gender prediction accuracy to obtain an age estimation model, including:
[0083] The process of training a preset neural network model using the age estimation result, gender output result, age label and gender label of each face image includes:
[0084] Step 301: Calculate a gender accuracy parameter value based on the gender output result and the gender label; wherein the gender accuracy parameter value is used to represent the accuracy of gender prediction;
[0085] In the above embodiment, it is mentioned that the gender output result can be obtained by using the discriminator. When calculating the gender accuracy parameter value, the accuracy of gender prediction can be characterized by determining the gender classification loss function value of the discriminator, that is, the gender classification loss function of the discriminator is used as the gender accuracy parameter value.
[0086] In a specific embodiment, the gender output result can be input into the prediction function to obtain a gender prediction vector; based on the gender prediction vector and the gender label, the gender classification loss function value is calculated, and the gender classification loss function value is used as the gender accuracy parameter value.
[0087] In the specific implementation, the prediction function can be a normalized exponential function (softmax function), or other prediction functions. The gender output result is fed into the softmax function to obtain the gender prediction vector
[0088]
[0089] in, represent The j-th element of , where j is 1 or 2; represent The jth element of , where j is 1 or 2. m represents the index of the element in the gender prediction vector, for example: There are two elements in the equation, the first element represents male and the second element represents female. When m=1, Represents the first element, that is, the vector element corresponding to males. When m=2, Represents the second element, the vector element representing female. Represents: Two elements are summed with e as the base.
[0090] After that, we predict the gender vector And gender label j∈{1,2} (for example: 1 represents male, 2 represents female) to calculate the gender classification loss function L gender :
[0091]
[0092] If the gender label is 1, that is, the marked gender is male, then when calculating the gender classification loss function, the element corresponding to male is used for calculation; otherwise, the element corresponding to female is used for calculation.
[0093] In addition, after calculating the gender accuracy parameter value based on the gender output results and gender labels, it also includes:
[0094] A second derivative of the age accuracy parameter value with respect to the second parameter in the discriminator is calculated to obtain a second derivative result, and based on the second derivative result, the second parameter value of the second parameter is updated so that in the next training process, the gender output result corresponding to the facial image feature is obtained through the updated discriminator.
[0095] When implemented with a discriminator, the discriminator's goal is to discriminate gender as accurately as possible through the facial image feature f, that is, the discriminator's goal is to minimize L gender , calculate the gender classification loss function L through the back propagation algorithm gender Derivatives of all parameters W2 with respect to N2 (i.e. the second derivative result), then update the various parameters of N2 through the stochastic gradient descent algorithm:
[0096]
[0097] Among them, α is the learning rate, which is a pre-set hyperparameter, and common values are 0.01, 0.001, etc.
[0098] During a training process, the second parameter value of the discriminator is updated so that the gender output result is more accurate during the next training process, ensuring that the training result of the age estimation model is more accurate.
[0099] Step 302: Calculate the absolute value of the difference between the age estimation result and the age label as the age accuracy parameter value; wherein the age accuracy parameter value is used to represent the accuracy of the age estimation;
[0100] When training the model, the age accuracy parameter value can be used as the age estimation loss function. Calculate the age estimation loss function L with the age label a age :
[0101]
[0102] Here, |*| represents the absolute value of *.
[0103] Step 303: Perform adversarial training on the preset neural network model using the gender accuracy parameter value and the age accuracy parameter value to update the first parameter value of the first parameter in the preset neural network model;
[0104] Specifically, the difference between the age accuracy parameter value and the gender accuracy parameter value is calculated, and the difference is used as the loss function of the preset neural network model; the first parameter value is updated using the loss function.
[0105] The purpose of training using the adversarial idea is to minimize the age estimation error while reducing the gender classification accuracy of N2. Through adversarial training between N1 and N2, the gender information contained in the facial image feature f is weakened, thereby obtaining a more robust age estimation model N1.
[0106] In the specific implementation, when designing the loss function of the preset neural network model, the difference between the age accuracy parameter value and the gender accuracy parameter value is used as the loss function, that is, the purpose of N1 is to minimize the age estimation loss function L age , while maximizing L gen der, so the loss function of N1 is L age with -L gender sum:
[0107] L=-L gender+L age
[0108] The derivative of the loss function L with respect to all parameters of N1 (i.e. the first parameter) is calculated through the back-propagation algorithm, and then the parameters of N1 are updated through the stochastic gradient descent algorithm:
[0109]
[0110] Among them, α is the learning rate, which is a pre-set hyperparameter, and common values are 0.01, 0.001, etc.
[0111] Step 304, determining whether the preset neural network model has converged, if not, executing step 305; otherwise, executing step 306;
[0112] Typically, model convergence is determined by comparing the stability of the loss function over several training cycles. If the loss function stabilizes within a certain value or range, the model is considered converged; otherwise, it is considered non-converged. However, in practice, convergence is not easy to achieve. Alternatively, the number of training cycles can be used as a proxy. If a preset number of training cycles is reached, for example, 10,000, the model is considered converged. Otherwise, the model is considered non-converged.
[0113] Step 305, executing the next training process according to the preset neural network model after updating the first parameter value;
[0114] If convergence does not occur and training needs to be continued, training is performed according to the preset neural network model after the first parameter value of the first parameter is updated, so as to continuously improve the network parameters in each training.
[0115] Step 306: Using the preset neural network model after updating the first parameter value as the age estimation model.
[0116] If the model converges, the training can be ended, and the preset neural network model after the first parameter value is updated is used as the age estimation model.
[0117] In an embodiment of the present application, the differences between male and female age patterns are explicitly considered. When training an age estimation model (age estimation model), gender output results are introduced, and the model is adversarially trained using age accuracy parameter values and gender accuracy parameter values. Specifically, a discriminator is introduced into the deep age estimation model. The goal of the discriminator (N2) is to accurately identify gender based on facial image features obtained by the age estimation model, while the goal of the age estimation model (N1) is to minimize the age estimation error while reducing the gender classification accuracy of the discriminator. Through such adversarial training, the gender information contained in the facial image features extracted by the age estimation model can be minimized, thereby improving the prediction robustness of the model when facing different genders.
[0118] After training the model using the above method, you can select a test sample X from the test set Data2 and feed it into the trained model N1 to get the age estimation result. The final predicted age is in, Represents a floor operation on *.
[0119] The above embodiment focuses on the specific steps in the model training stage, and after the model is trained, it can be used in actual testing. Figure 4 As shown, the embodiment of the present application also provides an age estimation method, including:
[0120] Step 401, obtaining a target face image to be estimated;
[0121] Step 402: Input the target face image into a pre-trained age estimation model to obtain an estimated target age; wherein the age estimation model is trained based on the above-mentioned age estimation model training method.
[0122] The age estimation method provided in the embodiment of the present application is obtained through the above-mentioned trained model recognition, which can ensure the prediction robustness of the model when facing different genders. Therefore, the age estimation result is more accurate.
[0123] Based on the same concept, an embodiment of the present application provides a training device for an age estimation model. The specific implementation of the device can be found in the description of the method embodiment part, and the repeated parts will not be repeated. Figure 5 As shown, the device mainly includes:
[0124] The first acquisition module 501 is used to acquire a training set; wherein the training set includes: a plurality of face images, and each face image is annotated with an age label and a gender label;
[0125] Processing module 502, configured to input each of the facial images into a preset neural network model to obtain facial image features and age estimation results corresponding to each of the facial images;
[0126] The second acquisition module 503 is used to obtain the gender output result corresponding to each of the facial image features;
[0127] The training module 504 is used to perform adversarial training between the age estimation accuracy and the gender prediction accuracy on the preset neural network model based on the age estimation results, the gender output results, the age labels and the gender labels corresponding to each facial image, to obtain the age estimation model.
[0128] In a specific embodiment, the training module 504 is used to calculate a gender accuracy parameter value based on the gender output result and the gender label; wherein the gender accuracy parameter value is used to characterize the accuracy of gender prediction; the absolute value of the difference between the age estimation result and the age label is calculated as the age accuracy parameter value; wherein the age accuracy parameter value is used to characterize the accuracy of age estimation; the preset neural network model is adversarially trained using the gender accuracy parameter value and the age accuracy parameter value to update the first parameter value of the first parameter in the preset neural network model; if it is determined that the preset neural network model does not converge, the next training process is performed according to the preset neural network model after the first parameter value is updated; otherwise, the preset neural network model after the first parameter value is updated is used as the age estimation model.
[0129] In a specific embodiment, the training module 504 is used to calculate the difference between the age accuracy parameter value and the gender accuracy parameter value, and use the difference as the loss function of the preset neural network model; and use the loss function to update the first parameter value.
[0130] In a specific embodiment, the training module 504 is configured to calculate the derivative of the loss function with respect to the first parameter to obtain a first derivative result; and update a first parameter value of the first parameter based on the first derivative result.
[0131] In a specific embodiment, the training module 504 is used to input the gender output result into the prediction function to obtain a gender prediction vector; based on the gender prediction vector and the gender label, calculate the gender classification loss function value, and use the gender classification loss function value as the gender accuracy parameter value.
[0132] In a specific embodiment, the training module 504 is configured to obtain a vector element value corresponding to the gender label from the gender prediction vector; and take a negative logarithm of the vector element value to obtain the gender classification loss function value.
[0133] In a specific embodiment, the training module 504 is configured to determine the gender output result corresponding to each of the facial image features through a discriminator.
[0134] In a specific embodiment, a training device for an age estimation model provided in an embodiment of the present application further includes: an updating module for calculating a second derivative of the age accuracy parameter value with respect to a second parameter in the discriminator after calculating a gender accuracy parameter value based on the gender output result and the gender label, obtaining a second derivative result, and updating the second parameter value of the second parameter based on the second derivative result, so that in the next training process, the gender output result corresponding to the facial image feature can be obtained through the updated discriminator.
[0135] In a specific embodiment, the first acquisition module 501 is used to acquire multiple facial images; for each of the facial images, obtain at least one annotation result for the age of the facial image, calculate the average value of the at least one annotation result, and round down the average value to obtain a rounded result; use the rounded result as the age label of the facial image, and obtain the gender label of the facial image to obtain a labeled facial image; and use each of the labeled facial images as the training set.
[0136] In addition, the embodiment of the present application also provides an age estimation device. The specific implementation of the device can be found in the description of the method embodiment part, and the repeated parts will not be repeated. Figure 6 As shown, the device mainly includes:
[0137] The third acquisition module 601 is used to acquire the target face image to be estimated;
[0138] The estimation module 602 is configured to input the target face image into a pre-trained age estimation model to obtain an estimated target age; wherein the age estimation model is trained based on the above-mentioned age estimation model training method.
[0139] Based on the same concept, an electronic device is also provided in the embodiment of the present application, such as Figure 7As shown, the electronic device mainly includes: a processor 701, a memory 702 and a communication bus 703, wherein the processor 701 and the memory 702 communicate with each other via the communication bus 703. The memory 702 stores a program that can be executed by the processor 701, and the processor 701 executes the program stored in the memory 702 to implement the following steps:
[0140] Obtaining a training set; wherein the training set includes: a plurality of face images, and each face image is annotated with an age label and a gender label;
[0141] Inputting each of the facial images into a preset neural network model to obtain facial image features and age estimation results corresponding to each of the facial images;
[0142] Obtaining a gender output result corresponding to each of the facial image features;
[0143] Based on the age estimation result, the gender output result, the age label, and the gender label corresponding to each facial image, performing adversarial training between age estimation accuracy and gender prediction accuracy on the preset neural network model to obtain the age estimation model;
[0144] or,
[0145] Obtain the target face image to be estimated;
[0146] The target face image is input into a pre-trained age estimation model to obtain an estimated target age; wherein the age estimation model is trained based on the above-mentioned age estimation model training method.
[0147] The communication bus 703 mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus 703 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 Only one thick line is used in the diagram, but this does not mean that there is only one bus or one type of bus.
[0148] The memory 702 may include a random access memory (RAM) or a non-volatile memory, such as at least one disk storage. Alternatively, the memory may be at least one storage device located away from the processor 701.
[0149] The above-mentioned processor 701 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc., and can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
[0150] In another embodiment of the present application, a computer-readable storage medium is provided, which stores a computer program. When the computer program is run on a computer, the computer executes a training method for an age estimation model or an age estimation method described in the above embodiment.
[0151] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instruction is loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instruction can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instruction is transmitted from a website, computer, server or data center to another website, computer, server or data center by wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium can be a magnetic medium (such as a floppy disk, hard disk, tape, etc.), an optical medium (such as a DVD) or a semiconductor medium (such as a solid-state hard disk), etc.
[0152] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0153] The foregoing description is intended only to provide specific embodiments of the present invention, which will enable those skilled in the art to understand and implement the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not intended to be limited to the embodiments shown herein, but is intended to be accorded the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A training method for an age estimation model, characterized in that: include: Obtaining a training set; wherein the training set includes: a plurality of face images, and each face image is annotated with an age label and a gender label; Inputting each of the facial images into a preset neural network model to obtain facial image features and age estimation results corresponding to each of the facial images; Obtaining a gender output result corresponding to each of the facial image features; Based on the age estimation results, the gender output results, the age labels, and the gender labels corresponding to each facial image, adversarial training is performed on the preset neural network model between the age estimation accuracy and the gender prediction accuracy to obtain the age estimation model, wherein the adversarial training between the feature extraction part, the age estimation part, and the discriminator of the preset neural network model weakens the gender information contained in the shared facial image features, thereby improving the age estimation accuracy of the preset neural network model and reducing the gender classification accuracy.
2. The method for training an age estimation model according to claim 1, wherein: The method further comprises performing adversarial training on the preset neural network model between age estimation accuracy and gender prediction accuracy based on the age estimation result, the gender output result, the age label, and the gender label corresponding to each facial image to obtain the age estimation model, including: The process of training the preset neural network model once using the age estimation result, the gender output result, the age label, and the gender label of each face image includes: Calculating a gender accuracy parameter value based on the gender output result and the gender label; wherein the gender accuracy parameter value is used to characterize the accuracy of gender prediction; Calculating the absolute value of the difference between the age estimation result and the age label as an age accuracy parameter value; wherein the age accuracy parameter value is used to characterize the accuracy of age estimation; Performing adversarial training on the preset neural network model using the gender accuracy parameter value and the age accuracy parameter value to update a first parameter value of a first parameter in the preset neural network model; If it is determined that the preset neural network model does not converge, executing the next training process according to the preset neural network model after updating the first parameter value; Otherwise, the preset neural network model after updating the first parameter value is used as the age estimation model.
3. The method for training an age estimation model according to claim 2, wherein: The method of performing adversarial training on the preset neural network model by using the gender accuracy parameter value and the age accuracy parameter value to update a first parameter value of a first parameter in the preset neural network model includes: Calculating a difference between the age accuracy parameter value and the gender accuracy parameter value, and using the difference as a loss function of the preset neural network model; The first parameter value is updated using the loss function.
4. The method for training an age estimation model according to claim 3, wherein: The updating of the first parameter value by using the loss function includes: A derivative of the loss function with respect to the first parameter is obtained to obtain a first derivative result; and a first parameter value of the first parameter is updated based on the first derivative result.
5. The method for training an age estimation model according to claim 2, wherein: The calculating of a gender accuracy parameter value based on the gender output result and the gender label includes: Inputting the gender output result into a prediction function to obtain a gender prediction vector; Based on the gender prediction vector and the gender label, a gender classification loss function value is calculated, and the gender classification loss function value is used as the gender accuracy parameter value.
6. The method for training an age estimation model according to claim 5, wherein: The calculating the gender classification loss function value based on the gender prediction vector and the gender label includes: Obtaining, from the gender prediction vector, a vector element value corresponding to the gender label; Taking the negative logarithm of the vector element value to obtain the gender classification loss function value.
7. The method for training an age estimation model according to any one of claims 2 to 6, wherein: The obtaining of the gender output result corresponding to each of the facial image features includes: The discriminator determines the gender output result corresponding to each of the facial image features.
8. The method for training an age estimation model according to claim 7, wherein: After calculating the gender accuracy parameter value based on the gender output result and the gender label, the method further includes: Calculate the second derivative of the age accuracy parameter value with respect to the second parameter in the discriminator to obtain a second derivative result, and update the second parameter value of the second parameter based on the second derivative result, so that in the next training process, the gender output result corresponding to the facial image feature is obtained through the updated discriminator.
9. The method for training an age estimation model according to claim 1, wherein: The obtaining of the training set comprises: Get multiple face images; For each of the facial images, obtaining at least one labeling result for the age of the facial image, calculating an average of the at least one labeling result, and rounding down the average to obtain a rounded result; using the rounded result as the age label of the facial image, and obtaining a gender label for the facial image, thereby obtaining a labeled facial image; Each of the labeled face images is used as the training set.
10. A method for estimating age, characterized in that: include: Obtain the target face image to be estimated; The target face image is input into a pre-trained age estimation model to obtain an estimated target age; wherein the age estimation model is trained based on the age estimation model training method according to any one of claims 1 to 9.
11. A training device for an age estimation model, characterized in that: include: A first acquisition module is configured to acquire a training set, wherein the training set includes: a plurality of face images, each of which is annotated with an age label and a gender label; A processing module, configured to input each of the facial images into a preset neural network model to obtain facial image features and age estimation results corresponding to each of the facial images; A second acquisition module is used to obtain the gender output result corresponding to each of the facial image features; A training module is configured to perform adversarial training on the preset neural network model between age estimation accuracy and gender prediction accuracy based on the age estimation results, the gender output results, the age labels, and the gender labels corresponding to each facial image, to obtain the age estimation model, wherein the adversarial training between the feature extraction part, the age estimation part, and the discriminator of the preset neural network model weakens the gender information contained in the shared facial image features, thereby improving the age estimation accuracy of the preset neural network model and reducing the gender classification accuracy.
12. An age estimation device, characterized in that: include: The third acquisition module is used to acquire the target face image to be estimated; An estimation module is used to input the target face image into a pre-trained age estimation model to obtain an estimated target age; wherein the age estimation model is trained based on the age estimation model training method according to any one of claims 1 to 9.
13. An electronic device, characterized in that: include: A processor, a memory, and a communication bus, wherein the processor and the memory communicate with each other via the communication bus; The memory is used to store computer programs; The processor is configured to execute the program stored in the memory to implement the age estimation model training method according to any one of claims 1 to 9 or the age estimation method according to claim 10.
14. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the age estimation model training method according to any one of claims 1 to 9 or the age estimation method according to claim 10 is implemented.
Citation Information
Patent Citations
Training method of gender and age recognition model, recognition method, medium and equipment
CN112329693A
Unsupervised cross-domain distance metric adaptation with feature transfer network
US20190354801A1