Method for training age prediction model, age prediction method and related device
By constructing an age prediction model, utilizing a face encoding network and a perceptron age prediction network, fusing feature maps and constructing a loss function, the problem of insufficient generalization ability caused by the uniqueness of facial features is solved, and the accuracy and robustness of age prediction are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-29
- Publication Date
- 2026-03-31
AI Technical Summary
In existing technologies, facial age estimation methods suffer from poor generalization performance and insufficient generalization ability due to the uniqueness of facial features.
An age prediction model is adopted, including a face encoding network, a face decoding network, and a perceptron age prediction network. By acquiring a face dataset, processing the original face images and age-style images, fusing feature maps, and constructing an age-style loss function for training until the loss function converges, the generalization ability of the model is improved.
By combining style and optimizing the loss function, the accuracy of age prediction was improved, and the robustness of the model in practical applications was enhanced.
Smart Images

Figure CN115147910B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of facial image recognition technology, and in particular to a training method for an age prediction model, an age prediction method, and related devices. Background Technology
[0002] Facial images contain various facial feature information, such as face shape, skin condition, facial expression, facial features, and age. Among these, facial age, as a relatively important feature, has been widely used in the field of facial image recognition. For example, some clients running on mobile devices have facial age recognition functionality. These clients acquire facial images and output the recognized facial age based on the acquired images, providing feedback to the user.
[0003] Currently, facial age estimation methods typically utilize convolutional neural networks. The process involves: constructing a dataset; dividing the dataset into training and validation sets; constructing mini-batches in pairs at the network input layer and then feeding them into two Siamese networks for training; constructing a VGG-16 network; network training; using softmax loss and revised contrastive loss as supervisory signals to adjust the network; network evaluation; and finally, estimating the age as the class corresponding to the highest probability obtained from the softmax layer.
[0004] However, this approach uses paired input images with different age values, extracts facial features by sharing network parameters, and then calculates the feature differences between paired samples through metric learning. Since facial features are unique, people of the same age can have different facial features, resulting in poor generalization performance of the model in practical applications. Summary of the Invention
[0005] This application provides a training method for an age prediction model, an age prediction method, and related apparatus to address the problem of insufficient model generalization ability caused by the uniqueness of facial features, thereby improving the accuracy of age prediction.
[0006] In a first aspect, embodiments of this application provide a training method for an age prediction model, the age prediction model including a face encoding network, a face decoding network, and a perceptron age prediction network, the method including:
[0007] Obtain a face dataset, which includes face images with multiple different age values;
[0008] Based on the face encoding network, the original face images and age style images in the face dataset are processed to obtain the feature maps corresponding to the original face images and the age style images. The original face images and the age style images have the same age value.
[0009] The feature map is obtained by fusing the feature map corresponding to the original face image and the feature map corresponding to the age style image.
[0010] The fused feature map is input into the face decoding network to obtain the decoded face image;
[0011] The feature map corresponding to the original face image is input into the perceptron age prediction network, which is used to predict the age corresponding to the original face image.
[0012] An age-style loss function is constructed, and the age prediction model is trained based on the face dataset and the age-style loss function until the age-style loss function converges. The age-style loss function includes the content loss of the decoded face image and the original face image output by the face decoding network, as well as the style loss of the decoded face image and the original face image output by the face decoding network.
[0013] In some embodiments, the feature map corresponding to the original face image and the feature map corresponding to the age style image are fused to obtain the fused feature map, including:
[0014] The original face image is sorted according to the size of the pixel value of each pixel, and the first sorting index corresponding to the original face image is determined. The first sorting index is used to determine the original position of each pixel in the original face image before sorting.
[0015] The age-style images are sorted according to the size of the pixel value of each pixel, and a second sorting index is determined for the age-style images. The second sorting index is used to determine the original position of each pixel in the age-style images before sorting.
[0016] Based on the first sorting index, the age-style image is processed to obtain the processed feature map;
[0017] The original face image is fused with the processed feature map to obtain the fused feature map.
[0018] In some embodiments,
[0019] Based on the first sorting index, the age-style image is processed to obtain the processed feature map, including:
[0020] Based on the first sorting index, each pixel of the age-style image is extracted to obtain the processed feature map;
[0021] The original face image is fused with the processed feature map to obtain the fused feature map, which includes:
[0022] The pixel value of each pixel in the original face image is added one-to-one with the pixel value of each pixel in the processed feature map to obtain the fused pixel value of each pixel, thus obtaining the fused feature map.
[0023] In some embodiments, the age-style loss function includes:
[0024] Loss=a*L c +α*L pix +β*L dis +γ*L style
[0025] Among them, Loss represents age-style loss, and L c L is the age cross-entropy loss between the predicted age and the actual age in a perceptron age prediction network. pix L represents the content loss between the decoded face image and the original face image output by the face decoding network. dis To determine the loss, L style Let α be the style loss of the decoded face image output by the face decoding network and the original face image, α be the weight corresponding to the age cross-entropy loss, α be the first weight corresponding to the content loss, β be the second weight corresponding to the discriminative loss, and γ be the third weight corresponding to the style loss.
[0026] In some embodiments, the age cross-entropy loss includes:
[0027]
[0028] Among them, L c Y is the age cross-entropy loss between the predicted age and the actual age in a perceptron age prediction network, where i is the age value, n is the maximum age value, and Y is the age cross-entropy loss between the predicted age and the actual age. i P represents the actual age corresponding to age value i. i Let i be the probability value of the predicted age corresponding to age value i.
[0029] In some embodiments, content loss includes:
[0030] L pix =E T,S [‖TG(T,S)‖] mse
[0031] Among them, L pixLet T be the content loss between the decoded face image and the original face image output by the face decoding network, and let S be the age-style image with the same age as the original face image. Let G(T,S) be the decoded face image output by the face decoding network, and E be the content loss between the decoded face image and the original face image. T,S [‖TG(T,S)‖] mse This is the mean square error between the decoded face image output by the face decoding network and the original face image.
[0032] In some embodiments, the age prediction model further includes: a discriminant network for determining whether the decoded face image is a real face image;
[0033] Loss assessment includes:
[0034] L dis =E T [logD(T)]+E T,S [log(1-D(G(T,S)))]
[0035] Among them, L dis For the discriminant loss, T is the original face image, S is an age-style image with the same age as the original face image, G(T,S) is the decoded face image output by the face decoding network, D(T) is the probability value of the discriminant network judging the original face image as real or fake, D(G(T,S)) is the probability value of the discriminant network judging the decoded face image output by the face decoding network as real or fake, and E T [logD(T)] is the expected value of the discrimination network's judgment that the original face image is true, E T,S [log(1-D(G(T,S)))] is the expected value of the discrimination network's judgment that the decoded face image output by the face decoding network is false.
[0036] In some embodiments, style loss includes:
[0037]
[0038] Where i is the i-th feature scale, n is the number of feature scales, and L style For style loss, T is the original face image, S is an age-style image with the same age as the original face image, and G(T,S) is the decoded face image output by the face decoding network. The original face image is input into the VGG network to obtain the feature value of the i-th feature scale. The decoded face image is input into the VGG network to obtain the feature value of the i-th feature scale.
[0039] Secondly, embodiments of this application provide an age prediction method, including:
[0040] Obtain the face image to be predicted;
[0041] The face image to be predicted is input into the age prediction model to obtain the predicted age corresponding to the face image. The age prediction model is trained based on the method provided in the first aspect above.
[0042] In some embodiments, inputting a face image into an age prediction model to obtain the predicted age corresponding to the face image to be predicted includes:
[0043] The face image to be predicted is input into the face encoding network of the age prediction model to obtain the feature map corresponding to the face image to be predicted.
[0044] The feature map corresponding to the face image to be predicted is input into the perceptron age prediction network of the age prediction model to obtain the predicted age corresponding to the face image to be predicted.
[0045] Thirdly, embodiments of this application provide a training device for an age prediction model. The age prediction model includes a face encoding network, a face decoding network, and a perceptron age prediction network. The device includes:
[0046] The acquisition module is used to acquire a face dataset, which includes face images with multiple different age values.
[0047] The encoding module is used to process the original face images and age-style images in the face dataset based on the face encoding network, so as to obtain the feature map corresponding to the original face image and the feature map corresponding to the age-style image. The original face image and the age-style image have the same age value.
[0048] The fusion module is used to fuse the feature map corresponding to the original face image and the feature map corresponding to the age style image to obtain the fused feature map.
[0049] The decoding module is used to input the fused feature map into the face decoding network to obtain the decoded face image;
[0050] The prediction module is used to input the feature map corresponding to the original face image into the perceptron age prediction network, whereby the perceptron age prediction network is used to predict the age corresponding to the original face image.
[0051] The training module is used to construct the age-style loss function. Based on the face dataset and the age-style loss function, the age prediction model is trained until the age-style loss function converges. The age-style loss function includes the content loss of the decoded face image and the original face image output by the face decoding network, as well as the style loss of the decoded face image and the original face image output by the face decoding network.
[0052] Fourthly, embodiments of this application provide an age prediction device, comprising:
[0053] Image acquisition module, used to acquire the face image to be predicted;
[0054] The age prediction module is used to input the face image to be predicted into the age prediction model to obtain the predicted age corresponding to the face image. The age prediction model is trained based on the method provided in the first aspect above.
[0055] Fifthly, embodiments of this application provide an electronic device, including:
[0056] At least one processor, and
[0057] A memory communicatively connected to at least one processor, wherein,
[0058] The memory stores instructions that can be executed by at least one processor to enable the at least one processor to perform the methods provided in the first or second aspect above.
[0059] In a sixth aspect, embodiments of this application provide a non-volatile computer-readable storage medium storing computer-executable instructions for causing an electronic device to perform the method provided in the first aspect above.
[0060] The beneficial effects of this application's embodiments: Unlike existing technologies, the age prediction model training method provided in this application's embodiments includes a face encoding network, a face decoding network, and a perceptron age prediction network. The method includes: acquiring a face dataset, wherein the face dataset includes multiple face images with different age values; processing the original face images and age-style images in the face dataset based on the face encoding network to obtain feature maps corresponding to the original face images and age-style images, wherein the original face images and age-style images correspond to the same age value; and fusing the feature maps corresponding to the original face images and age-style images. The feature maps are fused to obtain a fused feature map. The fused feature map is then input into a face decoding network to obtain a decoded face image. The feature map corresponding to the original face image is input into a perceptron age prediction network, which is used to predict the age corresponding to the original face image. An age-style loss function is constructed, and the age prediction model is trained based on the face dataset and the age-style loss function until the age-style loss function converges. The age-style loss function includes the content loss of the decoded face image and the original face image output by the face decoding network, as well as the style loss of the decoded face image and the original face image output by the face decoding network.
[0061] This application uses a face encoding network to process an age-style image with the same age as the original face image, and then performs style fusion on the processed feature maps. The fused feature maps are further decoded by a face decoding network. In addition, a perceptron age prediction network is used to predict the age of the original face image. An age-style loss function is constructed to train the age prediction model. This application can solve the problem of insufficient model generalization ability caused by the uniqueness of face features and improve the accuracy of age prediction. Attached Figure Description
[0062] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.
[0063] Figure 1 This is a schematic diagram illustrating the application environment of a training method for an age prediction model provided in an embodiment of this application;
[0064] Figure 2 This is a flowchart illustrating a training method for an age prediction model provided in an embodiment of this application;
[0065] Figure 3 yes Figure 2 Detailed flowchart of step S203 in the process;
[0066] Figure 4 This is a schematic diagram of an age prediction model provided in an embodiment of this application;
[0067] Figure 5 This is a flowchart illustrating an age prediction method provided in an embodiment of this application;
[0068] Figure 6 yes Figure 5 Detailed flowchart of step S502 in the process;
[0069] Figure 7 This is a schematic diagram of the structure of a training device for an age prediction model provided in an embodiment of this application;
[0070] Figure 8 This is a schematic diagram of the structure of an age prediction device provided in an embodiment of this application;
[0071] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0072] The present application will now be described in detail with reference to specific embodiments. These embodiments will help those skilled in the art to further understand the present application, but do not limit the present application in any way. It should be noted that those skilled in the art can make several modifications and improvements without departing from the concept of the present application. These all fall within the protection scope of the present application.
[0073] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0074] It should be noted that, unless there is a conflict, the various features in the embodiments of this application can be combined with each other, all of which are within the protection scope of this application. Furthermore, although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than the module division in the device or the order in the flowchart. In addition, the terms "first," "second," and "third" used herein do not limit the data or execution order, but only distinguish identical or similar items with essentially the same function and effect.
[0075] Unless otherwise defined, all technical and scientific terms used in this specification have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The term "and / or" as used in this specification includes any and all combinations of one or more of the associated listed items.
[0076] Furthermore, the technical features involved in the various embodiments of this application described below can be combined with each other as long as they do not conflict with each other.
[0077] Please see Figure 1 , Figure 1 This is a schematic diagram illustrating the application environment of a training method for an age prediction model provided in an embodiment of this application;
[0078] like Figure 1 As shown, the application environment 100 includes a terminal 101 and a server 102, which communicate with each other via wired or wireless communication.
[0079] The terminal 101 can be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, etc., but is not limited to these. The terminal 101 may include a client, which can be a video client, browser client, online shopping client, instant messaging client, etc. This application does not limit the type of client.
[0080] Terminal 101 and server 102 can be connected directly or indirectly via wired or wireless communication, and this application does not impose any restrictions. Terminal 101 can receive the predicted age of a face image sent by server 102 and display the face image and its predicted age on a visual interface. In response to a user-triggered age prediction command, the terminal can acquire a face image using an image acquisition device. This image acquisition device can be built into terminal 101 or externally connected to terminal 101, and this application does not impose any restrictions on this.
[0081] Terminal 101 can send the age prediction instruction and the collected face image to server 102, and receive the predicted age corresponding to the face image returned by server 102. Then, it can display the face image and its corresponding predicted age on the visualization interface so that users can understand the predicted age corresponding to one or more face images.
[0082] It is understood that terminal 101 can refer to one of multiple terminals, and this application embodiment only uses terminal 101 as an example. Those skilled in the art will know that the number of terminals can be more or less. For example, there may be only one terminal, or there may be dozens or hundreds of terminals, or more. This application embodiment does not limit the number of terminals or the type of device.
[0083] Among them, server 102 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery network (CDN), and big data and artificial intelligence platforms.
[0084] Server 102 and terminal 101 can be connected directly or indirectly via wired or wireless communication, which is not limited herein. Server 102 can maintain a face image database to store multiple face images, wherein each face image corresponds to an age tag, which is the real age corresponding to the face image. Server 102 can receive an age prediction instruction and a face image sent by terminal 101, and perform age prediction on the face image according to the age prediction instruction, and then send the predicted age corresponding to the face image to terminal 101.
[0085] It is understood that the number of servers 102 described above may be more or less, and this application embodiment does not limit this. Of course, servers 102 may also include other functional servers in order to provide more comprehensive and diversified services.
[0086] The technical solution of this application is applicable to various scenarios of face recognition. Specifically, the technical solution of this application can be used to identify the facial age corresponding to a face image in a face recognition scenario. In some implementations of face recognition, an age prediction model with age prediction function is used to identify the face image in the scenario to determine the facial age corresponding to the face image. The age prediction model is obtained through pre-training.
[0087] In the process of training the age prediction model, a large number of face images are acquired, and each face image is labeled with a corresponding age. Then, each face image and its corresponding age label are input into an untrained neural network for training. This allows the trained age prediction model to output an age prediction result that is infinitely close to the age label corresponding to each face image. As a result, the age prediction model learns the facial features of these face images and thus has the ability to distinguish face images of different ages. An age prediction model that can distinguish face images of different ages can be used to identify the age of the face image.
[0088] Currently, facial age estimation methods typically utilize convolutional neural networks. The process involves: constructing a dataset; dividing the dataset into training and validation sets; constructing mini-batches in pairs at the network input layer and then feeding them into two Siamese networks for training; constructing a VGG-16 network; network training; using softmax loss and revised contrastive loss as supervisory signals to adjust the network; network evaluation; and finally, estimating the age as the class corresponding to the highest probability obtained from the softmax layer.
[0089] However, this approach uses paired input images with different age values, extracts facial features by sharing network parameters, and then calculates the feature differences between paired samples through metric learning. Since facial features are unique, people of the same age can have different facial features, resulting in poor generalization performance of the model in practical applications.
[0090] In view of this, embodiments of this application provide a training method for an age prediction model, an age prediction method, and related apparatus to solve the problem of insufficient model generalization ability caused by the uniqueness of facial features, and to improve the accuracy of age prediction.
[0091] Example 1
[0092] Please see Figure 2 , Figure 2 This is a flowchart illustrating a training method for an age prediction model provided in an embodiment of this application;
[0093] This method can be applied to various face recognition devices. The age prediction model includes a face encoding network, a face decoding network, and a perceptron age prediction network.
[0094] like Figure 2 As shown, the training method for this age prediction model includes:
[0095] Step S201: Obtain a face dataset, wherein the face dataset includes face images with multiple different age values;
[0096] Specifically, this face dataset includes a large number of face images, each containing a face. Understandably, each face image in this dataset is labeled with an age tag (i.e., the actual age), and each age tag covers an age range of 1-130 years. Multiple face images exist for each age value; that is, multiple face images have the same age value. This ensures that the age tag covers every age value, and that multiple face images exist for each age value, which is beneficial for extracting age-style features based on face images with the same age value.
[0097] The age labels for each face image can be generated using a hot-coding method. For example, if the age range to be identified is between 1 and 130, a 130-dimensional vector can be used as the age label for a face image. A 130-dimensional vector indicates the age corresponding to a face image. It is understood that hot-coding is a common method used by those skilled in the art, and will not be described in detail here.
[0098] In some embodiments, the face images in the face dataset can be preprocessed and normalized to the same size, for example, normalized to 320*320*3. Since there is an imbalance in the number of face images of different ages in actual image collection, in some embodiments, operations such as illumination transformation and rotation can be performed on the face images to perform data augmentation, which helps improve the robustness of the model.
[0099] Step S202: Based on the face encoding network, process the original face images and age style images in the face dataset to obtain the feature maps corresponding to the original face images and the age style images, wherein the age values corresponding to the original face images and the age style images are the same.
[0100] Specifically, a face encoding network is constructed, which is used as input to an original face image and an age-style image with the same age value as the original face image, wherein the original face image and the age-style image share the network parameters of the face encoding network.
[0101] In some embodiments, the face encoding network can be a neural network such as MobileNet or YOLOv3. The face encoding network includes multiple sequentially connected feature extraction convolutional layers, fully connected layers, and softmax layers. Each feature extraction convolutional layer is followed by an activation function layer and a normalization layer.
[0102] The mathematical expression for this face coding network can be represented by the following formula:
[0103]
[0104] in, This represents the nth feature map of the (l+l)th layer. Let represent the m-th feature map of the l-th layer, W represent the convolution kernel, B represent the bias term, σ(·) represent the ReLU activation function, and IN represent instance normalization.
[0105] In some embodiments, the kernel size in the feature extraction convolutional layer is set to 3×3, which helps reduce the aliasing effect after feature map fusion. Since downsampling and upsampling lead to information loss, uniform stride convolution is used, meaning the stride of the kernels in each feature extraction convolutional layer is consistent. The number of feature extraction convolutional layers can be 5, and the number of kernels in each layer can be set to 16, 32, 64, 128, or 256 respectively, ultimately resulting in an 8*8*256 feature map.
[0106] Step S203: Fuse the feature map corresponding to the original face image with the feature map corresponding to the age style image to obtain the fused feature map;
[0107] For details, please refer to [link / reference]. Figure 3 , Figure 3 yes Figure 2 Detailed flowchart of step S203 in the process;
[0108] like Figure 3 As shown, step S203 includes:
[0109] Step S2031: Sort the original face image according to the size of the pixel value of each pixel, and determine the first sorting index corresponding to the original face image;
[0110] Specifically, assuming the feature map corresponding to the original face image output by the face encoding network is 8*8*256 in size, and the value of each pixel in the feature map of the original face image is [-1, 1], after obtaining the feature map corresponding to the original face image, it is sorted according to the value of each pixel in the original face image, and the first sorting index corresponding to the original face image is determined. The first sorting index is used to determine the original position of each pixel in the original face image before sorting. For example, [[0.3, 0.1], [0.2, 0.4]] is first tiled, and [0.3, 0.1, 0.2, 0.4] is sorted to [0.1, 0.2, 0.3, 0.4]. At this time, the first sorting index is [1, 2, 0, 3].
[0111] Step S2032: Sort the age style image according to the size of the pixel value of each pixel, and determine the second sorting index corresponding to the age style image, wherein the second sorting index is used to determine the original position of each pixel in the age style image before sorting.
[0112] Specifically, assuming the feature map corresponding to the age style image is 8*8*256 in size, and each pixel value in the feature map is [-1, 1], after obtaining the feature map, it is sorted according to the pixel value of each pixel in the age style image, and the second sorting index corresponding to the age style image is determined. The second sorting index is used to determine the original position of each pixel in the age style image before sorting. For example, [[0.2, 0.4], [0.6, 0.5]] is first tiled, and [0.2, 0.4, 0.6, 0.5] is sorted to [0.2, 0.4, 0.5, 0.6]. At this time, the second sorting index is [0, 1, 3, 2].
[0113] Step S2033: Process the age-style image according to the first sorting index to obtain the processed feature map;
[0114] Specifically, based on the first sorting index, the age-style image is processed to obtain the processed feature map, including:
[0115] Based on the first sorting index, each pixel of the age-style image is extracted to obtain the processed feature map. For example, if the first sorting index is [1,2,0,3] and the pixels of the age-style image are [0.2,0.4,0.5,0.6], then based on the first sorting index, each pixel of the age-style image is extracted to obtain the processed feature map [0.4,0.5,0.2,0.6].
[0116] Step S2034: Fuse the original face image with the processed feature map to obtain the fused feature map.
[0117] Specifically, the original face image is fused with the processed feature map to obtain the fused feature map, including:
[0118] The pixel value of each pixel in the original face image is added one-to-one with the pixel value of each pixel in the processed feature map to obtain the fused pixel value of each pixel, thus obtaining the fused feature map.
[0119] For example: Suppose the original face image is That is, the original image features are Age-style images That is, the stylistic characteristics are First, reorder the features of both from smallest to largest, then sort the style features. Based on the characteristics of the original image The indexes are sorted from smallest to largest, then extracted and recombined. This re-sorting and recombination achieves consistency in style distribution between the two. The calculation formula is as follows:
[0120]
[0121]
[0122]
[0123] Among them Index t Sorted represents the index after sorting the features of the original image. s Sorted represents the value after sorting style features. s (Index t ) indicates that the sorted style features will be re-extracted according to the index, and fr represents the fused features.
[0124] Assumption The expression is [[0.3,0.1],[0.2,0.4]]. The features are [[0.2,0.4],[0.6,0.5]]. First, the first sorting index [1,2,0,3] is obtained for the original image features. The style features are then re-sorted [0.2,0.4,0.5,0.6]. Then, the style features are extracted again according to the first sorting index of the original image features, resulting in [0.4,0.5,0.2,0.6]. A reshape operation is then performed [[0.4,0.5],[0.2,0.6]]. The resulting fused features are [[0.3,0.1],[0.2,0.4]] + [[0.4,0.5],[0.2,0.6]] = [[0.7,0.6],[0.4,1]].
[0125] Step S204: Input the fused feature map into the face decoding network to obtain the decoded face image;
[0126] Specifically, a face decoding network is constructed to decode the fused feature maps and generate a decoded face image. This network includes a transposed convolutional layer, an activation function layer, and an instance normalization layer. The transposed convolutional layer maps the feature layers to the input size; compared to upsampling, transposed convolution has been shown to better recover image details. The final convolutional layer has three filters, and the output decoded face image is 256*256*3 in size.
[0127] Step S205: Input the feature map corresponding to the original face image into the perceptron age prediction network, wherein the perceptron age prediction network is used to predict the age corresponding to the original face image;
[0128] Specifically, a perceptron age prediction network is constructed. This perceptron age prediction network is a network structure designed for age recognition. It includes an input layer, multiple hidden layers, and an output layer. The input layer consists of N neural units, thus requiring the acquisition of original image features of size 8*8*256. The feature vector is transformed into a 1*N feature vector, where N is 16384. The network consists of a hidden layer with Q neurons and an output layer with K (K = 1024) neurons. Assuming the input layer is represented by vector X, the output of the hidden layer is f(W1X + b1), where W1 is the weight (also called the connection coefficient), b1 is the bias, and the function f can be a commonly used sigmoid function or tanh function. In fact, the process from the hidden layer to the output layer can be viewed as a multi-class logistic regression, i.e., softmax regression. Therefore, the output of the output layer is softmax(W2X1 + b2), where X1 represents the output of the hidden layer f(W1X + b1). The network structure formula of this perceptron age prediction network is expressed as follows:
[0129]
[0130] Where G represents the softmax activation function, h represents the number of hidden layers, and W... i and b i Let W represent the weights and biases of the i-th hidden layer, X represent the input feature vector, and W represent the weights and biases of the i-th hidden layer. 1 and b 1 represents the weights and biases of the input layer, and S represents the activation function.
[0131] In some embodiments, the age prediction model further includes a discriminant network for determining whether a generated face image is a real or fake image.
[0132] In this embodiment, facial data of different ages are collected, a face encoding network is constructed to obtain encoded features of the same age, style fusion is performed, a face decoding network is constructed to regenerate the original image, the age encoded feature vector is input into the perceptron network structure for age prediction, and finally an age style loss is constructed for model training. The face encoding network, face decoding network and perceptron age prediction network are optimized by using the direction of minimum backpropagation loss. This makes the face encoding network no longer only focus on age features, but also on the age style features extracted from the same age, thereby weakening the influence of the uniqueness of facial features on age prediction, thus making it more robust in practical applications and improving the accuracy of age prediction.
[0133] For details, please refer to Figure 4 , Figure 4 This is a schematic diagram of an age prediction model provided in an embodiment of this application;
[0134] like Figure 4 As shown, the age prediction model includes: a face encoding network, a style fusion network, a face decoding network, a discriminant network, and a perceptron age prediction network.
[0135] The face encoding network is used to process the original face images and age-style images in the face dataset to obtain the feature maps corresponding to the original face images and the age-style images, wherein the age values corresponding to the original face images and the age-style images are the same.
[0136] In this embodiment, image style transfer is achieved because the original face image and the age-style image share the network parameters of the face coding network. It can be understood that image style transfer refers to transferring the style of image A to image B to obtain a new image, named "new B," where "new B" contains both the content of image B and the style of image A.
[0137] The style fusion network is used to fuse the feature map corresponding to the original face image and the feature map corresponding to the age style image to obtain a fused feature map. In this embodiment, the style fusion network can be a style fusion module used to fuse the feature map corresponding to the original face image and the feature map corresponding to the age style image. Specifically, the style fusion network is used to perform... Figure 3 The steps involved will not be repeated here.
[0138] The face decoding network is used to decode the fused feature map to obtain the decoded face image.
[0139] The discriminative network is used to determine whether a generated face image is real or fake. Understandably, the goal of this discriminative network is to determine as accurately as possible whether a sample comes from real data or is generated by the generative network. In this embodiment, the discriminative network includes a binary classifier.
[0140] The perceptron age prediction network is used to predict the age of a face image being tested. This perceptron age prediction network includes an input layer, a hidden layer, and an output layer.
[0141] In this embodiment of the application, the perceptron age prediction network outputs a one-dimensional vector of size 1*N. This one-dimensional vector is input into the softmax layer for classification. The softmax layer outputs an age probability vector of size 130*1, wherein the age probability vector includes the probability values of the age corresponding to the face image being any of the ages from 1 to 130 years old.
[0142] Understandably, the age value with the highest probability value in the age probability vector is considered the predicted age output by the perceptron age prediction network.
[0143] It is understandable that training an age prediction model is essentially training the face encoding network, style fusion network, face decoding network, discrimination network, and perceptron age prediction network.
[0144] In this embodiment, the face encoding network, style fusion network, face decoding network, discriminant network, and perceptron age prediction network are optimized by minimizing backpropagation loss. This makes the face encoding network not only focus on age features, but also on age style features extracted from the same age group. This weakens the impact of the uniqueness of face features on age prediction, making it more robust in practical applications and improving the accuracy of age prediction.
[0145] Step S206: Construct an age-style loss function. Based on the face dataset and the age-style loss function, train the age prediction model until the age-style loss function converges. The age-style loss function includes the content loss of the decoded face image and the original face image output by the face decoding network, as well as the style loss of the decoded face image and the original face image output by the face decoding network.
[0146] Specifically, the age style loss function is used to calculate the age style loss, which consists of the age cross-entropy loss between the predicted age and the real age of the perceptron age prediction network, the content loss between the decoded face image and the original face image output by the face decoding network, the discrimination loss of the discriminator network, and the style loss between the decoded face image and the original face image output by the face decoding network.
[0147] Specifically, the age-style loss function includes:
[0148] Loss=a*L c +α*L pix +β*L dis +γ*L style
[0149] Among them, Loss represents age-style loss, and L c L is the age cross-entropy loss between the predicted age and the actual age in a perceptron age prediction network.pix L represents the content loss between the decoded face image and the original face image output by the face decoding network. dis To determine the loss, L style Let α be the style loss of the decoded face image output by the face decoding network and the original face image, α be the weight corresponding to the age cross-entropy loss, α be the first weight corresponding to the content loss, β be the second weight corresponding to the discriminative loss, and γ be the third weight corresponding to the style loss.
[0150] In some embodiments, the age cross-entropy loss includes:
[0151]
[0152] Among them, L c Y is the age cross-entropy loss between the predicted age and the actual age in a perceptron age prediction network, where i is the age value, n is the maximum age value, and Y is the age cross-entropy loss between the predicted age and the actual age. i P represents the actual age corresponding to age value i. i Let i be the probability value of the predicted age corresponding to age value i.
[0153] In some embodiments, content loss includes:
[0154] L pix =E T,s [‖TG(T,S)‖] mse
[0155] Among them, L pix Let T be the content loss between the decoded face image and the original face image output by the face decoding network, and let S be the age-style image with the same age as the original face image. Let G(T,S) be the decoded face image output by the face decoding network, and E be the content loss between the decoded face image and the original face image. T,S [‖TG(T,S)‖] mse This is the mean square error between the decoded face image output by the face decoding network and the original face image.
[0156] In some embodiments, the age prediction model further includes: a discriminant network for determining whether the decoded face image is a real face image;
[0157] The loss assessment includes:
[0158] L dis =E T [logD(T)]+E T,S [log(1-D(G(T,S)))]
[0159] Among them, L disFor the discriminant loss, T is the original face image, S is an age-style image with the same age as the original face image, G(T,S) is the decoded face image output by the face decoding network, D(T) is the probability value of the discriminant network judging the original face image as real or fake, D(G(T,S)) is the probability value of the discriminant network judging the decoded face image output by the face decoding network as real or fake, and E T [logD(T)] is the expected value of the discrimination network's judgment that the original face image is true, E T,S [log(1-D(G(T,S)))] is the expected value of the discrimination network's judgment that the decoded face image output by the face decoding network is false.
[0160] In some embodiments, style loss includes:
[0161]
[0162] Where i is the i-th feature scale, n is the number of feature scales, and L style For style loss, T is the original face image, S is an age-style image with the same age as the original face image, and G(T,S) is the decoded face image output by the face decoding network. The original face image is input into the VGG network to obtain the feature value of the i-th feature scale. The decoded face image is input into the VGG network to obtain the feature value of the i-th feature scale.
[0163] The VGG network is used to calculate style loss, which is the difference between the parameters of the convolutional layers in the VGG network and the style image. The number of feature scales can be set to 5 or other values.
[0164] In summary, the age-style loss function is:
[0165]
[0166] Where 'a' is the weight corresponding to the age cross-entropy loss, α is the first weight corresponding to the content loss, β is the second weight corresponding to the discriminative loss, and γ is the third weight corresponding to the style loss.
[0167] In the embodiments of this application, the weight corresponding to the age cross-entropy loss is greater than the first weight, the second weight, or the third weight. For example, α is set to 100, and the first weight α, the second weight β, and the third weight γ are all set to 10. It should be noted that α, β, and γ can be set according to specific needs and are not limited here, all of which fall within the protection scope of this application.
[0168] In this embodiment, a loss function is used for backpropagation to bring the age prediction model to convergence. Convergence of the age prediction model includes minimizing the loss and / or allowing the loss to fluctuate within a certain range and / or reaching a certain number of training iterations. For example, the Adam algorithm is used to optimize the model parameters, with 500 iterations, an initial learning rate of 0.001, and a weight decay of 0.0005. Every 50 iterations, the learning rate is decayed to 1 / 10 of its original value. The age prediction model is trained until convergence, and then the model is saved.
[0169] In this embodiment, by learning the feature information of age style, the features of different age values are transformed into age style features, so as to learn the common feature information of each age value, thereby weakening the uniqueness of facial features and performing age prediction. This embodiment can solve the problem of insufficient model generalization ability caused by the uniqueness of facial features and improve the accuracy of age prediction.
[0170] In this embodiment, a training method for an age prediction model is provided. This model includes a face encoding network, a face decoding network, and a perceptron age prediction network. The face encoding network processes an age-style image with the same age as the original face image, and the processed feature maps are style-fused. The face decoding network then decodes the fused feature maps. Furthermore, the perceptron age prediction network predicts the age of the original face image. An age-style loss function is constructed to train the age prediction model. This loss function includes the content loss of the decoded face image and the original face image output by the face decoding network, as well as the style loss of the decoded face image and the original face image output by the face decoding network. This ensures that the trained age prediction model not only focuses on age features but also on age-style features extracted from the same age. This application addresses the problem of insufficient model generalization ability caused by the uniqueness of face features, thereby improving the accuracy of age prediction.
[0171] Example 2
[0172] After training the age prediction model using the method provided in the above embodiments, a trained age prediction model is obtained, which can be used to predict the age of a person's face.
[0173] It is understood that the above embodiment one is the training stage of the age prediction model, and embodiment two of this application is the prediction stage of the age prediction model. The prediction stage needs to utilize a face encoding network and a perceptron age prediction network to obtain the predicted age corresponding to the face image to be predicted.
[0174] For details, please refer to Figure 5 , Figure 5This is a flowchart illustrating an age prediction method provided in an embodiment of this application;
[0175] like Figure 5 As shown, this age prediction method includes:
[0176] Step S501: Obtain the face image to be predicted;
[0177] Specifically, after obtaining the trained age prediction model, the face image to be predicted is acquired.
[0178] The age prediction model is trained from the composite neural network (including face encoding network, style fusion network, face decoding network, discriminant network, and perceptron age prediction network) in the above embodiments. It has the same structure and function as the composite neural network. The specific processing method of the age prediction model for the face image to be predicted is the same as the processing method of the composite neural network for the face image to be predicted in the above embodiments, and will not be described in detail here.
[0179] Step S502: Input the face image to be predicted into the age prediction model to obtain the predicted age corresponding to the face image;
[0180] For details, please refer to [link / reference]. Figure 6 , Figure 6 yes Figure 5 Detailed flowchart of step S502 in the process;
[0181] like Figure 6 As shown, step S502 includes:
[0182] Step S5021: Input the face image to be predicted into the face encoding network of the age prediction model to obtain the feature map corresponding to the face image to be predicted;
[0183] It should be noted that the relevant content of the face coding network can be found in the above embodiments, and will not be repeated here.
[0184] Step S5022: Input the feature map corresponding to the face image to be predicted into the perceptron age prediction network of the age prediction model to obtain the predicted age corresponding to the face image to be predicted.
[0185] It should be noted that the relevant content of the perceptron age prediction network can be found in the above embodiments and will not be repeated here.
[0186] In this embodiment, features are first extracted from the input face image using a face encoding network, and then a perceptron age prediction network is used. However, due to the uniqueness of facial features, they are not well-suited for age prediction and lack generalization ability. Therefore, this application utilizes the idea of style transfer, using other face images of the same age as references for style transfer during the training of the age prediction model. New features are fused using the features from both, and finally, the face image is reconstructed using the face encoding network. A loss function is then applied to allow the network to learn common feature information for the same age value. Once the age prediction model converges, a combination of the face encoding network and the perceptron age prediction network can be directly used for age prediction.
[0187] In this embodiment, an age prediction method is provided, comprising: acquiring a face image to be predicted; inputting the face image to be predicted into an age prediction model to obtain the predicted age corresponding to the face image, wherein the age prediction model is trained based on the method provided in the above embodiment. An age-style image with the same age as the original face image is processed by a face encoding network, and the processed feature maps are style-fused. The fused feature maps are further decoded by a face decoding network, and the original face image is predicted by a perceptron age prediction network. An age-style loss function is constructed to train the age prediction model. The age-style loss function includes the content loss of the decoded face image and the original face image output by the face decoding network, and the style loss of the decoded face image and the original face image output by the face decoding network. This ensures that the trained age prediction model not only focuses on age features but also on the age-style features extracted from the same age. This application can solve the problem of insufficient model generalization ability caused by the uniqueness of face features and improve the accuracy of age prediction.
[0188] Example 3
[0189] Please see Figure 7 , Figure 7 This is a schematic diagram of the structure of a training device for an age prediction model provided in an embodiment of this application;
[0190] The age prediction model includes a face encoding network, a face decoding network, and a perceptron age prediction network, such as... Figure 7 As shown, the training device 70 for the age prediction model includes:
[0191] The acquisition module 701 is used to acquire a face dataset, which includes face images with multiple different age values;
[0192] The encoding module 702 is used to process the original face image and age style image in the face dataset based on the face encoding network to obtain the feature map corresponding to the original face image and the feature map corresponding to the age style image, wherein the age value corresponding to the original face image and the age style image is the same.
[0193] The fusion module 703 is used to fuse the feature map corresponding to the original face image and the feature map corresponding to the age style image to obtain the fused feature map.
[0194] The decoding module 704 is used to input the fused feature map into the face decoding network to obtain the decoded face image;
[0195] The prediction module 705 is used to input the feature map corresponding to the original face image into the perceptron age prediction network, wherein the perceptron age prediction network is used to predict the age corresponding to the original face image.
[0196] Training module 706 is used to construct the age-style loss function. Based on the face dataset and the age-style loss function, the age prediction model is trained until the age-style loss function converges. The age-style loss function includes the content loss of the decoded face image and the original face image output by the face decoding network, as well as the style loss of the decoded face image and the original face image output by the face decoding network.
[0197] In the embodiments of this application, the training device for the age prediction model can also be built from hardware devices. For example, the training device for the age prediction model can be built from one or more chips, and the chips can work together to complete the training method for the age prediction model described in the above embodiments. As another example, the training device for the age prediction model can also be built from various logic devices, such as general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), microcontrollers, ARM (Acorn RISC Machine) or other programmable logic devices, discrete gate or transistor logic, discrete hardware components, or any combination of these components.
[0198] The training device for the age prediction model in this application embodiment can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. For example, mobile electronic devices can be mobile phones, tablets, laptops, PDAs, in-vehicle electronic devices, wearable devices, ultra-mobile personal computers (UMPCs), netbooks, or personal digital assistants (PDAs), etc., while non-mobile electronic devices can be servers, network-attached storage (NAS), personal computers (PCs), televisions (TVs), ATMs, or self-service machines, etc. This application embodiment does not impose specific limitations.
[0199] The training device for the age prediction model in this application embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit the specific operating system used.
[0200] The training device for the age prediction model provided in this application embodiment can achieve Figure 2 To avoid repetition, the various processes involved will not be described in detail here.
[0201] It should be noted that the training device for the age prediction model described above can execute the training method for the age prediction model provided in the embodiments of this application, and has the corresponding functional modules and beneficial effects of the method. Technical details not described in detail in the embodiments of the age prediction model training device can be found in the training method for the age prediction model provided in the above embodiments.
[0202] In this embodiment, a training device for an age prediction model is provided. The age prediction model includes a face encoding network, a face decoding network, and a perceptron age prediction network. The device includes: an acquisition module for acquiring a face dataset, wherein the face dataset includes multiple face images with different age values; an encoding module for processing the original face images and age-style images in the face dataset based on the face encoding network to obtain feature maps corresponding to the original face images and age-style images, wherein the original face images and age-style images correspond to the same age value; and a fusion module for fusing the feature maps corresponding to the original face images and age-style images to obtain fused features. The system consists of a feature map; a decoding module, which inputs the fused feature map into the face decoding network to obtain the decoded face image; a prediction module, which inputs the feature map corresponding to the original face image into the perceptron age prediction network, whereby the perceptron age prediction network is used to predict the age corresponding to the original face image; and a training module, which constructs an age-style loss function and trains the age prediction model based on the face dataset and the age-style loss function until the age-style loss function converges. The age-style loss function includes the content loss of the decoded face image and the original face image output by the face decoding network, as well as the style loss of the decoded face image and the original face image output by the face decoding network.
[0203] This application processes an age-style image with the same age as the original face image using a face encoding network, and then fuses the processed feature maps using style. The fused feature maps are further decoded using a face decoding network. Additionally, a perceptron age prediction network is used to predict the age of the original face image. An age-style loss function is constructed to train the age prediction model. This loss function includes the content loss of the decoded face image and the original face image output by the face decoding network, as well as the style loss of the decoded face image and the original face image output by the face decoding network. This ensures that the trained age prediction model not only focuses on age features but also on the age-style features extracted from the same age. This application addresses the problem of insufficient model generalization ability caused by the uniqueness of face features, thereby improving the accuracy of age prediction.
[0204] Example 4
[0205] Please see Figure 8 , Figure 8 This is a schematic diagram of the structure of an age prediction device provided in an embodiment of this application;
[0206] like Figure 8 As shown, the age prediction device 80 includes:
[0207] Image acquisition module 801 is used to acquire the face image to be predicted;
[0208] The age prediction module 802 is used to input the face image to be predicted into the age prediction model to obtain the predicted age corresponding to the face image to be predicted. The age prediction model is trained based on the training method of the age prediction model provided in the above embodiment.
[0209] In the embodiments of this application, the age prediction device can also be constructed from hardware devices. For example, the age prediction device can be constructed from one or more chips, and the chips can work together to complete the age prediction method described in the above embodiments. Furthermore, the age prediction device can also be constructed from various logic devices, such as general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), microcontrollers, ARM (Acorn RISC Machine) or other programmable logic devices, discrete gate or transistor logic, discrete hardware components, or any combination of these components.
[0210] The age prediction device in this application embodiment can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. For example, mobile electronic devices can be mobile phones, tablets, laptops, PDAs, in-vehicle electronic devices, wearable devices, ultra-mobile personal computers (UMPCs), netbooks, or personal digital assistants (PDAs), etc., while non-mobile electronic devices can be servers, network-attached storage (NAS), personal computers (PCs), televisions (TVs), ATMs, or self-service machines, etc. This application embodiment does not impose specific limitations.
[0211] The age prediction device in this application embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this application embodiment does not specifically limit it.
[0212] The age prediction device provided in this application embodiment can achieve... Figure 5 To avoid repetition, the various processes involved will not be described in detail here.
[0213] It should be noted that the age prediction device described above can execute the age prediction method provided in the embodiments of this application, and has the corresponding functional modules and beneficial effects of the method. Technical details not described in detail in the age prediction device embodiments can be found in the age prediction method provided in the above embodiments.
[0214] In this embodiment of the application, an age prediction device is provided, comprising: an image acquisition module for acquiring a face image to be predicted; and an age prediction module for inputting the face image to be predicted into an age prediction model to obtain the predicted age corresponding to the face image, wherein the age prediction model is trained based on the training method of the age prediction model provided in the above embodiment.
[0215] This application processes an age-style image with the same age as the original face image using a face encoding network, and then fuses the processed feature maps using style. The fused feature maps are further decoded using a face decoding network. Additionally, a perceptron age prediction network is used to predict the age of the original face image. An age-style loss function is constructed to train the age prediction model. This loss function includes the content loss of the decoded face image and the original face image output by the face decoding network, as well as the style loss of the decoded face image and the original face image output by the face decoding network. This ensures that the trained age prediction model not only focuses on age features but also on the age-style features extracted from the same age. This application addresses the problem of insufficient model generalization ability caused by the uniqueness of face features, thereby improving the accuracy of age prediction.
[0216] Example 5
[0217] Please see Figure 9 , Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;
[0218] like Figure 9 As shown, the electronic device 90 includes one or more processors 901 and a memory 902. Wherein, Figure 9 Take the 901 processor as an example.
[0219] Processor 901 and memory 902 can be connected via a bus or other means. Figure 9 Taking the example of a connection between China and Israel via a bus.
[0220] Processor 901 provides computing and control capabilities to control electronic device 90 to perform corresponding tasks, such as controlling electronic device 90 to perform the training method of the age prediction model in any of the above method embodiments, including: acquiring a face dataset, wherein the face dataset includes multiple face images with different age values; processing the original face images and age-style images in the face dataset based on a face coding network to obtain feature maps corresponding to the original face images and age-style images, wherein the original face images and age-style images correspond to the same age value; and fusing the feature maps corresponding to the original face images and age-style images. The fused feature map is obtained; the fused feature map is input into the face decoding network to obtain the decoded face image; the feature map corresponding to the original face image is input into the perceptron age prediction network, where the perceptron age prediction network is used to predict the age corresponding to the original face image; an age style loss function is constructed, and the age prediction model is trained based on the face dataset and the age style loss function until the age style loss function converges. The age style loss function includes the content loss of the decoded face image and the original face image output by the face decoding network, and the style loss of the decoded face image and the original face image output by the face decoding network.
[0221] This application processes an age-style image with the same age as the original face image using a face encoding network, and then fuses the processed feature maps using style. The fused feature maps are further decoded using a face decoding network. Additionally, a perceptron age prediction network is used to predict the age of the original face image. An age-style loss function is constructed to train the age prediction model. This loss function includes the content loss of the decoded face image and the original face image output by the face decoding network, as well as the style loss of the decoded face image and the original face image output by the face decoding network. This ensures that the trained age prediction model not only focuses on age features but also on the age-style features extracted from the same age. This application addresses the problem of insufficient model generalization ability caused by the uniqueness of face features, thereby improving the accuracy of age prediction.
[0222] Alternatively, the electronic device 90 may execute the age prediction method in any of the above method embodiments, including: acquiring a face image to be predicted; inputting the face image to be predicted into an age prediction model to obtain the predicted age corresponding to the face image to be predicted, wherein the age prediction model is trained based on the training method of the age prediction model provided in the above embodiments.
[0223] By employing the concept of style transfer, the encoding network, which originally focused on extracting facial features, learns more about age-related style features, while de-emphasizing the extraction of unique facial features. This transforms features from different age values into age-style features, learning common feature information for each age value. This addresses the problem of poor model generalization caused by the uniqueness of facial features, thereby improving the accuracy of age prediction.
[0224] Processor 901 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), a hardware chip, or any combination thereof; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The aforementioned PLD can be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0225] Memory 902, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer-executable programs, and modules, such as the training method for the age prediction model or the program instructions / modules corresponding to the age prediction method in the embodiments of this application. Processor 901, by running the non-transitory software programs, instructions, and modules stored in memory 902, can implement the training method for the age prediction model or the age prediction method in any of the following method embodiments. Specifically, memory 902 may include volatile memory (VM), such as random access memory (RAM); memory 902 may also include non-volatile memory (NVM), such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (SSD) or other non-transitory solid-state storage devices; memory 902 may also include combinations of the above types of memory.
[0226] Memory 902 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 902 may optionally include memory remotely located relative to processor 901, which can be connected to processor 901 via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0227] One or more modules are stored in memory 902. When executed by one or more processors 901, they execute the training method or age prediction method of the age prediction model in any of the above method embodiments. For example, they execute the methods described above. Figure 2 , 3 The steps shown in 5 and 6 can also be implemented. Figure 7 , 8 The functions of each module or unit.
[0228] In this embodiment, the electronic device 90 may also have wired or wireless network interfaces, keyboards, and input / output interfaces for input and output. The electronic device 90 may also include other components for implementing device functions, which will not be described in detail here.
[0229] The electronic devices described in this application exist in various forms, and perform the above-described... Figure 2 , 3 The steps shown in 5 and 6 can also be implemented. Figure 7 , 8 The functions of each unit include, but are not limited to: mobile terminals, smartwatches, fixed terminals, wearable devices, and other devices.
[0230] This application also provides a computer-readable storage medium, such as a memory including program code, which can be executed by a processor to complete the training method or age prediction method of the age prediction model in the above embodiments. For example, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CDROM), magnetic tape, floppy disk, and optical data storage device, etc.
[0231] This application also provides a computer program product comprising one or more lines of program code stored in a computer-readable storage medium. A processor of an electronic device reads the program code from the computer-readable storage medium and executes the program code to complete the training method or method steps of the age prediction model provided in the above embodiments.
[0232] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware, or by a program or program code related to hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0233] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software and a general-purpose hardware platform, or of course, using hardware. Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0234] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and not to limit them; under the concept of this application, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations as described above in different aspects of this application, which are not provided in detail for the sake of brevity; although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A training method for an age prediction model, characterized in that, The age prediction model comprises a face encoding network, a face decoding network, and a perceptual machine age prediction network, and the method comprises: obtaining a face dataset, wherein the face dataset comprises face images of multiple different age values; processing original face images and age style images in the face dataset based on the face encoding network to obtain feature maps corresponding to the original face images and feature maps corresponding to the age style images, wherein the original face images and the age style images correspond to the same age value; fusing the feature maps corresponding to the original face images and the feature maps corresponding to the age style images to obtain fused feature maps; inputting the fused feature maps into the face decoding network to obtain decoded face images; inputting the feature maps corresponding to the original face images into the perceptual machine age prediction network, wherein the perceptual machine age prediction network is used to predict the age corresponding to the original face images; constructing an age style loss function, training the age prediction model based on the face dataset and the age style loss function until the age style loss function converges, wherein the age style loss function comprises a content loss of decoded face images output by the face decoding network and original face images, and a style loss of the decoded face images output by the face decoding network and the original face images.
2. The method of claim 1, wherein, The fusing of the feature maps corresponding to the original face images and the feature maps corresponding to the age style images to obtain fused feature maps comprises: sorting the feature maps corresponding to the original face images according to the size of the pixel value of each pixel point and determining a first sorting index corresponding to the feature maps corresponding to the original face images, wherein the first sorting index is used to determine the original position of each pixel point in the feature maps corresponding to the original face images before sorting; sorting the feature maps corresponding to the age style images according to the size of the pixel value of each pixel point and determining a second sorting index corresponding to the feature maps corresponding to the age style images, wherein the second sorting index is used to determine the original position of each pixel point in the feature maps corresponding to the age style images before sorting; processing the feature maps corresponding to the age style images according to the first sorting index to obtain processed feature maps; fusing the feature maps corresponding to the original face images and the processed feature maps to obtain fused feature maps.
3. The method of claim 2, wherein the processing of the feature maps corresponding to the age style images according to the first sorting index to obtain processed feature maps comprises: extracting each pixel point of the feature maps corresponding to the age style images according to the first sorting index to obtain processed feature maps; the fusing of the feature maps corresponding to the original face images and the processed feature maps to obtain fused feature maps comprises: Add the pixel value of each pixel point of the feature map corresponding to the original face image to the pixel value of each pixel point of the processed feature map one by one to obtain a fusion pixel value of each pixel point to obtain a fused feature map.
4. The method according to any one of claims 1 to 3, characterized in that, The age style loss function comprises: wherein, is an age style loss, is an age cross-entropy loss of a predicted age of the perception machine age prediction network and a real age, is a content loss of a decoded face image output by the face decoding network and an original face image, is a discrimination loss, is a style loss of the decoded face image output by the face decoding network and the original face image, a is a weight corresponding to the age cross-entropy loss, is a first weight corresponding to the content loss, is a second weight corresponding to the discrimination loss, is a third weight corresponding to the style loss.
5. The method of claim 4, wherein, The age cross-entropy loss comprises: wherein, is the age cross-entropy loss of the predicted age of the perception machine age prediction network and the real age, i is the age value, and n is the maximum age value, is the real age corresponding to the age value i, is the probability value of the predicted age corresponding to the age value i.
6. The method of claim 4, wherein, The content loss comprises: wherein, a content loss of the decoded face image output by the face decoding network and the original face image, an original face image, an age style image of the same age as the original face image, a decoded face image output by the face decoding network, a mean square error of the decoded face image output by the face decoding network and the original face image.
7. The method of claim 4, wherein, The age prediction model further comprises a discriminator network configured to determine whether the decoded face image is a real face image. The discriminator loss comprises: wherein, is a discriminative loss, is an original face image, is an age style image with the same age as the original face image, is a decoded face image output by a face decoding network, is a probability value of a discriminative network judging the original face image to be true or false, is a probability value of the discriminative network judging the decoded face image output by the face decoding network to be true or false, is an expected value of the discriminative network judging the original face image to be true, is an expected value of the discriminative network judging the decoded face image output by the face decoding network to be false.
8. The method of claim 4, wherein, The style loss comprises: wherein k is the kth feature scale, and n is the number of feature scales, is a style loss, is an original face image, is an age style image of the same age as the original face image, is a decoded face image output by the face decoding network, is a feature value of the kth feature scale obtained by inputting the original face image into the VGG network, is a feature value of the kth feature scale obtained by inputting the decoded face image into the VGG network.
9. An age prediction method characterized by, comprises: Obtaining a face image to be predicted; inputting the face image to be predicted into an age prediction model to obtain a predicted age corresponding to the face image to be predicted, wherein the age prediction model is trained based on the method in any one of claims 1-8.
10. The method of claim 9, wherein, The inputting the face image to be predicted into the age prediction model to obtain the predicted age corresponding to the face image to be predicted comprises: inputting the face image to be predicted into a face encoding network of the age prediction model to obtain a feature map corresponding to the face image to be predicted; inputting the feature map corresponding to the face image to be predicted into a perceptual machine age prediction network of the age prediction model to obtain the predicted age corresponding to the face image to be predicted.
11. An electronic device, comprising: comprises: at least one processor, and a memory connected in communication with the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method in any one of claims 1-10.
12. A non-transitory computer readable storage medium, comprising: The non-volatile computer readable storage medium stores computer executable instructions for causing an electronic device to perform the method in any one of claims 1-10. The non-volatile computer readable storage medium stores computer executable instructions for causing an electronic device to perform the method in any one of claims 1-10.
Citation Information
Patent Citations
Generation method of age transformation face image and generative adversarial network model
CN112883756A
Age recognition model training method, face age recognition method and related device
CN113065525A