Face feature extraction method, device, equipment and storage medium
By combining the feature network and the attention network in the facial feature extraction model, the attention feature is used to adjust the initial facial features, which solves the problem of unstable feature extraction caused by changes in the environment and angle in face recognition, and achieves higher accuracy. performance and robustness.
Patent Information
- Application Number
- CN202210316045.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-29
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2042-03-29
AI Technical Summary
In face recognition, it is difficult for the existing technology to maintain the accuracy and stability of feature extraction in different environments and angles, especially when faced with large-scale side faces, light and shade, background and occlusion, resulting in feature extraction problems. Accuracy is inconsistent.
A facial feature extraction model including feature network and attention network is used. The attention feature indicates the importance of the feature factors in the initial facial feature, and feature fusion and weight adjustment are performed to generate the final facial feature to improve the accuracy of extraction. and robustness.
It improves the accuracy and stability of facial feature extraction, is suitable for face recognition in a variety of scenarios, enhances the ability to extract features under different angles and lights, and reduces the impact of noise.
Smart Images

Figure CN114783019B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence, and in particular to a method, device, equipment and storage medium for extracting facial features. Background Art
[0002] The attention mechanism was first proposed in the field of NLP (Neuro-Linguistic Programming). The transformer structure based on the attention mechanism has shined in various NLP tasks in recent years. In visual tasks, the attention mechanism has also received a lot of attention. The more famous methods include Non-Local Network, which can model global relationships in spatiotemporal volumes and achieve good results. However, the self-attention module in visual tasks usually requires matrix multiplication of large matrices, which takes up a lot of video memory and is relatively time-consuming. At present, the following problems are encountered in face recognition or face tracking: large-scale side faces, light and dark, background (such as clothes, walls, etc.), occlusion, even if feature extraction can achieve feature distance similarity, but with the changes in different environments, this similarity threshold is randomly variable, resulting in unstable feature accuracy; if features are simply extracted from CNN (Convolutional Neural Networks), it is bound to introduce a lot of noise, and simple data augmentation cannot cover any situation. Summary of the invention
[0003] The present invention provides a method, device, equipment and storage medium for extracting facial features, which are used to improve the accuracy of facial feature extraction.
[0004] To achieve the above-mentioned purpose, the first aspect of the present invention provides a facial feature extraction method, comprising: obtaining a target image containing a face; inputting the target image into a pre-trained facial feature extraction model; wherein the facial feature extraction model comprises a feature network and an attention network; outputting the initial facial features of the face in the target image through the feature network; outputting the attention features in the target image through the attention network; wherein the attention network is a student network of a preset teacher network; the attention network is obtained based on the teacher network training; the attention features are used to indicate the importance of the feature factors in the initial facial features; the initial facial features are processed based on the attention features to obtain the final facial features of the face in the target image.
[0005] Optionally, in a first implementation method of the first aspect of the present invention, the feature dimension of the attention feature is the same as the number of dimensions of the feature dimension of the initial facial feature; the step of processing the initial facial feature based on the attention feature to obtain the final facial feature of the face in the target image includes: fusing the feature data with the same feature dimension in the initial facial feature and the attention feature to obtain the final facial feature of the face in the target image.
[0006] Optionally, in a second implementation method of the first aspect of the present invention, the initial facial feature includes initial factor values of multiple feature factors; the attention feature includes the weight of each feature factor; the feature data with the same feature dimension in the initial facial feature and the attention feature are fused to obtain the final facial feature of the face in the target image, comprising: for each feature factor in the initial facial feature, extracting the weight of the feature factor from the attention feature, multiplying the initial factor value of the feature factor by the weight to obtain the final factor value of the feature factor; and determining the final factor value of each feature factor as the final facial feature of the face in the target image.
[0007] Optionally, in a third implementation method of the first aspect of the present invention, the initial facial feature includes initial factor values of multiple feature factors; the attention feature includes an indication value of each feature factor; and the feature data with the same feature dimension in the initial facial feature and the attention feature are fused to obtain the final facial feature of the face in the target image, comprising: for each feature factor in the initial facial feature, extracting the indication value of the feature factor from the attention feature; if the indication value is a preset first value, determining the initial factor value of the feature factor as the final factor value of the feature factor; if the indication value is a preset second value, deleting the feature factor and the factor value of the feature factor; and determining the final factor value of the remaining feature factors as the final facial feature of the face in the target image.
[0008] Optionally, in a fourth implementation method of the first aspect of the present invention, the attention network is trained specifically in the following manner: obtaining a sample image group containing human faces; wherein the sample image group includes multiple images, the human faces in the multiple images are the same, and the shooting angles of the human faces in the multiple images are different; extracting a first image feature of a first image in the sample image group, inputting the first image into a preset teacher network, and outputting a first attention feature; obtaining a first output result based on the first image feature and the first attention feature; extracting a second image feature of a second image in the sample image group, inputting the second image into a preset student network, and outputting a second attention feature; obtaining a second output result based on the second image feature and the second attention feature; calculating a loss value based on the first output result and the second output result, training the student network based on the loss value until the loss value converges, and determining the student network when the loss value converges as the attention network.
[0009] Optionally, in a fifth implementation of the first aspect of the present invention, the step of obtaining a first output result based on the first image feature and the first attention feature includes: performing feature fusion processing on the feature values at the same position in the first image feature and the first attention feature to obtain the first output result; the step of obtaining a second output result based on the second image feature and the second attention feature includes: performing feature fusion processing on the feature values at the same position in the second image feature and the second attention feature to obtain the second output result.
[0010] Optionally, in a sixth implementation of the first aspect of the present invention, the step of calculating a loss value based on the first output result and the second output result, and training the student network based on the loss value until the loss value converges, includes: calculating the loss value based on the first output result and the second output result; updating network parameters of the student network and the teacher network respectively based on the loss value; and continuing to execute the step of obtaining a sample image group containing human faces until the loss value converges.
[0011] The second aspect of the present invention provides a facial feature extraction device, including an acquisition module for acquiring a target image containing a face; an input module for inputting the target image into a pre-trained facial feature extraction model; wherein the facial feature extraction model includes a feature network and an attention network; a first output module for outputting the initial facial features of the face in the target image through the feature network; a second output module for outputting the attention features in the target image through the attention network; wherein the attention network is a student network of a preset teacher network; the attention network is obtained based on the teacher network training; the attention features are used to indicate the importance of the feature factors in the initial facial features; and an acquisition module for processing the initial facial features based on the attention features to obtain the final facial features of the face in the target image.
[0012] Optionally, in a first implementation method of the second aspect of the present invention, the feature dimension of the attention feature is the same as the number of dimensions of the feature dimension of the initial facial feature; the acquisition module is specifically used to: fuse the feature data with the same feature dimension in the initial facial feature and the attention feature to obtain the final facial feature of the face in the target image.
[0013] Optionally, in a second implementation method of the second aspect of the present invention, the above-mentioned initial facial features include initial factor values of multiple feature factors; the above-mentioned attention features include the weight of each feature factor; the above-mentioned acquisition module is specifically used to: for each feature factor in the above-mentioned initial facial features, extract the weight of the feature factor from the attention feature, multiply the initial factor value of the feature factor by the weight to obtain the final factor value of the feature factor; and determine the final factor value of each feature factor as the final facial feature of the face in the target image.
[0014] Optionally, in a third implementation method of the second aspect of the present invention, the above-mentioned initial facial features include initial factor values of multiple feature factors; the above-mentioned attention features include an indication value of each feature factor; the above-mentioned acquisition module is specifically used to: for each feature factor in the above-mentioned initial facial features, extract the indication value of the feature factor from the attention feature; if the indication value is a preset first value, determine the initial factor value of the feature factor as the final factor value of the feature factor; if the indication value is a preset second value, delete the feature factor and the factor value of the feature factor; and determine the final factor value of the remaining feature factors as the final facial features of the face in the target image.
[0015] Optionally, in a fourth implementation manner of the second aspect of the present invention, the above-mentioned device also includes a training module, which is used to: obtain a sample image group containing a human face; wherein the sample image group includes multiple images, the human faces in the multiple images are the same, and the shooting angles of the human faces in the multiple images are different; extract a first image feature of a first image in the sample image group, input the first image into a preset teacher network, and output a first attention feature; obtain a first output result based on the first image feature and the first attention feature; extract a second image feature of a second image in the sample image group, input the second image into a preset student network, and output a second attention feature; obtain a second output result based on the second image feature and the second attention feature; calculate a loss value based on the first output result and the second output result, train the student network based on the loss value until the loss value converges, and determine the student network when the loss value converges as the attention network.
[0016] Optionally, in a fifth implementation of the second aspect of the present invention, the above-mentioned training module is also specifically used to: perform feature fusion processing on the feature values at the same position in the first image feature and the first attention feature to obtain a first output result; perform feature fusion processing on the feature values at the same position in the second image feature and the second attention feature to obtain a second output result.
[0017] Optionally, in a sixth implementation of the second aspect of the present invention, the above-mentioned training module is further specifically used to: calculate a loss value based on the first output result and the second output result; update network parameters of the student network and the teacher network respectively based on the loss value; and continue to execute the step of obtaining a sample image group containing human faces until the loss value converges.
[0018] The third aspect of the present invention provides a facial feature extraction device, comprising: a memory and at least one processor, wherein the memory stores instructions; the at least one processor calls the instructions in the memory so that the facial feature extraction device executes the above-mentioned facial feature extraction method.
[0019] A fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the above-mentioned facial feature extraction method.
[0020] In the technical solution provided by the present invention, a target image containing a face is obtained; the target image is input into a pre-trained face feature extraction model; wherein the face feature extraction model includes a feature network and an attention network; the initial face features of the face in the target image are output through the feature network; the attention features in the target image are output through the attention network; wherein the attention network is a student network of a preset teacher network; the attention network is obtained based on the teacher network training; the attention features are used to indicate the importance of the feature factors in the initial face features; the initial face features are processed based on the attention features to obtain the final face features of the face in the target image. In this method, the face feature extraction model not only extracts the initial face features, but also outputs the attention features for the face features, and the attention features are used to indicate the importance of each feature factor in the face features, thereby highlighting the important features in the face features and weakening the unimportant features, thereby improving the accuracy of face feature extraction, and can be applied to face feature extraction and face recognition in a variety of scenarios, so that the face recognition accuracy is higher. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 A schematic diagram of an embodiment of a method for extracting facial features in an embodiment of the present invention;
[0022] Figure 2 A schematic diagram of another embodiment of the method for extracting facial features in an embodiment of the present invention;
[0023] Figure 3 A schematic diagram of an embodiment of a facial feature extraction device in an embodiment of the present invention;
[0024] Figure 4 Schematic diagram of an embodiment of a facial feature extraction device in an embodiment of the present invention. DETAILED DESCRIPTION
[0025] The embodiments of the present invention provide a method, device, equipment and storage medium for extracting facial features, which are used to improve the accuracy of facial feature extraction.
[0026] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0027] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 , an embodiment of the method for extracting facial features in an embodiment of the present invention includes:
[0028] 100. Obtain a target image containing a face;
[0029] Facial recognition technology is being used more and more in life, work, and study. For example, when entering important places such as stations and office buildings, you need to swipe your identity credentials and determine whether the target person matches the identity credentials based on the facial recognition results. When the police are arresting suspects or fugitives, they can use facial recognition technology to identify faces that meet the facial features of suspects or fugitives from among many faces in the video data collected by the camera, and so on.
[0030] Facial feature extraction is one of the most basic problems in face recognition technology. Facial feature extraction not only extracts the most beneficial features for pattern classification from the original pattern information, but also greatly reduces the dimension of pattern samples. Facial feature extraction is the preliminary work of pattern recognition and has a great impact on the results of later face recognition.
[0031] In the process of facial feature extraction, it is first necessary to obtain a target image containing a face. Since face recognition technology is widely used in various fields, the target image can be an image containing multiple faces obtained in different scenes, or an image of a target person in different states.
[0032] Specifically, the target image includes at least one face. In actual implementation, if the target face needs to be determined, in one way, the target face can be determined based on the proportion of the face in the image. For example, when multiple faces appear in the image, the face with the larger proportion in the image is determined to be the target face. In another way, the target face can be determined based on the position of the face in the image. For example, when multiple faces appear in the image, the face at the center or near the center of the image is determined to be the target face. Alternatively, the target face can be selected manually or intelligently.
[0033] 101. Input a target image into a pre-trained facial feature extraction model; wherein the facial feature extraction model includes a feature network and an attention network;
[0034] After the acquisition module acquires the target image, the target image is input into a pre-trained facial feature extraction model, which includes a feature network and an attention network. In an embodiment of the present invention, the feature network can be used to extract the initial facial features of the face in the target image. The initial facial features can include multiple feature factors and the value of each feature factor. The attention network can be used to indicate the importance of the feature factors in the initial facial features. Based on this, some unimportant features in the initial facial features can be screened and excluded, thereby improving the extraction of important facial features.
[0035] 102. Outputting initial facial features of the face in the target image through the feature network;
[0036] In actual implementation, the feature network in the face recognition model extracts the initial face features of the face in the target image and outputs the initial face features, which can be represented by feature factors. The initial face features include the features of the face itself, such as: specific parts (eyes, nose and mouth, etc.) and overall feature information. In addition, the initial face features also include facial expression features under the shooting angle in the target image and the emotional state of the person.
[0037] 103. Outputting the attention features in the target image through an attention network; wherein the attention network is a student network of a preset teacher network; the attention network is trained based on the teacher network; the attention features are used to indicate the importance of feature factors in the initial facial features;
[0038] In actual implementation, the attention network in the face recognition model extracts the attention features of the face in the target image and outputs the attention features, which are used to indicate the importance of each feature in the above-mentioned initial face features. In an optional manner, the face feature extraction method of the present invention can be applied to an intelligent teaching auxiliary system to help teachers better judge students' learning status, knowledge point absorption, etc. The above-mentioned attention network is a student network of a preset teacher network. Specifically, the attention network is obtained based on the training of the teacher network.
[0039] After the target image is input into the pre-trained facial feature extraction model, it is processed by the facial feature extraction model to output the initial facial features of the face in the target image and the attention features of the target image. Optionally, in the facial feature extraction model, the initial facial features of the face in the target image are calculated and output through the feature network, and the attention features in the target image are calculated and output through the attention network, wherein the initial facial features can reflect the basic feature information of the face, such as the geometric features between the nose, eyes and other parts, and the facial expression features. The basic feature information is represented by feature factors, and the attention features are used to indicate the importance of the feature factors in the initial facial features.
[0040] In actual implementation, the acquisition scenarios of the target image are diverse, and the human states when acquiring the target image are also diverse, which will cause the above-mentioned initial facial features to be different. When achieving the purpose of feature distance similarity by extracting facial features, this embodiment introduces attention features to stabilize the accuracy of facial features, maintain the stability of the threshold, has good robustness, can also obtain more accurate facial features, and has a wider range of usage scenarios.
[0041] When the embodiments of the present invention are applied to an intelligent teaching assistance system, it can better help teachers judge students' learning status, knowledge point absorption and other related information, so that teachers can understand each student's learning situation in real time during the teaching process and take corresponding measures in time to help students learn better.
[0042] 104. Process the initial facial features based on the attention features to obtain the final facial features of the face in the target image.
[0043] Specifically, based on the importance of the feature factors in the initial face features indicated in the above attention features, the initial face features can be processed more specifically to obtain the final face features of the face in the target image. The final face features can be used to realize face recognition of target images obtained in various scenarios.
[0044] This step adds and stores attention features based on the initial facial features, which can compress some feature storage and improve the accuracy of facial features.
[0045] In an embodiment of the present invention, a target image containing a face is obtained; the target image is input into a pre-trained face feature extraction model; wherein the face feature extraction model includes a feature network and an attention network; the initial face features of the face in the target image are output through the feature network; the attention features in the target image are output through the attention network; wherein the attention network is a student network of a preset teacher network; the attention network is obtained based on the teacher network training; the attention features are used to indicate the importance of the feature factors in the initial face features; the initial face features are processed based on the attention features to obtain the final face features of the face in the target image. In this method, the face feature extraction model not only extracts the initial face features, but also outputs the attention features for the face features, and the attention features are used to indicate the importance of each feature factor in the face features, thereby highlighting the important features in the face features and weakening the unimportant features, thereby improving the accuracy of face feature extraction, and can be applied to face feature extraction and face recognition in a variety of scenarios, so that the face recognition accuracy is higher.
[0046] In an optional manner, the feature dimension of the attention feature is the same as the feature dimension of the initial face feature, and the feature data with the same feature dimension in the initial face feature and the attention feature are fused to obtain the final face feature of the face in the target image. Figure 2 .
[0047] In this embodiment, steps 200-203 are the same as the above steps 100-103 and will not be repeated here.
[0048] 204. The feature data with the same feature dimension in the initial face feature and the attention feature are fused to obtain the final face feature of the face in the target image.
[0049] In actual implementation, facial features have multiple dimensions, each dimension can be represented by a feature vector, and the above-mentioned attention features and initial facial features also have multiple dimensions, and the number of dimensions is the same. Fusion of feature data with the same feature dimensions can enhance the feature information in the target image, and then obtain the final facial features of the face in the target image. The final facial features are noise-removing features, that is, removing factors that hinder the sensory organs from understanding the received source information. Based on this, the facial feature extraction model can better analyze the target image. By introducing attention features, it can more specifically extract the important feature positions of the face in different states in the target image, thereby achieving the purpose of compressing important features and removing noise interference.
[0050] Optionally, the initial facial feature includes initial factor values of multiple feature factors; the attention feature includes the weight of each feature factor; for each feature factor in the initial facial feature, the weight of the feature factor is extracted from the attention feature, and the initial factor value of the feature factor is multiplied by the weight to obtain the final factor value of the feature factor; the final factor value of each feature factor is determined as the final facial feature of the face in the target image.
[0051] It is understandable that each face has its own unique features, and the same face will show different features under different light and at different angles. Facial features include key point information of the face, such as the geometric relationship between facial features such as eyes, nose and mouth. This key point information can be used for face similarity comparison, face recognition and other aspects. Since the acquisition scenes of the target image are diverse, the state of the person when acquiring the target image is also diverse. In order to more accurately express the facial features, each dimensional feature in the target image can be expressed by the initial factor value of the feature factor. When the factors affecting the facial features change, such as: the lighting changes or the face is blocked by external objects, and the facial expression of the face changes, etc., the initial factor value of the above feature factor will also change accordingly to accurately reflect the facial features, so that the difference in the feature factors of different faces is as large as possible, and the difference in the feature factors of the same face is as small as possible.
[0052] In actual implementation, for each feature factor in the initial facial features, the weight of the feature factor is extracted from the attention feature, and the final factor value of the feature factor is obtained by multiplying the initial factor value of the feature factor with the above weight. Further, the final factor value of each feature factor is determined as the final facial feature of the face in the target image. Based on this, the attention feature identifies and marks the key features in the above target image through a new layer of weights, allowing the network to learn the areas that need more attention in each target image, so that the feature gap between different faces is as large as possible, and the feature gap between the same face is as small as possible. In addition, it can also capture the emotional changes of the face more sensitively.
[0053] Optionally, the initial facial feature includes initial factor values of multiple feature factors; the attention feature includes an indication value of each feature factor; for each feature factor in the initial facial feature, the indication value of the feature factor is extracted from the attention feature, and if the indication value is a preset first value, the initial factor value of the feature factor is determined as the final factor value of the feature factor; if the indication value is a preset second value, the feature factor and the factor value of the feature factor are deleted; and the final factor values of the remaining feature factors are determined as the final facial features of the face in the target image.
[0054] Furthermore, the attention feature also includes an indication value of each feature factor, which is used to indicate whether the initial factor value of the feature factor has a feature value. A first value and a second value are preset. For each feature factor in the initial face feature, the indication value of the feature factor is extracted from the attention feature. If the indication value corresponding to a feature factor is the preset first value, it indicates that the feature factor can accurately express the feature and has a feature value, and then the initial factor value of the feature factor is determined as the final factor value of the feature factor; if the indication value corresponding to a feature factor is the preset second value, it indicates that the feature factor is not needed, that is, the feature factor does not have a feature value, and then the feature factor and the factor value of the feature factor are deleted; the final factor value of the remaining feature factors is determined as the final face feature of the face in the target image. Based on this, unnecessary features can be screened out, and then some feature storage can be compressed to reduce the pressure on the system, so that the picture response is faster and smoother.
[0055] By adopting this step, the same face can be trained in various scenarios, and the important feature positions of the face in different states can be extracted to solve the problem of face pattern variability caused by factors such as facial skin color and expression.
[0056] Optionally, the attention network is trained specifically in the following manner: obtaining a sample image group containing a face; wherein the sample image group includes multiple images, the faces in the multiple images are the same, and the faces in the multiple images are shot at different angles; extracting a first image feature of a first image in the sample image group, inputting the first image into a preset teacher network, and outputting a first attention feature; obtaining a first output result based on the first image feature and the first attention feature; extracting a second image feature of a second image in the sample image group, inputting the second image into a preset student network, and outputting a second attention feature; obtaining a second output result based on the second image feature and the second attention feature; calculating a loss value based on the first output result and the second output result, training a student network based on the loss value until the loss value converges, and determining the student network when the loss value converges as the attention network.
[0057] Specifically, the above attention network is trained in the following way:
[0058] First, a sample image group containing human faces is obtained, where the sample image group includes multiple images. Optionally, the human faces in the multiple images are the same, but the shooting angles are different. It is understandable that the feature data extracted from the same face at different shooting angles are different.
[0059] Secondly, extract the first image feature of the first image in the sample image group, input the first image into the preset teacher network, and output the predicted value first attention feature, wherein the first image feature is the facial feature under the shooting angle in the first image, and the first attention feature is used to indicate the importance of the feature factor in the first image feature. The first image feature and the first attention feature are fused. Specifically, the data with the same dimension in the first image feature and the first attention feature are combined to make the important features in the first image feature more obvious, and the unimportant features are removed, so as to obtain the first output result;
[0060] Then, extract the second image feature of the second image in the sample image group, input the second image into a preset student network, and output a predicted value second attention feature, wherein the second image feature is a facial feature under a shooting angle in the second image, and the second attention feature is used to indicate the importance of a feature factor in the second image feature, and fuse the second image feature and the second attention feature. Specifically, combine the data with the same dimension in the second image feature and the second attention feature, so that the important features in the second image feature are more obvious, and remove unimportant features, so as to obtain a second output result;
[0061] Finally, the loss value is calculated based on the first output result and the second output result. The loss value can be implemented in many ways, for example, Cross Entropy Loss function, Contrastive Loss function, etc. Repeat the above steps until the loss value converges. At this time, the first output result and the second output result are close to the expected threshold, and the student network when the loss value converges is determined as the attention network.
[0062] By adopting this step, the stability of the similarity threshold can be maintained, which effectively solves the problem of random changes in the similarity threshold due to different shooting angles, lighting intensity, background (clothes, walls, etc.), occlusion and other factors during the face recognition process. In addition, some feature storage can be compressed.
[0063] Optionally, feature fusion processing is performed on the feature values at the same position in the first image feature and the first attention feature to obtain a first output result; feature fusion processing is performed on the feature values at the same position in the second image feature and the second attention feature to obtain a second output result.
[0064] In actual implementation, the first image feature can enable the computer to learn the initial facial features in the first image, and then combine the first attention feature of the first image output by the preset teacher network, combine the first image feature and the feature value of the first attention feature at the same position in the first image, and obtain the first output result. The second image feature can enable the computer to learn the initial facial features in the second image, and then combine the second attention feature of the second image output by the preset teacher network, combine the feature value of the second image feature and the second attention feature at the same position in the second image, and obtain the second output result. Based on this, the computer can learn the important features of the above-mentioned initial facial features, thereby improving the extraction of important facial features.
[0065] Further, a loss value is calculated based on the first output result and the second output result; network parameters of the student network and the teacher network are updated respectively based on the loss value; and the step of obtaining a sample image group containing faces is continued until the loss value converges.
[0066] Specifically, the above-mentioned calculation of the loss value based on the first output result and the second output result, that is, receiving the predicted values of the preset teacher network and student network, and then calculating the difference between the predicted value and the true value, and then updating the network parameters of the student network and the teacher network respectively according to the above-mentioned loss value, so that the difference between the predicted value and the true value is infinitely small, and the predicted value is close to the true value. For situations such as images of the same face at multiple shooting angles and images of different faces at multiple shooting angles, continue to perform the above-mentioned step of obtaining a sample image group containing a face until the loss value converges. Based on this, the attention network in the above-mentioned facial feature extraction model can be obtained, and the attention network can output attention features for indicating the importance of feature factors in the initial facial features.
[0067] The above describes the face feature extraction method in the embodiment of the present invention. The following describes the face feature extraction device in the embodiment of the present invention. Figure 3 , an embodiment of the face feature extraction device in the embodiment of the present invention includes:
[0068] An acquisition module 300 is used to acquire a target image containing a human face;
[0069] An input module 301 is used to input a target image into a pre-trained facial feature extraction model; wherein the facial feature extraction model includes a feature network and an attention network;
[0070] A first output module 302, configured to output initial facial features of a face in a target image through a feature network;
[0071] The second output module 303 is used to output the attention features in the target image through the attention network; wherein the attention network is a student network of a preset teacher network; the attention network is obtained based on the teacher network training; the attention features are used to indicate the importance of the feature factors in the initial face features;
[0072] The acquisition module 304 is used to process the initial facial features based on the attention features to obtain the final facial features of the face in the target image.
[0073] In an embodiment of the present invention, a target image containing a face is obtained; the target image is input into a pre-trained face feature extraction model; wherein the face feature extraction model includes a feature network and an attention network; the initial face features of the face in the target image are output through the feature network; the attention features in the target image are output through the attention network; wherein the attention network is a student network of a preset teacher network; the attention network is obtained based on the teacher network training; the attention features are used to indicate the importance of the feature factors in the initial face features; the initial face features are processed based on the attention features to obtain the final face features of the face in the target image. In this method, the face feature extraction model not only extracts the initial face features, but also outputs the attention features for the face features, and the attention features are used to indicate the importance of each feature factor in the face features, thereby highlighting the important features in the face features and weakening the unimportant features, thereby improving the accuracy of face feature extraction, and can be applied to face feature extraction and face recognition in a variety of scenarios, so that the face recognition accuracy is higher.
[0074] The feature dimensions of the above attention feature are the same as the feature dimensions of the initial face feature; optionally, the obtaining module 304 may also be specifically used for:
[0075] The feature data with the same feature dimension in the initial face features and attention features are fused to obtain the final face features of the face in the target image.
[0076] The initial face feature includes initial factor values of multiple feature factors; the attention feature includes the weight of each feature factor; optionally, the acquisition module 304 may also be specifically used for:
[0077] For each feature factor in the above initial facial features, the weight of the feature factor is extracted from the attention feature, and the initial factor value of the feature factor is multiplied by the weight to obtain the final factor value of the feature factor; the final factor value of each feature factor is determined as the final facial feature of the face in the target image.
[0078] The initial face feature includes initial factor values of multiple feature factors; the attention feature includes an indication value of each feature factor; optionally, the acquisition module 304 may also be specifically used for:
[0079] For each feature factor in the above-mentioned initial facial features, an indication value of the feature factor is extracted from the attention feature; if the indication value is a preset first value, the initial factor value of the feature factor is determined as the final factor value of the feature factor; if the indication value is a preset second value, the feature factor and the factor value of the feature factor are deleted; the final factor value of the remaining feature factor is determined as the final facial feature of the face in the target image.
[0080] Optionally, the above-mentioned device also includes a training module, which is used to: obtain a sample image group containing a face; wherein the sample image group includes multiple images, the faces in the multiple images are the same, and the shooting angles of the faces in the multiple images are different; extract the first image feature of the first image in the sample image group, input the first image into a preset teacher network, and output a first attention feature; obtain a first output result based on the first image feature and the first attention feature; extract the second image feature of the second image in the sample image group, input the second image into a preset student network, and output a second attention feature; obtain a second output result based on the second image feature and the second attention feature; calculate the loss value based on the first output result and the second output result, train the student network based on the loss value until the loss value converges, and determine the student network when the loss value converges as the attention network.
[0081] Optionally, the above training module may also be specifically used for:
[0082] The feature values at the same position in the first image feature and the first attention feature are subjected to feature fusion processing to obtain a first output result; the step of obtaining the second output result based on the second image feature and the second attention feature includes: the feature values at the same position in the second image feature and the second attention feature are subjected to feature fusion processing to obtain a second output result.
[0083] Optionally, the above training module may also be specifically used for:
[0084] The loss value is calculated based on the first output result and the second output result; the network parameters of the student network and the teacher network are updated respectively based on the loss value; and the step of obtaining a sample image group containing human faces is continued until the loss value converges.
[0085] The above figure describes in detail the facial feature extraction device in the embodiment of the present invention. The following describes in detail the facial feature extraction device in the embodiment of the present invention from the perspective of hardware processing.
[0086] Figure 44 is a schematic diagram of the structure of a facial feature extraction device provided by an embodiment of the present invention. The facial feature extraction device 400 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 410 (for example, one or more processors) and a memory 420, and one or more storage media 430 (for example, one or more mass storage devices) storing application programs 433 or data 432. Among them, the memory 420 and the storage medium 430 can be short-term storage or permanent storage. The program stored in the storage medium 430 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the facial feature extraction device 400. Furthermore, the processor 410 may be configured to communicate with the storage medium 430 to execute a series of instruction operations in the storage medium 430 on the facial feature extraction device 400.
[0087] The facial feature extraction device 400 may also include one or more power supplies 440, one or more wired or wireless network interfaces 450, one or more input and output interfaces 460, and / or one or more operating systems 431, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. Those skilled in the art will appreciate that Figure 4 The structure of the facial feature extraction device shown does not constitute a limitation of the facial feature extraction device, and may include more or fewer components than shown in the figure, or a combination of certain components, or a different arrangement of components.
[0088] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When the instructions are executed on a computer, the computer executes the steps of the facial feature extraction method.
[0089] The present invention also provides a facial feature extraction device, which includes a memory and a processor. The memory stores instructions, and when the instructions are executed by the processor, the processor executes the steps of the facial feature extraction method in the above embodiments.
[0090] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0091] The blockchain referred to in the present invention is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the blockchain underlying platform, platform product service layer, and application service layer.
[0092] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0093] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the whole or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.
[0094] It should be further explained that the facial image data used in this application are obtained with the user's authorization, and the technical solutions provided in this application are legally implemented.
[0095] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A facial feature extraction method, It is characterized in that The facial feature extraction method comprises: Get a target image containing a face; Inputting the target image into a pre-trained facial feature extraction model; wherein the facial feature extraction model includes a feature network and an attention network; Outputting initial facial features of the face in the target image through the feature network; Outputting the attention features in the target image through the attention network; wherein the attention network is a student network of a preset teacher network; the attention network is trained based on the teacher network; the attention features are used to indicate the importance of feature factors in the initial facial features; Processing the initial facial features based on the attention features to obtain final facial features of the face in the target image; The feature dimension of the attention feature is the same as the feature dimension of the initial face feature; the step of processing the initial face feature based on the attention feature to obtain the final face feature of the face in the target image includes: Fusing the feature data with the same feature dimension in the initial face feature and the attention feature to obtain the final face feature of the face in the target image; The initial facial features include initial factor values of multiple feature factors; the attention features include weights of each of the feature factors; the step of fusing the feature data with the same feature dimensions in the initial facial features and the attention features to obtain the final facial features of the face in the target image includes: For each feature factor in the initial face feature, extract the weight of the feature factor from the attention feature, and multiply the initial factor value of the feature factor by the weight to obtain a final factor value of the feature factor; The final factor value of each of the feature factors is determined as the final facial feature of the face in the target image.
2. The facial feature extraction method according to claim 1, It is characterized in that The initial face feature includes initial factor values of multiple feature factors; the attention feature includes an indication value of each feature factor; the feature dimension of the initial face feature and the attention feature is The step of fusing the same feature data to obtain the final face features of the face in the target image comprises: For each feature factor in the initial face feature, extract an indication value of the feature factor from the attention feature, and if the indication value is a preset first value, determine the initial factor value of the feature factor as the final factor value of the feature factor; if the indication value is a preset second value, delete the feature factor and the factor value of the feature factor; The final factor value of the remaining feature factor is determined as the final facial feature of the face in the target image.
3. The facial feature extraction method according to claim 1, It is characterized in that The attention network is specifically trained in the following way: Acquire a sample image group containing a human face; wherein the sample image group includes a plurality of images, the human faces in the plurality of images are the same, and the human faces in the plurality of images are taken at different angles; Extracting a first image feature of a first image in the sample image group, inputting the first image into a preset teacher network, and outputting a first attention feature; and obtaining a first output result based on the first image feature and the first attention feature; Extracting a second image feature of a second image in the sample image group, inputting the second image into a preset student network, and outputting a second attention feature; and obtaining a second output result based on the second image feature and the second attention feature; A loss value is calculated based on the first output result and the second output result, the student network is trained based on the loss value until the loss value converges, and the student network when the loss value converges is determined as the attention network.
4. The method for extracting facial features according to claim 3, It is characterized in that The step of obtaining a first output result based on the first image feature and the first attention feature includes: performing feature fusion processing on feature values at the same position in the first image feature and the first attention feature to obtain a first output result; The step of obtaining a second output result based on the second image feature and the second attention feature includes: performing feature fusion processing on the feature values at the same position in the second image feature and the second attention feature to obtain a second output result.
5. The method for extracting facial features according to claim 3, It is characterized in that The step of calculating a loss value based on the first output result and the second output result, and training the student network based on the loss value until the loss value converges comprises: Calculate a loss value based on the first output result and the second output result; Based on the loss value, the network parameters of the student network and the teacher network are respectively updated; The step of obtaining a set of sample images containing human faces is continued until the loss value converges.
6. A facial feature extraction device, It is characterized in that The facial feature extraction device comprises: An acquisition module is used to acquire a target image containing a face; An input module, inputting the target image into a pre-trained facial feature extraction model; wherein the facial feature extraction model includes a feature network and an attention network; A first output module, configured to output initial facial features of a face in the target image through the feature network; A second output module is used to output the attention features in the target image through the attention network; wherein the attention network is a student network of a preset teacher network; the attention network is trained based on the teacher network; the attention features are used to indicate the importance of feature factors in the initial facial features; An acquisition module, configured to process the initial facial features based on the attention features to obtain final facial features of the face in the target image; The feature dimension of the attention feature is the same as the feature dimension of the initial face feature; the acquisition module is further used to fuse the feature data with the same feature dimension in the initial face feature and the attention feature to obtain the final face feature of the face in the target image; The initial facial feature includes initial factor values of multiple feature factors; the attention feature includes the weight of each feature factor; the acquisition module is also used to extract the weight of the feature factor from the attention feature for each feature factor in the initial facial feature, multiply the initial factor value of the feature factor by the weight to obtain the final factor value of the feature factor; the final factor value of each feature factor is determined as the final facial feature of the face in the target image.
7. A facial feature extraction device, It is characterized in that The facial feature extraction device comprises: a memory and at least one processor, wherein instructions are stored in the memory; The at least one processor calls the instructions in the memory so that the facial feature extraction device executes the facial feature extraction method as described in any one of claims 1-5.
8. A computer-readable storage medium having stored thereon instructions, It is characterized in that When the instructions are executed by the processor, the facial feature extraction method as described in any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Expression recognition method, device and system
CN109815924A
Face recognition network training method, device, equipment and storage medium
CN111783606A
