Face attribute detection method, device, storage medium, and terminal

By determining whether the face images in the current frame and the previous frame belong to the same person, and performing smoothing and weight calculation, the problem of unstable face attribute detection results is solved, and more stable and accurate detection results are achieved.

CN114627345BActive Publication Date: 2025-09-05RDA MICROELECTRONICS BEIJING
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210254925.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-15
Publication Date
2025-09-05
Estimated Expiration
2042-03-15

AI Technical Summary

Technical Problem

The facial attribute detection results in the existing technology are unstable and easily affected by factors such as facial posture and lighting environment.

Method used

By judging whether the face image of the current frame and the face image of the previous frame belong to the same person, if so, the face attribute information of the current frame is smoothed, the identity consistency is judged using the identity feature vector and error threshold, and a weight-based calculation is performed to determine the face attribute result.

Benefits of technology

The stability of facial attribute detection is improved, the sudden change of facial attribute results for the same person is reduced, and the accuracy and stability of the detection results are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114627345B_ABST
    Figure CN114627345B_ABST
Patent Text Reader

Abstract

A method and device for detecting facial attributes, a storage medium, and a terminal are disclosed. The method comprises: obtaining a facial image of a current frame; performing facial attribute detection on the facial image of the current frame to obtain facial attribute information of the current frame; determining whether the facial image of the current frame and the facial image of the previous frame belong to the same person; if so, smoothing the facial attribute information of the current frame based on the facial attribute information of the previous frame, and determining the facial attribute results of the current frame based on the smoothing results. The solution provided by the present invention can make facial attribute detection results more stable.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to a method and device for detecting facial attributes, a storage medium, and a terminal. Background Art

[0002] With the development of image processing technology, techniques for detecting facial attributes from facial images have emerged. For example, a person's age and gender can be identified based on facial images. However, existing techniques for detecting facial attributes in video streams can easily lead to unstable detection results. Therefore, there is an urgent need for a facial attribute detection method that can improve the stability of facial attribute detection results. Summary of the Invention

[0003] The technical problem solved by the present invention is how to improve the stability of face attribute detection results.

[0004] To solve the above technical problems, an embodiment of the present invention provides a method for detecting facial attributes, which includes: obtaining a facial image of a current frame; performing facial attribute detection on the facial image of the current frame to obtain facial attribute information of the current frame; judging whether the facial image of the current frame and the facial image of the previous frame belong to the same person; if so, smoothing the facial attribute information of the current frame according to the facial attribute information of the previous frame, and determining the facial attribute result of the current frame according to the processing result.

[0005] Optionally, determining whether the facial image of the current frame and the facial image of the previous frame belong to the same person includes: performing facial recognition on the facial image of the current frame to obtain an identity feature vector of the current frame; obtaining the identity feature vector of the previous frame; calculating a feature distance between the identity feature vector of the current frame and the identity feature vector of the previous frame; and determining whether the feature distance is less than a preset distance threshold; if so, determining that the facial image of the current frame and the facial image of the previous frame belong to the same person; otherwise, determining that they do not belong to the same person.

[0006] Optionally, the facial attribute information is a facial attribute feature or a facial attribute result.

[0007] Optionally, the type of the facial attribute result is a continuous numerical type, and smoothing the facial attribute information of the previous frame and the facial attribute information of the current frame includes: performing a weight-based calculation on the facial attribute result of the previous frame and the facial attribute result of the current frame to obtain the processing result.

[0008] Optionally, the error between the facial attribute result of the current frame and the facial attribute result of the previous frame is calculated and recorded as the current error; whether the current error is greater than or equal to a first preset error threshold is determined, and if so, whether the facial image of the next frame and the facial image of the current frame belong to the same person; if the facial image of the next frame and the facial image of the current frame belong to the same person, the facial attribute result of the next frame and the facial attribute result of the current frame are calculated based on weights to obtain the processing result.

[0009] Optionally, the type of the facial attribute result is a discrete numerical type, and smoothing the facial attribute information of the current frame based on the facial attribute information of the previous frame includes: calculating the error between the facial attribute result of the current frame and the facial attribute result of the previous frame, recorded as the current error; calculating the sum of the cumulative error and the current error, and taking the sum as the cumulative error; judging whether the cumulative error is less than a third preset error threshold, if so, taking the facial attribute result of the previous frame as the processing result, otherwise taking the facial attribute result of the current frame as the processing result and clearing the cumulative error.

[0010] Optionally, before calculating the sum of the cumulative error and the current error, the method also includes: determining whether the current error is greater than or equal to a fourth preset error threshold, and if so, determining whether the facial image of the next frame and the facial image of the current frame belong to the same person; if the facial image of the next frame and the facial image of the current frame belong to the same person and the error between the facial attribute result of the next frame and the facial attribute result of the current frame is less than the fourth preset error threshold, then taking the facial attribute result of the current frame as the processing result.

[0011] Optionally, the facial attribute information is the facial attribute features, and smoothing the facial attribute information of the current frame based on the facial attribute information of the previous frame includes: fusing the facial attribute features of the previous frame and the facial attribute features of the current frame to obtain the processing result.

[0012] In order to solve the above-mentioned technical features, an embodiment of the present invention also provides a facial attribute detection device, which includes: an acquisition module for acquiring a facial image of the current frame; a detection module for performing facial attribute detection on the facial image of the current frame to obtain facial attribute information of the current frame; a post-processing module for determining whether the facial image of the current frame and the facial image of the previous frame belong to the same person. If so, the facial attribute information of the current frame is smoothed according to the facial attribute information of the previous frame, and the facial attribute result of the current frame is determined according to the processing result.

[0013] An embodiment of the present invention further provides a storage medium storing a computer program. When the computer program is executed by a processor, the computer program executes the steps of the above-mentioned method for detecting facial attributes.

[0014] An embodiment of the present invention further provides a terminal comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and the processor executes the steps of the above-mentioned facial attribute detection method when running the computer program.

[0015] Compared with the prior art, the technical solution of the embodiment of the present invention has the following beneficial effects:

[0016] In the embodiment of the present invention, after calculating the facial attribute information of the current frame, a determination is made as to whether the facial image in the current frame and the facial image in the previous frame belong to the same person. Because facial attributes refer to the physiological attributes of the subject, which are inherently stable and subject to individual differences, if the facial image in the current frame and the facial image in the previous frame belong to the same person, the facial attribute information of the current frame is smoothed, and the facial attribute results for the current frame are determined based on the processing results. This approach can reduce the occurrence of sudden changes in the facial attribute results for the same person, thereby improving the stability of facial attribute detection.

[0017] Furthermore, in the solution of this embodiment, the type of facial attribute result is a continuous numerical type. Before performing a weight-based calculation on the facial attribute results of the previous frame and the facial attribute results of the current frame, the error between the facial attribute results of the previous frame and the facial attribute results of the current frame is calculated and recorded as the current error. If the current error is greater than or equal to a first preset error threshold, it is determined whether the facial image of the next frame and the facial image of the current frame belong to the same person. If the facial image of the next frame and the facial image of the current frame belong to the same person, the facial attribute results of the next frame and the facial attribute results of the current frame are calculated based on the weights to obtain the processing result. By adopting such a solution, the facial attribute results of the same subject can be made more stable, and the situation where the facial attribute results of different subjects are mistakenly regarded as the facial attribute results of the same subject when identity recognition is wrong can be reduced, thereby taking into account the stability and accuracy of the detection results of numerical attributes.

[0018] Furthermore, in the solution of this embodiment, the type of facial attribute result is a discrete numerical type, and smoothing the facial attribute information of the previous frame and the facial attribute information of the current frame includes: calculating the error between the facial attribute result of the previous frame and the facial attribute result of the current frame, recording it as the current error; calculating the sum of the cumulative error and the current error, and taking the sum as the cumulative error; judging whether the cumulative error is less than a third preset error threshold, if so, taking the facial attribute result of the previous frame as the processing result, otherwise taking the facial attribute result of the current frame as the processing result and clearing the cumulative error. By adopting such a solution, the facial attribute results of the same subject can be made more stable, and the situation where the facial attribute results of different subjects are mistakenly regarded as the facial attribute results of the same subject in the event of identity recognition errors can be reduced, thereby taking into account the stability and accuracy of the detection results of category-type attributes. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 1 is a flow chart of a method for detecting facial attributes according to an embodiment of the present invention;

[0020] Figure 2 It is a structural diagram of a facial attribute detection device in an embodiment of the present invention. DETAILED DESCRIPTION

[0021] As described in the background art, there is an urgent need for a facial attribute detection method to improve the stability of facial attribute detection results.

[0022] Research has found that existing facial attribute detection technologies are susceptible to instability due to factors such as facial posture and lighting conditions. For example, when detecting age, the detected age can fluctuate significantly due to changes in the subject's posture, such as looking up or down.

[0023] In order to solve the above technical problems, an embodiment of the present invention provides a method for detecting facial attributes. In the scheme of the embodiment of the present invention, after calculating the facial attribute information of the current frame, it is determined whether the facial image of the current frame and the facial image of the previous frame belong to the same person. Since facial attributes refer to the physiological attributes of the person being photographed, which have the characteristics of inherent stability and individual differences, if the facial image of the current frame and the facial image of the previous frame belong to the same person, the facial attribute information of the current frame is smoothed, and the facial attribute results of the current frame are determined based on the processing results. Adopting such a scheme can reduce the occurrence of sudden changes in the facial attribute results of the same person, which is conducive to improving the stability of facial attribute detection.

[0024] In order to make the above-mentioned objects, features and beneficial effects of the present invention more obvious and easy to understand, specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0025] Reference Figure 1 , Figure 1 The following is a flow chart illustrating a method for detecting facial attributes according to an embodiment of the present invention. The method can be executed by a terminal, which can be any existing terminal device capable of receiving and processing data, such as, but not limited to, a mobile phone, a computer, an IoT device, or a server. By implementing the solution of this embodiment of the present invention, the variation in attribute detection results for the same person over a short period of time can be reduced, thereby making the facial attribute detection results in the video stream more stable and improving the user experience.

[0026] It should be noted that the solution in this embodiment is used to detect facial attributes in a video stream, where the video stream contains a facial image of the subject. The facial attributes refer to the physiological attributes of the subject and are not limited to the attributes of the subject's face. Specifically, the facial attributes in this embodiment have the characteristics of inherent stability and individual differences. More specifically, the facial attributes of the same person will not mutate in a short period of time. For example, they may be age, skin color, and gender, but are not limited to these. In other words, facial attributes that may mutate in a short period of time are not the facial attributes to be detected by the embodiments of the present invention, such as posture, expression, whether the face is obstructed, whether glasses are worn, etc.

[0027] Figure 1 The method for detecting facial attributes shown may include:

[0028] Step S101: Acquire the face image of the current frame;

[0029] Step S102: performing facial attribute detection on the facial image of the current frame to obtain facial attribute information of the current frame;

[0030] Step S103: Determine whether the facial image of the current frame and the facial image of the previous frame belong to the same person. If so, smooth the facial attribute information of the current frame based on the facial attribute information of the previous frame, and determine the facial attribute result of the current frame based on the processing result.

[0031] It is understandable that, in a specific implementation, the method can be implemented in the form of a software program, which runs in a processor integrated inside a chip or chip module; or, the method can be implemented in the form of hardware or a combination of hardware and software.

[0032] In the specific implementation of step S101, the face image of the current frame can be obtained from the video stream. The video stream can be a video being recorded or a video stream that has been recorded, which is not limited in this embodiment.

[0033] In a specific implementation, images may be extracted from the video stream at preset time intervals, and the currently extracted image may be recorded as the current frame, the previously extracted image as the previous frame, and the next extracted image as the next frame.

[0034] Furthermore, the video stream may include an image of the person being filmed. After each image is extracted, it can be determined whether the image contains a face region. If so, the face region in the image can be extracted to obtain a face image. Specifically, face detection can be performed on the extracted image to obtain a face detection result, which can be used to indicate whether the image contains a face. It should be noted that the solution of this embodiment is not limited to every captured image frame containing a face.

[0035] In the specific implementation of step S102, facial attribute detection can be performed on the facial image of the current frame to obtain facial attribute information of the current frame. The facial attribute information can be facial attribute features or facial attribute results. Facial attribute features refer to characteristic parameters used to describe facial features, such as feature vectors obtained by a facial attribute detection algorithm. Facial attribute results refer to recognition results obtained after calculation based on facial attribute features. The recognition results can be values ​​describing various dimensions of a face, such as age, gender, and other dimensions.

[0036] In a specific example, the facial image of the current frame may be input into a pre-trained attribute detection model to obtain facial attribute information of the current frame.

[0037] More specifically, the attribute detection model can be obtained by pre-training a first preset model using first training data, wherein the first training data can include multiple facial images, each facial image has an attribute label, and the attribute label can be used to indicate the facial attributes in the facial image. The method of training the first preset model using the first training data can be various existing appropriate training methods, and this embodiment does not limit this. When the pre-set training end condition is met, the attribute detection model can be obtained. The pre-set training end condition can also be various existing appropriate training end conditions, for example, the batch of training data reaches a first preset value, the error rate is less than a second preset value, etc., but is not limited to this.

[0038] Furthermore, the trained attribute detection model may include: a first feature extraction module and a prediction module. The first feature extraction module may be used to extract a feature vector of a facial image. In other words, the input of the first feature extraction module may be a facial image, and the output may be a feature vector. The output of the first feature extraction module may be recorded as a facial attribute feature. The prediction module may be used to calculate the detection result of the facial attribute based on the facial attribute features output by the first feature extraction module, and record it as a facial attribute result. In other words, the input of the prediction module may be a facial attribute feature, and the output may be a facial attribute result. In a specific embodiment, the facial attribute information in step S102 may refer to: a facial attribute result.

[0039] In other embodiments, the facial attribute information in step S102 may also be: facial attribute features. In other words, the facial attribute information may also refer to the feature vector used to calculate the facial attribute result, that is, the facial attribute information may also be facial attribute features.

[0040] In the specific implementation of step S103 , it can be determined whether the face image in the current frame and the face image in the previous frame belong to the same person.

[0041] In a specific implementation, before executing step S103, the face detection result of the previous frame and the face detection result of the current frame can be obtained first. The face detection result of the previous frame can be used to indicate whether the previous frame contains a face image, and the face detection result of the current frame can be used to indicate whether the current frame contains a face image. If the previous frame does not contain a face image and the current frame contains a face image, the face attribute result of the current frame can be determined based only on the face attribute information in step S102. With such a solution, if the previous frame does not contain a face image and the current frame contains a face image, it can be determined that the subject of the current frame is not the same person as the previous subject, and changes in the subject can be accurately identified.

[0042] It should be noted that, in the solution of this embodiment, determining the facial attribute result of the current frame based solely on the facial attribute information obtained in step S102 may include: if the facial attribute information is a facial attribute result, then the facial attribute information obtained in step S102 may be used as the facial attribute result of the current frame image. If the facial attribute information is a facial attribute feature, then the facial attribute result of the current frame may be calculated solely based on the facial attribute features of the current frame. For example, the facial attribute features of the current frame may be input into the above-mentioned prediction module to obtain the facial attribute result of the current frame.

[0043] Furthermore, if the previous frame contains a face image and the current frame contains a face image, the identity information of the previous frame can be obtained, and the face image of the current frame can be recognized to obtain the identity information of the current frame. By comparing the identity information of the previous frame with the identity information of the current frame, it can be determined whether the face image of the previous frame and the face image of the current frame belong to the same person.

[0044] In a specific implementation, the identity information may be an identity feature vector. The facial image of the current frame may be input into a pre-trained facial recognition model to obtain the identity feature vector of the current frame. Furthermore, the identity feature vector of the current frame may be saved to facilitate subsequent determination of whether the facial image of the next frame and the facial image of the current frame belong to the same person.

[0045] Specifically, the facial recognition model can be obtained by pre-training a second preset model using second training data. The second training data can include multiple facial images, each facial image having an identity tag, and the identity tag can be used to indicate the identity of the person photographed in the facial image. The method for training the second preset model using the second training data can be various existing appropriate training methods, and this embodiment is not limited to this. When the preset training end conditions are met, the facial recognition model can be obtained.

[0046] Furthermore, the trained face recognition model can include a second feature extraction module, where the input of the second feature extraction module can be a face image, and the output can be a face identity feature. In other words, the second feature extraction module can be used to extract a feature vector from the face image. The feature vector extracted by the second feature extraction module can be recorded as an identity feature vector, which can be used to determine the identity of the subject corresponding to the face image.

[0047] Furthermore, the identity feature vector of the previous frame can be obtained, and the feature distance between the identity feature vector of the current frame and the identity feature vector of the previous frame can be calculated, which can be recorded as the first feature distance. The first feature distance can be Euclidean distance, cosine distance, etc., which is not limited in this embodiment.

[0048] Furthermore, it can be determined whether the first feature distance is less than a preset distance threshold. If so, it can be determined that the face image of the current frame and the face image of the previous frame belong to the same person; if the feature distance is greater than or equal to the preset distance threshold, it can be determined that the face image of the current frame and the face image of the previous frame do not belong to the same person.

[0049] Furthermore, if the facial image of the current frame and the facial image of the previous frame do not belong to the same person, the facial attribute result of the current frame can be determined based solely on the facial attribute information obtained in step S102. If the facial image of the current frame and the facial image of the previous frame belong to the same person, the facial attribute information of the current frame can be smoothed, and the facial attribute result of the current frame can be determined based on the smoothing result.

[0050] Specifically, if the facial attribute information is a facial attribute result, the processing result can be directly used as the facial attribute result of the current frame and output; if the facial attribute information is a facial attribute feature, the processing result is also a facial attribute feature, and the processing result can be further calculated to obtain the facial attribute result of the current frame and output.

[0051] In the solution of this embodiment, if the facial attribute information is a facial attribute result, different smoothing methods can be used for different types of attributes. In specific implementations, facial attribute results are typically expressed in numerical form. For example, age can be expressed numerically; for another example, gender can be expressed numerically, with a facial attribute result of 0 indicating male gender and a facial attribute result of 1 indicating female gender.

[0052] Furthermore, the values ​​of facial attribute results have different characteristics depending on the attribute type. Specifically, facial attribute results can be continuous numerical or discrete numerical. A continuous numerical facial attribute result can correspond to a numerical attribute, and a continuous numerical facial attribute result can be used to indicate the size of the numerical attribute. A discrete numerical facial attribute result can correspond to a categorical attribute, and a discrete numerical facial attribute result can indicate the category of the categorical attribute. For example, a numerical attribute can be age, body temperature, etc. For another example, a categorical attribute can be gender, skin color, etc.

[0053] On the one hand, if the type of the facial attribute result is a continuous numerical type, the facial attribute result of the previous frame and the facial attribute result of the current frame can be calculated based on weights to obtain a processing result, and then the processing result can be used as the facial attribute result of the current frame.

[0054] In a non-limiting example, the facial attribute results of the previous frame and the facial attribute results of the current frame can be weighted and summed to obtain a processing result. For example, the weight of the facial attribute results of the previous frame and the weight of the facial attribute results of the current frame can both be 0.5, but this is not limited to this. In other embodiments, the sum of the weight of the facial attribute results of the previous frame and the weight of the facial attribute results of the current frame is 1, and the weight of the facial attribute results of the previous frame can be greater than the weight of the facial attribute results of the current frame. Adopting such a solution can reduce the occurrence of sudden changes in facial attribute results, which is conducive to making the detection results of numerical attributes more stable.

[0055] In another non-limiting example, before performing weight-based calculation on the facial attribute results of the previous frame and the facial attribute results of the current frame, the error between the facial attribute results of the current frame and the facial attribute results of the previous frame can be calculated and recorded as the current error.

[0056] Furthermore, it can be determined whether the current error is greater than or equal to a first preset error threshold. If the current error is less than the first preset error threshold, a weighted calculation can be performed on the facial attribute results of the previous frame and the facial attribute results of the current frame. If the current error is greater than or equal to the first preset error threshold, it can be determined that there may be an error in the identity comparison, that is, the facial image of the current frame and the facial image of the previous frame may not belong to the same person.

[0057] Furthermore, if the current error is greater than or equal to the first preset error threshold, a facial image of the next frame may be acquired, and facial attribute information and an identity feature vector for the next frame may be acquired. For more information on acquiring facial attribute information and an identity feature vector for the next frame, please refer to the above description regarding acquiring facial attribute information and an identity feature vector for the current frame, and will not be repeated here.

[0058] Furthermore, a determination is made as to whether the facial image in the next frame and the facial image in the current frame belong to the same person. Specifically, a characteristic distance between the identity feature vector of the next frame and the identity feature vector of the current frame can be calculated, which can be recorded as a second characteristic distance. If the second characteristic distance is less than a preset distance threshold, it can be determined that the facial image in the next frame and the facial image in the current frame belong to the same person. For more information on the second characteristic distance, please refer to the above description of the first characteristic distance and will not be repeated here.

[0059] Furthermore, if the facial image of the next frame and the facial image of the current frame belong to the same person, a weight-based calculation is performed on the facial attribute result of the next frame and the facial attribute result of the current frame to obtain the processing result.

[0060] In a specific implementation, it can be determined whether the error between the facial attribute results of the next frame image and the facial attribute results of the current frame is less than a second preset error threshold. If the error between the facial attribute results of the next frame image and the facial attribute results of the current frame is less than the second preset error threshold, a weighted calculation can be performed based on the facial attribute results of the current frame and the facial attribute results of the next frame to obtain a processing result. If the error between the facial attribute results of the next frame image and the facial attribute results of the current frame is greater than or equal to the second preset error threshold, a weighted calculation can still be performed on the facial attribute results of the previous frame and the facial attribute results of the current frame to obtain a processing result. The second preset error threshold is less than or equal to the first preset error threshold. In other words, in the solution of this embodiment, before using the facial attribute results of the next frame to smooth the facial attribute results of the current frame, a double judgment is required: that is, to determine whether the second feature distance is less than the preset distance threshold and to determine whether the error between the facial attribute results of the next frame image and the facial attribute results of the current frame is less than the second preset error threshold.

[0061] Furthermore, if the facial image of the next frame and the facial image of the current frame do not belong to the same person, the facial attribute results of the previous frame and the facial attribute results of the current frame can be calculated based on weights to obtain the smoothing processing result of the current frame.

[0062] The above scheme can not only make the facial attribute results of the same subject more stable, but also reduce the situation where the facial attribute results of different subjects are mistakenly regarded as the facial attribute results of the same subject when identity recognition errors occur, thereby taking into account the stability and accuracy of the detection results of numerical attributes.

[0063] On the other hand, if the type of the facial attribute result is a discrete numerical type, the error between the facial attribute result of the previous frame and the facial attribute result of the current frame can be calculated and recorded as the current error; further, the sum of the cumulative error and the current error can be calculated, and the sum can be used as the cumulative error. In other words, the cumulative error can be updated based on the sum of the cumulative error and the current error, and the updated cumulative error is the sum of the cumulative error before the update and the current error.

[0064] Furthermore, it can be determined whether the updated cumulative error is less than a third preset error threshold. If so, the facial attribute result of the previous frame can be used as the processing result. If the cumulative error is greater than or equal to the third preset error threshold, the facial attribute result of the current frame can be used as the processing result and the cumulative error can be cleared.

[0065] In other words, when the updated cumulative error is less than the third preset error threshold, it can be determined that the error between the facial attribute results of the current frame and the facial attribute results of the previous frame may be caused by changes in other factors (for example, lighting environment, facial posture, etc.), and the facial attribute results of the previous frame shall still be used as the basis; when the updated cumulative error is greater than or equal to the third preset error threshold, it means that there are errors between the facial attribute results of multiple frames and the facial attribute results of their respective previous frames, and it can be determined that the error between the facial attribute results of the current frame and the facial attribute results of the previous frame is caused by changes in the person being photographed, and the facial attribute results of the current frame shall be used as the basis.

[0066] The above scheme can not only make the facial attribute results of the same subject more stable, but also reduce the situation where the facial attribute results of different subjects are mistakenly regarded as the facial attribute results of the same subject when identity recognition errors occur, thereby taking into account the stability and accuracy of the detection results of category attributes.

[0067] In a non-limiting example, after calculating the error between the facial attribute results of the previous frame and the facial attribute results of the current frame (i.e., the current error), before calculating the sum of the cumulative error and the current error, it is also possible to first determine whether the current error is greater than or equal to a fourth preset error threshold.

[0068] If the current error is less than the fourth preset error threshold, it can be determined that the result of the identity comparison between the previous frame and the current frame is correct, and the sum of the accumulated error and the current error can be further calculated, and the above steps can be continued.

[0069] If the current error is greater than or equal to the fourth preset error threshold, it can be determined that there may be an error in the identity comparison. Further, it can be determined whether the facial image of the next frame and the facial image of the current frame belong to the same person.

[0070] If the face image of the next frame and the face image of the current frame do not belong to the same person, the possibility that the identity comparison results of the previous frame and the current frame are wrong can be ruled out. Therefore, the sum of the cumulative error and the current error can be further calculated, and the steps described above can be continued.

[0071] If the facial image of the next frame and the facial image of the current frame belong to the same person, and the error between the facial attribute result of the next frame and the facial attribute result of the current frame is less than the fourth preset error threshold, it can be determined that the result of the identity comparison between the previous frame and the current frame is wrong. Therefore, the facial attribute result of the current frame can be used as the processing result, and the current accumulated error can also be cleared.

[0072] If the facial image of the next frame and the facial image of the current frame belong to the same person, and the error between the facial attribute results of the next frame and the facial attribute results of the current frame is greater than or equal to the fourth preset error threshold, it can be determined that only using the next frame cannot accurately verify whether there is an error in the identity comparison results of the previous frame and the current frame. At this time, based on considerations of processing efficiency and stability, the sum of the cumulative error and the current error can be further calculated, and the steps described above can be continued.

[0073] It should be noted that this embodiment does not limit the magnitude relationship between the third preset error threshold and the first preset threshold and the second preset threshold, nor does it limit the magnitude relationship between the fourth preset error threshold and the first preset threshold and the second preset threshold.

[0074] In a non-limiting example, the facial attribute information in step S102 may be facial attribute features, and the facial attribute features of the previous frame and the facial attribute features of the current frame may be fused to obtain a processing result. In other words, the processing result may be the fused facial attribute features. In a specific implementation, the fusion process may be a weighted summation process of the facial attribute features of the previous frame and the facial attribute features of the current frame to obtain the processing result, wherein the sum of the weights of the facial attribute features of the previous frame and the facial attribute features of the current frame may be 1.

[0075] More specifically, the weight of the facial attribute features of the previous frame can be determined based on the first characteristic distance. The smaller the first characteristic distance, the greater the likelihood that the facial image in the previous frame and the facial image in the current frame belong to the same person, and the greater the weight of the facial attribute features of the previous frame. Conversely, the smaller the first characteristic distance, the less likely the facial image in the previous frame and the facial image in the current frame belong to the same person, and the smaller the weight of the facial attribute features of the previous frame.

[0076] Furthermore, facial attribute results can be determined based on the fused facial attribute features. Specifically, the processed results can be input into the prediction module of the attribute detection model to obtain the facial attribute results output by the prediction module. This approach maintains the stability of the facial attribute detection results while making the smoothed detection results more accurate.

[0077] Reference Figure 2 , Figure 2 is a schematic structural diagram of a facial attribute detection device according to an embodiment of the present invention. Figure 2 The apparatus shown may include:

[0078] An acquisition module 21 is used to acquire a face image of a current frame;

[0079] The detection module 22 is used to perform facial attribute detection on the facial image of the current frame to obtain facial attribute information of the current frame;

[0080] The post-processing module 23 is used to determine whether the facial image of the current frame and the facial image of the previous frame belong to the same person. If so, the facial attribute information of the current frame is smoothed according to the facial attribute information of the previous frame, and the facial attribute result of the current frame is determined according to the processing result.

[0081] For more information about the working principle, working method, beneficial effects, etc. of the facial attribute detection device in the embodiment of the present invention, please refer to the above description of the facial attribute detection method, which will not be repeated here.

[0082] An embodiment of the present invention further provides a storage medium having a computer program stored thereon. When the computer program is executed by a processor, the computer program performs the steps of the above-mentioned facial attribute detection method. The storage medium may include ROM, RAM, a magnetic disk, or an optical disk. The storage medium may also include non-volatile memory or non-transitory memory.

[0083] An embodiment of the present invention further provides a terminal comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, and when the processor executes the computer program, the steps of the above-described method for detecting facial attributes are performed. The terminal includes, but is not limited to, mobile phones, computers, tablet computers, and other terminal devices.

[0084] It should be understood that in the embodiments of the present application, the processor may be a central processing unit (CPU), or may be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.

[0085] It should also be understood that the memory in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), and direct rambus RAM (DR RAM).

[0086] The above embodiments can be implemented in whole or in part by software, hardware, firmware or any other combination. When implemented using software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer program are loaded or executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer program can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer program can be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired or wireless means.

[0087] In the several embodiments provided in this application, it should be understood that the disclosed methods, devices and systems can be implemented in other ways. For example, the device embodiments described above are merely schematic; for example, the division of the units is merely a logical function division, and there may be other division methods in actual implementation; for example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment.

[0088] In addition, the functional units in the various embodiments of the present invention may be integrated into one processing unit, or each unit may be physically included separately, or two or more units may be integrated into one unit. The above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units. For example, for various devices and products applied to or integrated into a chip, the various modules / units contained therein may all be implemented in the form of hardware such as circuits, or at least some of the modules / units may be implemented in the form of software programs, which run on the processor integrated inside the chip, and the remaining (if any) modules / units may be implemented in the form of hardware such as circuits; for various devices and products applied to or integrated into a chip module, the various modules / units contained therein may all be implemented in the form of hardware such as circuits, and different modules / units may be located in the same component (such as a chip, circuit module, etc.) or different components of the chip module, or at least some of the modules / units may be implemented in the form of hardware such as circuits. The element can be implemented in the form of a software program, which runs on the processor integrated inside the chip module, and the remaining (if any) modules / units can be implemented in the form of hardware such as circuits; for various devices and products applied to or integrated in the terminal, the various modules / units contained therein can be implemented in the form of hardware such as circuits, and different modules / units can be located in the same component (for example, chip, circuit module, etc.) or different components in the terminal, or, at least some modules / units can be implemented in the form of a software program, which runs on the processor integrated inside the terminal, and the remaining (if any) modules / units can be implemented in the form of hardware such as circuits.

[0089] It should be understood that the term "and / or" as used herein simply describes an association between related objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A exists alone, A and B exist simultaneously, or B exists alone. Furthermore, the character " / " as used herein indicates that the related objects are in an "or" relationship.

[0090] The "multiple" appearing in the embodiments of the present application refers to two or more. The first, second, etc. descriptions appearing in the embodiments of the present application are only for illustration and distinction of the description objects. There is no order, nor does it represent a special limitation on the number of devices in the embodiments of the present application, and cannot constitute any limitation on the embodiments of the present application. Although the present invention is disclosed as above, the present invention is not limited thereto. Any person skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present invention should be based on the scope defined by the claims.

[0091] Although the present invention is disclosed as above, the present invention is not limited thereto. Any person skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present invention should be based on the scope defined by the claims.

Claims

1. A method for detecting facial attributes, characterized in that: The method comprises: Get the face image of the current frame; Performing facial attribute detection on the facial image of the current frame to obtain facial attribute information of the current frame; Determine whether the facial image of the current frame and the facial image of the previous frame belong to the same person; if so, perform smoothing on the facial attribute information of the current frame based on the facial attribute information of the previous frame, and determine the facial attribute result of the current frame based on the smoothing result; If the type of the facial attribute result is a continuous numerical type, smoothing the facial attribute information of the previous frame and the facial attribute information of the current frame includes: performing a weight-based calculation on the facial attribute result of the previous frame and the facial attribute result of the current frame to obtain the processing result; Alternatively, if the type of the facial attribute result is a discrete numerical value, smoothing the facial attribute information of the current frame according to the facial attribute information of the previous frame includes: Calculating the error between the facial attribute result of the current frame and the facial attribute result of the previous frame, and recording it as the current error; Calculating a sum of a cumulative error and the current error, and using the sum as the cumulative error; determining whether the accumulated error is less than a third preset error threshold; if so, using the facial attribute result of the previous frame as the processing result; otherwise, using the facial attribute result of the current frame as the processing result and clearing the accumulated error; Alternatively, if the facial attribute information is the facial attribute feature, smoothing the facial attribute information of the current frame according to the facial attribute information of the previous frame includes: The facial attribute features of the previous frame and the facial attribute features of the current frame are fused to obtain the processing result.

2. The method for detecting facial attributes according to claim 1, wherein: Determining whether the facial image in the current frame and the facial image in the previous frame belong to the same person includes: Performing face recognition on the face image of the current frame to obtain an identity feature vector of the current frame; Get the identity feature vector of the previous frame; Calculate the feature distance between the identity feature vector of the current frame and the identity feature vector of the previous frame; It is determined whether the feature distance is less than a preset distance threshold; if so, it is determined that the face image of the current frame and the face image of the previous frame belong to the same person; otherwise, they do not belong to the same person.

3. The method for detecting facial attributes according to claim 1, wherein: Before performing weight-based calculation on the facial attribute result of the previous frame and the facial attribute result of the current frame, the method further includes: Calculating the error between the facial attribute result of the current frame and the facial attribute result of the previous frame, and recording it as the current error; Determine whether the current error is greater than or equal to a first preset error threshold, and if so, determine whether the facial image of the next frame and the facial image of the current frame belong to the same person; If the facial image of the next frame and the facial image of the current frame belong to the same person, a weight-based calculation is performed on the facial attribute result of the next frame and the facial attribute result of the current frame to obtain the processing result.

4. The method for detecting facial attributes according to claim 1, wherein: Before calculating the sum of the cumulative error and the current error, the method further includes: Determining whether the current error is greater than or equal to a fourth preset error threshold, and if so, determining whether the facial image of the next frame and the facial image of the current frame belong to the same person; If the facial image of the next frame and the facial image of the current frame belong to the same person and the error between the facial attribute result of the next frame and the facial attribute result of the current frame is less than a fourth preset error threshold, the facial attribute result of the current frame is used as the processing result.

5. A facial attribute detection device, characterized in that: The device comprises: The acquisition module is used to obtain the face image of the current frame; A detection module, configured to perform facial attribute detection on the facial image of the current frame to obtain facial attribute information of the current frame; a post-processing module, configured to determine whether the facial image of the current frame and the facial image of the previous frame belong to the same person; if so, smoothing the facial attribute information of the current frame based on the facial attribute information of the previous frame, and determining the facial attribute result of the current frame based on the processing result; The post-processing module is further configured to, if the type of the facial attribute result is a continuous numerical value, perform a weight-based calculation on the facial attribute result of the previous frame and the facial attribute result of the current frame to obtain the processing result; Alternatively, the post-processing module is further configured to, if the type of the facial attribute result is a discrete numerical type, calculate the error between the facial attribute result of the current frame and the facial attribute result of the previous frame, recording the error as the current error; calculate the sum of the cumulative error and the current error, and use the sum as the cumulative error; determine whether the cumulative error is less than a third preset error threshold; if so, use the facial attribute result of the previous frame as the processing result; otherwise, use the facial attribute result of the current frame as the processing result and clear the cumulative error; Alternatively, the post-processing module is further configured to, if the facial attribute information is the facial attribute feature, fuse the facial attribute feature of the previous frame and the facial attribute feature of the current frame to obtain the processing result.

6. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for detecting facial attributes according to any one of claims 1 to 4 are executed.

7. A terminal comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor runs the computer program, the processor performs the steps of the method for detecting facial attributes according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Face attribute recognition method and device and mobile terminal

    CN112069885A

  • Person attribute estimation device, person attribute estimation method and program

    JP2012053813A