Face recognition method and device, equipment, medium and product
By using the RetinaFace model for face detection in street video surveillance scenarios, and combining the method of matching non-facial recognition networks and feature library, the problem of low face recognition efficiency and accuracy in the existing technology is solved, and efficient and accurate are achieved face recognition.
Patent Information
- Application Number
- CN202411523840.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-02-07
AI Technical Summary
The prior art facial recognition methods in street-side video surveillance scenarios lack a complete process of face detection, quality evaluation and image optimization, resulting in low recognition efficiency and accuracy.
Face detection model (such as RetinaFace model) is used for face detection, combined with non-facial face recognition network for image screening, and matches with the pre-constructed feature library through feature vector calculation to achieve face recognition.
It improves the accuracy and efficiency of face recognition, and solves the problems of difficult face capture, great fuzzy impact and low timeliness in traditional methods.
Smart Images

Figure CN119399813A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of face recognition technology, and in particular to a face recognition method, device, equipment, medium and product. Background Art
[0002] The traditional face search method has the following three main disadvantages: (1) Since there are many cameras along the street and it is usually difficult to capture the face of the target person, it is necessary to compare and analyze video data from multiple channels at multiple times, which has high manpower and time costs. (2) Street cameras have problems such as blur, overexposure, and light interference. The accuracy of relying solely on naked eye comparison is low. (3) The timeliness of the traditional face search method is low: if real-time video is analyzed, it is easy to overlook the target person due to the large number of video channels, which wastes time. If post-event recordings are analyzed, only the movement of the target person can be determined, and the target person cannot be quickly locked.
[0003] It can be seen from the above description that there is no way to perform efficient and accurate face recognition on audio and video files in the prior art.
[0004] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention
[0005] The main purpose of this application is to provide a face recognition method, device, equipment, medium and product, aiming to solve the technical problem that the current face recognition for street video surveillance scenes does not involve a complete face recognition process including face detection, face quality assessment, face image optimization, etc., and cannot achieve efficient and accurate face recognition.
[0006] To achieve the above object, the present application proposes a face recognition method, which is applied to a face recognition system and includes:
[0007] Performing face detection on image data using a pre-built face detection model to obtain a face image set, wherein the face detection model is constructed by combining a learnable feature graph weighted fusion module with a feature pyramid network;
[0008] Performing image screening on the face image set through a non-frontal face recognition network to obtain a final face image set;
[0009] Vector calculation is performed on the final face image set to obtain a feature vector, and based on the feature vector, face recognition is performed on the final face image set through a pre-constructed feature library to obtain a recognition result.
[0010] In one embodiment, before the step of performing face detection on the image data using a pre-built face detection model to obtain a face image set, the method further includes:
[0011] Based on the first loss function, a face detection and positioning loss function and a face key point position function are created;
[0012] A face category loss function is created based on the second loss function;
[0013] A multi-task loss function is constructed by using the face detection and positioning loss function, the face key point position function and the face category loss function;
[0014] A learnable feature map weighted fusion module is constructed through several learnable parameter components;
[0015] An initial face detection model is constructed based on a preset feature pyramid network, the multi-task loss function and the learnable feature map weighted fusion module, and the initial face detection model is trained to obtain a face detection model.
[0016] In one embodiment, the step of training the initial face detection model to obtain the face detection model includes:
[0017] Use the data annotation tool Labelme to annotate faces in the preset training data set and obtain the annotation results;
[0018] According to the labeling results and the training data set, the initial face detection model is trained by a stochastic gradient descent (SGD) optimizer to obtain a face detection RetinaFace model.
[0019] In one embodiment, the step of performing face detection on image data using a pre-built face detection model to obtain a face image set includes:
[0020] Adjusting the image data according to an input size of the RetinaFace model to obtain adjusted image data;
[0021] Extracting features from the adjusted image data through the feature graph weighted fusion module and the feature pyramid network to obtain a feature image set;
[0022] The feature image set is calculated using the multi-task loss function to obtain a face image set.
[0023] In one embodiment, before the step of screening the face image set by a non-frontal face recognition network to obtain a final face image set, the method further comprises:
[0024] The initial non-frontal face recognition network is constructed through several convolutional layers, several pooling layers and several fully connected layers;
[0025] Annotate the pre-acquired non-frontal face recognition data set to obtain a frontal face label data set and a non-frontal face label data set;
[0026] After data enhancement is performed on the front face label data set and the non-front face label data set, the data set is input into the initial non-front face recognition network for training to obtain a non-front face recognition network.
[0027] In one embodiment, the step of performing image screening on the face image set through a non-frontal face recognition network to obtain a final face image set comprises:
[0028] Filtering the face image set according to a preset image size to obtain a first face image set;
[0029] Performing a quality assessment on the first face image set using a quality detection model to obtain a quality score, and screening the first face image set based on the quality score to obtain a second face image set;
[0030] The non-frontal face recognition network is used to perform non-frontal face detection on the second face image set, and the detected non-frontal faces are deleted from the second face image set to obtain a final face image set.
[0031] In one embodiment, the step of performing vector calculation on the final face image set to obtain a feature vector comprises:
[0032] Optimizing the final face image set by repairing the model CodeFormer to obtain an optimization result;
[0033] Based on the facial key points of the final facial image set, performing affine transformation on the optimization result to obtain a transformation result;
[0034] The transformation result is vectorized by using the face recognition model ArcFace to obtain the feature vector of the final face image set.
[0035] In addition, to achieve the above-mentioned purpose, the present application also proposes a face recognition device, which is applied to a face recognition system, and the device includes:
[0036] A detection module, used to perform face detection on image data using a pre-built face detection model to obtain a face image set, wherein the face detection model is constructed by combining a learnable feature graph weighted fusion module with a feature pyramid network;
[0037] A screening module, used for screening the face image set through a non-frontal face recognition network to obtain a final face image set;
[0038] The recognition module is used to perform vector calculation on the final face image set to obtain a feature vector, and based on the feature vector, perform face recognition on the final face image set through a pre-built feature library to obtain a recognition result.
[0039] In addition, to achieve the above-mentioned purpose, the present application also proposes a face recognition device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the face recognition method described above.
[0040] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the face recognition method described above are implemented.
[0041] One or more technical solutions proposed in this application have at least the following technical effects:
[0042] The embodiment of the present application proposes a face recognition method, device, equipment and computer program product, which performs face detection on image data through a pre-constructed face detection model to obtain a face image set, wherein the face detection model is constructed by a learnable feature graph weighted fusion module combined with a feature pyramid network; the face image set is screened through a non-frontal face recognition network to obtain a final face image set; vector calculation is performed on the final face image set to obtain a feature vector, and based on the feature vector, face recognition is performed on the final face image set through a pre-constructed feature library to obtain a recognition result. Thus, face detection is performed on the received image data through a pre-constructed face detection model to obtain a face image set, and then the face image set is screened through a non-frontal face recognition network to obtain a final face image, and finally, face recognition is performed on the final face image set based on a pre-constructed feature library to obtain a recognition result, which solves the problem that the current face recognition for street video surveillance scenes does not involve a complete face recognition process including face detection, face quality assessment, face image optimization, etc., and cannot achieve efficient and accurate face recognition, thereby improving the accuracy of face recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0044] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0045] Figure 1 A schematic diagram of a flow chart provided for the first embodiment of the face recognition method of the present application;
[0046] Figure 2 A schematic diagram of the RetinaFace model structure involved in the face recognition method of the present application;
[0047] Figure 3 A schematic diagram of the flow chart provided for the second embodiment of the face recognition method of the present application;
[0048] Figure 4 A schematic diagram of a non-frontal face recognition network structure involved in the face recognition method of the present application;
[0049] Figure 5 A schematic diagram of the face recognition method for the present application involving the quality assessment of face images;
[0050] Figure 6 A brief flowchart of the face recognition method provided in Example 2 of the present application;
[0051] Figure 7 This is a schematic diagram of the module structure of the face recognition device according to an embodiment of the present application;
[0052] Figure 8 Schematic diagram of the device structure of the hardware operating environment involved in the face recognition method in the embodiment of the present application.
[0053] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0054] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0055] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0056] The main solution of the embodiment of the present application is: based on the first loss function, a face detection positioning loss function and a face key point position function are created; based on the second loss function, a face category loss function is created; a multi-task loss function is constructed through the face detection positioning loss function, the face key point position function and the face category loss function; a learnable feature map weighted fusion module is constructed through several learnable parameter components; an initial face detection model is constructed based on a preset feature pyramid network, the multi-task loss function and the learnable feature map weighted fusion module, and the initial face detection model is trained to obtain a face detection model. The preset training data set is annotated with faces using the data annotation tool Labelme to obtain an annotation result; based on the annotation result and the training data set, the initial face detection model is trained using the stochastic gradient descent SGD optimizer to obtain a face detection RetinaFace model. According to the input size of the RetinaFace model, the image data is adjusted to obtain adjusted image data; the feature image set is extracted from the adjusted image data through the feature map weighted fusion module and the feature pyramid network; the face image set is calculated through the multi-task loss function. The initial non-frontal face recognition network is constructed by a number of convolutional layers, a number of pooling layers and a number of fully connected layers; the pre-acquired non-frontal face recognition data set is annotated to obtain a frontal face label data set and a non-frontal face label data set; the frontal face label data set and the non-frontal face label data set are data enhanced and input into the initial non-frontal face recognition network for training to obtain a non-frontal face recognition network. The face image set is screened according to a preset image size to obtain a first face image set; the quality of the first face image set is evaluated by a quality detection model to obtain a quality score, and the first face image set is screened based on the quality score to obtain a second face image set; the second face image set is detected by the non-frontal face recognition network, and the detected non-frontal faces are deleted from the second face image set to obtain a final face image set. The final face image set is optimized by the repair model CodeFormer to obtain an optimization result; based on the face key points of the final face image set, the optimization result is affine transformed to obtain a transformation result; the transformation result is vector calculated by the face recognition model ArcFace to obtain a feature vector of the final face image set. This solves the problem that the current face recognition for street video surveillance scenes does not involve a complete face recognition process including face detection, face quality assessment, face image optimization, etc., and cannot achieve efficient and accurate face recognition, realizes face recognition, and improves the accuracy of face recognition.Based on the scheme of the present invention, a face recognition method is designed based on the problem that the actual manual face search method mainly relies on the naked eye observation of the staff, and compares the facial features of the people appearing in the surveillance video with the target person one by one, and then locks the target person, but cannot realize whether the recognition result is accurate, thus resulting in low efficiency. The effectiveness of the face recognition method of the present invention is verified when recognizing faces, and finally the accuracy of face recognition performed by the method of the present invention is significantly improved.
[0057] In this embodiment, for the convenience of description, the following description is made with the face recognition device as the execution subject.
[0058] In the prior art, due to the large number of street cameras and the difficulty in capturing the faces of target persons, it is necessary to compare and analyze video data from multiple channels at multiple times, which has high manpower and time costs. In addition, street cameras are blurry, overexposed, and have light interference. The accuracy of naked eye comparison is low. In addition, the traditional face search method has low timeliness. If real-time video is analyzed, the target person may be easily overlooked due to the large number of video channels, which wastes time. If post-event recording is analyzed, only the movement of the target person can be determined, and the target person cannot be quickly locked.
[0059] This application provides a solution that uses a pre-built RetinaFace model in a face recognition system to better recognize faces, improve the accuracy of face recognition, and provide users with better services.
[0060] From the above embodiments, it can be seen that the present application performs face detection on the image data through a pre-constructed face detection model to obtain a face image set, and the face detection model is constructed by a learnable feature graph weighted fusion module combined with a feature pyramid network; the face image set is screened through a non-frontal face recognition network to obtain a final face image set; vector calculation is performed on the final face image set to obtain a feature vector, and based on the feature vector, face recognition is performed on the final face image set through a pre-constructed feature library to obtain a recognition result. Thus, face detection is performed on the received image data through a pre-constructed face detection model to obtain a face image set, and then the face image set is screened through a non-frontal face recognition network to obtain a final face image, and finally, face recognition is performed on the final face image set based on a pre-constructed feature library to obtain a recognition result, which solves the problem that the current face recognition for street video surveillance scenes does not involve a complete face recognition process including face detection, face quality assessment, face image optimization, etc., and cannot achieve efficient and accurate face recognition, thereby improving the accuracy of face recognition.
[0061] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device, an intention device device, etc. that can realize the above functions. The following takes a face recognition device as an example to illustrate this embodiment and the following embodiments.
[0062] Based on this, the present application embodiment provides a face recognition method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the face recognition method of the present application.
[0063] In this embodiment, the face recognition method is applied to a face recognition system, and the method includes steps S06 to S11:
[0064] Step S06, performing face detection on the image data by using a pre-built face detection model to obtain a face image set, wherein the face detection model is constructed by combining a learnable feature graph weighted fusion module with a feature pyramid network;
[0065] It should be clear that the present embodiment targets the following three drawbacks of the existing face search method: (1) Since there are many cameras along the street and it is usually difficult to capture the face of the target person, it is necessary to compare and analyze video data from multiple channels at multiple times, which has high manpower and time costs; (2) Street cameras have problems such as blur, overexposure, and light interference, and the accuracy of relying solely on naked eye comparison is low; (3) The timeliness of the traditional face search method is low: if real-time video is analyzed, the target person is easily overlooked due to the large number of video channels, which wastes time; if post-event video is analyzed, only the movement of the target person can be determined, and the target person cannot be quickly locked.
[0066] Therefore, in this embodiment, face detection is performed on image data through a pre-built face detection RetinaFace model to obtain a face image set, wherein the image data is obtained when the actual camera equipment performs road monitoring, that is, the image data in this embodiment is obtained in real time. In addition, the RetinaFace model in this embodiment includes at least a feature map weighted fusion module, and RetinaFace is a deep learning model for face detection, mainly based on a single-stage convolutional neural network (CNN). Its features include:
[0067] (1) Efficiency: RetinaFace can achieve fast detection while maintaining high accuracy in real-time detection tasks;
[0068] (2) Multi-scale features: Through the feature pyramid network (FPN), RetinaFace can process faces of different sizes, making it particularly effective in detecting small objects;
[0069] (3) Key point detection: In addition to the bounding box of the face, RetinaFace can also detect the key points of the face, such as the positions of the eyes, nose, and mouth;
[0070] (4) Loss function: A new loss function is used, which combines classification, regression and key point detection to improve the overall performance of the model.
[0071] Step S10, performing image screening on the face image set through a non-frontal face recognition network to obtain a final face image set;
[0072] After obtaining the face image set, since the actual images may be blurred, side-faced, or too small, the face image set is screened through a non-frontal face recognition network, and images that do not meet the requirements are deleted to obtain the final face image library that can be used for face recognition.
[0073] Step S11, performing vector calculation on the final face image set to obtain a feature vector, and based on the feature vector, performing face recognition on the final face image set through a pre-constructed feature library to obtain a recognition result.
[0074] After completing the screening of the images, the final face image library that can be used for identification is obtained. At this time, the pre-constructed feature library is used for face recognition to obtain the recognition result. Among them, the feature library in this embodiment can be the face image recorded when the identity card is made, the passport is processed, and the household registration is transferred, etc., so the user's specific face image can be recorded. The feature library constructed in this way has a better effect when tracking the target person, etc. It should be clear that the principle of recognition by the feature library in this embodiment is to use the final face image set to perform vector calculation to obtain the feature vector of the image set, and then use the feature library to perform similarity matching on the feature vector of the final image set, thereby realizing further recognition of the face.
[0075] Specifically, before the step S06, in which a face detection model is pre-built to perform face detection on the image data to obtain a face image set, the method further includes:
[0076] Step S01, creating a face detection and positioning loss function and a face key point position function based on the first loss function;
[0077] Step S02, creating a face category loss function based on the second loss function;
[0078] Step S03, constructing a multi-task loss function through the face detection and positioning loss function, the face key point position function and the face category loss function;
[0079] Step S04, constructing a learnable feature graph weighted fusion module through a number of learnable parameter components;
[0080] Step S05, constructing an initial face detection model based on a preset feature pyramid network, the multi-task loss function and the learnable feature map weighted fusion module, and training the initial face detection model to obtain a face detection model.
[0081] It should be clear that the RetinaFace model in this embodiment has more differences from the common models in the prior art in addition to the feature map weighted fusion module, such as adding four learnable parameter components L2, L3, L4 and L5 for feature maps C2, C3, C4 and C5 respectively. In addition, the loss function used by the RetinaFace model in this embodiment is:
[0082] The dense autoregression loss in the original RetinaFace model is deleted, and only the face detection and positioning loss L is retained. loc , face category loss L c , face key point position loss L landmark , where the face detection positioning loss and the face key point position loss use the Smooth L1 loss function, and the face category loss uses the cross entropy loss function. The weights of the three loss functions are all 1, and the final loss function form is as follows:
[0083] L=L loc +L c +L landmark
[0084] Specifically, the face detection and positioning loss function uses the Smooth L1 loss function to describe the gap between the face frame predicted by the model and the real face frame. Its specific form is as follows:
[0085]
[0086] in, represents the x and y coordinates of the upper left corner of the i-th positive sample face frame predicted by the improved RetinaFace model, and the width and length of the frame, represents the x, y coordinates of the upper left corner of the normalized real face frame corresponding to the i-th positive sample face frame and the width and length of the frame, "pos" represents the positive sample, N pos is the number of positive samples;
[0087] The face category loss function uses the traditional binary cross entropy loss function to describe the classification accuracy of the face target in the prediction box. Its specific form is as follows:
[0088]
[0089] Among them, p i is the probability value of the i-th sample predicted by the improved RetinaFace model, y i is the label of whether the i-th sample is a face, “0” represents not a face, “1” represents a face, and N is the number of all samples;
[0090] The face key point position loss function also uses the Smooth L1 loss function to describe the prediction accuracy of the positions of the five face key points (one key point for each eye, one key point for the nose, and one key point for each left and right corner of the mouth). Its specific form is as follows:
[0091]
[0092] in, represents the coordinates of the jth key point of the ith positive sample predicted by the improved RetinaFace model, Indicates the coordinates of the true jth key point corresponding to the ith positive sample, "pos" represents the positive sample, N pos is the number of positive samples.
[0093] A multi-task loss function is constructed by the above-mentioned face detection positioning loss function, face key point position function and face category loss function, and then an initial face detection model is constructed based on a preset feature pyramid network, the multi-task loss function and the learnable feature map weighted fusion module, and the initial face detection model is trained to obtain a face detection model.
[0094] More specifically, the step S04 of training the initial face detection model to obtain the face detection model includes:
[0095] Step S051, using the data annotation tool Labelme to annotate faces in a preset training data set to obtain an annotation result;
[0096] Step S052: According to the labeling result and the training data set, the initial face detection model is trained by a stochastic gradient descent (SGD) optimizer to obtain a face detection RetinaFace model.
[0097] The model training process in this embodiment can be:
[0098] The first step is to use the open source WIDERFACE dataset for pre-training, and the second step is to use image data collected from actual street surveillance scenes for model fine-tuning training;
[0099] Since the first step is the same as the traditional RetinaFace training process, this article mainly describes the second step of training:
[0100] First, 1,000 videos of street surveillance scenes were collected. Each video was about 1 minute long. A frame was sampled every 10 seconds to obtain a real-scene training dataset containing 6,000 frame images.
[0101] Then, we use the data annotation software Labelme to annotate the faces in all images, frame the area where the face is located, and define the category as face. The position and size of the frame are used as scalar data and correspond one-to-one to the face.
[0102] Finally, the model was fine-tuned for a second time using the actual scenario dataset. During the second fine-tuning training, the SGD optimizer was used, the learning rate was 0.0001, the momentum was set to 0.9, the weight decay coefficient was 0.0005, and the number of training rounds was 30.
[0103] Furthermore, in the above step S06, the step of performing face detection on the image data using a pre-built face detection model to obtain a face image set includes:
[0104] Step S061, adjusting the image data according to the input size of the RetinaFace model to obtain adjusted image data;
[0105] Step S062, extracting features from the adjusted image data through the feature map weighted fusion module and the feature pyramid network to obtain a feature image set;
[0106] Step S063, calculating the feature image set by using the multi-task loss function to obtain a face image set.
[0107] After using the above solution, you can get the RetinaFace model, which can then be used for face recognition. The steps are as follows:
[0108] First, the input image size of the original RetinaFace was adjusted from 640×640 to 1280×1280. By increasing the size of the input image, the loss of face clarity during image preprocessing can be reduced, and the size of the original detection anchor point can be reduced compared to the image, making it more suitable for detecting small faces at medium and long distances.
[0109] In order to make each layer of the feature pyramid network output feel the features of different scales and enhance the fusion ability of the output features of the RetinaFace feature pyramid network with the features of each scale, this proposal uses a feature map weighted fusion module to increase the interaction between features of each layer, balance the information flow, enhance feature discrimination, and improve the ability to extract tiny features, thereby increasing the model's detection performance for small faces at medium and long distances, such as Figure 2 As shown, four learnable parameter components L2, L3, L4 and L5 are added for feature maps C2, C3, C4 and C5 respectively. Since the calculation steps of each learnable component are similar, this proposal takes L2 as an example to introduce the calculation process of this component in detail:
[0110] The input of the L2 component is the C2 feature map of the Resnet50 network. Assume that its dimension is (B, C, H, W), where B is the batch size ("batch size" or "batch size" refers to the number of samples passed to the model for training at one time when training a neural network model. Batch size is an important hyperparameter in deep learning and has a significant impact on the training process and model performance), C is the number of channels, H is the height of the feature map, and W is the width of the feature map. First, perform a pooling calculation operation on the C2 feature map with 256 channels to obtain M2. The dimension of M2 is (B, C). The calculation method for each element (i, j) of M2 is:
[0111]
[0112] Among them, i and j represent the jth channel of the i-th sample;
[0113] Next, a trainable fully connected layer F2 is constructed, the input feature dimension of the fully connected layer is C, and the output feature dimension is 1. By inputting M2 into the fully connected layer, a weight value W2 with a dimension of (B, 1) can be obtained;
[0114] The calculation process of L3, L4 and L5 is exactly the same as that of L2, and the values of weights W3, W4 and W5 can be obtained respectively. After obtaining the weights of W2, W3, W4 and W5, it is necessary to perform weighted summation calculation of the feature maps. Therefore, relevant transformations must be used to make the number of channels and length and width of the C2, C3, C4 and C5 feature maps completely equal. First, a trainable convolution layer is used for C2, C3, C4 and C5 respectively, with a convolution kernel size of 1×1 and a step size of 1, and the number of channels is converted to 256, which is equivalent to the number of output feature channels of the feature pyramid network. Then, since the size of the C3, C4 and C5 feature maps is smaller than that of C2, in order to perform subsequent weighted summation calculations, the length and width of the C3, C4 and C5 feature maps need to be scaled to make their length and width equal to the C2 feature map. The image scaling method uses bilinear interpolation. Here, the converted C2, C3, C4, and C5 feature maps are denoted as T2, T3, T4, and T5, and their dimensions are all (B, 256, H, W). Here, H and W are equal to the C2 feature map. In summary, the weighted summation result of the feature map is:
[0115] M=W2×T2+W3×T3+W4×T4+W5×T5
[0116] The dimension of M is (B, 256, H, W). Finally, M is scaled to the length and width of P2, P3, and P4 respectively, and the feature map is added to P2, P3, and P4 of the original feature pyramid (such as Figure 2 shown).
[0117] Considering that the faces captured by street cameras are small, we add anchor points on the P2 feature map scale to the anchor points of the original RetinaFace network. The anchor points are squares with the shortest side of 16. Specifically, at each point in the P2 feature map, we set a 16×16 box as an anchor point. Here, 16×16 is the pixel size mapped to the original image, and the resulting face image set can be output.
[0118] This embodiment uses the above scheme to perform face detection on the image data through a pre-built face detection model to obtain a face image set, and the face detection model is constructed by combining a learnable feature graph weighted fusion module with a feature pyramid network; the face image set is screened through a non-frontal face recognition network to obtain a final face image set; vector calculation is performed on the final face image set to obtain a feature vector, and based on the feature vector, face recognition is performed on the final face image set through a pre-built feature library to obtain a recognition result. Thus, face detection is performed on the received image data through a pre-built face detection model to obtain a face image set, and then the face image set is screened through a non-frontal face recognition network to obtain a final face image, and finally, face recognition is performed on the final face image set based on a pre-built feature library to obtain a recognition result, which solves the problem that the current face recognition for street video surveillance scenes does not involve a complete face recognition process including face detection, face quality assessment, face image optimization, etc., and cannot achieve efficient and accurate face recognition, thereby improving the accuracy of face recognition.
[0119] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 3 Before the step S10 of screening the face image set by a non-frontal face recognition network to obtain a final face image set, the face recognition method further includes steps S07 to S09:
[0120] Step S07, constructing an initial non-frontal face recognition network through a plurality of convolutional layers, a plurality of pooling layers, and a plurality of fully connected layers;
[0121] Step S08, annotating the pre-acquired non-frontal face recognition data set to obtain a frontal face label data set and a non-frontal face label data set;
[0122] Step S09, performing data enhancement on the frontal face label data set and the non-frontal face label data set, and then inputting the data into the initial non-frontal face recognition network for training to obtain a non-frontal face recognition network.
[0123] Before the non-frontal face network is used, it needs to be pre-built. In this embodiment, the non-frontal face network is as follows: Figure 4 As shown, "Conv3x3,64" means 3×3 convolution kernel, 64 channel output, and stride 1;
[0124] "MaxPool2x2" means a 2×2 maximum pooling layer, "BN-ReLU" means batch normalization followed by ReLU activation function, and "FC" means a fully connected layer. The model contains 3 convolutional layers, 3 pooling layers, and 1 fully connected layer. Batch normalization is used after each convolutional layer, and then the ReLU activation function is used to process the output features. The network input is a 64×64 face image. If the face image itself is not 64×64, the face image must be transformed first: ensure that the long side of the face image is 64, and then add 0 pixels on both sides of the short side until the short side is also 64 in length.
[0125] In order to build the network, we first need to build a training data set. The training data used in this proposal comes from 500 videos collected by actual street camera scenes. Each video is 1 minute long and a frame is taken every 10 seconds, so a total of 3,000 training images are obtained. After that, all faces in the 3,000 training images are labeled and divided into two labels: front face and non-front face. Low-quality faces are deleted according to the above face quality assessment method (except side face recognition). In order to enhance the model training effect, the image is horizontally mirrored and randomly rotated 0-15 degrees left and right for online data enhancement. The model training process uses the Adam optimizer with a learning rate of 0.0001 and 30 training rounds. After the model training is completed, the face image is input and the probability value of the face being a front face or a non-front face is output. The faces with a non-front face probability value greater than 0.8 are deleted.
[0126] Specifically, in the above embodiment, the step S10, the step of screening the face image set by a non-frontal face recognition network to obtain a final face image set includes:
[0127] Step S101, screening the face image set according to a preset image size to obtain a first face image set;
[0128] Step S102, performing quality assessment on the first face image set using a quality detection model to obtain a quality score, and screening the first face image set based on the quality score to obtain a second face image set;
[0129] Step S103, performing non-frontal face detection on the second face image set through the non-frontal face recognition network, deleting the detected non-frontal faces from the second face image set, and obtaining a final face image set.
[0130] In this embodiment, the image screening is as follows Figure 5As shown in the figure, first, the detected faces that are too small will be deleted. The rule is that if the length of the long side or the short side of the detected face is less than 16, the face is considered an unqualified face and is deleted directly. Then, the open source face quality detection model TOPIQ is used to evaluate the quality of all detected face images, and the poor quality faces with a quality score lower than 0.1 are deleted. Finally, the non-frontal face recognition network is used to delete the detected non-frontal faces. Among them, TOPIQ is a face detection and recognition model for deep learning, which aims to improve accuracy and efficiency. It combines multiple technologies, such as attention mechanism and feature fusion, to optimize the extraction and recognition of facial features. The model usually performs well when dealing with complex scenes or diverse faces.
[0131] More specifically, in the above embodiment, the step S11 of performing vector calculation on the final face image set to obtain a feature vector includes:
[0132] Step S111, optimizing the final face image set by repairing the model CodeFormer to obtain an optimization result;
[0133] Step S112, performing affine transformation on the optimization result based on the facial key points of the final facial image set to obtain a transformation result;
[0134] Step S113, performing vector calculation on the transformation result through the face recognition model ArcFace to obtain the feature vector of the final face image set.
[0135] First, the pre-trained CodeFormer model is used to further enhance the quality of the final face image set, improve the resolution, and optimize some blurred or missing face details;
[0136] Then, the five facial key points generated by the RetinaFace model are used to uniformly scale the face to a size of 112×112, and then the affine transformation method is used to align the detected face image with the given template feature point position, thereby achieving the calibration operation of the face image and reducing the impact of geometric factors such as tilt angle on the system;
[0137] Then, the pre-trained ArcFace model is used to calculate the feature vector of the above calibrated face image;
[0138] Finally, a pre-built feature library is used to perform face recognition through feature vectors to obtain recognition results. The construction of the feature library is implemented using the Milvus vector retrieval engine. Milvus is a high-performance open source feature vector similarity search engine that is suitable for scenarios where massive vector data needs to be saved and retrieved. It can achieve a millisecond-level vector retrieval latency of millions. The specific implementation method is to create a collection in the Milvus engine to store and manage face data. The collection contains three fields, one of which is a scalar field for storing the address of the face picture, one is a scalar field for the face name, and one is a floating-point vector field for storing the image feature embedding vector. In the face search task, the face image data stored in the feature library is uploaded in advance, usually in the form of ID photos. The uploaded face ID photos are also used to calculate the face feature vector, and the face storage address and name are simultaneously annotated. After the feature extraction and annotation of the face ID photos are completed, they are stored in the above-mentioned Milvus vector retrieval engine.
[0139] According to the actual face data and usage requirements, the IVF_FLAT method is used to index the feature embedding vector field. The calculation indicator of the distance between vectors is the inner product. In this embodiment, vectors with similar distances are divided into 512 clustering units (hyperparameters of IVF_FLAT) so that the sum of the distances between each vector and the cluster center to which it belongs is minimized. The IVF_FLAT index does not occupy much memory space and does not further encode the data. The original data is directly calculated during retrieval, which ensures a high recall rate while ensuring a high retrieval speed.
[0140] In the face search task, the feature vector of the face detected in the street camera scene must be matched with the face feature vector stored in the above-mentioned library. Specifically, relying on the Milvus vector search engine, the feature vector calculated by the detected face is calculated with the feature vector stored in the library. When there is a feature vector with an inner product greater than 0.5 in the library, it is considered that the detected face is in the library, otherwise it is considered that it is not in the library. By further returning the face image and the corresponding name corresponding to the feature vector with the largest inner product, the face search task can be completed.
[0141] This embodiment uses the above scheme to construct an initial non-frontal face recognition network through several convolutional layers, several pooling layers and several fully connected layers; annotate the pre-acquired non-frontal face recognition data set to obtain a frontal face label data set and a non-frontal face label data set; perform data enhancement on the frontal face label data set and the non-frontal face label data set and input them into the initial non-frontal face recognition network for training to obtain a non-frontal face recognition network. Thus, face detection is performed on the received image data through a pre-constructed face detection model to obtain a face image set, and then the face image set is screened through a non-frontal face recognition network to obtain a final face image, and finally face recognition is performed on the final face image set based on a pre-constructed feature library to obtain a recognition result, which solves the problem that the current face recognition for street video surveillance scenes does not involve a complete face recognition process including face detection, face quality assessment, face image optimization, etc., and cannot achieve efficient and accurate face recognition, thereby improving the accuracy of face recognition.
[0142] For example, to help understand the implementation process of the face recognition method obtained by combining this embodiment with the above-mentioned embodiment 1, please refer to Figure 6 , Figure 6 A brief flow chart of a face recognition method is provided, specifically:
[0143] Step 1: Use the improved RetinaFace model to implement face detection in street surveillance scenarios, obtain the face detection frame and the corresponding five face key points, and further obtain the face image through the detection frame;
[0144] Step 2: In complex scenarios such as street cameras, the quality of the facial images obtained in step 1 varies. It is necessary to evaluate the quality of the facial images and remove facial images that do not meet the quality requirements to ensure the accuracy of subsequent facial matching.
[0145] Step 3: Use the pre-trained (deep learning model) CodeFormer model to further optimize the face image quality;
[0146] Step 4: Based on the five facial key points generated in step 1, a geometric transformation method is used to calibrate the facial image to reduce the impact of geometric factors such as tilt angles on the system;
[0147] Step 5: Based on the calibrated face image obtained in step 4, use the pre-trained ArcFace model (ArcFace is a deep learning model for facial recognition, mainly used to improve the accuracy of face recognition. The core idea is to optimize the embedded representation of facial features by introducing a new loss function, the ArcFace loss function. This method maps facial features to a high-dimensional space and optimizes the angle interval to improve recognition accuracy) to extract facial image features;
[0148] Step 6: Use Milvus (Milvus is an open source vector database designed for processing and managing large-scale, high-dimensional vector data. It is widely used in machine learning and artificial intelligence applications, especially those that require efficient retrieval and analysis of large amounts of vector data, such as image retrieval, speech recognition, and natural language processing) vector retrieval engine to build a facial feature vector database. Use vector retrieval to determine whether a given face is already in the face vector database, thereby realizing the face search function.
[0149] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the face recognition method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0150] This application also provides a face recognition device, please refer to Figure 7 , the device is applied to a face recognition system, and the device comprises:
[0151] A detection module 10 is used to perform face detection on image data using a pre-built face detection model to obtain a face image set, wherein the face detection model is constructed by combining a learnable feature graph weighted fusion module with a feature pyramid network;
[0152] A screening module 20, configured to screen the face image set through a non-frontal face recognition network to obtain a final face image set;
[0153] The recognition module 30 is used to perform vector calculation on the final face image set to obtain a feature vector, and based on the feature vector, perform face recognition on the final face image set through a pre-built feature library to obtain a recognition result.
[0154] The face recognition device provided by the present application adopts the face recognition method in the above embodiment, which can solve the technical problem that the current face recognition for street video surveillance scenes does not involve a complete face recognition process including face detection, face quality assessment, face image optimization, etc., and cannot achieve efficient and accurate face recognition. Compared with the prior art, the beneficial effects of the face recognition device provided by the present application are the same as the beneficial effects of the face recognition method provided by the above embodiment, and the other technical features of the face recognition device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0155] The present application provides a face recognition device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the face recognition method in the above-mentioned embodiment 1.
[0156] Reference below Figure 8 , which shows a schematic diagram of the structure of a face recognition device suitable for implementing the embodiment of the present application. The face recognition device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 8 The facial recognition device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0157] like Figure 8As shown, the face recognition device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the face recognition device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the face recognition device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows a face recognition device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or provided instead.
[0158] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0159] The face recognition device provided by this application adopts the face recognition method in the above embodiment, which can solve the technical problem that the current face recognition for street video surveillance scenes does not involve a complete face recognition process including face detection, face quality assessment, face image optimization, etc., and cannot achieve efficient and accurate face recognition. Compared with the prior art, the beneficial effects of the face recognition device provided by this application are the same as the beneficial effects of the face recognition method provided by the above embodiment, and the other technical features in the face recognition device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0160] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0161] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0162] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, wherein the computer-readable program instructions are used to execute the face recognition method in the above-mentioned embodiment.
[0163] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0164] The computer-readable storage medium may be included in the face recognition device; or may exist independently without being assembled into the face recognition device.
[0165] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by a face recognition device, the face recognition device: performs face detection on image data through a pre-built face detection model to obtain a face image set, wherein the face detection model is constructed by a learnable feature graph weighted fusion module combined with a feature pyramid network; performs image screening on the face image set through a non-frontal face recognition network to obtain a final face image set; performs vector calculation on the final face image set to obtain a feature vector, and based on the feature vector, performs face recognition on the final face image set through a pre-built feature graph library to obtain a recognition result.
[0166] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0167] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0168] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0169] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned face recognition method, and can solve the technical problem that the current face recognition for street video surveillance scenes does not involve a complete face recognition process including face detection, face quality assessment, face image optimization, etc., and cannot achieve efficient and accurate face recognition. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the face recognition method provided by the above-mentioned embodiment, which will not be repeated here.
[0170] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned face recognition method when executed by a processor.
[0171] The computer program product provided by this application can solve the technical problem that the current face recognition for street video surveillance scenes does not involve a complete face recognition process including face detection, face quality assessment, face image optimization, etc., and cannot achieve efficient and accurate face recognition. Compared with the prior art, the beneficial effects of the computer program product provided by this application are the same as the beneficial effects of the face recognition method provided by the above embodiment, which will not be repeated here.
[0172] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A face recognition method, characterized in that: The method is applied to a face recognition system, and the method comprises: Performing face detection on image data using a pre-built face detection model to obtain a face image set, wherein the face detection model is constructed by combining a learnable feature graph weighted fusion module with a feature pyramid network; Performing image screening on the face image set through a non-frontal face recognition network to obtain a final face image set; Vector calculation is performed on the final face image set to obtain a feature vector, and based on the feature vector, face recognition is performed on the final face image set through a pre-constructed feature library to obtain a recognition result.
2. The method according to claim 1, characterized in that Before the step of performing face detection on the image data using a pre-built face detection model to obtain a face image set, the method further includes: Based on the first loss function, a face detection and positioning loss function and a face key point position function are created; A face category loss function is created based on the second loss function; A multi-task loss function is constructed by using the face detection and positioning loss function, the face key point position function and the face category loss function; A learnable feature map weighted fusion module is constructed through several learnable parameter components; An initial face detection model is constructed based on a preset feature pyramid network, the multi-task loss function and the learnable feature map weighted fusion module, and the initial face detection model is trained to obtain a face detection model.
3. The method according to claim 2, characterized in that The step of training the initial face detection model to obtain the face detection model comprises: Use the data annotation tool Labelme to annotate faces in the preset training data set and obtain the annotation results; According to the labeling results and the training data set, the initial face detection model is trained by a stochastic gradient descent (SGD) optimizer to obtain a face detection RetinaFace model.
4. The method according to claim 3, characterized in that The step of performing face detection on the image data using a pre-built face detection model to obtain a face image set comprises: Adjusting the image data according to an input size of the RetinaFace model to obtain adjusted image data; Extracting features from the adjusted image data through the feature graph weighted fusion module and the feature pyramid network to obtain a feature image set; The feature image set is calculated using the multi-task loss function to obtain a face image set.
5. The method according to claim 1, characterized in that Before the step of screening the face image set by a non-frontal face recognition network to obtain a final face image set, the method further comprises: The initial non-frontal face recognition network is constructed through several convolutional layers, several pooling layers and several fully connected layers; Annotate the pre-acquired non-frontal face recognition data set to obtain a frontal face label data set and a non-frontal face label data set; After data enhancement is performed on the front face label data set and the non-front face label data set, the data set is input into the initial non-front face recognition network for training to obtain a non-front face recognition network.
6. The method according to claim 1, characterized in that The step of performing image screening on the face image set through the non-frontal face recognition network to obtain the final face image set comprises: Filtering the face image set according to a preset image size to obtain a first face image set; Performing a quality assessment on the first face image set using a quality detection model to obtain a quality score, and screening the first face image set based on the quality score to obtain a second face image set; The non-frontal face recognition network is used to perform non-frontal face detection on the second face image set, and the detected non-frontal faces are deleted from the second face image set to obtain a final face image set.
7. The method according to claim 1, characterized in that The step of performing vector calculation on the final face image set to obtain a feature vector comprises: Optimizing the final face image set by repairing the model CodeFormer to obtain an optimization result; Based on the facial key points of the final facial image set, performing affine transformation on the optimization result to obtain a transformation result; The transformation result is vectorized by using the face recognition model ArcFace to obtain the feature vector of the final face image set.
8. A face recognition device, characterized in that: The device is applied to a face recognition system, and comprises: A detection module, used to perform face detection on image data using a pre-built face detection model to obtain a face image set, wherein the face detection model is constructed by combining a learnable feature graph weighted fusion module with a feature pyramid network; A screening module, used for screening the face image set through a non-frontal face recognition network to obtain a final face image set; The recognition module is used to perform vector calculation on the final face image set to obtain a feature vector, and based on the feature vector, perform face recognition on the final face image set through a pre-built feature library to obtain a recognition result.
9. A face recognition device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the face recognition method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the face recognition method according to any one of claims 1 to 7 are implemented.
11. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the face recognition method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Personal image digital human generation system
CN120954063A