Age estimation method, device, equipment and storage medium based on image
By combining the subject convolutional neural network layer, the age classification layer and the exact age classification layer in the neural network model, using the labeled first sample image and the second sample image of the preset age group, the age of the face image is solved The problems of high training cost and low accuracy in estimation are achieved to achieve more efficient age prediction.
Patent Information
- Application Number
- CN202011001040.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-22
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2040-09-22
AI Technical Summary
Existing age estimation methods based on face images require a large amount of labeled face image data for training, resulting in high training costs and low model accuracy, which are limited by the scarcity of labeled data and high collection costs.
Using a neural network model including a main convolutional neural network layer, an age classification layer and an exact age classification layer, the training cost is reduced by using the first sample image with an age label and the second sample image with a preset age group for training. and improve model accuracy.
It effectively reduces the training cost of the neural network model and improves the accuracy of age estimation. By increasing the use of sample images of preset age groups, the amount of training data is increased and the prediction accuracy of the model is improved.
Smart Images

Figure CN112183283B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of information technology, and in particular to an image-based age estimation method, device, equipment and storage medium. Background Art
[0002] In the field of computer vision, age estimation based on face images is an important branch. Specifically, based on a face image, estimating the exact age of the person in the image has important application value in the fields of human-computer interaction, user profiling, video surveillance, information recommendation, etc.
[0003] At present, the age estimation method based on face images requires a large amount of labeled face image data to train the neural network model, where the label can be the exact age of the person in the image. However, there are currently few labeled face images in stock, and the cost of collecting them is very high and not easy to obtain. Therefore, the cost of training the neural network model is too high. In addition, since there are fewer face images used to train the neural network model, the accuracy of the trained neural network model is low, thereby reducing the accuracy of age estimation. Summary of the invention
[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides an image-based age estimation method, device, equipment and storage medium to reduce the training cost of the neural network model and improve the accuracy of the neural network model in predicting age.
[0005] In a first aspect, an embodiment of the present disclosure provides an age estimation method based on an image, comprising:
[0006] Acquire a target image, wherein the target image includes a target object;
[0007] Input the target image into a trained neural network model, wherein the neural network model is trained based on a first sample image with an age label and a second sample image corresponding to each preset age group in a plurality of preset age groups, wherein the neural network model comprises a main convolutional neural network layer, an age group classification layer and an exact age classification layer, wherein the main convolutional neural network layer is used to perform feature extraction on the target image to obtain target feature information corresponding to the target image, the age group classification layer is used to determine the age group probability information of the target object based on the target feature information, and the exact age classification layer is used to determine the age probability information of the target object based on the target feature information;
[0008] The age of the target object is determined according to the age group probability information of the target object and the age probability information of the target object.
[0009] In a second aspect, an embodiment of the present disclosure provides a neural network model training method, wherein the neural network model includes: a main convolutional neural network layer, an age group classification layer, and an exact age classification layer; the method includes:
[0010] Acquire a first sample image and the age of a first object in the first sample image;
[0011] According to a plurality of preset age groups, obtaining a second sample image corresponding to each preset age group;
[0012] According to the first sample image and the age of the first object in the first sample image, performing model training on the main convolutional neural network layer, the age group classification layer and the exact age classification layer in the neural network model;
[0013] According to the second sample image and the preset age group corresponding to the second sample image, model training is performed on the main convolutional neural network layer and the age group classification layer in the neural network model.
[0014] In a third aspect, an embodiment of the present disclosure provides an image-based age estimation device, comprising:
[0015] An acquisition module, used for acquiring a target image, wherein the target image includes a target object;
[0016] An input module, used for inputting the target image into a trained neural network model, wherein the neural network model is trained based on a first sample image with an age label and a second sample image corresponding to each preset age group in a plurality of preset age groups, wherein the neural network model comprises a main convolutional neural network layer, an age group classification layer and an exact age classification layer, wherein the main convolutional neural network layer is used for performing feature extraction on the target image to obtain target feature information corresponding to the target image, the age group classification layer is used for determining age group probability information of the target object based on the target feature information, and the exact age classification layer is used for determining age probability information of the target object based on the target feature information;
[0017] The determination module is used to determine the age of the target object according to the age group probability information of the target object and the age probability information of the target object.
[0018] In a fourth aspect, an embodiment of the present disclosure provides a neural network model training device, wherein the neural network model comprises: a main convolutional neural network layer, an age group classification layer, and an exact age classification layer; the neural network model training device comprises:
[0019] A first acquisition module, configured to acquire a first sample image and the age of a first object in the first sample image;
[0020] A second acquisition module, configured to acquire, according to a plurality of preset age groups, a second sample image corresponding to each preset age group;
[0021] A first training module, configured to perform model training on a main convolutional neural network layer, an age group classification layer, and an exact age classification layer in the neural network model according to the first sample image and the age of the first object in the first sample image;
[0022] The second training module is used to perform model training on the main convolutional neural network layer and the age group classification layer in the neural network model according to the second sample image and the preset age group corresponding to the second sample image.
[0023] In a fifth aspect, an embodiment of the present disclosure provides an image-based age estimation device, comprising:
[0024] Memory;
[0025] Processor; and
[0026] Computer programs;
[0027] The computer program is stored in the memory and is configured to be executed by the processor to implement the method as described in the first aspect.
[0028] In a sixth aspect, an embodiment of the present disclosure provides a neural network model training device, including:
[0029] Memory;
[0030] Processor; and
[0031] Computer programs;
[0032] The computer program is stored in the memory and is configured to be executed by the processor to implement the method as described in the second aspect.
[0033] In a seventh aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the method described in the first aspect or the second aspect.
[0034] The image-based age estimation method, device, equipment and storage medium provided by the embodiments of the present disclosure estimate the age of the target object in the target image through a trained neural network model, and the neural network model is obtained by training based on a first sample image with an age label and a second sample image corresponding to each preset age group in a plurality of preset age groups. That is to say, when training the neural network model, not only sample images of exact ages are required, but also sample images of preset age groups are required, and the collection cost of sample images of preset age groups is much lower than the collection cost of sample images of exact ages, and sample images of preset age groups are easier to obtain, thereby reducing the training cost of the neural network model. In addition, in the process of using a small number of sample images of exact ages to train the neural network model, by adding a large number of sample images of preset age groups for auxiliary training, the number of sample images used to train the neural network model can be increased, thereby improving the accuracy of the trained neural network model. In addition, the neural network model includes a main convolutional neural network layer, an age group classification layer and an exact age classification layer, wherein the main convolutional neural network layer is used to extract features from the target image to obtain target feature information corresponding to the target image, the age group classification layer is used to predict the age group of the target object, and the exact age classification layer is used to predict the age of the target object. Therefore, based on the age group probability information of the target object and the age probability information of the target object, the age of the target object is determined with high accuracy, which improves the accuracy of the neural network model in predicting age. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0036] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0037] Figure 1 A schematic diagram of an application scenario provided by an embodiment of the present disclosure;
[0038] Figure 2 A schematic diagram of a neural network model training method provided in an embodiment of the present disclosure;
[0039] Figure 3 A schematic diagram of a neural network model training method provided in an embodiment of the present disclosure;
[0040] Figure 4 A schematic diagram of the structure of a neural network model provided in an embodiment of the present disclosure;
[0041] Figure 5 A schematic diagram of a neural network model training method provided in an embodiment of the present disclosure;
[0042] Figure 6 A schematic diagram of a probability density function provided by an embodiment of the present disclosure;
[0043] Figure 7 A flow chart of an age estimation method based on an image provided in an embodiment of the present disclosure;
[0044] Figure 8 A flow chart of an age estimation method based on an image provided in an embodiment of the present disclosure;
[0045] Fig. 9 A flow chart of an age estimation method based on an image provided in an embodiment of the present disclosure;
[0046] Fig.10 A schematic diagram of the structure of an image-based age estimation device provided in an embodiment of the present disclosure;
[0047] Fig.11 A schematic diagram of the structure of a neural network model training device provided in an embodiment of the present disclosure;
[0048] Fig.12 A schematic diagram of the structure of an image-based age estimation device provided in an embodiment of the present disclosure;
[0049] Fig.13 A schematic diagram of the structure of a neural network model training device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0050] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0051] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0052] At present, the age estimation method based on face images requires a large amount of labeled face image data to train the neural network model, wherein the label can specifically be the accurate age of the person in the image. However, the current stock of labeled face images is small, and the cost of collecting them is very high, and they are not easy to obtain. Therefore, the cost of training the neural network model is too high. In addition, since there are fewer labeled face images used to train the neural network model, the accuracy of the age predicted by the trained neural network model is low. To address this problem, the embodiments of the present disclosure provide an image-based age estimation method, which is described below in conjunction with specific embodiments.
[0053] Specifically, the image-based age estimation method can be executed by a terminal or a server. Specifically, the terminal or the server can estimate the age of the target object in the target image through a neural network model. The execution subject of the training method of the neural network model and the execution subject of the age estimation method can be the same or different.
[0054] For example, in an application scenario, such as Figure 1 As shown, the server 12 trains the neural network model. The terminal 11 obtains the trained neural network model from the server 12, and the terminal 11 estimates the age of the target object in the target image through the trained neural network model. The target image may be obtained by taking a picture by the terminal 11. Alternatively, the target image is an image obtained by the terminal 11 after performing image processing on a preset image, and the preset image may be obtained by taking a picture by the terminal 11, or the preset image may be obtained by the terminal 11 from other devices. Here, no specific limitation is made to other devices.
[0055] In another application scenario, the server 12 trains the neural network model. Further, the server 12 estimates the age of the target object in the target image through the trained neural network model. The way in which the server 12 obtains the target image can be similar to the way in which the terminal 11 obtains the target image as described above, which will not be repeated here.
[0056] In another application scenario, the terminal 11 trains the neural network model. Further, the terminal 11 estimates the age of the target object in the target image through the trained neural network model.
[0057] It is understandable that the neural network model training method and the image-based age estimation method provided by the embodiments of the present disclosure are not limited to the several possible scenarios described above. Since the trained neural network model can be applied to the image-based age estimation method, before introducing the image-based age estimation method, the neural network model training method can be introduced below.
[0058] The following introduces a neural network model training method, that is, the training process of the neural network model, by taking the server 12 training the neural network model as an example. It is understandable that the neural network model training method is also applicable to the scenario where the terminal 11 trains the neural network model.
[0059] It is understandable that the image-based age estimation method provided in the embodiments of the present disclosure can be used not only to estimate the age of a person, but also to estimate the age of an animal. If the age estimation method is used to estimate the age of a person, the sample images used to train the neural network model may be images including the person, for example, facial images. If the age estimation method is used to estimate the age of a certain animal, the sample images used to train the neural network model may be images including the animal. The embodiments of the present disclosure are schematically illustrated using the estimation of the age of a person as an example. The method for estimating the age of an animal is similar to the method for estimating the age of a person.
[0060] Figure 2 A neural network model training method is provided in an embodiment of the present disclosure. The neural network model includes: a main convolutional neural network layer, an age group classification layer and an exact age classification layer; the method includes: Figure 2 The following steps are shown:
[0061] S201: Acquire a first sample image and the age of a first object in the first sample image.
[0062] In this embodiment, the first sample image may specifically be an image including a person or a face image. Accordingly, the first object in the first sample image may specifically be a person or a face. The age of the person or face in the first sample image is accurate and known. The age of the face may be understood as the age of the person. The age of the face or the age of the person may refer to a specific age value.
[0063] If the first sample image is an image including a person, an image processing method may be used to extract a face image from the first sample image. Further, the neural network model is trained based on the face image. Alternatively, the face image is processed to adjust parameters such as the clarity and / or position of the face in the face image, and then the neural network model is trained based on the adjusted face image.
[0064] If the first sample image is a face image, the neural network model can be trained based on the face image. Alternatively, the face image is further processed to adjust parameters such as the clarity and / or position of the face in the face image, and then the neural network model is trained based on the adjusted face image.
[0065] Optionally, the first sample image is a face image, and the first object in the first sample image is a face.
[0066] In this embodiment, the first sample image being a face image is taken as an example for illustrative purposes. The number of the first sample images can be one or multiple. The ways for the server 12 to obtain the first sample images include the following several feasible implementation manners:
[0067] In a feasible implementation manner, the server 12 may pre-store multiple first sample images. Alternatively, the server 12 may obtain multiple first sample images from the terminal 11 or other servers. It can be understood that the number of the terminals 11 can be one or multiple.
[0068] In another feasible implementation manner, the server 12 may pre-store multiple preset images. Alternatively, the server 12 obtains multiple preset images from the terminal 11 or other servers. Each preset image includes one or more persons. Further, the server 12 may use face recognition technology to recognize the faces of the persons in each preset image, and use image processing methods to obtain the face images in each preset image. For example, the face images of the target persons in each preset image may be obtained. The target persons may be the persons selected by the user, or may be the persons satisfying preset conditions. Alternatively, the face images with a clarity greater than or equal to a preset threshold in each preset image may be obtained. Or, the face images of each person in the preset image may be obtained. Further, image processing is performed on the face images of each person to adjust the clarity and / or position of the faces, and the face images with a clarity greater than or equal to the preset threshold and / or the face images with the face positions at preset positions are retained. Among them, the methods for obtaining face images from the preset images include, but are not limited to: methods such as intercepting, copying, and cropping. Further, the server 12 uses the face images obtained from the preset images as the first sample images.
[0069] Specifically, multiple first sample images and the ages of the faces in each first sample image may constitute a first data set, which may be denoted as D1. D1 may be expressed as the following formula (1):
[0070]
[0071] where 0≤i<n1, n1 represents the number of the first sample images in the first data set, represents the i-th first sample image in the first data set. represents the age of the face in the i-th first sample image. This age may be an exact age. This exact age may also be denoted as the labeled age.
[0072] S202: According to a plurality of preset age groups, obtain a second sample image corresponding to each preset age group.
[0073] In the embodiment of the present disclosure, the second sample image may specifically be an image including a person or a face image. Accordingly, the second object in the second sample image may specifically be a person or a face. However, unlike the first sample image described above, the age of the person or face in the second sample image is imprecise and unknown, but the age range of the person or face in the second sample image is known.
[0074] Similarly, if the second sample image is an image including a person, an image processing method can be used to extract a face image in the second sample image. Further, the neural network model is trained based on the face image. Alternatively, further, the face image is processed to adjust parameters such as the clarity and / or position of the face in the face image, and then the neural network model is trained based on the adjusted face image.
[0075] If the second sample image is a face image, the neural network model can be trained based on the face image. Alternatively, the face image is further processed to adjust parameters such as the clarity and / or position of the face in the face image, and then the neural network model is trained based on the adjusted face image.
[0076] Optionally, the second sample image is a face image, and the second object in the second sample image is a face. Optionally, a face image includes a face.
[0077] This embodiment is schematically described by taking the second sample image as a face image as an example. The number of the second sample images can be one or more. The server 12 obtains the second sample image in the following feasible implementations:
[0078] In a possible implementation, the server 12 or a database corresponding to the server 12 may pre-store multiple types of facial images, such as facial images of infants, adolescents, teenagers, young people, middle-aged people, and elderly people. Further, the server 12 obtains facial images corresponding to each type from the local or database corresponding to the server 12. The number of facial images of each type obtained by the server 12 may be the same or different. Each type of facial image may be used as a second sample image.
[0079] Specifically, "infants", "juveniles", "adolescents", "youth", "middle-aged", and "elderly" can be used as labels for multiple preset age groups. The corresponding relationship between labels and preset age groups is shown in Table 1 below:
[0080] Table 1
[0081]
[0082] In another feasible implementation, the server 12 uses "infancy", "juvenile", "adolescent", "youth", "middle-aged", and "elderly" as keywords to crawl the second sample images corresponding to "infancy", "juvenile", "adolescent", "youth", "middle-aged", and "elderly" respectively from the network, such as the Internet. Specifically, for these 6 types of "infancy", "juvenile", "adolescent", "youth", "middle-aged", and "elderly", the server 12 crawls the corresponding second sample images according to the ratio of 1:1:1:1:1:1, that is, the number of second sample images of each preset age group crawled by the server 12 from the Internet is the same. For example, the server 12 crawls 100 second sample images of each preset age group from the Internet.
[0083] Specifically, multiple second sample images and the preset age group corresponding to each second sample image can form a second data set, which can be denoted as D2. D2 can be expressed by the following formula (2):
[0084]
[0085] Where 0 ≤ i < n2, and n2 represents the number of second sample images in this second data set. 0 ≤ j < m1, and m1 represents the number of preset age groups. Represents the i-th second sample image in this second data set. Represents the preset age group corresponding to the i-th second sample image.
[0086] Furthermore, sample images are randomly selected from the first data set D1 and the second data set D2. This sample image may be a first sample image or a second sample image. Furthermore, this sample image is input into the neural network model, and the neural network model is trained through this sample image. It can be understood that the neural network model can be iteratively trained once through a sample image, and the neural network model can be iteratively trained multiple times through multiple sample images. During the multiple iterative training processes, the parameters of the neural network model can be continuously updated, making the accuracy of the neural network model higher and higher. Among them, the parameters of the neural network model can specifically include: the parameters of the main convolutional neural network layer, the parameters of the age group classification layer, and the parameters of the exact age classification layer.
[0087] Since the process of training the neural network model through each sample image is similar, therefore, in this embodiment, taking a sample image as an example, the process of training the neural network model through this sample image is introduced.
[0088] S203. Perform model training on the main convolutional neural network layer, the age group classification layer and the exact age classification layer in the neural network model according to the first sample image and the age of the first object in the first sample image.
[0089] When the sample image is the first sample image, that is, the sample image comes from the first data set D1, since the first sample image corresponds to an exact age, the main convolutional neural network layer, the age group classification layer and the exact age classification layer in the neural network model can be trained according to the first sample image and the age of the first object in the first sample image.
[0090] S204: Perform model training on the main convolutional neural network layer and the age group classification layer in the neural network model according to the second sample image and the preset age group corresponding to the second sample image.
[0091] When the sample image is the second sample image, that is, the sample image comes from the second data set D2, since the second sample image corresponds to an age group or an age group label, the main convolutional neural network layer and the age group classification layer in the neural network model can be trained according to the second sample image.
[0092] The disclosed embodiment trains the neural network model by using a first sample image corresponding to an exact age and a second sample image that does not correspond to an exact age but corresponds to a preset age group. The neural network model includes a main convolutional neural network layer, an age group classification layer, and an exact age classification layer. The first sample image and the exact age corresponding to the first sample image are used to perform model training on the main convolutional neural network layer, the age group classification layer, and the exact age classification layer. The second sample image and the preset age group corresponding to the second sample image are used to perform model training on the main convolutional neural network layer and the age group classification layer. Thus, the training process of the neural network model not only relies on the first sample image of the exact age, but also relies on the second sample image of the preset age group. Since the collection cost of the second sample image is much lower than the collection cost of the first sample image, and the second sample image is easier to obtain, the training cost of the neural network model is reduced. In addition, when the first sample image of the exact age and the second sample image of the preset age group are used to train the neural network model, since the second sample image is easier to obtain, in the process of using a small number of first sample images of the exact age to train the neural network model, a large number of second sample images of the preset age group can be added for auxiliary training, thereby improving the accuracy of the neural network model.
[0093] Based on the above embodiment, optionally, according to the first sample image and the age of the first object in the first sample image, model training is performed on the main convolutional neural network layer, the age group classification layer and the exact age classification layer in the neural network model, including: Figure 3 The following steps are shown:
[0094] S301. Input the first sample image into the main convolutional neural network layer in the neural network model to obtain first feature information corresponding to the first sample image.
[0095] like Figure 4 The figure shows a schematic diagram of the structure of a neural network model provided by an embodiment of the present disclosure. The neural network model includes: a main convolutional neural network layer, an age group classification layer and an exact age classification layer.
[0096] When a sample image randomly selected from the first data set D1 and the second data set D2 is a first sample image, the first sample image is input into Figure 4 In the main convolutional neural network layer (Convolutional Neural Networks, CNN) shown in FIG. The main convolutional neural network layer is used to extract features of the first sample image to obtain first feature information corresponding to the first sample image.
[0097] S302: Input the first feature information into the exact age classification layer in the neural network model to obtain a first prediction vector.
[0098] S303: Input the first feature information into the age group classification layer in the neural network model to obtain a second prediction vector.
[0099] Since the first sample image comes from the first data set D1, the face in the first sample image has an exact age, and the exact age group can be determined based on the exact age. Therefore, the main convolutional neural network layer can input the first feature information corresponding to the first sample image into the age group classification layer and the exact age classification layer respectively.
[0100] The exact age classification layer can specifically output an exact age prediction vector based on the first feature information corresponding to the first sample image. In the training stage, the exact age prediction vector is recorded as the first prediction vector. The first prediction vector is an M-dimensional vector, that is, the first prediction vector includes M element values. This embodiment does not limit the specific value of M, for example, M=100. Each element value in the first prediction vector corresponds to a preset age. Each element value in the first prediction vector represents the probability that the age of the face in the first sample image predicted by the exact age classification layer is the preset age. The first prediction vector is recorded as P1, and P1 can be expressed as:
[0101] P1=[p11,p12,......,p1 100 ]
[0102] Among them, p11 is the first element value in the first prediction vector, p12 is the second element value in the first prediction vector, and so on. 100 is the 100th element value in the first prediction vector. p11 corresponds to 1 year old, p12 corresponds to 2 years old, and so on. 100 p11 represents the probability that the age of the face in the first sample image predicted by the exact age classification layer is 1 year old, p12 represents the probability that the age of the face in the first sample image predicted by the exact age classification layer is 2 years old, and so on. 100 represents the probability that the age of the face in the first sample image predicted by the exact age classification layer is 100. Optionally, the sum of all element values in the first prediction vector is 1.
[0103] The age group classification layer can specifically output an age group prediction vector based on the first feature information corresponding to the first sample image. During the training phase, the age group prediction vector is recorded as the second prediction vector. The second prediction vector is an N-dimensional vector. This embodiment does not limit the specific value of N. For example, N can be the same as the number of preset age groups as described above, for example, N=6. Each element value in the second prediction vector corresponds to a preset age group. Each element value in the second prediction vector represents the probability that the age group of the face in the first sample image predicted by the age group classification layer is a preset age group. The second prediction vector can be recorded as P2, and P2 can be expressed as:
[0104] P2=[p21, p22,..., p26]
[0105] Among them, p21 is the first element value in the second prediction vector, p22 is the second element value in the second prediction vector, and so on, p26 is the sixth element value in the second prediction vector. The corresponding relationship between each element value in the second prediction vector and the preset age group is shown in Table 2 below:
[0106] Table 2
[0107] Element Value Default age group <![CDATA[p21]]> 0(newborn)-6 years old <![CDATA[p22]]> 7-12 years old <![CDATA[p23]]> 13-17 years old <![CDATA[p24]]> 18-45 years old <![CDATA[p25]]> 46-69 years old <![CDATA[p26]]> Over 69 years old
[0108] In addition, p21 represents the probability that the age range of the face in the first sample image predicted by the age range classification layer is 0 (newborn)-6 years old, p22 represents the probability that the age range of the face in the first sample image predicted by the age range classification layer is 7-12 years old, and so on, p26 represents the probability that the age range of the face in the first sample image predicted by the age range classification layer is greater than 69 years old. Optionally, the sum of all element values in the second prediction vector is 1.
[0109] S304: Determine a first loss function according to the first prediction vector, the second prediction vector, and the age of the first object in the first sample image.
[0110] Optionally, determining a first loss function based on the first prediction vector, the second prediction vector and the age of the first object in the first sample image includes: determining a first sample vector based on the age of the first object in the first sample image, the first sample vector being used to represent the age of the first object; determining a second sample vector based on the first sample vector, the second sample vector being used to represent the age range of the first object; determining a first loss function based on the first prediction vector, the second prediction vector, the first sample vector and the second sample vector.
[0111] For example, in formula (1) represents the age of the face in the i-th first sample image in the first data set D1. A vector may be determined, and the vector is recorded as a first sample vector. The first sample vector may also be referred to as a true value vector of age. The first sample vector is used to represent the exact age of the face in the first sample image. Each element value in the first sample vector is recorded as a first element value. The first sample vector may be an M-dimensional vector, that is, the M-dimensional vector includes M element values. Each element value in the M element values corresponds to a preset age. The first sample vector may be recorded as W1, and W1 may be expressed as:
[0112] W1=[w11,w12,......,w1 100 ]
[0113] Among them, w11 is the first element value in the first sample vector, w12 is the second element value in the first sample vector, and so on. 100 is the 100th element value in the first sample vector. w11 corresponds to 1 year old, w12 corresponds to 2 years old, and so on. 100 Corresponds to 100 years old.
[0114] For example, the age of the face in a first sample image is 18 years old, and the first sample vector corresponding to the first sample image is a 100-dimensional vector. Since the age of the face in the first sample image is exact, the 100-dimensional vector contains the 18th element value w1. 18 Except for the 18th element value w1, all other element values are 0. 18 A 100-dimensional first sample vector in which all element values except 1 are 0 indicates that the age of the face in the first sample image is 18 years old.
[0115] Further, a second sample vector can be determined based on the first sample vector, and the second sample vector can also be called the true value vector of the age group. The second sample vector is used to represent the age group of the face in the first sample image. Since the age of the face in the first sample image is exact, the exact age group can be determined based on the exact age. The specific determination method can refer to the corresponding relationship in Table 1 above. The second sample vector is recorded as W2, and W2 can be expressed as:
[0116] W2=[w21,w22,...,w26]
[0117] Among them, w21 is the first element value in the second sample vector, w22 is the second element value in the second sample vector, and so on, w26 is the sixth element value in the second sample vector. The corresponding relationship between each element value in the second sample vector and the preset age group is shown in Table 3 below:
[0118] Table 3
[0119] Element Value Default age group <![CDATA[w21]]> 0(newborn)-6 years old <![CDATA[w22]]> 7-12 years old <![CDATA[w23]]> 13-17 years old <![CDATA[w24]]> 18-45 years old <![CDATA[w25]]> 46-69 years old <![CDATA[w26]]> Over 69 years old
[0120] For example, the exact age of the face in the first sample image is 18 years old. According to the corresponding relationship described in Table 1 above, the age group of the face in the first sample image is young people. In this case, W2 = [0,0,0,1,0,0], that is, except for the 4th element value of 1 in the second sample vector, the other element values are all 0, which indicates that the age group of the face in the first sample image is young people.
[0121] In summary, the first prediction vector P1 is the vector predicted by the exact age classification layer, and the first sample vector W1 is the true value vector relative to the first prediction vector P1. The second prediction vector P2 is the vector predicted by the age group classification layer, and the second sample vector W2 is the true value vector relative to the second prediction vector P2.
[0122] Further, a first loss function is determined based on the first prediction vector P1, the second prediction vector P2, the first sample vector W1 and the second sample vector W2. The first loss function can be recorded as L1 i , L1 i It is expressed as:
[0123]
[0124] Where i represents the i-th first sample image in the first data set D1. That is, each first sample image corresponds to a first loss function. L1 i represents the first loss function corresponding to the i-th first sample image. m is the mth element value in the first sample vector W1. p1 mis the mth element value in the first prediction vector P1. 1≤m≤M. w2 n is the nth element value in the second sample vector W2. p2 n is the nth element value in the second prediction vector P2. 1≤n≤N. That is, in the embodiment of the present disclosure, capital letters such as M and lowercase letters such as m represent different meanings.
[0125] S305. According to the first loss function, update the parameters of the main convolutional neural network layer, the parameters of the age group classification layer, and the parameters of the exact age classification layer.
[0126] After calculating the first loss function, the parameters of the main convolutional neural network layer, the parameters of the age group classification layer and the parameters of the exact age classification layer can be updated according to the first loss function.
[0127] Optionally, according to the first loss function, the parameters of the main convolutional neural network layer, the parameters of the age group classification layer and the parameters of the exact age classification layer are updated, including: differentiating the parameters of the main convolutional neural network layer, the parameters of the age group classification layer and the parameters of the exact age classification layer in the first loss function to obtain a first derivative result; according to the first derivative result, updating the parameters of the main convolutional neural network layer, the parameters of the age group classification layer and the parameters of the exact age classification layer.
[0128] For example, through the back propagation algorithm, L1 i The parameters of the main convolutional neural network layer, the parameters of the age group classification layer, and the parameters of the exact age classification layer in are derived to obtain a derivative result, which is recorded as the first derivative result. Further, according to the first derivative result, the parameters of the main convolutional neural network layer, the parameters of the age group classification layer, and the parameters of the exact age classification layer are updated by a stochastic gradient descent algorithm.
[0129] The disclosed embodiment trains the neural network model through the first sample image, and can update the parameters of the main convolutional neural network layer, the parameters of the age group classification layer, and the parameters of the exact age classification layer. During multiple iterative training processes, the accuracy of the neural network model can be made higher and higher, thereby improving the accuracy of the neural network model.
[0130] On the basis of the above embodiment, optionally, according to the second sample image and the preset age group corresponding to the second sample image, the main convolutional neural network layer and the age group classification layer in the neural network model are trained, including: Figure 5 The following steps are shown:
[0131] S501. Input the second sample image into the main convolutional neural network layer in the neural network model to obtain second feature information corresponding to the second sample image.
[0132] When the sample image randomly selected from the first data set D1 and the second data set D2 is the second sample image, the second sample image is input into Figure 4 In the main convolutional neural network layer (Convolutional Neural Networks, CNN) shown in FIG. The main convolutional neural network layer is used to extract features of the second sample image to obtain second feature information corresponding to the second sample image.
[0133] S502: Input the second feature information into the age group classification layer in the neural network model to obtain a third prediction vector.
[0134] Since the second sample image comes from the second data set D2. The face in the second sample image does not have an exact age, but has a preset age group. Therefore, the main convolutional neural network layer can input the second feature information corresponding to the second sample image into the age group classification layer. Further, the exact age classification layer outputs an exact age prediction vector based on the second feature information, and the exact age prediction vector can be recorded as the third prediction vector. The third prediction vector is an N-dimensional vector. Each element value in the third prediction vector corresponds to a preset age group. Each element value in the third prediction vector represents the probability that the age group of the face in the second sample image predicted by the age group classification layer is a preset age group. The third prediction vector can be recorded as P3, and P3 can be expressed as:
[0135] P3=[p31, p32,..., p36]
[0136] Among them, p31 represents the probability that the age range of the face in the second sample image predicted by the age range classification layer is 0 (newborn)-6 years old, p32 represents the probability that the age range of the face in the second sample image predicted by the age range classification layer is 7-12 years old, and so on, p36 represents the probability that the age range of the face in the second sample image predicted by the age range classification layer is greater than 69 years old. Optionally, the sum of all element values in the third prediction vector is 1.
[0137] S503: Determine a second loss function according to the third prediction vector and a preset age group corresponding to the second sample image.
[0138] Optionally, determining a second loss function based on the third prediction vector and a preset age group corresponding to the second sample image includes: determining a third sample vector based on the preset age group corresponding to the second sample image, each third element value in the third sample vector representing the probability that the age group of the second object in the second sample image is the preset age group, and each third element value corresponds to a preset age group; determining a second loss function based on the third prediction vector and the third sample vector.
[0139] For example, in formula (2) represents the preset age group corresponding to the i-th second sample image in the second data set D2. A vector may be determined, and the vector is recorded as a third sample vector, and the third sample vector is used to represent the probability that the age group of the face in the second sample image is a preset age group. Each element value in the third sample vector is recorded as a third element value. Each third element value corresponds to a preset age group. The third sample vector may be an N-dimensional vector. The third sample vector may be recorded as W3, and W3 may be expressed as:
[0140] W3=[w31,w32,...,w36]
[0141] Among them, the preset age range corresponding to w31 is 0 (newborn)-6 years old, the preset age range corresponding to w32 is 7-12 years old, and so on, the preset age range corresponding to w36 is greater than 69 years old. w31 represents the probability that the age range of the face in the second sample image is 0 (newborn)-6 years old, w32 represents the probability that the age range of the face in the second sample image is 7-12 years old, and so on, w36 represents the probability that the age range of the face in the second sample image is greater than 69 years old. Optionally, the sum of all third element values in the third sample vector is 1.
[0142] Optionally, the age range of the second object follows a Gaussian distribution.
[0143] When the second sample images corresponding to "infancy", "juvenile", "adolescent", "youth", "middle-aged" and "elderly" are crawled from the Internet, the age range of the face in the second sample image may not be consistent with the keyword used in the search. For example, a second sample image is searched based on the keyword "infancy", but the age range of the face in the second sample image may not be 0 (newborn)-6 years old, but may be other preset age ranges. In this case, it can be considered that the probability that the age range of the face in the second sample image is 0 (newborn)-6 years old is relatively high, and the probability that the age range of the face in the second sample image is other preset age ranges is relatively low. Moreover, the age range of the face in the second sample image follows a Gaussian distribution.
[0144] Similarly, if a second sample image is searched based on the keyword "teenagers", the probability that the age range of the face in the second sample image is 13-17 years old is higher, and the probability that the age range of the face in the second sample image is other preset age ranges is lower.
[0145] like Figure 6 The probability density function corresponding to the Gaussian distribution is shown. Wherein, x represents the preset age group, and f(x) represents the probability density function. That is, the preset age group corresponding to each third element value in the third sample vector W3 and each third element value meet f(x).
[0146] Specifically, the age groups of faces in the second sample images of the same type (e.g., corresponding to the same preset age group) obey the same Gaussian distribution. The age groups of faces in the second sample images of different types (e.g., corresponding to different preset age groups) obey different Gaussian distributions. For example, for the second sample image corresponding to "teenagers", the preset age group x corresponding to the highest point of the probability density function is 13-17 years old, and the function value of the probability density function gradually decays along both sides of the highest point. Assume that the Gaussian distribution is N(μ,σ 2 ), where μ represents the expected value, σ 2 represents the variance. Specifically, σ = 1. μ corresponds to the highest point.
[0147] Optionally, the third sample vectors corresponding to the second sample images of the same type are the same, that is, the third sample vectors corresponding to different second sample images searched using the same keyword are the same. The third sample vectors corresponding to the second sample images of different types are different, that is, the third sample vectors corresponding to different second sample images searched using different keywords are different.
[0148] In summary, the third prediction vector P3 is a vector predicted by the age group classification layer, and the third sample vector W3 is a true value vector relative to the third prediction vector P3.
[0149] Further, according to the third prediction vector P3 and the third sample vector W3, a second loss function is determined. The second loss function can be recorded as L2 i , L2 i It is expressed as:
[0150]
[0151] Where i represents the i-th second sample image in the second data set D2. That is, each second sample image corresponds to a second loss function. L2 i represents the second loss function corresponding to the i-th second sample image. n is the nth element value in the third sample vector W3.n It is the nth element value in the third prediction vector P3. 1≤n≤N.
[0152] S504. Update the parameters of the main convolutional neural network layer and the parameters of the age group classification layer according to the second loss function.
[0153] After calculating the second loss function, the parameters of the main convolutional neural network layer and the parameters of the age group classification layer can be updated according to the second loss function.
[0154] Optionally, according to the second loss function, the parameters of the main convolutional neural network layer and the parameters of the age group classification layer are updated, including: differentiating the parameters of the main convolutional neural network layer and the parameters of the age group classification layer in the second loss function to obtain a second derivative result; according to the second derivative result, updating the parameters of the main convolutional neural network layer and the parameters of the age group classification layer.
[0155] For example, through the back-propagation algorithm, L2 i The parameters of the main convolutional neural network layer and the parameters of the age group classification layer in are derived to obtain a derivative result, which is recorded as a second derivative result. Further, according to the second derivative result, the parameters of the main convolutional neural network layer and the parameters of the age group classification layer are updated by a stochastic gradient descent algorithm.
[0156] The disclosed embodiment trains the neural network model through the second sample image, and can update the parameters of the main convolutional neural network layer and the parameters of the age group classification layer. During multiple iterative training processes, the accuracy of the neural network model can be made higher and higher, thereby improving the accuracy of the neural network model.
[0157] It can be understood that the sample images randomly selected from the first data set D1 and the second data set D2 can be input into the main convolutional neural network layer, and the main convolutional neural network layer is used to extract the features of the sample images to obtain the feature information of the sample images. When the sample image is the first sample image, the main convolutional neural network layer inputs the feature information of the sample image into the age classification layer and the exact age classification layer respectively. When the sample image is the second sample image, the main convolutional neural network layer inputs the feature information of the sample image only into the age classification layer. That is to say, each first sample image can update the parameters of the main convolutional neural network layer, the parameters of the age classification layer and the parameters of the exact age classification layer once, and each second sample image can update the parameters of the main convolutional neural network layer and the parameters of the age classification layer once. In the process of multiple iterative training, the parameters of the main convolutional neural network layer, the parameters of the age classification layer and the parameters of the exact age classification layer are continuously updated, so that the accuracy of the neural network model is getting higher and higher. Specifically, when the function value of the first loss function and / or the second loss function as described above is lower than the preset threshold, or the number of iterations reaches the preset number, the training can be terminated to obtain a trained neural network model.
[0158] Figure 7 A flow chart of an image-based age estimation method provided in an embodiment of the present disclosure. For example, the image-based age estimation method can be executed by the terminal 11. Similarly, the image-based age estimation method can also be executed by the server 12. Specifically, the terminal 11 can obtain a trained neural network model from the server 12, and further, the terminal 11 estimates the age of the target object in the target image according to the trained neural network model. Specifically, the method has the following specific steps:
[0159] S701: Acquire a target image, where the target image includes a target object.
[0160] For example, the terminal 11 may be provided with a camera, and the terminal 11 may collect a target image through the camera. Optionally, the target image is a face image, and the target object is a face.
[0161] In other embodiments, the target image may be a face image obtained by the terminal 11 from a person image. The generation process or source of the person image is not limited here. Alternatively, the target image may also be a face image obtained by the terminal 11 from other terminals or servers.
[0162] Specifically, the target object in the target image may be a face of a person whose age is to be determined.
[0163] S702. Input the target image into a trained neural network model, wherein the neural network model is trained based on a first sample image with an age label and a second sample image corresponding to each preset age group in a plurality of preset age groups, and the neural network model includes a main convolutional neural network layer, an age group classification layer, and an exact age classification layer, wherein the main convolutional neural network layer is used to perform feature extraction on the target image to obtain target feature information corresponding to the target image, the age group classification layer is used to determine the age group probability information of the target object based on the target feature information, and the exact age classification layer is used to determine the age probability information of the target object based on the target feature information.
[0164] Further, the terminal 11 can input the target image into the trained neural network model. The neural network model is trained based on the first sample image with the age label and the second sample image corresponding to each preset age group in the plurality of preset age groups. The specific training process can refer to the training process described in the above embodiment, which will not be described here.
[0165] Assume that in this embodiment, Figure 4 The neural network model shown is a trained neural network model. Specifically, after the target image is input into the trained neural network model, the target image is first input into the main convolutional neural network layer, and the main convolutional neural network layer can perform feature extraction on the target image to obtain the target feature information corresponding to the target image. Further, the main convolutional neural network layer inputs the target feature information into the age group classification layer and the exact age classification layer respectively. Specifically, the age group classification layer can output an age group prediction vector based on the target feature information. In the stage of using the neural network model for age estimation, the age group prediction vector can be recorded as the age group probability information of the target object, and the age group probability information is used to indicate the probability that the age group of the target object predicted by the age group classification layer is each preset age group. The exact age classification layer can output an exact age prediction vector based on the target feature information. In the stage of using the neural network model for age estimation, the exact age prediction vector can be recorded as the age probability information of the target object, and the age probability information is used to indicate the probability that the age of the target object predicted by the exact age classification layer is each preset age.
[0166] S703: Determine the age of the target object according to the age group probability information of the target object and the age probability information of the target object.
[0167] Further, based on the target object's age group probability information, i.e., the probability that the target object's age group is predicted by the age group classification layer as each preset age group, and the target object's age probability information, i.e., the probability that the target object's age is predicted by the exact age classification layer as each preset age, the target object's age is determined, and the target object's age may be the target object's specific age value.
[0168] The disclosed embodiment estimates the age of the target object in the target image through a trained neural network model, and the neural network model is obtained by training based on a first sample image with an age label and a second sample image corresponding to each preset age group in a plurality of preset age groups. That is to say, when training the neural network model, not only sample images of exact ages are required, but also sample images of preset age groups are required, and the collection cost of sample images of preset age groups is much lower than the collection cost of sample images of exact ages, and sample images of preset age groups are easier to obtain, thus reducing the training cost of the neural network model. In addition, in the process of using a small number of sample images of exact ages to train the neural network model, by adding a large number of sample images of preset age groups for auxiliary training, the number of sample images used to train the neural network model can be increased, thereby improving the accuracy of the trained neural network model. In addition, the neural network model includes a main convolutional neural network layer, an age group classification layer and an exact age classification layer, wherein the main convolutional neural network layer is used to extract features from the target image to obtain target feature information corresponding to the target image, the age group classification layer is used to predict the age group of the target object, and the exact age classification layer is used to predict the age of the target object. Therefore, based on the age group probability information of the target object and the age probability information of the target object, the age of the target object is determined with high accuracy, which improves the accuracy of the neural network model in predicting age.
[0169] Based on the above embodiment, optionally, the age group probability information of the target object includes a first target vector, each first element value in the first target vector represents the probability that the age group of the target object is a preset age group, and each first element value corresponds to a preset age group.
[0170] For example, the first target vector is recorded as K1, which can be expressed as:
[0171] K1=[k11,k12,...,k16]
[0172] Among them, k11 represents the probability that the age range of the target object predicted by the age range classification layer is 0 (newborn)-6 years old, k12 represents the probability that the age range of the target object predicted by the age range classification layer is 7-12 years old, and so on, k16 represents the probability that the age range of the target object predicted by the age range classification layer is greater than 69 years old. Among them, the corresponding relationship between each first element value in the first target vector and a preset age range can be parameterized as the corresponding relationship in Table 2 or Table 3 above, which will not be repeated here.
[0173] Optionally, the age probability information of the target object includes a second target vector, each second element value in the second target vector represents the probability that the age of the target object is a preset age, and each second element value corresponds to a preset age.
[0174] For example, the second target vector is recorded as K2, which can be expressed as:
[0175] K2=[k21,k22,......,k2 100 ]
[0176] Among them, k21 represents the probability that the age of the target object predicted by the exact age classification layer is 1, k22 represents the probability that the age of the target object predicted by the exact age classification layer is 2, and so on. 100 Indicates the probability that the age of the target object predicted by the exact age classification layer is 100. It is understandable that, in other embodiments, the maximum age that can be predicted by the exact age classification layer is not limited to 100, but can also be an age greater than 100. In addition, the exact age classification layer can also predict the probability that the age of the target object is 0. Some vectors described in this embodiment are only schematic illustrations and are not specifically limited. Among them, the corresponding relationship between each second element value in the second target vector and a preset age can be a parameter such as the corresponding relationship in Table 1 above, which will not be repeated here.
[0177] Optionally, determining the age of the target object according to the age group probability information of the target object and the age probability information of the target object includes: Figure 8 The following steps are shown:
[0178] S801. Determine a target age group of the target object according to the first target vector, where the target age group is a preset age group corresponding to the largest first element value in the first target vector.
[0179] For example, according to the first target vector K1, the target age group of the target object is determined, and the target age group may be the preset age group corresponding to the largest first element value in the first target vector K1. For example, if k12 in the first target vector K1 is the largest, then the preset age group corresponding to k12, 7-12 years old, is the target age group of the target object.
[0180] S802: According to the target age group, obtain a sub-vector corresponding to the target age group from the second target vector.
[0181] For example, the second target vector K2 includes 100 second element values. When the target age range is 7-12 years old, a subvector corresponding to 7-12 years old can be obtained from the second target vector K2. The subvector can specifically be [k27, k28, k29, k2 10 , k2 11 , k2 12 ].
[0182] S803: Determine the age of the target object according to the sub-vector.
[0183] Further, according to the sub-vector [k27, k28, k29, k2 10 , k2 11 , k2 12 ] to determine the age of the target audience.
[0184] Optionally, determining the age of the target object according to the sub-vector includes: Fig. 9 The following steps are shown:
[0185] S901. Normalize the second element value in the sub-vector.
[0186] Since the second target vector K2=[k21, k22, ..., k2 100 ] and the sum of all second element values is equal to 1, so the subvector [k27, k28, k29, k2 10 , k2 11 , k2 12 ] the sum of the values of each second element in is less than 1.
[0187] In this embodiment, the sub-vector [k27, k28, k29, k2 10 , k2 11 , k2 12 ] are normalized so that the sum of each second element value in the normalized sub-vector is equal to 1.
[0188] For example, the normalized subvector is [k2'7, k2'8, k2'9, k2' 10 , k2' 11 , k2' 12 ].
[0189] S902: Perform a weighted average on each preset age in the target age range according to the second element value in the normalized sub-vector to obtain the age of the target object.
[0190] Since the subvector [k27, k28, k29, k2 10 , k2 11 , k2 12 ] corresponds to 7, 8, 9, 10, 11, and 12 years old, respectively. Therefore, the normalized sub-vector [k2'7, k2'8, k2'9, k2' 10 , k2' 11 , k2' 12 ], and take the weighted average of 7, 8, 9, 10, 11, and 12 years old to get the age of the target object. The weighted coefficient for 7 years old is k2'7, the weighted coefficient for 8 years old is k2'8, and so on. The weighted coefficient for 12 years old is k2' 12 Specifically, a weighted average is taken for 7, 8, 9, 10, 11 and 12 years old, and after obtaining the weighted average, the weighted average is rounded up, and the result after rounding up is used as the age of the target object, that is, the final prediction result.
[0191] It can be understood that when the execution subject of the training method of the neural network model and the execution subject of the age estimation method are the same execution subject, before acquiring the target image in S701, the execution subject can also train the neural network model. The specific training process can refer to the training method of the neural network model described in the above embodiment, which will not be repeated here.
[0192] This embodiment obtains a sub-vector corresponding to the target age group from the second target vector through the target age group of the target object, further normalizes the second element value in the sub-vector, and performs a weighted average on each preset age in the target age group through the second element value in the normalized sub-vector to obtain the age of the target object, thereby further improving the accuracy of the age of the target object.
[0193] Fig.10 The schematic diagram of the structure of the image-based age estimation device provided in the embodiment of the present disclosure is as follows. The image-based age estimation device provided in the embodiment of the present disclosure can execute the processing flow provided in the image-based age estimation method embodiment, such as Fig.10 As shown, the image-based age estimation device 100 includes:
[0194] An acquisition module 101 is used to acquire a target image, wherein the target image includes a target object;
[0195] An input module 102 is used to input the target image into a trained neural network model, wherein the neural network model is trained based on a first sample image with an age label and a second sample image corresponding to each preset age group in a plurality of preset age groups, and the neural network model includes a main convolutional neural network layer, an age group classification layer, and an exact age classification layer, wherein the main convolutional neural network layer is used to perform feature extraction on the target image to obtain target feature information corresponding to the target image, the age group classification layer is used to determine the age group probability information of the target object based on the target feature information, and the exact age classification layer is used to determine the age probability information of the target object based on the target feature information;
[0196] The determination module 103 is used to determine the age of the target object according to the age group probability information of the target object and the age probability information of the target object.
[0197] Optionally, the age group probability information of the target object includes a first target vector, each first element value in the first target vector represents the probability that the age group of the target object is a preset age group, and each first element value corresponds to a preset age group;
[0198] The age probability information of the target object includes a second target vector, each second element value in the second target vector represents the probability that the age of the target object is a preset age, and each second element value corresponds to a preset age.
[0199] Optionally, when determining the age of the target object based on the age group probability information of the target object and the age probability information of the target object, the determination module 103 is specifically used to: determine the target age group of the target object based on the first target vector, the target age group being a preset age group corresponding to the largest first element value in the first target vector; based on the target age group, obtain a sub-vector corresponding to the target age group from the second target vector; and determine the age of the target object based on the sub-vector.
[0200] Optionally, when the determination module 103 determines the age of the target object based on the sub-vector, it is specifically used to: normalize the second element value in the sub-vector; and perform weighted averaging on each preset age in the target age group based on the second element value in the sub-vector after normalization to obtain the age of the target object.
[0201] Optionally, the target image is a face image, and the target object is a face.
[0202] Optionally, the image-based age estimation device 100 further includes: a first training module 104 and a second training module 105;
[0203] The acquisition module 101 is further used to: acquire a first sample image and the age of a first object in the first sample image; and acquire a second sample image corresponding to each preset age group according to a plurality of preset age groups;
[0204] A first training module 104 is used to perform model training on a main convolutional neural network layer, an age group classification layer, and an exact age classification layer in the neural network model according to the first sample image and the age of the first object in the first sample image;
[0205] The second training module 105 is used to perform model training on the main convolutional neural network layer and the age group classification layer in the neural network model according to the second sample image and the preset age group corresponding to the second sample image.
[0206] Optionally, when the first training module 104 performs model training on the main convolutional neural network layer, the age group classification layer and the exact age classification layer in the neural network model according to the first sample image and the age of the first object in the first sample image, it is specifically used to:
[0207] Inputting the first sample image into the main convolutional neural network layer in the neural network model to obtain first feature information corresponding to the first sample image;
[0208] Inputting the first feature information into the exact age classification layer in the neural network model to obtain a first prediction vector;
[0209] Inputting the first feature information into the age group classification layer in the neural network model to obtain a second prediction vector;
[0210] determining a first loss function according to the first prediction vector, the second prediction vector, and the age of the first object in the first sample image;
[0211] According to the first loss function, the parameters of the main convolutional neural network layer, the parameters of the age group classification layer and the parameters of the exact age classification layer are updated.
[0212] Optionally, when the first training module 104 determines the first loss function according to the first prediction vector, the second prediction vector and the age of the first object in the first sample image, it is specifically configured to:
[0213] determining a first sample vector according to the age of the first object in the first sample image, where the first sample vector is used to represent the age of the first object;
[0214] Determine a second sample vector according to the first sample vector, where the second sample vector is used to represent the age group of the first object;
[0215] A first loss function is determined according to the first prediction vector, the second prediction vector, the first sample vector, and the second sample vector.
[0216] Optionally, when the first training module 104 updates the parameters of the main convolutional neural network layer, the parameters of the age group classification layer, and the parameters of the exact age classification layer according to the first loss function, it is specifically used to:
[0217] Derivative the parameters of the main convolutional neural network layer, the parameters of the age group classification layer, and the parameters of the exact age classification layer in the first loss function to obtain a first derivative result;
[0218] According to the first derivative result, the parameters of the main convolutional neural network layer, the parameters of the age group classification layer and the parameters of the exact age classification layer are updated.
[0219] Optionally, when the second training module 105 performs model training on the main convolutional neural network layer and the age group classification layer in the neural network model according to the second sample image and the preset age group corresponding to the second sample image, it is specifically used to:
[0220] Inputting the second sample image into the main convolutional neural network layer in the neural network model to obtain second feature information corresponding to the second sample image;
[0221] Inputting the second feature information into the age group classification layer in the neural network model to obtain a third prediction vector;
[0222] determining a second loss function according to the third prediction vector and a preset age group corresponding to the second sample image;
[0223] According to the second loss function, the parameters of the main convolutional neural network layer and the parameters of the age group classification layer are updated.
[0224] Optionally, when the second training module 105 determines the second loss function according to the third prediction vector and the preset age group corresponding to the second sample image, it is specifically used to:
[0225] Determine a third sample vector according to the preset age group corresponding to the second sample image, wherein each third element value in the third sample vector represents a probability that the age group of the second object in the second sample image is the preset age group, and each third element value corresponds to a preset age group;
[0226] A second loss function is determined according to the third prediction vector and the third sample vector.
[0227] Optionally, the age range of the second object follows a Gaussian distribution.
[0228] Optionally, when the second training module 105 updates the parameters of the main convolutional neural network layer and the parameters of the age group classification layer according to the second loss function, it is specifically used to:
[0229] Derivative the parameters of the main convolutional neural network layer and the parameters of the age group classification layer in the second loss function to obtain a second derivative result;
[0230] According to the second derivative result, the parameters of the main convolutional neural network layer and the parameters of the age group classification layer are updated.
[0231] Optionally, the first sample image is a face image, and the first object is a face;
[0232] The second sample image is a face image, and the second object in the second sample image is a face.
[0233] Fig.10 The image-based age estimation device of the illustrated embodiment can be used to implement the technical solution of the above-mentioned method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0234] Fig.11 The schematic diagram of the structure of the neural network model training device provided in the embodiment of the present disclosure. The neural network model training device provided in the embodiment of the present disclosure can execute the processing flow provided in the embodiment of the neural network model training method, such as Fig.11 As shown, the neural network model training device 110 includes:
[0235] A first acquisition module 111 is used to acquire a first sample image and the age of a first object in the first sample image;
[0236] A second acquisition module 112 is used to acquire, according to a plurality of preset age groups, a second sample image corresponding to each preset age group;
[0237] A first training module 113 is used to perform model training on a main convolutional neural network layer, an age group classification layer, and an exact age classification layer in the neural network model according to the first sample image and the age of the first object in the first sample image;
[0238] The second training module 114 is used to perform model training on the main convolutional neural network layer and the age group classification layer in the neural network model according to the second sample image and the preset age group corresponding to the second sample image.
[0239] Optionally, when the first training module 113 performs model training on the main convolutional neural network layer, the age group classification layer and the exact age classification layer in the neural network model according to the first sample image and the age of the first object in the first sample image, it is specifically used to:
[0240] Inputting the first sample image into the main convolutional neural network layer in the neural network model to obtain first feature information corresponding to the first sample image;
[0241] Inputting the first feature information into the exact age classification layer in the neural network model to obtain a first prediction vector;
[0242] Inputting the first feature information into the age group classification layer in the neural network model to obtain a second prediction vector;
[0243] determining a first loss function according to the first prediction vector, the second prediction vector, and the age of the first object in the first sample image;
[0244] According to the first loss function, the parameters of the main convolutional neural network layer, the parameters of the age group classification layer and the parameters of the exact age classification layer are updated.
[0245] Optionally, when the first training module 113 determines the first loss function according to the first prediction vector, the second prediction vector and the age of the first object in the first sample image, it is specifically used to:
[0246] determining a first sample vector according to the age of the first object in the first sample image, where the first sample vector is used to represent the age of the first object;
[0247] Determine a second sample vector according to the first sample vector, where the second sample vector is used to represent the age group of the first object;
[0248] A first loss function is determined according to the first prediction vector, the second prediction vector, the first sample vector, and the second sample vector.
[0249] Optionally, when the first training module 113 updates the parameters of the main convolutional neural network layer, the parameters of the age group classification layer, and the parameters of the exact age classification layer according to the first loss function, it is specifically used to:
[0250] Derivative the parameters of the main convolutional neural network layer, the parameters of the age group classification layer, and the parameters of the exact age classification layer in the first loss function to obtain a first derivative result;
[0251] According to the first derivative result, the parameters of the main convolutional neural network layer, the parameters of the age group classification layer and the parameters of the exact age classification layer are updated.
[0252] Optionally, when the second training module 114 performs model training on the main convolutional neural network layer and the age group classification layer in the neural network model according to the second sample image and the preset age group corresponding to the second sample image, it is specifically used to:
[0253] Inputting the second sample image into the main convolutional neural network layer in the neural network model to obtain second feature information corresponding to the second sample image;
[0254] Inputting the second feature information into the age group classification layer in the neural network model to obtain a third prediction vector;
[0255] determining a second loss function according to the third prediction vector and a preset age group corresponding to the second sample image;
[0256] According to the second loss function, the parameters of the main convolutional neural network layer and the parameters of the age group classification layer are updated.
[0257] Optionally, when the second training module 114 determines the second loss function according to the third prediction vector and the preset age group corresponding to the second sample image, it is specifically used to:
[0258] Determine a third sample vector according to the preset age group corresponding to the second sample image, wherein each third element value in the third sample vector represents a probability that the age group of the second object in the second sample image is the preset age group, and each third element value corresponds to a preset age group;
[0259] A second loss function is determined according to the third prediction vector and the third sample vector.
[0260] Optionally, the age range of the second object follows a Gaussian distribution.
[0261] Optionally, when the second training module 114 updates the parameters of the main convolutional neural network layer and the parameters of the age group classification layer according to the second loss function, it is specifically used to:
[0262] Derivative the parameters of the main convolutional neural network layer and the parameters of the age group classification layer in the second loss function to obtain a second derivative result;
[0263] According to the second derivative result, the parameters of the main convolutional neural network layer and the parameters of the age group classification layer are updated.
[0264] Optionally, the first sample image is a face image, and the first object is a face;
[0265] The second sample image is a face image, and the second object in the second sample image is a face.
[0266] Fig.11 The neural network model training device of the illustrated embodiment can be used to execute the technical solution of the above-mentioned method embodiment. Its implementation principle and technical effects are similar and will not be repeated here.
[0267] Fig.12 The schematic diagram of the structure of the image-based age estimation device provided in the embodiment of the present disclosure. The image-based age estimation device provided in the embodiment of the present disclosure can execute the processing flow provided in the image-based age estimation method embodiment, such as Fig.12 As shown, the image-based age estimation device 120 includes: a memory 121, a processor 122, a computer program and a communication interface 123; wherein the computer program is stored in the memory 121 and is configured so that the processor 122 executes the image-based age estimation method as described above.
[0268] Fig.13 The schematic diagram of the structure of the neural network model training device provided in the embodiment of the present disclosure. The neural network model training device provided in the embodiment of the present disclosure can execute the processing flow provided in the embodiment of the neural network model training method, such as Fig.13 As shown, the neural network model training device 130 includes: a memory 131, a processor 132, a computer program and a communication interface 133; wherein the computer program is stored in the memory 131 and is configured so that the processor 132 executes the neural network model training method as described above.
[0269] In addition, an embodiment of the present disclosure also provides a computer-readable storage medium on which a computer program is stored, and the computer program is executed by a processor to implement the image-based age estimation method or the neural network model training method described in the above embodiments.
[0270] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0271] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An image-based age estimation method, characterized in that: The method comprises: Acquire a target image, wherein the target image includes a target object; Input the target image into a trained neural network model, wherein the neural network model is trained based on a first sample image with an age label and a second sample image corresponding to each preset age group in a plurality of preset age groups, wherein the neural network model comprises a main convolutional neural network layer, an age group classification layer and an exact age classification layer, wherein the main convolutional neural network layer is used to perform feature extraction on the target image to obtain target feature information corresponding to the target image, the age group classification layer is used to determine the age group probability information of the target object based on the target feature information, and the exact age classification layer is used to determine the age probability information of the target object based on the target feature information; Determining the age of the target object according to the age group probability information of the target object and the age probability information of the target object; The target object's age group probability information includes a first target vector, each first element value in the first target vector represents the probability that the target object's age group is a preset age group, and each first element value corresponds to a preset age group; The age probability information of the target object includes a second target vector, each second element value in the second target vector represents the probability that the age of the target object is a preset age, and each second element value corresponds to a preset age; Determining the age of the target object according to the age group probability information of the target object and the age probability information of the target object includes: Determining a target age group of the target object according to the first target vector, the target age group being a preset age group corresponding to the largest first element value in the first target vector; According to the target age group, acquiring a subvector corresponding to the target age group from the second target vector; Determining the age of the target object according to the sub-vector; Before acquiring the target image, the method further includes: Acquire a first sample image and the age of a first object in the first sample image; According to a plurality of preset age groups, obtaining a second sample image corresponding to each preset age group; According to the first sample image and the age of the first object in the first sample image, performing model training on the main convolutional neural network layer, the age group classification layer and the exact age classification layer in the neural network model; According to the second sample image and the preset age group corresponding to the second sample image, model training is performed on the main convolutional neural network layer and the age group classification layer in the neural network model.
2. The method according to claim 1, characterized in that Determining the age of the target object according to the sub-vector includes: Normalizing the second element value in the sub-vector; According to the second element value in the normalized sub-vector, a weighted average is performed on each preset age in the target age range to obtain the age of the target object.
3. The method according to claim 1, characterized in that The target image is a face image, and the target object is a face.
4. The method according to claim 1, characterized in that: According to the first sample image and the age of the first object in the first sample image, model training is performed on the main convolutional neural network layer, the age group classification layer and the exact age classification layer in the neural network model, including: Inputting the first sample image into the main convolutional neural network layer in the neural network model to obtain first feature information corresponding to the first sample image; Inputting the first feature information into the exact age classification layer in the neural network model to obtain a first prediction vector; Inputting the first feature information into the age group classification layer in the neural network model to obtain a second prediction vector; determining a first loss function according to the first prediction vector, the second prediction vector, and the age of the first object in the first sample image; According to the first loss function, the parameters of the main convolutional neural network layer, the parameters of the age group classification layer and the parameters of the exact age classification layer are updated.
5. The method according to claim 4, characterized in that Determining a first loss function according to the first prediction vector, the second prediction vector, and the age of the first object in the first sample image includes: determining a first sample vector according to the age of the first object in the first sample image, where the first sample vector is used to represent the age of the first object; Determine a second sample vector according to the first sample vector, where the second sample vector is used to represent the age group of the first object; A first loss function is determined according to the first prediction vector, the second prediction vector, the first sample vector, and the second sample vector.
6. The method according to claim 4, characterized in that According to the first loss function, updating the parameters of the main convolutional neural network layer, the parameters of the age group classification layer and the parameters of the exact age classification layer includes: Derivative the parameters of the main convolutional neural network layer, the parameters of the age group classification layer, and the parameters of the exact age classification layer in the first loss function to obtain a first derivative result; According to the first derivative result, the parameters of the main convolutional neural network layer, the parameters of the age group classification layer and the parameters of the exact age classification layer are updated.
7. The method according to claim 1, characterized in that According to the second sample image and the preset age group corresponding to the second sample image, model training is performed on the main convolutional neural network layer and the age group classification layer in the neural network model, including: Inputting the second sample image into the main convolutional neural network layer in the neural network model to obtain second feature information corresponding to the second sample image; Inputting the second feature information into the age group classification layer in the neural network model to obtain a third prediction vector; determining a second loss function according to the third prediction vector and a preset age group corresponding to the second sample image; According to the second loss function, the parameters of the main convolutional neural network layer and the parameters of the age group classification layer are updated.
8. The method according to claim 7, characterized in that Determining a second loss function according to the third prediction vector and a preset age group corresponding to the second sample image includes: Determine a third sample vector according to the preset age group corresponding to the second sample image, wherein each third element value in the third sample vector represents a probability that the age group of the second object in the second sample image is the preset age group, and each third element value corresponds to a preset age group; A second loss function is determined according to the third prediction vector and the third sample vector.
9. The method according to claim 7, characterized in that: According to the second loss function, updating the parameters of the main convolutional neural network layer and the parameters of the age group classification layer includes: Derivative the parameters of the main convolutional neural network layer and the parameters of the age group classification layer in the second loss function to obtain a second derivative result; According to the second derivative result, the parameters of the main convolutional neural network layer and the parameters of the age group classification layer are updated.
10. The method according to claim 1, characterized in that The first sample image is a face image, and the first object is a face; The second sample image is a face image, and the second object in the second sample image is a face.
11. A neural network model training method, characterized in that: The neural network model includes: a main convolutional neural network layer, an age group classification layer and an exact age classification layer; the method includes: Acquire a first sample image and the age of a first object in the first sample image; According to a plurality of preset age groups, obtaining a second sample image corresponding to each preset age group; According to the first sample image and the age of the first object in the first sample image, performing model training on the main convolutional neural network layer, the age group classification layer and the exact age classification layer in the neural network model; According to the second sample image and the preset age group corresponding to the second sample image, performing model training on the main convolutional neural network layer and the age group classification layer in the neural network model; The main convolutional neural network layer is used to extract features from the target image to obtain target feature information corresponding to the target image, the age group classification layer is used to determine the age group probability information of the target object according to the target feature information, and the exact age classification layer is used to determine the age probability information of the target object according to the target feature information; The target object's age group probability information includes a first target vector, each first element value in the first target vector represents the probability that the target object's age group is a preset age group, and each first element value corresponds to a preset age group; The age probability information of the target object includes a second target vector, each second element value in the second target vector represents the probability that the age of the target object is a preset age, and each second element value corresponds to a preset age; The first target vector is used to determine the target age group of the target object, and the target age group is a preset age group corresponding to the largest first element value in the first target vector; The target age group is used to obtain a sub-vector corresponding to the target age group from the second target vector; the sub-vector is used to determine the age of the target object.
12. An image-based age estimation device, characterized in that: include: An acquisition module, used for acquiring a target image, wherein the target image includes a target object; An input module, used for inputting the target image into a trained neural network model, wherein the neural network model is trained based on a first sample image with an age label and a second sample image corresponding to each preset age group in a plurality of preset age groups, wherein the neural network model comprises a main convolutional neural network layer, an age group classification layer and an exact age classification layer, wherein the main convolutional neural network layer is used for performing feature extraction on the target image to obtain target feature information corresponding to the target image, the age group classification layer is used for determining age group probability information of the target object based on the target feature information, and the exact age classification layer is used for determining age probability information of the target object based on the target feature information; A determination module, configured to determine the age of the target object according to the age group probability information of the target object and the age probability information of the target object; The target object's age group probability information includes a first target vector, each first element value in the first target vector represents the probability that the target object's age group is a preset age group, and each first element value corresponds to a preset age group; The age probability information of the target object includes a second target vector, each second element value in the second target vector represents the probability that the age of the target object is a preset age, and each second element value corresponds to a preset age; The determining module is used to: Determining a target age group of the target object according to the first target vector, the target age group being a preset age group corresponding to the largest first element value in the first target vector; According to the target age group, acquiring a subvector corresponding to the target age group from the second target vector; Determining the age of the target object according to the sub-vector; The acquisition module is further used to: acquire a first sample image and the age of a first object in the first sample image; and acquire a second sample image corresponding to each preset age group according to a plurality of preset age groups; A first training module, configured to perform model training on a main convolutional neural network layer, an age group classification layer, and an exact age classification layer in the neural network model according to the first sample image and the age of the first object in the first sample image; The second training module is used to perform model training on the main convolutional neural network layer and the age group classification layer in the neural network model according to the second sample image and the preset age group corresponding to the second sample image.
13. A neural network model training device, characterized in that: The neural network model includes: a main convolutional neural network layer, an age group classification layer and an exact age classification layer; the neural network model training device includes: A first acquisition module, configured to acquire a first sample image and the age of a first object in the first sample image; A second acquisition module, configured to acquire, according to a plurality of preset age groups, a second sample image corresponding to each preset age group; A first training module, configured to perform model training on a main convolutional neural network layer, an age group classification layer, and an exact age classification layer in the neural network model according to the first sample image and the age of the first object in the first sample image; A second training module, configured to perform model training on a main convolutional neural network layer and an age group classification layer in the neural network model according to the second sample image and a preset age group corresponding to the second sample image; The main convolutional neural network layer is used to extract features from the target image to obtain target feature information corresponding to the target image, the age group classification layer is used to determine the age group probability information of the target object according to the target feature information, and the exact age classification layer is used to determine the age probability information of the target object according to the target feature information; The target object's age group probability information includes a first target vector, each first element value in the first target vector represents the probability that the target object's age group is a preset age group, and each first element value corresponds to a preset age group; The age probability information of the target object includes a second target vector, each second element value in the second target vector represents the probability that the age of the target object is a preset age, and each second element value corresponds to a preset age; The first target vector is used to determine the target age group of the target object, and the target age group is a preset age group corresponding to the largest first element value in the first target vector; The target age group is used to obtain a sub-vector corresponding to the target age group from the second target vector; the sub-vector is used to determine the age of the target object.
14. An image-based age estimation device, characterized in that: include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and is configured to be executed by the processor to implement the method according to any one of claims 1 to 10.
15. A neural network model training device, characterized in that: include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and is configured to be executed by the processor to implement the method as claimed in claim 11.
16. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 11 is implemented.
