[go: up one dir, main page]

CN112818946A - Training of age identification model, age identification method and device and electronic equipment - Google Patents

Training of age identification model, age identification method and device and electronic equipment Download PDF

Info

Publication number
CN112818946A
CN112818946A CN202110250897.3A CN202110250897A CN112818946A CN 112818946 A CN112818946 A CN 112818946A CN 202110250897 A CN202110250897 A CN 202110250897A CN 112818946 A CN112818946 A CN 112818946A
Authority
CN
China
Prior art keywords
age
value
probability
identification model
dimension
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110250897.3A
Other languages
Chinese (zh)
Inventor
李冰
肖潇
高子翔
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Keda Technology Co Ltd
Original Assignee
Suzhou Keda Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Keda Technology Co Ltd filed Critical Suzhou Keda Technology Co Ltd
Priority to CN202110250897.3A priority Critical patent/CN112818946A/en
Publication of CN112818946A publication Critical patent/CN112818946A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V40/00Recognition of biometric, human-related or animal-related patterns in image or video data
    • G06V40/10Human or animal bodies, e.g. vehicle occupants or pedestrians; Body parts, e.g. hands
    • G06V40/16Human faces, e.g. facial parts, sketches or expressions
    • G06V40/161Detection; Localisation; Normalisation
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/047Probabilistic or stochastic networks
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V40/00Recognition of biometric, human-related or animal-related patterns in image or video data
    • G06V40/10Human or animal bodies, e.g. vehicle occupants or pedestrians; Body parts, e.g. hands
    • G06V40/16Human faces, e.g. facial parts, sketches or expressions
    • G06V40/168Feature extraction; Face representation
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V40/00Recognition of biometric, human-related or animal-related patterns in image or video data
    • G06V40/10Human or animal bodies, e.g. vehicle occupants or pedestrians; Body parts, e.g. hands
    • G06V40/16Human faces, e.g. facial parts, sketches or expressions
    • G06V40/178Human faces, e.g. facial parts, sketches or expressions estimating age from face image; using age information for improving recognition

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • General Physics & Mathematics (AREA)
  • Oral & Maxillofacial Surgery (AREA)
  • Biomedical Technology (AREA)
  • Mathematical Physics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Biophysics (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Artificial Intelligence (AREA)
  • Computational Linguistics (AREA)
  • Software Systems (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Multimedia (AREA)
  • Human Computer Interaction (AREA)
  • Probability & Statistics with Applications (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Image Analysis (AREA)

Abstract

The invention relates to the technical field of video monitoring, in particular to an age identification model training method, an age identification device and electronic equipment, wherein the training method comprises the steps of obtaining sample images and label information of each sample image, wherein the label information comprises a plurality of age label values and the probability of each age dimension; inputting the sample image into an age identification model to obtain a plurality of age predicted values and the probability of each age predicted value; and calculating a loss function according to the probability of each age dimension, the probability of each age predicted value, the plurality of age marking values and the plurality of age predicted values so as to train the age identification model and determine the target age identification model. The labeled difference is represented by the probability of the age dimension, and the difference is subsequently combined to train the age identification model, so that the age value can be accurately identified by the trained target age identification model, and the accuracy of age identification is improved.

Description

Training of age identification model, age identification method and device and electronic equipment
Technical Field
The invention relates to the technical field of video monitoring, in particular to a training and age identification method and device of an age identification model and electronic equipment.
Background
With the development of deep learning, more and more recognition algorithms for the attributes shown in the images are generated, and part of the algorithms are researches on the attributes of ages shown in the face images. At present, there is a technology that considers the identification of age as a regression problem, that is, inputting the age label of a real person into a deep neural network, and regressing the real value by using the training of the euclidean distance loss function through an iterative training mode. Yet another general approach is to treat the regression problem as a classification problem, i.e. to classify the ages into different age groups, e.g. 0 to 5 years of real age into one age group, then an image comprising an age set of 0 to 85 may be classified into an age group of the shape [ (0, 5), (5, 10) (10, 15), (15, 20), (20, 30), …, (70, 75) (75, 80) (80, 85) ]. Using such classified age groups as tags, training using the softmax loss function through a deep neural network can learn to which age group the age shown in the image belongs.
In the prior art introduced above, in the actual monitoring security field, the effect of direct application is not good, for the following reasons: the method based on the Euclidean distance uses the global information of the image, and in an actual security scene, the background is too complex, so that too much background information participates in calculation, a certain difference exists between a regression value and a real age label, and the regression value is relatively inaccurate. The age group information obtained by the classification-based method is not suitable for actual service requirements, namely, the actual service requires relatively accurate actual age information rather than age group information.
Disclosure of Invention
In view of this, embodiments of the present invention provide an age identification method, an age identification device, and an electronic device, so as to solve the problem of low accuracy of age identification.
According to a first aspect, an embodiment of the present invention provides a training method for an age identification model, where the training method includes:
acquiring sample images and labeling information of each sample image, wherein the labeling information comprises a real age value and the probability of each age dimension;
inputting the sample image into an age identification model to obtain a plurality of age predicted values and the probability of each age predicted value;
and calculating a loss function according to the probability of each age dimension, the probability of each age predicted value, the real age value and the age predicted values so as to train the age identification model and determine a target age identification model.
According to the training method of the age identification model provided by the embodiment of the invention, the labeling information comprises the real age value and the probability of each age dimension, the labeled difference is represented by the probability of the age dimension, and the training of the age identification model is carried out by combining the difference subsequently, so that the target age identification model obtained by training can accurately identify the age value, and the accuracy of age identification is improved.
With reference to the first aspect, in a first implementation manner of the first aspect, the obtaining the annotation information of each sample image includes:
acquiring a plurality of age marking values of the same sample image;
and calculating distribution information of labeled ages by using the age labeled values to obtain the real age value and the probability of each age dimension.
According to the training method of the age identification model provided by the embodiment of the invention, as the age marking values have subjective consciousness, but a plurality of age marking values accord with a certain distribution condition, the probability of each age dimension is obtained by calculating the distribution information of the marked ages, so that the obtained probability of each age dimension can be ensured to accord with the actual condition better.
With reference to the first implementation manner of the first aspect, in a second implementation manner of the first aspect, the calculating, by using the plurality of age labels, distribution information of each of the age labels to obtain a probability of each of the age dimensions and the real age value includes:
calculating the mean value and the variance of the age labeling values, wherein the real age value is the mean value;
and calculating the Gaussian weight of each age dimension by using the mean value and the variance to obtain the probability of each age dimension.
According to the training method of the age identification model provided by the embodiment of the invention, the Gaussian weight calculation is carried out on each age dimension, namely, each age dimension is fitted into Gaussian distribution, so that the influence of subjective consciousness of manual labeling on a labeling result can be eliminated as far as possible.
With reference to the first aspect, in a third implementation manner of the first aspect, the performing a computation of a loss function according to a probability of each age dimension, a probability of each age prediction value, the real age value, and a plurality of age prediction values to train the age identification model to determine a target age identification model includes:
acquiring a target age predicted value, wherein the target age predicted value is the age predicted value with the maximum probability;
calculating a loss function value based on the probability of each said age predictor, the probability of each age dimension, a plurality of age predictors, and said true age value;
and adjusting parameters of the age identification model by using the loss function value to determine the target age identification model.
According to the training method of the age identification model provided by the embodiment of the invention, the loss function is calculated by combining the probability of the age predicted value or the probability of the age dimension in the training process, so that the calculated loss function value can better meet the actual condition, and the calculation accuracy of the loss function is improved.
With reference to the third implementation manner of the first aspect, in a fourth implementation manner of the first aspect, the calculating a loss function value based on the probability of each of the age prediction values, the probability of each of the age dimensions, a plurality of age prediction values, and the true age value includes:
determining a penalty coefficient by using the difference value between the target age predicted value and the real age value;
calculating a loss function value using the probability of each said age predictor, the probability of each age dimension, said penalty factor, the plurality of age predictors, and said true age value.
According to the training method of the age identification model provided by the embodiment of the invention, the penalty coefficient is reflected by the difference value between the target age predicted value and the real age value, so that the training process can be accelerated and the training efficiency can be improved by adding the penalty coefficient in the calculation process of the loss function.
With reference to the fourth embodiment of the first aspect, in the fifth embodiment of the first aspect, the calculation of the loss function is performed by using the following formula:
Figure BDA0002966022970000031
wherein E iskIs the loss function value after the Kth iteration, alpha is a penalty coefficient,
Figure BDA0002966022970000032
the target age predictor for the kth iteration, y the real age value, l the number of age predictors, WjIs the probability of the jth said age predictor or the probability of the jth said age dimension.
According to a second aspect, an embodiment of the present invention further provides an age identification method, where the identification method includes:
acquiring an image to be identified;
inputting the image to be recognized into a target age recognition model to obtain a plurality of age values and probabilities of the age values, and determining the age value with the maximum probability as the target age value, wherein the target age recognition model is obtained by training according to the first aspect of the present invention or the training method of the age recognition model in any embodiment of the first aspect.
According to the age identification method provided by the embodiment of the invention, the target age identification model with higher identification accuracy is used for identifying the age of the face in the image to be identified, so that the identification accuracy can be ensured, and the identified age value is closer to the true value.
According to a third aspect, an embodiment of the present invention further provides a training apparatus for an age identification model, where the training apparatus includes:
the system comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring sample images and labeling information of each sample image, and the labeling information comprises a real age value and the probability of each age dimension;
the prediction module is used for inputting the sample image into an age identification model to obtain a plurality of age prediction values and the probability of each age prediction value;
and the training module is used for calculating a loss function according to the probability of each age dimension, the probability of each age predicted value, the real age value and the age predicted values so as to train the age identification model and determine a target age identification model.
According to the training device of the age identification model, provided by the embodiment of the invention, the labeling information comprises the real age value and the probability of each age dimension, the labeled difference is represented by the probability of the age dimension, and the training of the age identification model is carried out by subsequently combining the difference, so that the target age identification model obtained by training can accurately identify the age value, and the accuracy of age identification is improved.
According to a fourth aspect, an embodiment of the present invention further provides an age identifying apparatus, including:
the second acquisition module is used for acquiring an image to be identified;
and an identification module, configured to input the image to be identified into a target age identification model to obtain a plurality of age values and probabilities of the age values, and determine an age value with a maximum probability as a target age value, where the target age identification model is obtained by training according to the first aspect of the present invention or the training method of the age identification model according to any embodiment of the first aspect.
The age identification device provided by the embodiment of the invention utilizes the target age identification model with higher identification accuracy to identify the age of the face in the image to be identified, so that the identification accuracy can be ensured, and the identified age value is closer to the true value.
According to a fifth aspect, an embodiment of the present invention provides an electronic device, including: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory having stored therein computer instructions, and the processor executing the computer instructions to perform the method for training an age identification model according to the first aspect or any one of the embodiments of the first aspect, or to perform the method for identifying an age according to the second aspect.
According to a sixth aspect, an embodiment of the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to execute the method for training an age identification model according to the first aspect or any one of the embodiments of the first aspect, or execute the method for identifying an age according to the second aspect.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a flow chart of a method of training an age identification model according to an embodiment of the present invention;
FIG. 2 is a flow chart of a method of training an age identification model according to an embodiment of the present invention;
FIG. 3 is a flow chart of a method of training an age identification model according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of training an age identification model according to an embodiment of the invention;
FIG. 5 is a flow chart of an age identification method according to an embodiment of the present invention;
fig. 6 is a block diagram of a structure of a training apparatus of an age recognition model according to an embodiment of the present invention;
fig. 7 is a block diagram of the structure of an age identifying apparatus according to an embodiment of the present invention;
fig. 8 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that, in the embodiment of the present invention, both the sample image and the image to be recognized are face images, and may be obtained by cropping an acquired image including a face, or may be obtained by directly acquiring a face image, which is not limited herein.
In accordance with an embodiment of the present invention, there is provided an embodiment of a method for training an age identification model, it being noted that the steps illustrated in the flowchart of the drawings may be performed in a computer system such as a set of computer-executable instructions and that, although a logical order is illustrated in the flowchart, in some cases the steps illustrated or described may be performed in an order different than presented herein.
In this embodiment, a training method of an age identification model is provided, which can be used in electronic devices, such as a computer, a mobile phone, a tablet computer, and the like, fig. 1 is a flowchart of a training method of an age identification model according to an embodiment of the present invention, and as shown in fig. 1, the flowchart includes the following steps:
s11, the sample image and the label information of each sample image are acquired.
The labeling information comprises real age values and probabilities of all age dimensions.
The sample image can be various face images, and further, in order to improve the robustness in the monitoring scene, monitoring backgrounds of different styles can be regenerated on the basis of the acquired face images. For example, a countermeasure generation network, generation of various styles of face images, and the like may be employed. The method is not limited in any way, and the method can be set according to actual conditions. Optionally, the acquired images may be processed uniformly, and the resolution of the acquired images is set to a preset resolution, for example, 224 × 224, so as to enhance the generalization capability of the training model.
For the collected face image, the age can be estimated in a manual labeling mode because the real age of the person is unknown. However, different people have different subjective recognitions, and in order to eliminate the influence of the subjective recognitions as much as possible, the average value of the age label values of the same sample image by multiple people is used as the real age value, or the percentage of each age label value in all the age label values is calculated, and the age label value with the largest percentage is determined as the real age value. The actual age value is not limited in any way herein.
Besides the real age value, the labeling information of the sample image also has the probability of each age dimension. The age dimension may be a plurality of age dimensions around the true age value, for example, if the true age value is 20, then the age dimensions may be 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, and 25; it is also possible to set the age dimension of all sample images to 0-99, i.e., 100 dimensions, regardless of the true age value. Specifically, there are corresponding probabilities for each age dimension, so that the annotation information of the sample image can be formed. For example, age dimension 0, corresponding to probability a 1; age dimension 1, corresponding to probability a 2; … …, respectively; age dimension 99, corresponding to probability a 99. Accordingly, the above-described type of label information is provided for each sample image.
Wherein, the probability calculation of each age dimension can be obtained by carrying out statistical analysis on the age label value; or the probability of each age dimension can be manually set on the basis of the real age value.
Alternatively, an image of a person with a true age of about eighteen years is shot, different people have different subjective guesses about the image, but all the people are based on the age of eighteen years, or above or below the image, and it is also clear that although different people have different subjective consciousness about the same image, the face image of a person with an age of eighteen years is recognized by different people, and the probability of the person with an age of sixty years is considered to be nearly zero. Therefore, the probability of each age dimension should also be combined with the distribution of the ages.
Details about this step will be described later.
S12, the sample image is input to the age recognition model, and a plurality of age prediction values and a probability of each age prediction value are obtained.
The age identification model is used for carrying out feature extraction on an input sample image to obtain a plurality of age predicted values and the probability of each age predicted value. The age identification model can be constructed based on a convolutional neural network or other types of neural networks, the specific network structure of the age identification model is not limited at all, and the age identification model can be set correspondingly according to actual conditions.
For example, any one of classical convolutional neural networks such as ResNet, VGG, MobileNet, and the like can be selected as a backbone network of the age recognition model, i.e., a backbone network, and in the embodiment of the present invention, the backbone network serves to extract features of the input face image. Considering that age identification needs information of a network bottom layer, feature extraction can be performed by using the first few layers of the backbone, then a full connection layer is used, and processing of subsequent steps is added after the full connection layer for iterative training to obtain a model. When reasoning, the output of the fully connected layer is then used directly as the predicted age value.
The number of the age prediction values output by the age identification model can be set according to the actual situation, and is not limited herein. For example, 10 age prediction values may be output, 5 age prediction values may be output, or 100 age prediction values may be output.
In this embodiment, the age identification model outputs 100 predicted age values as an example. Specifically, the age identification model outputs 100 age predictors between 0 and 99, and probabilities of the respective age predictors.
And S13, calculating a loss function according to the probability of each age dimension, the probability of each age predicted value, the real age value and the plurality of age predicted values, training the age identification model, and determining the target age identification model.
After obtaining the probabilities of the age dimensions, the labeled values of the ages and the probabilities thereof, the electronic device can calculate the loss function based on the probabilities. For example, the loss function value may be calculated in a euclidean distance manner, may be calculated in another manner, and so on. Optionally, a penalty factor may be further incorporated in the calculation of the loss function, wherein the penalty factor is used to indicate a difference between the age prediction value and the true age value. Specifically, the larger the difference between the age prediction value and the true age value, the larger the penalty coefficient; the smaller the difference between the age prediction value and the true age value, the smaller the penalty factor. The calculation of the loss function is not limited at all, and may be set according to actual conditions.
For example, the loss function may be calculated based on the product of each weight and age calculated using each probability as a weight corresponding to the age.
After obtaining the loss function value, the electronic device may train the age identification model in a back propagation manner, and then determine the target age identification model. The stopping condition of the training may be to set the number of iterations, to set a threshold of the loss function, or the like.
Details about this step will be described later.
According to the training method of the age identification model, the labeling information comprises the real age value and the probability of each age dimension, the labeled difference is represented by the probability of the age dimension, and the training of the age identification model is subsequently performed by combining the difference, so that the trained target age identification model can accurately identify the age value, and the accuracy of age identification is improved.
In this embodiment, a training method of an age identification model is provided, which can be used in electronic devices, such as a computer, a mobile phone, a tablet computer, and the like, fig. 2 is a flowchart of the training method of the age identification model according to the embodiment of the present invention, and as shown in fig. 2, the flowchart includes the following steps:
s21, the sample image and the label information of each sample image are acquired.
The labeling information comprises real age values and probabilities of all age dimensions.
Specifically, the above S21 may include the following steps:
and S211, acquiring a sample image.
The manner in which the electronic device obtains the sample image can be referred to the related description in the above embodiment S11, and is not described herein again.
S212, a plurality of age marking values of the same sample image are obtained.
The age labels may be obtained by labeling the ages of a plurality of sample images, or may be obtained by labeling the ages of the sample images in other manners, which is not limited herein.
S213, calculating the distribution information of the labeled ages by using the plurality of age labeled values to obtain the real age value and the probability of each age dimension.
As described above, although different people annotate the same sample image can obtain different age annotation values, the obtained age annotation values still conform to a certain distribution. Such as a normal distribution, a gaussian distribution, and the like.
The electronic equipment can calculate the distribution information of the age marking values on the basis of the age marking values to obtain the probability of each age dimension. The distribution information can be based on normal distribution, and the normal weight of each age marking value is calculated; the gaussian weights for each age dimension may also be calculated based on the gaussian distribution.
In some optional implementations of this embodiment, the step S213 may include the following steps:
(1) and calculating the mean value and the variance of the plurality of age labeling values, wherein the real age value is the mean value.
In this embodiment, a plurality of age labels are fitted to fit a gaussian distribution. However, if the standard gaussian distribution mean and variance are used in a unified manner, subjective consciousness different from that of a plurality of persons is not satisfied, and therefore, it is necessary to further process age-labeled values obtained by labeling a plurality of persons. Wherein the expected result of the further processing is that if the true age label fed into the age identification model is eighteen years old, then the regression of the age identification model to 18 years old, then the probability of the pair predicted by the model is considered to be almost 100%; conversely, if the true age label sent to the model is 18 years old and the predicted value of the model prediction is 60 years old, then the probability of the model prediction pair is considered to be almost 0.
Based on the method, the electronic equipment calculates the mean value and the variance of a plurality of age labeling values, and then calculates the mean value and the variance of the age labeling values on the basis. For example, when the same image is labeled by 10 persons, and the 1 st to 10 th persons label the image as 21 years old, 25 years old, 26 years old, 24 years old, 26 years old, 22 years old, 24 years old, 23 years old, 24 years old, and 23 years old, the average value of the image at the time of labeling is 23.8, and the variance is 2.36. It can thus be determined that the image corresponds to a true age value of 23.8.
(2) And calculating the Gaussian weight of each age dimension by using the mean value and the variance to obtain the probability of each age dimension.
After obtaining the mean and the variance, the electronic device may calculate a probability for each age dimension based thereon, where the probability is a gaussian weight for each age dimension.
Specifically, in this embodiment, the mean value of the age label values is used as the true age value corresponding to the sample image. The electronic equipment obtains the probability of each age dimension by adopting a formula (1):
labelmean=(label1+label2+label3+...+labeln)/n
labelage=fgaussi(labelmean) (1)
wherein, labelmeanIndicating the true age value, label, ultimately sent to the age identification networknIndicating the estimated age, label, of the face image for different personsageRepresenting the probability of each age dimension, the label is a 100-dimensional age probability (here 100 is an age value that mimics a human being of 0-99 years, where 0 represents an unknown age), fgaussiRepresenting a gaussian distribution function.
The gaussian weight can be calculated as shown in equation (2):
Figure BDA0002966022970000101
wherein, σ represents the standard deviation of multiple annotations in each sample image, u is the mean value of multiple annotations, and x is each age dimension.
In combination with the above example, the probability of 0.9974 for the dimension at age 24, 0.9933 for the dimensions at ages 23 and 25 can be calculated from equation (2), and the probabilities for the other dimensions can also be calculated.
And calculating the Gaussian weight of each age dimension, namely fitting each age dimension into Gaussian distribution, so that the influence of subjective consciousness of manual labeling on a labeling result can be eliminated as much as possible.
S22, the sample image is input to the age recognition model, and a plurality of age prediction values and a probability of each age prediction value are obtained.
Please refer to S12 in fig. 1, which is not described herein again.
And S23, calculating a loss function according to the probability of each age dimension, the probability of each age predicted value, the real age value and the plurality of age predicted values, training the age identification model, and determining the target age identification model.
Please refer to S13 in fig. 1, which is not described herein again.
According to the training method of the age identification model, because the age label values have subjective consciousness, but the age label values accord with a certain distribution condition, the probability of each age dimension is obtained by calculating the distribution information of the labeled ages, and therefore the obtained probability of each age dimension can be guaranteed to accord with the actual condition better.
In this embodiment, a training method of an age identification model is provided, which can be used in electronic devices, such as a computer, a mobile phone, a tablet computer, and the like, fig. 3 is a flowchart of a training method of an age identification model according to an embodiment of the present invention, and as shown in fig. 3, the flowchart includes the following steps:
s31, the sample image and the label information of each sample image are acquired.
The labeling information comprises real age values and probabilities of all age dimensions.
Please refer to S21 in fig. 2 for details, which are not described herein.
S32, the sample image is input to the age recognition model, and a plurality of age prediction values and a probability of each age prediction value are obtained.
Please refer to S12 in fig. 1, which is not described herein again.
And S33, calculating a loss function according to the probability of each age dimension, the probability of each age predicted value, the real age value and the plurality of age predicted values, training the age identification model, and determining the target age identification model.
Specifically, the above S33 may include the following steps:
and S331, acquiring a target age predicted value.
Wherein the target age prediction value is the age prediction value with the maximum probability.
After obtaining the plurality of age prediction values, the electronic device compares the probabilities corresponding to the age prediction values, and determines the age prediction value with the maximum probability as the target age prediction value.
S332, a loss function value is calculated based on the probability of each age prediction value, the probability of each age dimension, the plurality of age prediction values, and the true age value.
The electronic device may calculate the loss function value based on the euclidean distance calculation in combination with the probabilities of the respective age prediction values and the probabilities of the respective age dimensions.
For example, the square of the difference between each age prediction value and the real age may be calculated, and on the basis, the probability of each age prediction value or age dimension is used as a weight and multiplied by the result of the square of the difference; and summing the calculation results corresponding to the age prediction values to obtain the loss function value.
In some optional implementations of this embodiment, the step S332 may include the following steps:
(1) and determining a penalty coefficient by using the difference between the target age predicted value and the real age value.
In the present embodiment, the loss function is modified, specifically, if the euclidean distance is used for the regression, the input value of a model is regressed, and no consideration is given to any application context, but for the prediction of the age, if the true age is eighteen years, the prediction result is sixty or twenty, and in addition to the gaussian weight mentioned above, the difference between the true age and the predicted age value should be considered. That is, the error of the prediction of sixty is larger.
As described above, the target age prediction value is the most probable age prediction value. And the electronic equipment takes the difference between the target age predicted value and the real age value as a penalty coefficient.
(2) And calculating a loss function value by using the probability of each age predicted value, the probability of each age dimension, the penalty coefficient, the plurality of age predicted values and the real age value.
Specifically, the calculation of the loss function is performed using the following formula:
Figure BDA0002966022970000121
wherein E iskIs the loss function value after the Kth iteration, alpha is a penalty coefficient,
Figure BDA0002966022970000122
is the station of the k-th iterationThe target age predicted value, y is the real age value, l is the number of the age predicted values, WjIs the probability of the jth said age predictor or the probability of the jth said age dimension. When iteration starts, the probability of the age dimension can be adopted to calculate the loss function, and the probability of each round collar predicted value is adopted to calculate the loss function in the subsequent iteration process.
The penalty coefficient is reflected by the difference value between the target age predicted value and the real age value, so that the training process can be accelerated and the training efficiency can be improved by adding the penalty coefficient in the calculation process of the loss function.
And S333, adjusting parameters of the age identification model by using the loss function value, and determining the target age identification model.
After the electronic equipment calculates the loss function value, the parameters of the age identification model can be adjusted on the basis of the loss function value, and then the target age identification model is determined.
According to the training method of the age identification model, the loss function is calculated by combining the probability of the age prediction value or the probability of the age dimension in the training process, so that the calculated loss function value can better meet the actual situation, and the accuracy of calculation of the loss function is improved.
As a specific implementation manner of this embodiment, as shown in fig. 4, the method for training an age identification model includes:
acquiring annotation information of a sample image, wherein the annotation information is obtained by preprocessing an estimated age label; and then generating age weights based on the Gaussian kernels to obtain the probability of each age dimension.
Further, inputting the face image into an age identification model, and extracting a main network by using the characteristics of the age identification model for prediction to obtain a plurality of age prediction values and the probability of each age prediction value; on the basis, calculating a loss function by combining the labeling information, and training the age identification model by using the loss function value obtained by calculation to determine the target age identification model.
Table 1 shows the comparison between the age prediction value using the euclidean distance and the age prediction value in the embodiment of the present invention:
TABLE 1 comparison of age prediction values for Euclidean distance with age prediction values in the examples of the present invention
Figure BDA0002966022970000131
As can be seen from table 1, the age label value, i.e. the label calculated by formula (1), is 36 years, and the training using the euclidean distance without any processing results in an age of 39 years and an error of 3 years from the label age, whereas the method according to the embodiment of the present invention results in an age value of 35 years and an error of only 1 year from the label age. Similarly, the Euclidean distance is used for training, the obtained age errors are 3 years old and 5 years old, while the errors of the method provided by the embodiment of the invention are 0 years old and 2 years old, and the conclusion that the human face image is not easy to lose generality can be obtained on other similar human face images.
In accordance with an embodiment of the present invention, there is provided an age identification method embodiment, it being noted that the steps illustrated in the flowchart of the drawings may be performed in a computer system such as a set of computer-executable instructions and that, although a logical order is illustrated in the flowchart, in some cases the steps illustrated or described may be performed in an order different than here.
In this embodiment, an age identification method is provided, which may be used in electronic devices, such as a computer, a mobile phone, a tablet computer, and the like, fig. 5 is a flowchart of a training method of an age identification model according to an embodiment of the present invention, and as shown in fig. 5, the flowchart includes the following steps:
and S41, acquiring the image to be recognized.
The image to be recognized may be obtained by the electronic device from the outside, or may be stored in the electronic device in advance, where the source of the image to be recognized is not limited at all. For example, the third-party image acquisition device acquires an image to be recognized containing a human face, and sends the acquired image to be recognized to the electronic device; accordingly, the electronic device can acquire the image to be recognized.
And S42, inputting the image to be recognized into the target age recognition model to obtain a plurality of age values and the probability of each age value, and determining the age value with the maximum probability as the target age value.
The target age identification model is obtained by training according to the training method of the age identification model in any one of the above embodiments.
After the image to be recognized is acquired, the electronic equipment inputs the image to be recognized into a target age recognition model, and the target age recognition model outputs a plurality of age values and the probability of each age value. For example, the electronic device outputs 100 age values and probabilities corresponding to the ages, and the age values are 0 to 99.
Further, the electronic equipment determines the age value with the maximum probability as the target age value corresponding to the image to be recognized.
Please refer to the above embodiments for the training process of the age identification model, which is not described herein again.
According to the age identification method provided by the embodiment, the target age identification model with higher identification accuracy is used for identifying the age of the face in the image to be identified, so that the identification accuracy can be ensured, and the identified age value is closer to the true value.
In this embodiment, a training device for an age identification model, or an age identification device is further provided, and the device is used to implement the foregoing embodiments and preferred embodiments, which have already been described and are not described again. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
The present embodiment provides a training apparatus for an age recognition model, as shown in fig. 6, including:
a first obtaining module 51, configured to obtain sample images and annotation information of each sample image, where the annotation information includes a true age value and a probability of each age dimension;
a prediction module 52, configured to input the sample image into an age identification model to obtain a plurality of age prediction values and a probability of each age prediction value;
and the training module 53 is configured to perform calculation of a loss function according to the probability of each age dimension, the probability of each age prediction value, the real age value, and the plurality of age prediction values, so as to train the age identification model and determine the target age identification model.
The training device for the age identification model provided by the embodiment comprises the real age value and the probability of each age dimension in the labeling information, the labeled difference is represented by the probability of the age dimension, and the training of the age identification model is subsequently performed by combining the difference, so that the trained target age identification model can accurately identify the age value, and the accuracy of age identification is improved.
The present embodiment provides an age identifying apparatus, as shown in fig. 7, including:
the second obtaining module 61 is used for obtaining an image to be identified;
the identification module 62 is configured to input the image to be identified into a target age identification model, which is obtained by training according to the training method of the age identification model in any one of the above embodiments of the present invention, to obtain a plurality of age values and probabilities of the age values, and determine the age value with the highest probability as the target age value.
The age identification device provided by the embodiment utilizes the target age identification model with higher identification accuracy rate to identify the age of the face in the image to be identified, and can ensure the identification accuracy, so that the identified age value is closer to the true value.
The age identification model training device and the age identification device in this embodiment are presented in the form of functional units, where a unit refers to an ASIC circuit, a processor and memory executing one or more software or fixed programs, and/or other devices that can provide the above-described functionality.
Further functional descriptions of the modules are the same as those of the corresponding embodiments, and are not repeated herein.
An embodiment of the present invention further provides an electronic device, which includes the training apparatus for the age identification model shown in fig. 6 or the age identification apparatus shown in fig. 7.
Referring to fig. 8, fig. 8 is a schematic structural diagram of an electronic device according to an alternative embodiment of the present invention, and as shown in fig. 8, the electronic device may include: at least one processor 71, such as a CPU (Central Processing Unit), at least one communication interface 73, memory 74, at least one communication bus 72. Wherein a communication bus 72 is used to enable the connection communication between these components. The communication interface 73 may include a Display (Display) and a Keyboard (Keyboard), and the optional communication interface 73 may also include a standard wired interface and a standard wireless interface. The Memory 74 may be a high-speed RAM Memory (volatile Random Access Memory) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. The memory 74 may alternatively be at least one memory device located remotely from the processor 71. Wherein the processor 71 may be in connection with the apparatus described in fig. 6 or fig. 7, an application program is stored in the memory 74, and the processor 71 calls the program code stored in the memory 74 for performing any of the above-mentioned method steps.
The communication bus 72 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus 72 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 8, but this is not intended to represent only one bus or type of bus.
The memory 74 may include a volatile memory (RAM), such as a random-access memory (RAM); the memory may also include a non-volatile memory (english: non-volatile memory), such as a flash memory (english: flash memory), a hard disk (english: hard disk drive, abbreviated: HDD) or a solid-state drive (english: SSD); the memory 74 may also comprise a combination of memories of the kind described above.
The processor 71 may be a Central Processing Unit (CPU), a Network Processor (NP), or a combination of CPU and NP.
The processor 71 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a Programmable Logic Device (PLD), or a combination thereof. The PLD may be a Complex Programmable Logic Device (CPLD), a field-programmable gate array (FPGA), a General Array Logic (GAL), or any combination thereof.
Optionally, the memory 74 is also used for storing program instructions. Processor 71 may call program instructions to implement a training method for an age identification model as shown in the embodiments of fig. 1 to 3 of the present application, or an age identification method as shown in the embodiment of fig. 5.
The embodiment of the invention also provides a non-transitory computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions can execute the training method or the age identification method of the age identification model in any method embodiment. The storage medium may be a magnetic Disk, an optical Disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a Flash Memory (Flash Memory), a Hard Disk (Hard Disk Drive, abbreviated as HDD), a Solid State Drive (SSD), or the like; the storage medium may also comprise a combination of memories of the kind described above.
Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope defined by the appended claims.

Claims (11)

1. A training method of an age recognition model, the training method comprising:
acquiring sample images and labeling information of each sample image, wherein the labeling information comprises a real age value and the probability of each age dimension;
inputting the sample image into an age identification model to obtain a plurality of age predicted values and the probability of each age predicted value;
and calculating a loss function according to the probability of each age dimension, the probability of each age predicted value, the real age value and the age predicted values so as to train the age identification model and determine a target age identification model.
2. The training method according to claim 1, wherein obtaining the labeling information of each sample image comprises:
acquiring a plurality of age marking values of the same sample image;
and calculating distribution information of labeled ages by using the age labeled values to obtain the real age value and the probability of each age dimension.
3. The training method of claim 2, wherein the calculating distribution information of each age label value by using the plurality of age label values to obtain the real age value and the probability of each age dimension comprises:
calculating the mean value and the variance of the age labeling values, wherein the real age value is the mean value;
and calculating the Gaussian weight of each age dimension by using the mean value and the variance to obtain the probability of each age dimension.
4. The training method according to claim 1, wherein the calculating a loss function according to the probability of each age dimension, the probability of each age prediction value, the real age value and the plurality of age prediction values to train the age identification model to determine a target age identification model comprises:
acquiring a target age predicted value, wherein the target age predicted value is the age predicted value with the maximum probability;
calculating a loss function value based on the probability of each said age predictor, the probability of each age dimension, a plurality of age predictors, and said true age value;
and adjusting parameters of the age identification model by using the loss function value to determine the target age identification model.
5. Training method according to claim 4, wherein said calculating a loss function value based on a probability of each of said age prediction values, a probability of each age dimension, a plurality of age prediction values and said true age value comprises:
determining a penalty coefficient by using the difference value between the target age predicted value and the real age value;
calculating a loss function value using the probability of each said age predictor, the probability of each age dimension, said penalty factor, the plurality of age predictors, and said true age value.
6. Training method according to claim 5, characterized in that the calculation of the loss function is performed using the following formula:
Figure FDA0002966022960000021
wherein E iskIs the loss function value after the Kth iteration, alpha is a penalty coefficient,
Figure FDA0002966022960000022
the target age predictor for the kth iteration, y the real age value, l the number of age predictors, WjIs the probability of the jth said age predictor or the probability of the jth said age dimension.
7. An age identification method, characterized in that the identification method comprises:
acquiring an image to be identified;
inputting the image to be recognized into a target age recognition model to obtain a plurality of age values and the probability of each age value, and determining the age value with the maximum probability as the target age value, wherein the target age recognition model is obtained by training according to the training method of the age recognition model as claimed in any one of claims 1 to 6.
8. An apparatus for training an age recognition model, the apparatus comprising:
the system comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring sample images and labeling information of each sample image, and the labeling information comprises a real age value and the probability of each age dimension;
the prediction module is used for inputting the sample image into an age identification model to obtain a plurality of age prediction values and the probability of each age prediction value;
and the training module is used for calculating a loss function according to the probability of each age dimension, the probability of each age predicted value, the real age value and the age predicted values so as to train the age identification model and determine a target age identification model.
9. An age identifying device, characterized in that the identifying device comprises:
the second acquisition module is used for acquiring an image to be identified;
an identification module, configured to input the image to be identified into a target age identification model, so as to obtain a plurality of age values and probabilities of the age values, and determine an age value with a maximum probability as a target age value, where the target age identification model is obtained by training according to the training method of the age identification model according to any one of claims 1 to 6.
10. An electronic device, comprising:
a memory and a processor, the memory and the processor being communicatively connected to each other, the memory having stored therein computer instructions, the processor executing the computer instructions to perform the method for training an age identification model according to any one of claims 1 to 6, or to perform the method for identifying an age according to claim 7.
11. A computer-readable storage medium storing computer instructions for causing a computer to execute the method of training an age identification model according to any one of claims 1 to 6 or the method of identifying an age according to claim 7.
CN202110250897.3A 2021-03-08 2021-03-08 Training of age identification model, age identification method and device and electronic equipment Pending CN112818946A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110250897.3A CN112818946A (en) 2021-03-08 2021-03-08 Training of age identification model, age identification method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110250897.3A CN112818946A (en) 2021-03-08 2021-03-08 Training of age identification model, age identification method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN112818946A true CN112818946A (en) 2021-05-18

Family

ID=75862986

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110250897.3A Pending CN112818946A (en) 2021-03-08 2021-03-08 Training of age identification model, age identification method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN112818946A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113456031A (en) * 2021-08-09 2021-10-01 首都医科大学附属北京天坛医院 Training device and prediction device of brain state prediction model and electronic equipment
CN113780454A (en) * 2021-09-17 2021-12-10 平安科技(深圳)有限公司 Model training and calling method and device, computer equipment and storage medium
CN114299572A (en) * 2021-12-22 2022-04-08 云从科技集团股份有限公司 Face age estimation method and device and electronic equipment
CN115937932A (en) * 2022-11-08 2023-04-07 汇客云(上海)数据服务有限公司 Age prediction model training method, age prediction method and related equipment

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110399813A (en) * 2019-07-10 2019-11-01 深兰科技(上海)有限公司 A kind of age recognition methods, device, electronic equipment and storage medium
CN112085000A (en) * 2020-09-21 2020-12-15 北京金山云网络技术有限公司 Age recognition method, training method and device of age recognition model

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110399813A (en) * 2019-07-10 2019-11-01 深兰科技(上海)有限公司 A kind of age recognition methods, device, electronic equipment and storage medium
CN112085000A (en) * 2020-09-21 2020-12-15 北京金山云网络技术有限公司 Age recognition method, training method and device of age recognition model

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113456031A (en) * 2021-08-09 2021-10-01 首都医科大学附属北京天坛医院 Training device and prediction device of brain state prediction model and electronic equipment
CN113780454A (en) * 2021-09-17 2021-12-10 平安科技(深圳)有限公司 Model training and calling method and device, computer equipment and storage medium
CN113780454B (en) * 2021-09-17 2023-10-24 平安科技(深圳)有限公司 Model training and calling method and device, computer equipment and storage medium
CN114299572A (en) * 2021-12-22 2022-04-08 云从科技集团股份有限公司 Face age estimation method and device and electronic equipment
CN115937932A (en) * 2022-11-08 2023-04-07 汇客云(上海)数据服务有限公司 Age prediction model training method, age prediction method and related equipment

Similar Documents

Publication Publication Date Title
CN110020592B (en) Object detection model training method, device, computer equipment and storage medium
CN108229509B (en) Method and device for recognizing object type, electronic device
CN112818946A (en) Training of age identification model, age identification method and device and electronic equipment
CN111814810A (en) Image recognition method, device, electronic device and storage medium
CN110909618B (en) Method and device for identifying identity of pet
CN110807314A (en) Text emotion analysis model training method, device and equipment and readable storage medium
US12511944B2 (en) Companion animal life management system and method therefor
CN111401343B (en) Method for identifying attributes of people in image and training method and device for identification model
CN110378314A (en) A kind of human face region image archiving method, device, electronic equipment and storage medium
CN114419363B (en) Target classification model training method and device based on unlabeled sample data
CN113065525A (en) Age recognition model training method, face age recognition method and related device
CN111814832A (en) A target detection method, device and storage medium
WO2024060684A1 (en) Model training method, image processing method, device, and storage medium
CN108564102A (en) Image clustering evaluation of result method and apparatus
CN110928862A (en) Data cleaning method, data cleaning apparatus, and computer storage medium
CN110135505B (en) Image classification method and device, computer equipment and computer readable storage medium
CN115862119B (en) Attention mechanism-based face age estimation method and device
CN111753863A (en) An image classification method, device, electronic device and storage medium
CN113011532A (en) Classification model training method and device, computing equipment and storage medium
CN115034315B (en) Service processing method and device based on artificial intelligence, computer equipment and medium
CN113780145A (en) Sperm morphology detection method, sperm morphology detection device, computer equipment and storage medium
CN112183336A (en) Expression recognition model training method and device, terminal equipment and storage medium
CN118864876A (en) Zero-sample anomaly detection method and device based on image and text pre-training model
WO2023154986A1 (en) Method, system, and device using a generative model for image segmentation
CN114913487A (en) A target recognition detection method based on multimodal learning and related components

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210518