A training method and device for face key point detection model
By assigning calculation weights to face image samples according to their specialness and adjusting model parameters, the problem of low recognition accuracy of the face key point detection model in special face images is solved, and better learning of diverse face structures is achieved. and improvement in detection accuracy.
Patent Information
- Application Number
- CN202010333407.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-04-24
- Publication Date
- 2024-09-24
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing face key point detection models have low recognition accuracy when dealing with special face images such as non-frontal faces, exaggerated expressions, makeup, occlusion, uneven lighting, and blur.
By assigning a calculation weight to each face image sample according to its specialness, and inputting it into the basic face key point detection model for training, the model parameters are adjusted to improve the detection accuracy.
The recognition accuracy of facial key point detection in diverse facial images is improved, allowing the model to learn diverse facial structures in a more balanced manner.
Smart Images

Figure 00000000_0000
Abstract
Description
Technical Field
[0001] The present application relates to the field of face recognition technology, and in particular to a training method and device for a face key point detection model. Background Art
[0002] As a classic subject in the field of computer vision, face recognition has great research and application value, and is in high demand. Face recognition is a technology that extracts facial features from images containing faces, recognizes facial images based on facial features, and gives recognition results.
[0003] Facial key point detection is a key step in the field of face recognition and analysis. It is the premise and breakthrough for other face-related problems such as automatic face recognition, expression analysis, 3D face reconstruction and 3D animation. Facial key point detection is a technology for detecting and locating facial key points in a face image. At present, for normal face images, facial key points can be accurately detected. However, face images are rich and varied. For special face images with non-frontal faces, exaggerated expressions, makeup, occlusion, uneven lighting, and blur, the recognition accuracy of facial key points is not high. Summary of the invention
[0004] In view of this, the embodiments of the present application at least provide a method and device for training a facial key point detection model, which can improve the accuracy of facial key point detection by allowing the model to focus on learning special facial image samples.
[0005] This application mainly includes the following aspects:
[0006] In a first aspect, an embodiment of the present application provides a method for training a facial key point detection model, the training method comprising:
[0007] For each of the acquired multiple face image samples, determining a calculation weight for each face image sample according to a degree of particularity of at least one sample category to which each face image sample belongs;
[0008] Input each face image sample into the basic face key point detection model to determine the predicted coordinates of the face key points in each face image sample;
[0009] The basic facial key point detection model is trained according to the predicted coordinates and the real coordinates of the facial key points in each facial image sample and the calculated weights of each facial image sample.
[0010] In a possible implementation manner, the sample category includes at least one of the following categories:
[0011] The degree of face frontality, degree of exaggerated expression, degree of lighting, degree of makeup, degree of occlusion, and degree of image clarity.
[0012] In a possible implementation, for each sample category in the at least one sample category, the special degree of each sample category to which each face image sample belongs is determined according to the following steps:
[0013] Counting the target number of face image samples having target image features among the multiple face image samples obtained, and the total number of face image samples in the multiple face image samples; wherein the target image features are features of each face image sample under each sample category;
[0014] The special degree of each sample category to which each face image sample belongs is determined according to the total number and the target number.
[0015] In a possible implementation manner, determining the calculation weight of each face image sample according to the degree of particularity of at least one sample category to which each face image sample belongs includes:
[0016] The calculation weight of each face image sample is determined according to the special degree corresponding to each sample category in the at least one sample category to which each face image sample belongs.
[0017] In a possible implementation, the training of the basic facial key point detection model according to the predicted coordinates and the real coordinates of the facial key points in each facial image sample and the calculated weight of each facial image sample includes:
[0018] Determine the first cross entropy of each face image sample according to the predicted coordinates and the true coordinates of the face key points in each face image sample;
[0019] The first cross entropy is adjusted according to the calculation weight of each face image sample to obtain a second cross entropy of each face image sample;
[0020] According to the second cross entropy of each face image sample, the model parameters of the basic face key point detection model are adjusted.
[0021] In a possible implementation, after obtaining the second cross entropy of each face image sample, the training method further includes:
[0022] Determining an average cross entropy of the plurality of facial image samples according to the acquired second cross entropy of each facial image sample in the plurality of facial image samples;
[0023] When the average cross entropy meets a convergence condition, the training of the basic facial key point detection model is stopped.
[0024] In a possible implementation, determining the first cross entropy of each face image sample according to the predicted coordinates and the true coordinates of the face key points in each face image sample includes:
[0025] For each facial key point in each facial image sample, calculate the absolute difference between the predicted coordinates and the true coordinates of each facial key point, and calculate the entropy loss of each facial key point according to a calculation formula matching the absolute difference;
[0026] According to the entropy loss of each facial key point in each facial image sample, a first cross entropy of each facial image sample is determined.
[0027] In a possible implementation, if the absolute difference is less than a preset threshold, the calculation formula matching the absolute difference is:
[0028]
[0029] Wherein, ω, α, ∈ are the model parameters of the basic face key point detection model, y is the predicted coordinate of each face key point, is the real coordinate of each facial key point.
[0030] In a possible implementation, if the absolute difference is greater than or equal to a preset threshold, the calculation formula matching the absolute difference is:
[0031]
[0032] in, y is the predicted coordinate of each facial key point, is the real coordinate of each facial key point, ω, α, ∈ are the model parameters of the basic facial key point detection model, and θ is the preset threshold.
[0033] In a second aspect, an embodiment of the present application further provides a method for detecting key points of a face, the method comprising:
[0034] Get the face image to be detected;
[0035] The facial image to be detected is input into a facial key point detection model trained by the facial key point detection model training method described in the first aspect or any possible implementation manner of the first aspect to obtain the coordinates of the facial key points in the facial image to be detected.
[0036] In a third aspect, an embodiment of the present application further provides a training device for a facial key point detection model, the training device comprising:
[0037] A first determination module is used to determine, for each face image sample among the acquired multiple face image samples, a calculation weight of each face image sample according to a special degree of at least one sample category to which each face image sample belongs;
[0038] A second determination module is used to input each face image sample into a basic face key point detection model to determine the predicted coordinates of the face key points in each face image sample;
[0039] The training module is used to train the basic facial key point detection model according to the predicted coordinates and the real coordinates of the facial key points in each facial image sample and the calculated weights of each facial image sample.
[0040] In a possible implementation manner, the sample category includes at least one of the following categories:
[0041] The degree of face frontality, degree of exaggerated expression, degree of lighting, degree of makeup, degree of occlusion, and degree of image clarity.
[0042] In a possible implementation, for each sample category in the at least one sample category, the first determination module is further configured to determine the special degree of each sample category to which each face image sample belongs according to the following steps:
[0043] Counting the target number of face image samples having target image features among the multiple face image samples obtained, and the total number of face image samples in the multiple face image samples; wherein the target image features are features of each face image sample under each sample category;
[0044] The special degree of each sample category to which each face image sample belongs is determined according to the total number and the target number.
[0045] In a possible implementation manner, the first determination module is specifically configured to determine the calculation weight of each face image sample according to the following steps:
[0046] The calculation weight of each face image sample is determined according to the special degree corresponding to each sample category in the at least one sample category to which each face image sample belongs.
[0047] In a possible implementation, the training module includes:
[0048] A first determination unit, used for determining a first cross entropy of each face image sample according to the predicted coordinates and the true coordinates of the face key points in each face image sample;
[0049] a second determining unit, configured to adjust the first cross entropy according to the calculation weight of each face image sample to obtain a second cross entropy for each face image sample;
[0050] The adjusting unit is used to adjust the model parameters of the basic facial key point detection model according to the second cross entropy of each facial image sample.
[0051] In a possible implementation, the training device further includes a stop module; the stop module is used to stop training the basic face key point detection model according to the following steps:
[0052] Determining an average cross entropy of the plurality of facial image samples according to the acquired second cross entropy of each facial image sample in the plurality of facial image samples;
[0053] When the average cross entropy meets a convergence condition, the training of the basic facial key point detection model is stopped.
[0054] In a possible implementation manner, the first determining unit includes:
[0055] A calculation subunit, for calculating, for each facial key point in each facial image sample, an absolute difference between a predicted coordinate and a true coordinate of each facial key point, and calculating an entropy loss of each facial key point according to a calculation formula matching the absolute difference;
[0056] The determination subunit is used to determine the first cross entropy of each face image sample according to the entropy loss of each face key point in each face image sample.
[0057] In a possible implementation, if the absolute difference is less than a preset threshold, the calculation formula matching the absolute difference is:
[0058]
[0059] Wherein, ω, α, ∈ are the model parameters of the basic face key point detection model, y is the predicted coordinate of each face key point, is the real coordinate of each facial key point.
[0060] In a possible implementation, if the absolute difference is greater than or equal to a preset threshold, the calculation formula matching the absolute difference is:
[0061]
[0062] in, y is the predicted coordinate of each facial key point, is the real coordinate of each facial key point, ω, α, ∈ are the model parameters of the basic facial key point detection model, and θ is the preset threshold.
[0063] In a fourth aspect, a device for detecting key points of a face is provided, the device comprising:
[0064] An acquisition module is used to acquire a face image to be detected;
[0065] A determination module is used to input the face image to be detected into the face key point detection model trained by the training device of the face key point detection model described in the second aspect or any possible implementation manner of the second aspect, to obtain the coordinates of the face key points in the face image to be detected.
[0066] In a fifth aspect, an embodiment of the present application also provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and the machine-readable instructions are executed by the processor to execute the steps of the training method of the facial key point detection model described in the first aspect or any possible implementation scheme of the first aspect, and / or execute the steps of the facial key point detection method described in the second aspect.
[0067] In a sixth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the training method for a facial key point detection model described in the first aspect or any possible implementation scheme of the first aspect are executed, and / or the steps of the method for detecting facial key points described in the second aspect are executed.
[0068] The training method and device of the facial key point detection model provided in the embodiment of the present application can determine the calculation weight of each facial image sample according to the degree of specialness of at least one sample category in which each facial image sample belongs, and input each facial image sample into the basic facial key point detection model, so as to determine the predicted coordinates of the facial key points in each facial image sample. Furthermore, the basic facial key point detection model is trained according to the predicted coordinates and true coordinates of the facial key points in each facial image sample, and the calculation weight of the facial image sample. Based on the above method, when the model is trained using facial image samples, the calculation weights are assigned to the facial image samples according to the degree of specialness of the facial image samples, so that the model can learn the diverse facial structures in a balanced manner, thereby improving the accuracy of facial key point detection.
[0069] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0071] Figure 1 A flowchart of a method for training a facial key point detection model provided in an embodiment of the present application is shown;
[0072] Figure 2 A flow chart showing a method for detecting key points of a human face provided in an embodiment of the present application is shown;
[0073] Figure 3 One of the functional module diagrams of a training device for a facial key point detection model provided in an embodiment of the present application is shown;
[0074] Figure 4 Shows Figure 3 Functional module diagram of the training module in ;
[0075] Figure 5 The second functional module diagram of a training device for a facial key point detection model provided in an embodiment of the present application is shown;
[0076] Figure 6 Shows Figure 4 A functional module diagram of the first determining unit in;
[0077] Figure 7 A functional module diagram of a facial key point detection device provided in an embodiment of the present application is shown;
[0078] Figure 8 A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0079] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art, under the guidance of the content of the present application, can add one or more other operations to the flowchart, or remove one or more operations from the flowchart.
[0080] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0081] In order to enable those skilled in the art to use the contents of this application, the following implementation method is given in combination with the specific application scenario "training of facial key point detection model". For those skilled in the art, the general principles defined here can be applied to other embodiments and application scenarios without departing from the spirit and scope of this application.
[0082] The following methods, devices, electronic devices or computer-readable storage media of the embodiments of the present application can be applied to any scenario requiring training of a facial key point detection model. The embodiments of the present application are not limited to specific application scenarios. Any solution of the training method and device of the facial key point detection model provided by the embodiments of the present application is within the scope of protection of the present application.
[0083] It is worth noting that before the present application was filed, for normal face images, the facial key points could be accurately detected. However, since face images are rich and diverse, the proportion of special face images with non-frontal faces, exaggerated expressions, makeup, occlusion, uneven lighting, and blur may be lower than that of normal face images during the model training process. Therefore, the model cannot learn these special images well. Therefore, when detecting facial key points for such images, the recognition accuracy of facial key points is not high.
[0084] In response to the above problems, the embodiments of the present application can determine the calculation weight of each face image sample according to the degree of specialness of at least one sample category in which each face image sample belongs, and input each face image sample into the basic face key point detection model, so as to determine the predicted coordinates of the face key points in each face image sample. Furthermore, the basic face key point detection model is trained according to the predicted coordinates and true coordinates of the face key points in each face image sample, and the calculation weight of the face image sample. Based on the above method, when the model is trained using face image samples, calculation weights are assigned to the face image samples according to the degree of specialness of the face image samples. In this way, the model can learn the diverse face structures in a balanced manner, thereby improving the accuracy of face key point detection.
[0085] To facilitate the understanding of the present application, the technical solution provided by the present application is described in detail below in conjunction with specific embodiments.
[0086] Figure 1 The flowchart of a method for training a facial key point detection model provided in an embodiment of the present application is as follows. Figure 1 As shown, the training method of the face key point detection model provided in the embodiment of the present application includes the following steps:
[0087] S101: for each facial image sample among the acquired multiple facial image samples, determining a calculation weight for each facial image sample according to a special degree of at least one sample category to which each facial image sample belongs.
[0088] In a specific implementation, when training the basic face key point detection model, it is first necessary to obtain multiple face image samples for training the basic face key point detection model, and for each sample category in at least one preset sample category, determine the degree of specialness of each face image sample obtained in each sample category, and then determine the calculation weight of each face image sample based on the degree of specialness of at least one sample category in which each face image sample is located. Here, for each sample category, the degree of specialness of each face image sample in the sample category can be understood as the degree of specialness of the face image sample in the multiple face image samples obtained for the sample category, and the calculation weight of each face image sample participating in the training of the basic face key point detection model is calculated using the degree of specialness of each sample category in which each face image sample is located.
[0089] It should be noted that, if among the multiple face image samples obtained, for a sample category, the fewer the number of face image samples with the same image features as a face image sample in the sample category, the greater the special degree of the face image sample; conversely, if the more the number of face image samples with the same image features as a face image sample in the sample category, the smaller the special degree of the face image sample. For each sample category, if the special degree of a face image sample in the multiple face image samples obtained is high, the calculation weight of the face image sample is also high; conversely, for each sample category, if the special degree of a face image sample in the multiple face image samples obtained is low, the calculation weight of the face image sample is also low. In this way, by assigning a larger calculation weight to the special face image samples with a smaller number and assigning a smaller calculation weight to the ordinary face image samples with a larger number, the calculation weight can play a role in balancing the data, so that the diversity of the face structure can be balanced by the face key point detection model.
[0090] Here, at least one sample category may be preset, and the sample categories include but are not limited to a frontal face degree category, an expression exaggeration degree category, an illumination degree category, a makeup degree category, an occlusion degree category, and an image clarity degree category.
[0091] In one example, the sample category is an expression exaggeration category, and the image features of most of the face images in the multiple face image samples obtained are normal facial expressions. If an image feature of face image sample A is exaggerated facial expression, it means that for the expression exaggeration category, the feature degree of face image sample A in the expression exaggeration category is higher; conversely, if an image feature of face image sample A is normal facial expression, it means that for the expression exaggeration category, the feature degree of face image sample A in the expression exaggeration category is lower.
[0092] Further, for each sample category in at least one preset sample category, a process of determining the degree of uniqueness of each sample category to which each face image sample belongs is described, that is, for each sample category in at least one preset sample category, the degree of uniqueness of each sample category to which each face image sample belongs is determined according to the following steps:
[0093] Step 1011: Count the target number of face image samples having target image features among the multiple face image samples obtained, and the total number of face image samples in the multiple face image samples; wherein the target image features are the features of each face image sample under each sample category.
[0094] In a specific implementation, when calculating the degree of distinctiveness of any face image sample in any sample category, first, among the multiple face image samples obtained, face image samples having the same image features as the calculated face image sample under the sample category are searched, and then, the total number of the searched face image samples together with the face image sample is counted, that is, the target number of face image samples having the target image features is counted, wherein the target image features are the features of the calculated face image sample under the sample category, and the total number of face image samples in the multiple face image samples obtained is counted.
[0095] Step 1012: Determine the degree of distinctiveness of each sample category to which each face image sample belongs based on the total number and the target number.
[0096] In a specific implementation, the degree of distinctiveness of each sample category in which each face image sample belongs is jointly determined based on the total number of face image samples in the acquired multiple face image samples and the target number of face image samples having the target image features under the sample category (the features possessed by the face image samples). Here, since the face image samples with higher distinctiveness account for a lower proportion of all acquired face image samples, in order to evenly learn the diversity of face structures by the face key point detection model, a larger calculation weight can be assigned to the special face image samples with a smaller number, and the calculation weight is determined by the importance. Here, the ratio between the total number and the target number can be used as the degree of distinctiveness of each sample category in which each face image sample belongs.
[0097] Here, among the N face image samples obtained, the calculation formula for the special degree of face image sample n in sample category c is: Among them, σ represents the degree of specialness. If the image feature of face image sample n in sample category c is A, then M is the number of face image samples with image feature A in N face image samples.
[0098] In one example, the image feature of face image sample n in the makeup degree category is "heavy makeup feature". Among the 50 face image samples obtained, there are a total of 5 face image samples with the image feature of "heavy makeup feature" in the makeup degree category. Then the special degree of face image sample n in the makeup degree category is
[0099] Further, the process of determining the calculation weight of each face image sample is described below, that is, in step S101, the calculation weight of each face image sample is determined according to the special degree of at least one sample category to which each face image sample belongs, including the following steps:
[0100] The calculation weight of each face image sample is determined according to the special degree corresponding to each sample category in the at least one sample category to which each face image sample belongs.
[0101] In a specific implementation, at least one sample category may be preset, and then, the calculation weight of each face image sample may be jointly calculated according to the degree of specialness of each face image sample in each sample category. Here, two methods are given to determine the calculation weight:
[0102] Method 1: First determine the degree of distinctiveness of each face image sample in each sample category, add the degree of distinctiveness of each face image sample in each sample category in at least one preset sample category, and determine the sum obtained as the calculation weight of each face image sample.
[0103] In one example: there are 3 preset sample categories, including sample category A, sample category B and sample category C. The special degree of face image sample n in sample category A is a1, the special degree of face image sample n in sample category B is a2, and the special degree of face image sample n in sample category C is a3. Then the calculation weight of face image sample n is a1+a2+a3.
[0104] Method 2: First determine the degree of distinctiveness of each face image sample in each sample category, multiply the degree of distinctiveness of each face image sample in each sample category by the preset weight corresponding to the sample category, and sum the multiple values obtained by the multiplication, and determine the summed value as the calculation weight of each face image sample.
[0105] In an example: there are 3 preset sample categories, including sample category A, sample category B and sample category C. The special degree of face image sample n in sample category A is a1, the special degree of face image sample n in sample category B is a2, and the special degree of face image sample n in sample category C is a3. The preset weight corresponding to sample category A is b1, the preset weight corresponding to sample category B is b2, and the preset weight corresponding to sample category C is b3. Then the calculated weight of face image sample n is a1*b1+a2*b2+a3*b3.
[0106] S102: Input each face image sample into a basic face key point detection model to determine the predicted coordinates of the face key points in each face image sample.
[0107] In a specific implementation, when training the basic facial key point detection model, each of the acquired multiple facial image samples is input into the basic facial key point detection model, and the predicted coordinates of the facial key points in each facial image sample are predicted. Here, there is a difference between the predicted coordinates of the predicted facial key points and the actual coordinates of the corresponding facial key points, and this difference can be used to train the basic facial key point detection model.
[0108] S103: training the basic facial key point detection model according to the predicted coordinates and the real coordinates of the facial key points in each facial image sample and the calculated weight of each facial image sample.
[0109] In a specific implementation, when obtaining multiple face image samples for training the basic face key point detection model, it is also necessary to obtain the real coordinates of the face key points in each face image sample. Here, the real coordinates of the face key points in each face image sample can be manually annotated in advance, and then, according to the predicted coordinates, real coordinates of the face key points in each face image sample, and the calculation weight of each face image sample, the basic face key point detection model is trained. Here, when using face image samples to train the model, by assigning calculation weights to the face image samples according to the special degree of the face image samples, the model can learn the diverse face structures in a balanced manner, and then the accuracy of face key point detection can be improved. Specifically, a larger calculation weight can be assigned to a small number of special face image samples, and a smaller calculation weight can be assigned to a large number of ordinary face image samples, so that the calculation weight can play a role in balancing the data, so that the diversity of face structures can be balancedly learned by the face key point detection model, so as to achieve the purpose of improving the accuracy of face key point detection.
[0110] Furthermore, for each of the acquired multiple face image samples, the basic face key point detection model may be trained according to the following steps:
[0111] Step 1031: Determine the first cross entropy of each face image sample according to the predicted coordinates and the true coordinates of the face key points in each face image sample.
[0112] In a specific implementation, the first cross entropy of each face image sample is determined by first determining the difference between the predicted coordinates and the true coordinates of each face key point in each face image sample.
[0113] Here, each face image sample contains a plurality of face key points, including but not limited to the corners of the mouth, the tip of the nose, the corners of the eyes (inner corners of the eyes and outer corners of the eyes, etc.), and the tips of the eyebrows.
[0114] Further, determining the first cross entropy of each face image sample according to the predicted coordinates and the true coordinates of the face key points in each face image sample in step 1031 includes the following steps:
[0115] For each facial key point in each facial image sample, the absolute difference between the predicted coordinates and the true coordinates of each facial key point is calculated, and the entropy loss of each facial key point is calculated according to a calculation formula matching the absolute difference; according to the entropy loss of each facial key point in each facial image sample, the first cross entropy of each facial image sample is determined.
[0116] In a specific implementation, for any facial key point in multiple face image samples, the absolute difference between the predicted coordinates and the true coordinates of the facial key point is calculated, and the entropy loss of the facial key point is calculated according to a calculation formula matching the absolute difference.
[0117] Here, if the absolute difference is less than the preset threshold, the entropy loss of the facial key point is calculated according to the following formula:
[0118]
[0119] Wherein, ω, α, ∈ are the model parameters of the basic face key point detection model, y is the predicted coordinate of each face key point, is the true coordinate of each facial key point. Here, for the case where the difference between the predicted coordinates and the true coordinates of the facial key points is small, a nonlinear loss function is used for prediction, which can increase the impact on small errors. Model parameters are configuration variables within the model. When the basic facial key point detection model is trained with face image samples, the model parameters ω, α, ∈ are adjusted, that is, the model parameters change each time the training is performed to reduce the difference between the predicted coordinates and the true coordinates of the facial key points. The preset threshold can be set according to the actual model training accuracy requirements.
[0120] Here, if the absolute difference is greater than or equal to the preset threshold, the entropy loss of the facial key point is calculated according to the following formula:
[0121]
[0122] in, y is the predicted coordinate of each facial key point, is the true coordinate of each facial key point, ω, α, ∈ are the model parameters of the basic facial key point detection model, and θ is the preset threshold. Here, for the case where the difference between the predicted coordinates and the true coordinates of the facial key points is large, a linear loss function is used for prediction, and the linear loss is sufficient to make the training converge to the predicted position. The model parameters are configuration variables inside the model. When the basic facial key point detection model is trained with face image samples, the model parameters ω, α, ∈ are adjusted, that is, each time the training is performed, the model parameters will change to achieve the purpose of reducing the difference between the predicted coordinates and the true coordinates of the facial key points.
[0123] It should be noted that each time the basic face key point detection model is trained with a face image sample, the model parameters of the basic face key point detection model will be adjusted. Here, ω, α, ∈ can be adjusted, and the above loss function is an adaptive wing loss function.
[0124] Step 1032: The first cross entropy is adjusted according to the calculation weight of each face image sample to obtain a second cross entropy of each face image sample.
[0125] In a specific implementation, after calculating the calculation weights of each face image sample and the first cross entropy of each face image sample, the first cross entropy is adjusted by the calculation weights to obtain the second cross entropy of each face image sample. In this way, the calculation weights can balance the data, so that the diversity of the face structure can be evenly learned by the face key point detection model.
[0126] Step 1033: Adjust the model parameters of the basic facial key point detection model according to the second cross entropy of each facial image sample.
[0127] In a specific implementation, during the training process of the basic facial key point detection model through each facial image sample, the model parameters of the basic facial key point detection model can be adjusted according to the second cross entropy of each facial image sample.
[0128] Here, the process of training the basic face key point detection model by obtaining multiple face image samples is explained:
[0129] Any face image sample in the face image samples that have not participated in the model training in this round is used as the current image sample, and the first cross entropy of the current image sample is determined according to the predicted coordinates and actual coordinates of each face key point in the current image sample; the first cross entropy is adjusted according to the calculated weight of each face key point of the current image sample to determine the second cross entropy of the current image sample; according to the second cross entropy of the current image sample in this round, the model parameters of the basic face key point detection model are adjusted; the current image sample is used as the image sample participating in the model training in this round, and the step of determining the current image sample is returned until all image samples in the multiple face image samples obtained have completed the training of this round.
[0130] Here, multiple rounds of training process can be set, and multiple face image samples need to be obtained in each round. The basic key point detection model is trained by the multiple face image samples obtained in each round. Here, at the end of each round of training, the average cross entropy of the multiple face image samples participating in the model training in this round is determined, and whether to terminate the training of the basic face key point detection model is determined according to whether the average cross entropy converges, and then, the target face key point detection model that can perform face key point detection is obtained, that is, after the second cross entropy of each face image sample is obtained, the following steps are also included:
[0131] According to the second cross entropy of each face image sample in the multiple face image samples obtained, the average cross entropy of the multiple face image samples is determined; when the average cross entropy meets the convergence condition, the training of the basic face key point detection model is stopped.
[0132] Here, the average cross entropy is calculated as follows:
[0133]
[0134] Among them, Loss is the average cross entropy of N face image samples, c is the sample category, and C is the number of sample categories. is the degree of uniqueness of face image sample n in sample category c, k is the key point of the face, represents the entropy loss of facial key point k, K is the number of facial key points in face image sample n, is the true coordinate of the facial key point k in the face image sample n, is the predicted coordinates of the facial key point k in the face image sample n.
[0135] Here, a convergence threshold may be pre-set, and when the average cross entropy is less than or equal to the convergence threshold, it is determined that the average cross entropy meets the convergence condition, and the training of the basic face key point detection model is stopped.
[0136] In an embodiment of the present application, the calculation weight of each face image sample can be determined according to the degree of specialness of at least one sample category in which each face image sample belongs, and each face image sample is input into the basic face key point detection model, and the predicted coordinates of the face key points in each face image sample can be determined. Further, the basic face key point detection model is trained according to the predicted coordinates and actual coordinates of the face key points in each face image sample, and the calculation weight of the face image sample. Based on the above method, when the model is trained using face image samples, the calculation weights are assigned to the face image samples according to the degree of specialness of the face image samples, so that the model can learn the diverse face structures in a balanced manner, and thus the accuracy of face key point detection can be improved.
[0137] Figure 2 This is a flow chart of the method for detecting key points of a face provided in an embodiment of the present application. Figure 2 As shown, the method for detecting key points of a face provided in an embodiment of the present application comprises the following steps:
[0138] S201: Acquire a face image to be detected;
[0139] S202: Inputting the face image to be detected into a trained face key point detection model to obtain the coordinates of the face key points in the face image to be detected.
[0140] In the embodiment of the present application, when the model is trained using face image samples, calculation weights are assigned to the face image samples according to their special degree, so that the model can learn the diverse face structures in a balanced manner, thereby making the above-mentioned Figure 1 The target face key point detection model obtained by the training method of the face key point detection model shown in the figure detects key points of face images, which can improve the accuracy of face key point detection.
[0141] Based on the same application concept, the embodiments of the present application also provide a training device for a facial key point detection model corresponding to the training method for a facial key point detection model provided in the above embodiments. Since the principle of solving the problem by the device in the embodiments of the present application is similar to the training method for a facial key point detection model in the above embodiments of the present application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0142] like Figures 3 to 6 As shown, Figure 3 One of the functional module diagrams of a training device 300 for a facial key point detection model provided in an embodiment of the present application, Figure 4 Shows Figure 3 The functional module diagram of the training module 330 in FIG. Figure 5FIG2 shows a second functional module diagram of a training device 300 for a facial key point detection model provided in an embodiment of the present application. Figure 6 Shows Figure 4 Functional module diagram of the first determination unit 331 in .
[0143] like Figure 3 As shown, the training device 300 of the face key point detection model includes:
[0144] A first determination module 310 is used to determine, for each face image sample among the acquired multiple face image samples, a calculation weight of each face image sample according to a special degree of at least one sample category to which each face image sample belongs;
[0145] A second determination module 320, for inputting each face image sample into a basic face key point detection model to determine predicted coordinates of face key points in each face image sample;
[0146] The training module 330 is used to train the basic facial key point detection model according to the predicted coordinates and the real coordinates of the facial key points in each facial image sample and the calculated weights of each facial image sample.
[0147] In a possible implementation manner, the sample category includes at least one of the following categories:
[0148] The degree of face frontality, degree of exaggerated expression, degree of lighting, degree of makeup, degree of occlusion, and degree of image clarity.
[0149] In a possible implementation, Figure 3 As shown, for each sample category in the at least one sample category, the first determination module 310 is further used to determine the special degree of each sample category to which each face image sample belongs according to the following steps:
[0150] Counting the target number of face image samples having target image features among the multiple face image samples obtained, and the total number of face image samples in the multiple face image samples; wherein the target image features are features of each face image sample under each sample category;
[0151] The special degree of each sample category to which each face image sample belongs is determined according to the total number and the target number.
[0152] In a possible implementation, Figure 3 As shown, the first determination module 310 is specifically used to determine the calculation weight of each face image sample according to the following steps:
[0153] The calculation weight of each face image sample is determined according to the special degree corresponding to each sample category in the at least one sample category to which each face image sample belongs.
[0154] In a possible implementation, Figure 4 As shown, the training module 330 includes:
[0155] A first determining unit 331 is used to determine a first cross entropy of each face image sample according to the predicted coordinates and the true coordinates of the face key points in each face image sample;
[0156] A second determining unit 332, configured to adjust the first cross entropy according to the calculation weight of each face image sample to obtain a second cross entropy for each face image sample;
[0157] The adjusting unit 333 is used to adjust the model parameters of the basic facial key point detection model according to the second cross entropy of each facial image sample.
[0158] In a possible implementation, Figure 5 As shown, the training device 300 for the facial key point detection model further includes a stop module 340; the stop module 340 is used to stop the training of the basic facial key point detection model according to the following steps:
[0159] Determining an average cross entropy of the plurality of facial image samples according to the acquired second cross entropy of each facial image sample in the plurality of facial image samples;
[0160] When the average cross entropy meets a convergence condition, the training of the basic facial key point detection model is stopped.
[0161] In a possible implementation, Figure 6 As shown, the first determining unit 331 includes:
[0162] The calculation subunit 3311 is used to calculate the absolute difference between the predicted coordinates and the true coordinates of each facial key point in each facial image sample, and calculate the entropy loss of each facial key point according to a calculation formula matching the absolute difference;
[0163] The determination subunit 3312 is used to determine the first cross entropy of each face image sample according to the entropy loss of each face key point in each face image sample.
[0164] In a possible implementation, if the absolute difference is less than a preset threshold, the calculation formula matching the absolute difference is:
[0165]
[0166] Wherein, ω, α, ∈ are the model parameters of the basic face key point detection model, y is the predicted coordinate of each face key point, is the real coordinate of each facial key point.
[0167] In a possible implementation, if the absolute difference is greater than or equal to a preset threshold, the calculation formula matching the absolute difference is:
[0168]
[0169] in, y is the predicted coordinate of each facial key point, is the real coordinate of each facial key point, ω, α, ∈ are the model parameters of the basic facial key point detection model, and θ is the preset threshold.
[0170] In an embodiment of the present application, the calculation weight of each face image sample can be determined according to the degree of specialness of at least one sample category in which each face image sample belongs, and each face image sample is input into the basic face key point detection model, and the predicted coordinates of the face key points in each face image sample can be determined. Further, the basic face key point detection model is trained according to the predicted coordinates and actual coordinates of the face key points in each face image sample, and the calculation weight of the face image sample. Based on the above method, when the model is trained using face image samples, the calculation weights are assigned to the face image samples according to the degree of specialness of the face image samples, so that the model can learn the diverse face structures in a balanced manner, and thus the accuracy of face key point detection can be improved.
[0171] Figure 7 A functional module diagram of a facial key point detection device 700 provided in an embodiment of the present application, wherein the facial key point detection device 700 includes:
[0172] An acquisition module 710 is used to acquire a face image to be detected;
[0173] The determination module 720 is used to input the face image to be detected into the face key point detection model trained by the training device of the face key point detection model described in any of the above implementations to obtain the coordinates of the face key points in the face image to be detected.
[0174] In an embodiment of the present application, when using facial image samples to train the model, calculation weights are assigned to the facial image samples according to their degree of specialness. In this way, the model can learn diverse facial structures in a balanced manner. Furthermore, the trained target facial key point detection model can be used to detect key points of facial images, thereby improving the accuracy of facial key point detection.
[0175] Based on the same application concept, see Figure 8 As shown, it is a structural schematic diagram of an electronic device 800 provided in an embodiment of the present application, including: a processor 810, a memory 820 and a bus 830, the memory 820 stores machine-readable instructions executable by the processor 810, when the electronic device 800 is running, the processor 810 and the memory 820 communicate through the bus 830, and the machine-readable instructions are executed by the processor 810 when running to execute the steps of the training method of the facial key point detection model as described in any of the above embodiments, and / or execute the steps of the detection method of the facial key points as described in any of the above embodiments.
[0176] Specifically, when the machine-readable instruction is executed by the processor 810, the following processing may be performed:
[0177] For each of the acquired multiple face image samples, determining a calculation weight for each face image sample according to a degree of particularity of at least one sample category to which each face image sample belongs;
[0178] Input each face image sample into the basic face key point detection model to determine the predicted coordinates of the face key points in each face image sample;
[0179] The basic facial key point detection model is trained according to the predicted coordinates and the real coordinates of the facial key points in each facial image sample and the calculated weights of each facial image sample.
[0180] In the embodiment of the present application, the calculation weight of each face image sample can be determined according to the degree of specialness of at least one sample category in which each face image sample belongs, and each face image sample is input into the basic face key point detection model, and the predicted coordinates of the face key points in each face image sample can be determined. Further, the basic face key point detection model is trained according to the predicted coordinates and actual coordinates of the face key points in each face image sample, and the calculation weight of the face image sample. Based on the above method, when the model is trained using face image samples, the calculation weights are assigned to the face image samples according to the degree of specialness of the face image samples, so that the model can learn the diverse face structures in a balanced manner, and then the accuracy of face key point detection can be improved.
[0181] Based on the same application concept, an embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, the steps of the training method of the facial key point detection model provided in the above embodiment are executed, and / or the steps of the facial key point detection method as described in any of the above embodiments are executed.
[0182] Specifically, the storage medium can be a general storage medium, such as a mobile disk, a hard disk, etc. When the computer program on the storage medium is run, the training method of the above-mentioned facial key point detection model can be executed. By assigning calculation weights to the facial image samples according to the special degree of the facial image samples, the model can learn diverse facial structures in a balanced manner, thereby improving the accuracy of facial key point detection.
[0183] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0184] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0185] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0186] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program codes.
[0187] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A training method for a facial key point detection model, characterized in that: The training method comprises: For each face image sample among the acquired multiple face image samples, determining a calculation weight for each face image sample according to a special degree of at least one sample category to which each face image sample belongs; Input each face image sample into the basic face key point detection model to determine the predicted coordinates of the face key points in each face image sample; Training the basic facial key point detection model according to the predicted coordinates and the true coordinates of the facial key points in each facial image sample and the calculated weights of each facial image sample; The basic facial key point detection model is trained according to the predicted coordinates and the real coordinates of the facial key points in each facial image sample and the calculated weight of each facial image sample, including: Determine the first cross entropy of each face image sample according to the predicted coordinates and the true coordinates of the face key points in each face image sample; The first cross entropy is adjusted according to the calculation weight of each face image sample to obtain a second cross entropy of each face image sample; According to the second cross entropy of each face image sample, the model parameters of the basic face key point detection model are adjusted.
2. The training method according to claim 1, characterized in that: The sample category includes at least one of the following categories: The degree of face frontality, degree of exaggerated expression, degree of lighting, degree of makeup, degree of occlusion, and degree of image clarity.
3. The training method according to claim 1, characterized in that: For each sample category in the at least one sample category, the special degree of each sample category to which each face image sample belongs is determined according to the following steps: Counting the target number of face image samples having target image features among the multiple face image samples obtained, and the total number of face image samples in the multiple face image samples; wherein the target image features are features of each face image sample under each sample category; The special degree of each sample category to which each face image sample belongs is determined according to the total number and the target number.
4. The training method according to claim 1, characterized in that: The step of determining the calculation weight of each face image sample according to the degree of particularity of at least one sample category to which each face image sample belongs comprises: The calculation weight of each face image sample is determined according to the special degree corresponding to each sample category in the at least one sample category to which each face image sample belongs.
5. The training method according to claim 1, characterized in that: After obtaining the second cross entropy of each face image sample, the training method further includes: Determining an average cross entropy of the plurality of facial image samples according to the acquired second cross entropy of each facial image sample in the plurality of facial image samples; When the average cross entropy meets a convergence condition, the training of the basic facial key point detection model is stopped.
6. The training method according to claim 1, characterized in that: Determining the first cross entropy of each face image sample according to the predicted coordinates and the true coordinates of the face key points in each face image sample includes: For each facial key point in each facial image sample, calculate the absolute difference between the predicted coordinates and the true coordinates of each facial key point, and calculate the entropy loss of each facial key point according to a calculation formula matching the absolute difference; According to the entropy loss of each facial key point in each facial image sample, a first cross entropy of each facial image sample is determined.
7. The training method according to claim 6, characterized in that: If the absolute difference is less than the preset threshold, the calculation formula matching the absolute difference is: Wherein, ω, α, ∈ are the model parameters of the basic face key point detection model, y is the predicted coordinate of each face key point, is the real coordinate of each facial key point.
8. The training method according to claim 6, characterized in that: If the absolute difference is greater than or equal to the preset threshold, the calculation formula matching the absolute difference is: in, y is the predicted coordinate of each facial key point, is the real coordinate of each facial key point, ω, α, ∈ are the model parameters of the basic facial key point detection model, and θ is the preset threshold.
9. A method for detecting key points of a face, characterized in that: The detection method comprises: Get the face image to be detected; The face image to be detected is input into a face key point detection model trained by the face key point detection model training method described in any one of claims 1 to 8 to obtain the coordinates of the face key points in the face image to be detected.
10. A training device for a facial key point detection model, characterized in that: The training device comprises: A first determination module is used to determine, for each face image sample among the acquired multiple face image samples, a calculation weight of each face image sample according to a special degree of at least one sample category to which each face image sample belongs; A second determination module is used to input each face image sample into a basic face key point detection model to determine the predicted coordinates of the face key points in each face image sample; A training module, used for training the basic facial key point detection model according to the predicted coordinates and the real coordinates of the facial key points in each facial image sample and the calculated weights of each facial image sample; The training module includes: A first determination unit, used for determining a first cross entropy of each face image sample according to the predicted coordinates and the true coordinates of the face key points in each face image sample; a second determining unit, configured to adjust the first cross entropy according to the calculation weight of each face image sample to obtain a second cross entropy for each face image sample; The adjusting unit is used to adjust the model parameters of the basic facial key point detection model according to the second cross entropy of each facial image sample.
11. A device for detecting key points of a face, characterized in that: The detection device comprises: An acquisition module is used to acquire a face image to be detected; The determination module is used to input the face image to be detected into the face key point detection model trained by the training device of the face key point detection model described in claim 10 to obtain the coordinates of the face key points in the face image to be detected.
12. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate through the bus, and when the machine-readable instructions are run by the processor, the steps of the training method for the facial key point detection model as described in any one of claims 1 to 8 are executed, and / or the steps of the method for detecting facial key points as described in claim 9 are executed.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the computer program executes the steps of the training method of the facial key point detection model as described in any one of claims 1 to 8, and / or executes the steps of the facial key point detection method as described in claim 9.
