Method for predicting age based on facial image, computing device, and storage medium
Through the dual-network model architecture, combining the first network model and the second network model, the problem of insufficient generalization ability of the traditional facial age prediction model is solved, and accurate age recognition of different groups of people and improvement of model capacity are achieved.
Patent Information
- Application Number
- CN202510790554.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-13
- Publication Date
- 2025-09-26
AI Technical Summary
Traditional facial age prediction models based on convolutional neural networks have insufficient generalization capabilities and limited model capacity, resulting in large deviations in age prediction results for different populations. In addition, existing datasets are relatively single and cannot cover the facial features of different regions and populations around the world.
A dual-network model architecture is adopted, combining the first network model and the second network model. The first network model extracts facial image features to generate the first predicted age, and the second network model learns the distribution differences between facial features and different age categories to generate the second predicted age. The second network model is initialized through pre-trained parameters to improve the generalization and capacity of the model.
The accuracy and generalization ability of the facial age prediction model have been improved, which can better adapt to the facial features of different groups of people, improve the training efficiency and capacity of the model, and achieve accurate age recognition for different groups of people.
Smart Images

Figure CN120708261A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure generally relate to the technical field of facial age estimation, and more particularly to a method, computing device, and storage medium for predicting age based on facial images. Background Art
[0002] Traditional methods for predicting facial age usually use convolutional neural networks to build facial age prediction models, such as Resnet50, VGG19, and Se-Resnext50. However, traditional age prediction models based on convolutional neural network architectures have obvious problems with insufficient generalization ability when used for facial age estimation.
[0003] In addition, the capacity limitations of traditional facial age prediction methods make it difficult to support training models with large amounts of data. In addition, traditional facial datasets (for example, AFAD only contains Asian faces, and the CACD dataset only contains photos of 2,000 different celebrities from different periods) are relatively single. These factors will lead to deviations in the model's age prediction results.
[0004] In summary, the traditional method of predicting age based on facial images has the following shortcomings: the model lacks generalization and versatility, resulting in large deviations in age prediction results for different groups of people. Summary of the Invention
[0005] To address the above issues, the present disclosure provides a method, computing device, and storage medium for predicting age based on facial images, which can effectively improve the generalization and capacity of the model, thereby achieving excellent age prediction results for different groups of people.
[0006] According to a first aspect of the present disclosure, a method for predicting age based on facial images is provided, comprising: inputting acquired target facial image data of a target object to be predicted into a facial age prediction model, the facial age prediction model comprising a first network model and a second network model; extracting features of the target facial image data via the first network model to generate a first predicted age; learning, via the second network model, distribution differences between facial features of the target object to be predicted and facial features of different age categories based on the target facial image data to generate a second predicted age, the second network model being constructed by initializing network parameters of the pre-trained first network model; and generating a predicted age for the target facial image data based on the first predicted age and the second predicted age.
[0007] According to a second aspect of the present disclosure, a computing device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; the memory storing instructions executable by the at least one processor, the instructions being executed by the at least one processor so as to enable the at least one processor to execute the method of the first aspect of the present disclosure.
[0008] In a third aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program code is stored. When the computer program code is executed, the method of the first aspect of the present disclosure is performed.
[0009] In a fourth aspect of the present disclosure, a computer program product is provided, comprising a computer program, which performs the method of the first aspect of the present disclosure when executed by a machine.
[0010] In some embodiments, the method for predicting age based on facial images also includes: pre-training a first network model based on a constructed facial image dataset to determine multiple network parameters from the pre-trained first network model, the facial image dataset including facial images of multiple age categories of the sample object; initializing a second network model based on at least part of the determined multiple network parameters; training the initialized second network model based on the facial image dataset to learn the distribution differences of facial features of different age categories; and constructing a facial age prediction model based at least on the first network model and the second network model.
[0011] In some embodiments, a facial image dataset is constructed by: collecting different types of facial image data comprising multiple age categories, the types including multiple items of the following: gender, region, race, occupation, image source, and image quality; processing the collected facial image data so that the processed facial image data conforms to a normal distribution trend within a predetermined age range and to a uniform distribution trend outside the predetermined age range; and adding at least an age feature label to the processed facial image data to construct a facial image dataset.
[0012] In some embodiments, the first network model is constructed based on the Swin-Transformer architecture, and the first network model is pre-trained based on the constructed facial image dataset, so as to determine multiple network parameters from the pre-trained first network model, including: extracting multi-scale features about the facial image based on the facial image dataset through the Swin-Transformer backbone network of the first network model; processing the extracted multi-scale features of the facial image through the hidden layer; determining a first predicted age category of the facial image based on the multi-scale features processed by the hidden layer, and calculating a classification loss function related to the first predicted age category; calculating a first predicted age value of the facial image based on the multi-scale features processed by the fully connected layer, and calculating a regression loss function related to the first predicted age value; and training the first network model based on the classification loss function and the regression loss function.
[0013] In some embodiments, the plurality of network parameters include one or more of the following: self-attention weights, multi-layer perception weights, position encoding, window shift mechanism parameters, weight matrix, bias term.
[0014] In some embodiments, the second network model is constructed based on the Swin-Transformer architecture, and is trained on the initialized second network model based on the facial image dataset to learn the distribution differences of facial features of different age categories, including: dividing the facial image dataset into multiple subsets, each subset containing only facial image data of the same age category; inputting the facial image data included in each subset into the Swin-Transformer backbone network of the second network model respectively to obtain the age sample feature mean of the facial image data of each age category and the age sample feature mean set of facial image data for multiple age categories; and inputting the obtained age sample feature mean set into the multi-layer perception layer to learn the distribution mean and distribution variance of facial image features of different age categories.
[0015] In some embodiments, based on a facial image dataset, training is performed on an initialized second network model to learn the distribution differences of facial features of different age categories, including: inputting the image data in the facial image dataset into the Swin-Transformer backbone network of the second network model to obtain hidden layer features of each input image data; mapping the hidden layer features of each input image data to the distribution mean and distribution variance of facial image features of different age categories through an adaptive instance normalization layer to obtain the distribution differences between each input image and the facial features of each age category; and calculating the distribution differences obtained after mapping through a decoder to obtain a second predicted age for each input image.
[0016] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. In the accompanying drawings, the same or similar reference numerals represent the same or similar elements.
[0018] Figure 1 A schematic diagram of a system for implementing a method for predicting age based on facial images according to an embodiment of the present invention is shown.
[0019] Figure 2 A flowchart of a method 200 for predicting age based on a facial image according to an embodiment of the present disclosure is shown.
[0020] Figure 3 FIG. 3 is a flowchart of a method 300 for training a first network model according to an embodiment of the present disclosure.
[0021] Figure 4 FIG. 4 is a flowchart of a method 400 for training a second network model according to an embodiment of the present disclosure.
[0022] Figure 5 A model structure of an age prediction model according to an embodiment of the present disclosure is shown.
[0023] Figure 6 A block diagram of an electronic device according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0024] The following description of exemplary embodiments of the present disclosure is made in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0025] As used herein, the term "including" and its variations represent open inclusion, i.e., "including but not limited to." Unless otherwise stated, the term "or" means "and / or." The term "based on" means "based at least in part on." The terms "an example embodiment" and "an embodiment" mean "at least one example embodiment." The term "another embodiment" means "at least one additional embodiment." The terms "first," "second," etc. may refer to different or the same objects. Other explicit and implicit definitions may also be included below.
[0026] Facial age estimation technology uses facial images to predict a person's age. It is widely used in skin detection, human-computer interaction, and face recognition and detection. In the field of aging biology, facial age estimation can be used as a facial clock to assess an individual's health. Currently, deep learning has been widely applied in facial age estimation, and its age estimation accuracy exceeds that of the naked eye. Currently, deep learning models used for facial age estimation are primarily based on convolutional neural networks, such as Resnet50 (Residual Network 50-layer), VGG19 (Visual Geometry Group 19-layer network), and Se-Resnext50 (Squeeze-and-Excitation ResidualNext 50-layer). These models based on similar convolutional neural network architectures suffer from a significant generalization problem when it comes to facial age estimation. Specifically, models trained on a specific dataset often exhibit significant performance deviations when trained on cross-domain datasets. Furthermore, their model capacity is insufficient to support training on large amounts of facial data.
[0027] In addition, another factor that restricts the generalization and versatility of facial age estimation models is the data problem. There are currently multiple public facial age datasets, including AFAD (Asian Face Age Dataset), AgeDB (Age Database), CACD (Cross-Age Celebrity Dataset), FG-Net (FG-NET Aging Database), and other datasets. The facial data in these datasets are relatively simple. For example, the AFAD dataset only contains Asian faces, and the CACD dataset contains photos of 2,000 different celebrities from different periods. In short, the facial images in these datasets are not comprehensive enough and cannot include different facial types and most age groups in most regions of the world. As a result, the recognition effect of the model trained with a single dataset will be biased.
[0028] As described above, the traditional method of predicting age based on facial images has the following shortcomings: the model lacks generalization and versatility, resulting in large deviations in age prediction results for different groups of people.
[0029] In order to at least partially solve one or more of the above-mentioned problems and other potential problems, an example embodiment of the present disclosure proposes a scheme for predicting age based on facial images. In the scheme of the present disclosure, the target facial image data of the target object to be predicted is input into a facial age prediction model, and the facial age prediction model includes a first network model and a second network model; the two network models are combined to improve the capacity of the model; and the features of the target facial image data are extracted via the first network model to generate a first predicted age; then, the distribution differences between the facial features of the target object to be predicted and the facial features of different age categories are learned via the second network model based on the target facial image data to generate a second predicted age, and the second network model is initialized by the network parameters of the pre-trained first network model; then, the present disclosure can generate a predicted age for the target facial image data based on the first predicted age and the second predicted age; the age prediction results of the two models are combined, and the second model is initialized based on the parameters of the first model, which can effectively improve the training efficiency of the model, and can effectively improve the generalization and model capacity of the model, so that the age prediction results for different groups of people are excellent.
[0030] Figure 1 FIG. 1 is a schematic diagram of a system 100 for implementing a method for predicting age based on a facial image according to an embodiment of the present invention. Figure 1As shown in FIG, the system 100 includes a computing device 110, a user terminal 130, a network 140, and a facial image database 150. The computing device 110, the user terminal 130, and the facial image database 150 can exchange data through the network 140 (eg, the Internet).
[0031] The user terminal 130 includes, for example, but is not limited to, a personal computer, a server computer, a handheld or laptop device, a mobile device (such as a mobile phone, a personal digital assistant (PDA), a media player, etc.), a multi-processor system, a consumer electronic product, a minicomputer, a mainframe computer, a distributed computing environment including any of the above systems or devices, etc. The user terminal 130 can also capture a face image (facial image) in real time and provide the captured target facial image of the target object to be predicted to the computing device 110 to predict the age of the target object to be predicted.
[0032] Computing device 110 may include one or more processing units, including specialized processing units such as GPUs, FPGAs, and ASICs, as well as general-purpose processing units such as CPUs. Furthermore, one or more virtual machines may also be running on each computing device 110. In some embodiments, a facial image database 150 may be deployed in the storage module of computing device 110, or the facial image database 150 may be deployed in cloud storage or other storage devices or networks. In some embodiments, computing device 110 may include, for example, a facial image input module 112, a first age prediction module 114, a second age prediction module 116, and an age prediction module 118.
[0033] Regarding the facial image input module 112, it is used to input the acquired target facial image data of the target object to be predicted into the facial age prediction model, and the facial age prediction model includes a first network model and a second network model.
[0034] The first age prediction module 114 is configured to extract features of the target facial image data via a first network model to generate a first predicted age.
[0035] Regarding the second age prediction module 116, it is used to learn the distribution differences between the facial features of the target object to be predicted and the facial features of different age categories based on the target facial image data via a second network model, so as to generate a second predicted age. The second network model is constructed by initializing the network parameters of the pre-trained first network model.
[0036] The age prediction module 118 is configured to generate a predicted age for the target facial image data based on the first predicted age and the second predicted age.
[0037] It should be understood that this specification is only described in conjunction with relevant embodiments, and does not limit the scope of protection of this specification with the relevant embodiments. Any other disclosed technical solutions that fall within the scope of protection of this specification should be protected.
[0038] Figure 2 FIG. 2 shows a flow chart of a method 200 for predicting age based on a facial image according to an embodiment of the present disclosure. The method 200 may be performed by Figure 1 The computing device 110 shown is executed, and may also be executed on Figure 6 The method 200 is executed at the electronic device 600. It should be understood that the method 200 may further include additional steps not shown and / or may omit the steps shown, and the scope of the present disclosure is not limited in this respect.
[0039] In step 210 , the computing device 110 inputs the acquired target facial image data of the target object to be predicted into a facial age prediction model, where the facial age prediction model includes a first network model and a second network model.
[0040] In some embodiments, the computing device 110 pre-trains the first network model based on the constructed facial image dataset to determine multiple network parameters from the pre-trained first network model, where the facial image dataset includes facial images of multiple age categories of sample objects.
[0041] Regarding the training of the first network model, the following will be combined Figure 3 The method for training the first network model is described in detail and will not be repeated here.
[0042] Regarding multiple network parameters, for example, the weights of all trainable layers of the first network model (such as the query / key / value matrix of the self-attention layer, MLP (Multilayer Perceptron) weights, such as the weights of the fully connected layer, etc.), depending on the type of the first network model and the differences in all trainable layers, the multiple network parameters may also vary.
[0043] In some embodiments, the plurality of network parameters include one or more of the following: self-attention weights, multi-layer perception weights, position encoding, window shift mechanism parameters, weight matrix, bias term.
[0044] In some embodiments, the computing device 110 initializes a second network model based on at least part of the determined multiple network parameters; the computing device 110 also trains the initialized second network model based on the facial image dataset to learn the distribution differences of facial features of different age categories.
[0045] Regarding the training of the second network model, the following will be combined Figure 4 The method for training the second network model is described in detail and will not be repeated here.
[0046] In some embodiments, the computing device 110 constructs a facial age prediction model based on at least the first network model and the second network model.
[0047] At step 220 , the computing device 110 extracts features of the target facial image data via the first network model to generate a first predicted age.
[0048] In step 230, the computing device 110 learns the distribution differences between the facial features of the target object to be predicted and the facial features of different age categories based on the target facial image data via a second network model to generate a second predicted age. The second network model is constructed by initializing the network parameters of the pre-trained first network model.
[0049] At step 240 , computing device 110 generates a predicted age for the target facial image data based on the first predicted age and the second predicted age.
[0050] For example, the predicted age is generated by weighted summing of the first predicted age and the second predicted age, for example, the average of the first predicted age and the second predicted age is used as the predicted age.
[0051] In the above method, two network models, a first network model and a second network model, are used for ensemble learning to obtain a facial age prediction model. This allows the two models to observe facial image data in a facial image dataset from different perspectives, thereby improving the accuracy of facial age prediction. Furthermore, the combination of the two models can also increase the model capacity to support the large-capacity facial image dataset constructed in this solution. Furthermore, the first network model is pre-trained to obtain some parameters for initializing the second network model, thereby improving the training efficiency of the network models.
[0052] In addition, in order to achieve better ensemble learning effects, in terms of model selection, there needs to be a large difference between the first network model and the second network model structure, so that the data observation angles are different, and the errors of the two need to be similar for easy fitting. In this embodiment of the present scheme, the first network model and the second network model structure are both constructed using the Swin-Transformer framework, so that the two can have similar classification differences and thus use pre-training parameters. Transfer learning is introduced in the second network model part, so that learning can be performed from more angles. This also improves the model's capacity and data generalization capabilities. For specific model selection and an introduction to the architecture of the two models, please refer to Figure 3-Figure 5 , I will not go into details here.
[0053] In some embodiments, a facial image dataset is constructed by: collecting different types of facial image data comprising multiple age categories, the types including multiple items of the following: gender, region, race, occupation, image source, and image quality; processing the collected facial image data so that the processed facial image data conforms to a normal distribution trend within a predetermined age range and to a uniform distribution trend outside the predetermined age range; and adding at least an age feature label to the processed facial image data to construct a facial image dataset.
[0054] Regarding age categories, in this solution, 1 year old is considered as one age category. For example, the face dataset contains facial images of age categories ranging from 0 to 90 years old.
[0055] Regarding the preset age range, for example, it is 25-45 years old, for example, it is 20-50 years old, for example, it is 20-55 years old, for example, it is 20-60 years old, etc.
[0056] Regarding different types, the facial image dataset constructed by this solution contains images of different (gender, region, race, occupation, image source, and image quality), fully taking into account the large differences in facial features of people of different ages, regions, races, and occupations, and making the gender, region, occupational background, and race of the integrated sample data relatively evenly distributed, so that the trained age prediction model can be universal and can achieve accurate age recognition of targets to be predicted of different racial types, different occupational backgrounds, and different ages and genders.
[0057] Regarding the source of image data, this solution addresses the issue of uniformity in facial images within facial age datasets. We integrated and cleaned the majority of publicly available facial age datasets, ultimately producing a facial image dataset containing over 300,000 images, all accurately labeled with age, encompassing images of all age categories from 0 to 90. This resulting facial image dataset boasts a large volume, diverse sources, significant data diversity, and a balanced distribution of these differences. These characteristics also pose challenges to the model's capacity and learning efficiency. Existing facial age prediction models are no longer able to meet the training requirements of this facial image dataset.
[0058] Figure 3 FIG. 3 is a flow chart of a method 300 for training a first network model according to an embodiment of the present disclosure. Figure 1 The computing device 110 shown is executed, and may also be executed on Figure 6The method 300 is executed at the electronic device 600. It should be understood that the method 300 may further include additional steps not shown and / or may omit the steps shown, and the scope of the present disclosure is not limited in this respect.
[0059] In step 310 , the computing device 110 extracts multi-scale features about facial images based on a facial image dataset via a Swin-Transformer backbone network of a first network model.
[0060] Regarding the multi-scale features of facial images, such as low-level features: such as edges, textures, colors (such as skin roughness, wrinkle distribution), etc.; such as mid-level features: such as local structures (eyes, mouth shapes, facial key point positions), etc.; such as high-level features: global semantics (facial contours, age-related relaxation or bone changes), etc.
[0061] At step 320 , computing device 110 processes the extracted multi-scale features of the facial image via the hidden layer.
[0062] At step 330 , the computing device 110 determines a first predicted age category of the facial image based on the multi-scale features processed by the hidden layer, and calculates a classification loss function associated with the first predicted age category.
[0063] In step 340 , the computing device 110 calculates a first predicted age value of the facial image based on the multi-scale features processed by the fully connected layer, and calculates a regression loss function related to the first predicted age value.
[0064] In step 350 , the computing device 110 trains a first network model based on the classification loss function and the regression loss function.
[0065] For example, combined with Figure 3 The flowchart of the method 300 for training the first network model is shown and Figure 5 The following figure shows a model structure of an age prediction model. In this solution, both the first network model 51 and the second network model 52 are built based on the Swin-Transformer architecture. The first network model 51 includes at least a Swin-Transformer backbone network, hidden layers, fully connected layers, a classification module, and a regression module. It should be understood that this structural diagram omits some of the common Swin-Transformer network structures.
[0066] In the pre-training stage of the age prediction model, the first network model 51 is trained, and a joint loss function consisting of a classification loss function and a regression loss function is used to train the first network model 51.
[0067] In this embodiment, the classification loss function can be used to better fit facial age using age as the classification unit, thereby improving the efficiency and accuracy of age classification. However, the classification loss function has limitations in minimizing the difference between the predicted age distribution and the actual age distribution. For example, in the case of classification error (misclassifying an age category by several years, such as misclassifying a 10-year-old as 9), it is difficult to reflect the classification error. Then, combined with the regression loss function, the error error can be minimized. Thus, the first network model 51 is trained by jointly training the two training tasks, classification loss and regression loss.
[0068] For example, the classification loss function of the first network model 51 adopts the cross entropy loss function, which can better fit the facial age. During the training process, a joint loss function consisting of the cross entropy loss function and the mean absolute error loss is used. The cross entropy loss function is used to correctly classify the samples as much as possible, and the mean absolute error loss function minimizes the error of misclassification. The specific loss function is shown in the following formula (1):
[0069]
[0070] Among them, N represents the number of samples, M represents the number of classification categories (for example, the number of categories is 91, 0-90 years old), each age represents a category, j represents the category, y i Indicates the true age of the sample, y ij Indicates the probability that the i-th sample belongs to the j-th category, y′ ij ,y″ i They represent the first predicted age category and the first predicted age value respectively.
[0071] It is worth noting that the main network structure in pre-training uses Swin-Transformer; and in the inference process, for example, only the classification module is used as the age prediction value (i.e., the first predicted age) of the first network model 51.
[0072] In the above method, the classification module and the regression module share the parameters of the hidden layer, the fully connected layer, and the backbone network. The joint loss of the two can be back-propagated to the classification module, the regression module, the hidden layer, the backbone network, etc.; for example, the classification loss is used to optimize the weight of the classification loss, while affecting the feature extraction direction of the hidden layer and the backbone network. For example, the regression loss is used to correct the backbone network's sensitivity to age details (such as skin texture and wrinkles).
[0073] Figure 4 FIG. 4 is a flow chart of a method 400 for training a second network model according to an embodiment of the present disclosure. Figure 1 The computing device 110 shown is executed, and may also be executed on Figure 6The method 400 is executed at the electronic device 600. It should be understood that the method 400 may further include additional steps not shown and / or may omit the steps shown, and the scope of the present disclosure is not limited in this respect.
[0074] In step 420 , the computing device 110 inputs the image data in the facial image dataset into the Swin-Transformer backbone network of the second network model to obtain hidden layer features of each input image data.
[0075] Please combine Figure 5 In the second network module 52 of this solution, the principle of transfer learning is adopted. First, the Swin-Transformer module of the second network module 52 is initialized using multiple network parameters obtained after pre-training of the first network module 51.
[0076] After the second network module 52 is initialized, each input will first pass through the Swin-Transformer module of the second network module 52 to obtain the features Among them, x represents the sample, d represents the hidden layer dimension (for example Figure 5 1×d) indicated in FIG.
[0077] At step 410 , computing device 110 divides the facial image dataset into a plurality of subsets, each subset containing only facial image data of the same age category.
[0078] For example, the training data set is divided into 91 subsets: U = {U1, U2, ..., U 91}, each subset contains only samples of the same age, e.g. contains only facial image samples with age 0. For example, please refer to Figure 5 The facial image data subsets shown in the figure, for example, subset 0 only contains sample facial image data of 0-year-olds, subset 90 only contains sample facial image data of 90-year-olds, and for example, subset 40 only contains sample facial image data of 40-year-olds.
[0079] In step 412, the computing device 110 inputs the facial image data included in each subset into the Swin-Transformer backbone network of the second network model to obtain the age sample feature mean of the facial image data of each age category and a set of age sample feature mean values of facial image data for multiple age categories.
[0080] For example, subset 90 contains 1000 sample data. The sample feature value of each of the 1000 sample data is obtained, and then the mean is calculated to obtain the age sample feature mean of the facial image data of "age category 90". There are 91 age categories in total. The age sample feature mean of the facial image data of each age category from "age category 0" to "age category 90" is obtained to generate a set of age sample feature mean values of the facial image data of these 91 age categories (for example, Figure 5 91×d) indicated in FIG.
[0081] For example, 91 feature sets E(x)={E1(x), E2(x), ..., E 91 (x)}, where x represents the sample, E i Represents a sample feature set of a certain age:
[0082] E i ={E i (x1),E i (x2),...,E i (x n )} (2)
[0083] E in formula (2) i By taking the mean of the sample features in , we can get formula (3):
[0084]
[0085] Among them, each age sample set will get an E i ′(x), thus obtaining the set It contains the mean of sample features of different ages, for example, the mean of age sample features of facial image data of 91 age categories (0-90 years old) (for example Figure 5 91×d) indicated in FIG.
[0086] In step 414 , the computing device 110 inputs the obtained age sample feature mean set into a multi-layer perception layer to learn the distribution means and distribution variances of facial image features of different age categories.
[0087] For example, see Figure 5 , the age sample feature mean set of facial image data of 91 age categories (e.g. Figure 5 The 91×d) shown in FIG is input into an MLP (Multilayer Perceptron) to obtain the distribution mean and distribution variance of facial image features of different age categories.
[0088] Continuing with the above example, E′(x) is input into an MLP module for feature mapping to finally obtain formula (4), E″(x) represents the mean and variance of the distribution of facial image features at different ages. μ={μ0,μ1,...,μ 91} represents the mean of the facial image feature distribution of different ages, σ={σ0,σ1,...,σ 91} represents the variance of the distribution of facial image features at different ages. For example, Figure 5 The 91×(μ,σ) shown in the figure shows the mean and variance of the facial image feature distribution for the 91 age categories 0-90 years old.
[0089] In step 430 , the computing device 110 maps the hidden layer features of each input image data to the distribution means and distribution variances of facial image features of different age categories via an adaptive instance normalization layer to obtain the distribution differences between each input image and the facial features of each age category.
[0090] For more information about the adaptive instance normalization layer, please refer to Figure 5 AdaIN, namely Adaptive InstanceNormalization, realizes the style conversion operation of age features through it. For example, the feature distribution of C(x) is mapped to the feature distribution of E″(x) to obtain Here 91 represents different age styles. Then, C′(x) is decoded into the second predicted age through a decoder. The decoder, for example, contains two 1D convolution operations and a linear mapping layer. Please combine Figure 5 , about to Figure 5 The 1×d shown in the figure is mapped to 91×(μ,σ) through the AdaIN module, and then the second predicted age is obtained through the decoder.
[0091] In step 440 , the computing device 110 performs calculation on the distribution difference obtained after mapping via the decoder to obtain a second predicted age for each input image.
[0092] Therefore, in the above method, the first network module and the second network module are combined to perform pre-training and transfer learning of network parameters respectively, which not only improves the capacity and learning efficiency of the model, but also improves the model accuracy. In addition, in the first network module, two loss functions, classification loss + regression loss, are used for joint training. This can overcome the shortcomings of classification loss to minimize the error of misclassification while improving the accuracy of age category classification, further improving the accuracy. In addition, in the second network module, the hidden layer features of each image are transferred with the mean and variance of the facial image feature distribution of each age category to learn the distribution differences of facial features of different age categories, thereby obtaining more accurate age prediction results.
[0093] Figure 6 Schematic diagram of an example electronic device 600 that can be used to implement an embodiment of the present disclosure is shown. Figure 1 The computing device 110 shown can be implemented by an electronic device 600. As shown, the electronic device 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to computer program instructions stored in a read-only memory (ROM) 602 or computer program instructions loaded from a storage unit 608 into a random access memory (RAM) 603. In the random access memory 603, various programs and data required for the operation of the electronic device 600 can also be stored. The central processing unit 601, the read-only memory 602, and the random access memory 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0094] Multiple components in the electronic device 600 are connected to the input / output interface 605, including: an input unit 606, such as a keyboard, a mouse, a microphone, etc.; an output unit 607, such as various types of displays, speakers, etc.; a storage unit 608, such as a magnetic disk, an optical disk, etc.; and a communication unit 609, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 609 allows the device 600 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0095] The various processes and procedures described above, such as methods 200 to 400, may be performed by the central processing unit 601. For example, in some embodiments, the methods 200 to 400 may be implemented as a computer software program that is tangibly contained in a machine-readable medium, such as the storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed onto the device 600 via the read-only memory 602 and / or the communication unit 609. When the computer program is loaded into the random access memory 603 and executed by the central processing unit 601, one or more actions of the methods 200 to 400 described above may be performed.
[0096] The present disclosure relates to methods, apparatuses, systems, electronic devices, computer-readable storage media, and / or computer program products. The computer program products may include computer-readable program instructions for executing various aspects of the present disclosure.
[0097] A computer-readable storage medium can be a tangible device that can hold and store instructions for use by an instruction execution device. A computer-readable storage medium can be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination thereof. As used herein, a computer-readable storage medium is not to be construed as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through an electrical wire.
[0098] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge computing devices. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0099] The computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages such as Smalltalk, C++, and conventional procedural programming languages such as "C" language or similar programming languages. Computer-readable program instructions may be executed entirely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., utilizing an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be personalized by utilizing the state information of the computer-readable program instructions. The electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.
[0100] Various aspects of the present disclosure are described herein with reference to flowcharts and / or step diagrams of methods, devices (systems), and computer program products according to embodiments of the present disclosure. It should be understood that each step in the flowcharts and / or step diagrams, and any combination of the steps in the flowcharts and / or step diagrams, can be implemented by computer-readable program instructions.
[0101] These computer-readable program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine such that when these instructions are executed by the processing unit of the computer or other programmable data processing device, a device is generated that implements the functions / actions specified in one or more steps in the flowchart and / or step diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium, where these instructions cause the computer, programmable data processing device, and / or other device to operate in a specific manner. Thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing various aspects of the functions / actions specified in one or more steps in the flowchart and / or step diagram.
[0102] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operational steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more steps in the flowchart and / or step diagram.
[0103] The flowcharts and step diagrams in the accompanying drawings show the possible architectures, functions and operations of the systems, methods and computer program products according to multiple embodiments of the present disclosure. In this regard, each step in the flowchart or step diagram can represent a module, program segment or part of an instruction, and a module, program segment or part of an instruction contains one or more executable instructions for implementing the specified logical function. In some alternative implementations, the functions marked in the steps can also occur in an order different from that marked in the accompanying drawings. For example, two consecutive steps can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each step in the step diagram and / or flowchart, and the combination of the steps in the step diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or can be implemented using a combination of dedicated hardware and computer instructions.
[0104] While various embodiments of the present disclosure have been described above, the foregoing description is intended to be illustrative, non-exhaustive, and not limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is selected to best explain the principles of the embodiments, their practical applications, or technological improvements in the marketplace, or to enable others skilled in the art to understand the embodiments disclosed herein.
Claims
1. A method for predicting age based on a facial image, comprising: Inputting the acquired target facial image data of the target object to be predicted into a facial age prediction model, wherein the facial age prediction model includes a first network model and a second network model; extracting features of the target facial image data via the first network model to generate a first predicted age; Learning, via the second network model, distribution differences between facial features of a target object to be predicted and facial features of individuals of different age categories based on the target facial image data, so as to generate a second predicted age, wherein the second network model is constructed by initializing network parameters of the pre-trained first network model; as well as A predicted age is generated for the target facial image data based on the first predicted age and the second predicted age.
2. The method according to claim 1, characterized in that Also includes: Pre-training the first network model based on the constructed facial image dataset to determine a plurality of network parameters from the pre-trained first network model, wherein the facial image dataset includes facial images of sample subjects in a plurality of age categories; Initializing the second network model based on at least some of the determined plurality of network parameters; Based on the facial image dataset, training the initialized second network model to learn the distribution differences of facial features of different age categories; as well as A facial age prediction model is constructed based on at least the first network model and the second network model.
3. The method according to claim 2, characterized in that The facial image dataset is constructed by: Collecting facial image data of different types including multiple age categories, wherein the categories include multiple items of the following: gender, region, race, occupation, image source, and image quality; Processing the collected facial image data so that the processed facial image data conforms to a normal distribution trend within a predetermined age range and conforms to a uniform distribution trend outside the predetermined age range; as well as For the processed facial image data, at least an age feature label is added to construct a facial image dataset.
4. The method according to claim 1, wherein The first network model is constructed based on the Swin-Transformer architecture, and the first network model is pre-trained based on the constructed facial image dataset, so that a plurality of network parameters are determined from the pre-trained first network model, including: Extracting multi-scale features of facial images based on the facial image dataset via the Swin-Transformer backbone network of the first network model; Processing the multi-scale features of the facial image extracted by the hidden layer; determining a first predicted age category of the facial image based on the multi-scale features processed by the hidden layer, and calculating a classification loss function associated with the first predicted age category; Calculating a first predicted age value of the facial image based on the multi-scale features processed by the fully connected layer, and calculating a regression loss function related to the first predicted age value; and The first network model is trained based on the classification loss function and the regression loss function.
5. The method according to claim 4, characterized in that The plurality of network parameters include one or more of the following: Self-attention weights, multi-layer perception weights, position encoding, window shift mechanism parameters, weight matrix, bias term.
6. The method according to claim 1, characterized in that The second network model is constructed based on the Swin-Transformer architecture. Based on the facial image dataset, the initialized second network model is trained to learn the distribution differences of facial features of different age categories, including: Dividing the facial image dataset into a plurality of subsets, each subset containing only facial image data of the same age category; Inputting the facial image data included in each subset into the Swin-Transformer backbone network of the second network model to obtain the age sample feature mean of the facial image data of each age category and a set of age sample feature mean values of the facial image data of multiple age categories; and The obtained age sample feature mean set is input into a multi-layer perception layer to learn the distribution mean and distribution variance of facial image features of different age categories.
7. The method according to claim 2, characterized in that Based on the facial image dataset, the initialized second network model is trained to learn the distribution differences of facial features of different age categories, including: Inputting the image data in the facial image dataset into the Swin-Transformer backbone network of the second network model respectively to obtain hidden layer features of each input image data; Mapping the hidden layer features of each input image data to the distribution means and distribution variances of facial image features of different age categories via an adaptive instance normalization layer to obtain the distribution differences between each input image and the facial features of each age category; and The decoder calculates the distribution difference obtained after mapping to obtain a second predicted age for each input image.
8. A computing device comprising: at least one processing unit; At least one memory, the at least one memory being coupled to the at least one processing unit and storing instructions for execution by the at least one processing unit, the instructions, when executed by the at least one processing unit, causing the device to perform the steps of the method according to any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the method according to any one of claims 1 to 7 when executed by a machine.
10. A computer program product comprising a computer program, wherein when the computer program is executed by a machine, the method according to any one of claims 1 to 7 is performed.