A liveness detection method, device, and medium based on facial recognition
By using a neural network model with high-dimensional face recognition loss function and classification loss function, combined with residual network and Gaussian smoothing, the accuracy problem of existing liveness detection technology under rapid response and environmental changes is solved, thus improving the prevention of fake faces and environmental adaptability.
Patent Information
- Application Number
- CN202210968720.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-12
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2042-08-12
AI Technical Summary
Current liveness detection technology is time-consuming in fast-response scenarios, is not effective in preventing fake face attacks in unknown domains, is prone to failure when the environment changes, and has difficulty distinguishing between real and fake fake face photos when they are shaken, resulting in low classification accuracy.
A neural network model employing a high-dimensional face recognition loss function and a classification loss function is used. Features are extracted through a residual network, and Gaussian smoothing is combined to filter fake face photos, thereby enhancing the difference between real and fake face classes and improving environmental adaptability.
It achieves fast response with single-frame photo input, improves the ability to prevent fake faces of unknown attack types and the accuracy under environmental changes, and enhances the stability and accuracy of the model.
Smart Images

Figure CN115116148B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to facial recognition technology, and in particular to a liveness detection method, device and medium based on facial recognition. Background Technology
[0002] With technological advancements and societal development, facial recognition is finding increasingly diverse applications, such as smart security and mobile payments. A successful fake face attack could potentially cause significant losses, making its security a top priority in all scenarios, including security, payments, and others. Forgery attacks targeting this scenario include, but are not limited to, using printed paper, electronic screens, or mannequin masks. Therefore, determining whether a detected face is real or fake is one of the core technologies of this system.
[0003] Current liveness detection solutions are divided into dynamic liveness detection and silent liveness detection, which have the following problems:
[0004] ① At present, dynamic liveness detection is difficult to deploy in scenarios that require fast response: because the ordinary convolutional design method tends to use long sequences as input to extract dynamic features. Its model input is dynamic multi-frame images, or it needs to complete a combination of actions such as blinking, opening mouth, shaking head, and nodding, which makes the method time-consuming.
[0005] ② Currently, most silent dynamic liveness detection products are not effective against spoofing attacks in unknown domains: Existing products in the same field use classifiers to identify single-frame face images under visible light to determine whether the face is live or spoofed, and use cross-entropy or softmax loss functions for liveness detection. However, these loss functions only have separability, separating between classes but not discriminability, and cannot aggregate within classes. In other words, the extracted liveness features have too small an inter-class distance.
[0006] The problem of excessive intra-class distance affecting the accuracy of liveness classification makes it ineffective in preventing fake face attacks in unknown domains.
[0007] ③ Current silent liveness detection products are prone to failure when the environment changes (such as different light intensities): due to their model design, their effectiveness depends heavily on the training set data acquisition scenario. When the environment changes and is not in the data acquisition scenario, the model will fail.
[0008] ④ Current silent liveness detection products may miss liveness detection when some fake face photos are shaken: the silent liveness detection solution has limited information learned from a single frame photo and the model accuracy is insufficient in fast-response scenarios. Summary of the Invention
[0009] To address the aforementioned issues, this invention provides a liveness detection method based on facial recognition. It constructs a high-dimensional neural network model (hdfld-net) for liveness detection that integrates facial recognition loss functions and classification loss functions. This model uses facial recognition to reduce intra-class distance between real faces and increase inter-class differences between real and fake faces. Furthermore, it extracts fine-grained high-dimensional features from liveness photos, improving the accuracy of liveness detection under varying environmental conditions and enhancing its ability to prevent fake faces of unknown attack types. Gaussian smoothing between frames is used to filter out fake face photos with easily fluctuating scores in traditional silent liveness detection, improving the prevention of fake faces in unknown domains and increasing the model's accuracy under different environmental conditions.
[0010] This invention is achieved through the following technical solution:
[0011] This invention provides a liveness detection method based on facial recognition, comprising the following steps:
[0012] Step 1: Obtain and classify multiple face images of different types, and divide all face images into training set and test set according to a set ratio;
[0013] Step 2: Normalize the various types of face images classified in the training set and generate face image proxies for each type. Construct triplet data pairs for each face image based on the face image proxies for each type.
[0014] Step 3: Construct a backbone network based on the residual network, and build an integration system based on the backbone network.
[0015] A high-dimensional neural network model for silent face liveness detection, incorporating loss functions for face recognition and classification.
[0016] Step 4: Each time, input the triplet data pairs and liveness data of a face image from the training set into the high-dimensional silent face liveness detection neural network model, and output the model score of the face image. Train and optimize the high-dimensional silent face liveness detection neural network model through the input and output process.
[0017] Step 5: Input the face images in the test set into the high-dimensional silent liveness detection neural network model for testing. Obtain the prediction results according to different prediction thresholds. Determine the true positive rate and false positive rate based on the prediction results and the actual results. Determine the true and false classification thresholds based on the true positive rate and false positive rate.
[0018] Step 6: When performing face detection, acquire a face image of the current frame;
[0019] Step 7: Input the current frame face image into the trained high-dimensional silent face liveness detection neural network model, output the model score of the current frame face image, obtain the liveness score based on the model score of the current frame face image, the model score of the previous frame face image, and the model score of the next frame face image, compare the liveness score with the true / false classification threshold, and obtain the judgment result.
[0020] Furthermore, the procedure before step 1 includes:
[0021] Step 11: Collect multiple human images of different types using the device or download multiple human images of different types from the cloud. The multiple human images of different types constitute a liveness dataset.
[0022] Step 12: Classify the obtained live dataset into categories such as real humans, printed paper, electronic screens, 2D masks, and 3D masks.
[0023] Step 13: Crop the face image from each of the human body images.
[0024] Furthermore, step 13 specifically includes:
[0025] The face detection algorithm detects facial key points and face bounding boxes in each human body image. The aligned face images are cropped by affine transformation of the key points. All face images constitute a live face dataset. All face images in the live face dataset are divided into training set and test set according to a set ratio.
[0026] Furthermore, step 2 specifically includes:
[0027] The classified face images in the training set are normalized, and face image proxies P are generated for each type of face image using normal distribution filtering. j , where P j Let represent the face image proxy of the j-th class, and 1≤j≤k, where k represents the number of classes and j is a positive integer;
[0028] According to the facial image proxy P j Construct triplet data pairs (p) for each face image ij P j P h ), where p ij Let P represent the i-th face image sample that is proxies the j-th face image, where 1 ≤ i ≤ n, and n represents the total number of face image samples in the j-th class, where n is a positive integer; h Let h represent the face image proxy of class h, where 1 ≤ h ≤ k, k represents the number of classes, h is a positive integer, and h ≠ j.
[0029] Furthermore, step 3 specifically includes:
[0030] Step 31: Constructing a backbone network based on residual networks specifically includes: the backbone network consists of 8 residual blocks, extracts feature information and cross-channel information of face images through convolutional layers, increases network depth by using 1x1 convolutional layers, and places downsampling operations in non-1×1 convolutional layers to avoid losing feature information, and uses the swish activation function as the activation function of the backbone network to improve network performance.
[0031] Step 32: Constructing a high-dimensional silent liveness detection neural network model integrating face recognition loss function and classification loss function based on the backbone network specifically includes: inputting the triplet data into the backbone network for processing, extracting face features f1 through the face recognition loss function, inputting the liveness data of the face image into the backbone network to extract liveness features f2, f1 and f2 for feature fusion, and obtaining the liveness score of the face image frame after processing through a fully connected layer and a classification loss function in sequence.
[0032] Furthermore, step 4 specifically includes:
[0033] Step 41: Obtain the triplet data pairs and liveness data of the first face image in the training set, and input them into the high-dimensional silent face liveness detection neural network model;
[0034] Step 42: After the triplet data is input into the backbone network for processing, the face features f1 are extracted through the face recognition loss function;
[0035] Step 43: Input the live data into the backbone network to extract the live feature f2;
[0036] Step 44: Fuse features f1 and liveness features f2, and then process them through a fully connected layer and a classification loss function to obtain the liveness score of the face image in that frame.
[0037] Step 45: Continue to obtain the triplet data pairs and liveness data of the next face image in the training set and repeat the operations of steps 51-54 until all face images in the training set have been traversed.
[0038] Step 46: Train and optimize the high-dimensional silent face liveness detection neural network model by inputting and outputting all face images in the training set.
[0039] Furthermore, step 5 specifically includes:
[0040] Step 51: Input the face images in the test set into the high-dimensional silent face liveness detection neural network model for testing;
[0041] Step 52: The prediction threshold range is 0 to 1. Iterate through all possibilities from 0 to 1 and obtain different prediction results based on different prediction thresholds.
[0042] Step 53: Determine the true positive rate and false positive rate based on the predicted results and the actual results;
[0043] The formula is as follows:
[0044]
[0045]
[0046] Wherein, TPR represents the true positive rate; TP means the predicted result is positive and the actual result is positive; FN means the predicted result is negative and the actual result is positive; FPR represents the false positive rate; FP means the predicted result is positive and the actual result is negative; TN means the predicted result is negative and the actual result is negative.
[0047] Step 54: Find the true positive rate (TPR) and prediction threshold when the false positive rate (FPR) = 0.1%. If the true positive rate (TPR) > 95%, then determine the prediction threshold as the true / false classification threshold (TH). Otherwise, do not process it.
[0048] Furthermore, step 7 specifically includes:
[0049] Step 71: Input the current frame face image into the trained high-dimensional face silent liveness detection neural network model and output the model score s1 of the current frame face image;
[0050] Step 72: Calculate the model score s0 of the previous frame face image and the model score s2 of the next frame face image.
[0051] Step 73: Obtain the liveness score based on the model score s1 of the current frame face image, the model score s0 of the previous frame face image, and the model score s2 of the next frame face image.
[0052] The formula is as follows:
[0053] Score=a*s0+b*s1+c*s2 (3),
[0054] a+b+c=1 (4),
[0055]
[0056] σ represents the Gaussian smoothing factor. Let σ = 1, a:b:c = G(-1):G(0):G(1). Substituting into the formula, we get a = 0.28, b = 0.44, c = 0.28. Then, Score = 0.28*s0 + 0.44*s1 + 0.28*s2.
[0057] Step 74: Compare the liveness score (Score) with the real / fake classification threshold (TH). If Score > TH, the judgment result is that the face image in the current frame is a real face. If Score ≤ TH, the judgment result is that the face image in the current frame is a fake face.
[0058] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the above-described liveness detection method based on facial recognition.
[0059] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-described liveness detection method based on facial recognition.
[0060] The beneficial effects of this invention are:
[0061] ①This invention uses a silent liveness detection scheme, which requires a single-frame photo input, has low processing time, and can be deployed in fast-response scenarios;
[0062] ② By introducing a face recognition loss function, the intra-class compactness of real faces (reducing the intra-class distance of real faces) and the inter-class difference between real and fake faces are enhanced, thereby improving the ability to prevent fake faces of unknown attack types;
[0063] ③ By building a high-dimensional face liveness detection neural network model (hdfld-net) that integrates face recognition loss function and classification loss function, the extracted liveness features and photos are first input into the classifier for classification using a face recognition loss function such as arcface-loss. More fine-grained high-dimensional facial features, such as texture, facial features, and edge information, are extracted from the liveness photos to improve the model's accuracy under different environmental changes.
[0064] ④ Gaussian filtering (Gaussian smoothing) is applied to the liveness detection scores of multiple consecutive frames to filter out fake face photos that are prone to change in the silent liveness detection scheme. Attached Figure Description
[0065] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained from these drawings without creative effort.
[0066] Figure 1 This is a flowchart of a liveness detection method based on facial recognition provided in an embodiment of the present invention.
[0067] Figure 2 This is a diagram illustrating the cropping of a face image.
[0068] Figure 3 This is a schematic diagram of the backbone network structure based on residual networks.
[0069] Figure 4 This is a schematic diagram of the structure of a high-dimensional silent face liveness detection neural network model.
[0070] Figure 5 This is a schematic diagram of an electronic device provided in an embodiment of the present invention.
[0071] Figure 6 This is a schematic diagram of a computer-readable storage medium provided in an embodiment of the present invention. Detailed Implementation
[0072] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention. Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to represent selected embodiments of the invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0073] like Figure 1 As shown, this embodiment of the invention provides a liveness detection method based on facial recognition, including preprocessing, liveness detection model training, and liveness detection model application, wherein:
[0074] 1. Preprocessing includes the following steps:
[0075] Step 1: Obtain multiple human body images of different types and classify all human body images;
[0076] In this embodiment, the step specifically includes: acquiring multiple different types of human body images through a device (camera) or downloading multiple different types of human body images from the cloud, the multiple different types of human body images constituting a liveness dataset; and classifying the obtained liveness dataset, dividing all human body images in the liveness dataset into real human, printed paper, electronic screen, 2D mask, and 3D mask categories; the purpose of classifying human body images is to distinguish between real faces and fake faces. Since the texture edge differences of different categories of fake faces are different, multi-classification is adopted in order to allow the model to learn more detailed features of different categories.
[0077] Step 2: Crop the face image from each of the human body images, and divide all the face images into a training set and a test set according to a set ratio;
[0078] In this embodiment, this step specifically includes: detecting facial key points and face bounding boxes in each human body image using a face detection algorithm, wherein the face detection algorithm uses SCRFD face detection.
[0079] The algorithm, SCRFD, is a high-efficiency and high-precision face detection algorithm. It crops aligned face images through affine transformations of key points, and all face images constitute a live face dataset. Cropping face images from human images makes model training more targeted and accurate. All face images in the live face dataset are divided into training and test sets according to a set ratio, such as a 4:1 ratio. The purpose of dividing the training set is to train and optimize the model, enabling it to perform detection. The purpose of dividing the test set is to make predictions and derive the final real / fake classification threshold, thus obtaining the criteria and conditions for judging real and fake faces. Figure 2 As shown, M1 is the acquisition component, which is used to acquire human body images, and then obtain aligned face images through face key point detection algorithm and affine transformation, and then output them to the M2 component; M2 inputs the acquired face alignment image into the pre-trained model and obtains the final judgment result.
[0080] Step 3: Normalize the various types of face images classified in the training set and generate face image proxies for each type. Construct triplet data pairs for each face image based on the face image proxies for each type.
[0081] In this embodiment, the step specifically includes: normalizing the various types of face images classified in the training set. Here, normalization is z-score normalization, which scales the images to a mean of 0 and a variance of 1. The purpose of normalization is twofold: first, to bring features of different dimensions to the same numerical level, reducing the influence of features with large variance and making the model more accurate; and second, to accelerate the convergence speed of the learning algorithm.
[0082] And generate various face image proxies P by normal distribution filtering. j , where P j Let k represent the face image of the j-th class, where 1 ≤ j ≤ k, k represents the number of classes, and j is a positive integer; in this example, the number of classes k = 5, that is, there are 5 classes.
[0083] According to the facial image proxy P j Construct triplet data pairs (p) for each face image ij P j P h ), where p ij Let P represent the i-th face image sample that is proxies the j-th face image, where 1 ≤ i ≤ n, and n represents the total number of face image samples in the j-th class, where n is a positive integer; h Represents the h-th class of face images
[0084] Like a proxy, and 1≤h≤k, where k represents the number of categories, h is a positive integer, and h≠j; the purpose of constructing triplet data pairs is to compare the current class with other classes when entering the model for training, increase the intra-class compactness of real faces and the difference between real and fake face classes, improve the prevention effect against fake faces in unknown domains, and make the model more accurate;
[0085] Construct the first sample of class 1, that is, when j=1, i=1, the triplet data pair (p ij P j P h )=(p 11 P1, P2), P h It is a random one among P2, P3, P4 and P5, here we choose P2;
[0086] Construct the second sample of the first class, that is, when j=1, i=2, the triplet data pair (p ij P j P h )=(p 21 P1, P2), P h It is a random one among P2, P3, P4 and P5, here we choose P2;
[0087] Construct the third sample of class 1, that is, when j=1, i=3, the triplet data pair (p ij P j Ph )=(p 31 P1, P5), P h It is a random one of P2, P3, P4 and P5, here we choose P5;
[0088] Similarly, construct the triplet data pairs for all samples in class 1; similarly, construct the triplet data pairs for all samples in classes 2, 3, 4, and 5.
[0089] 2. The training of the liveness detection model includes the following steps:
[0090] Step 4: Construct a backbone network based on a residual network, and build a high-dimensional silent face liveness detection neural network model (hdfld-net) based on the backbone network, integrating the face recognition loss function (Arcface-loss) and the classification loss function; the classification loss function is the softmax function;
[0091] In this embodiment, as Figure 3 As shown, this step specifically includes:
[0092] Step 41, constructing a backbone network based on a residual network, specifically includes: the backbone network consists of 8 residual blocks, extracting feature information and cross-channel information of the face image through convolutional layers, increasing the network depth by using 1x1 convolutional layers, and placing the downsampling operation in a non-1×1 convolutional layer to avoid losing feature information, and using the swish activation function as the activation function of the backbone network to improve the network performance; the purpose is to extract feature information better and more accurately.
[0093] like Figure 4 As shown, step 42, building a high-dimensional silent face liveness detection neural network model integrating face recognition loss function and classification loss function based on the backbone network, specifically includes:
[0094] The triplet data is input into the backbone network and processed. Facial features f1 are extracted through the facial recognition loss function. Liveness data of the face image is input into the backbone network to extract liveness features f2. Features f1 and liveness features f2 are fused and then processed through a fully connected layer and a classification loss function to obtain the liveness score of the face image frame.
[0095] Step 5: Each time, input the triplet data pairs and liveness data of a face image in the training set into the high-dimensional silent face liveness detection neural network model, and output the model score of the face image. Train and optimize the high-dimensional silent face liveness detection neural network model through the input and output process.
[0096] In this embodiment, as Figure 4As shown, this step specifically includes:
[0097] Step 51: Obtain the triplet data pairs and liveness data of the first face image in the training set, and input them into the high-dimensional silent face liveness detection neural network model;
[0098] Step 52: After the triplet data is input into the backbone network for processing, the face features f1 are extracted through the face recognition loss function; the face recognition loss function can reduce the intra-class distance and increase the intra-class distance.
[0099] Step 53: Input the liveness data into the backbone network to extract liveness features f2; the loss function of the backbone network is the arcface function;
[0100] Step 54: Fuse features f1 and liveness features f2, and then process them through a fully connected layer and a classification loss function to obtain the liveness score of the face image in that frame.
[0101] Step 55: Continue to obtain the triplet data pairs and liveness data of the next face image in the training set and repeat the operations of steps 51-54 until all face images in the training set have been traversed.
[0102] Step 56: Train and optimize the high-dimensional silent face liveness detection neural network model by inputting and outputting all face images in the training set.
[0103] Step 6: Input the face images from the test set into the high-dimensional silent face liveness detection neural network model for testing. Obtain prediction results based on different prediction thresholds, and then compare the prediction results with the actual results.
[0104] If the true positive rate and false positive rate are determined, the true / false classification threshold is determined based on the true positive rate and false positive rate.
[0105] In this embodiment, the step specifically includes:
[0106] Step 61: Input the face images in the test set into the high-dimensional silent face liveness detection neural network model for testing;
[0107] Step 62: The prediction threshold range is 0 to 1. Iterate through all possibilities from 0 to 1 and obtain different prediction results based on different prediction thresholds.
[0108] Step 63: Determine the true positive rate and false positive rate based on the predicted results and the actual results;
[0109] The formula is as follows:
[0110]
[0111]
[0112] Wherein, TPR represents the true positive rate; TP means the predicted result is positive and the actual result is positive; FN means the predicted result is negative and the actual result is positive; FPR represents the false positive rate; FP means the predicted result is positive and the actual result is negative; TN means the predicted result is negative and the actual result is negative.
[0113] Step 64: Find the true positive rate (TPR) and prediction threshold when the false positive rate (FPR) = 0.1%. If the true positive rate (TPR) > 95%, then determine the prediction threshold as the true / false classification threshold (TH). Otherwise, do not process it.
[0114] 3. The application of the liveness detection model includes the following steps:
[0115] Step 7: When performing face detection, acquire a human body image of the current frame and crop out the aligned human body image of the current frame to obtain the face image of the current frame.
[0116] Step 8: Input the current frame face image into the trained high-dimensional silent face detection neural network model, output the model score of the current frame face image, and obtain the liveness detection result based on the model score of the current frame face image, the model score of the previous frame face image, and the model score of the next frame face image.
[0117] The liveness score is compared with the true / false classification threshold to obtain the judgment result;
[0118] In this embodiment, the step specifically includes:
[0119] Step 81: Input the current frame face image into the trained high-dimensional face silent liveness detection neural network model and output the model score s1 of the current frame face image;
[0120] Step 82: Calculate the model score s0 of the previous frame face image and the model score s2 of the next frame face image.
[0121] Step 83: Obtain the liveness score based on the model score s1 of the current frame face image, the model score s0 of the previous frame face image, and the model score s2 of the next frame face image.
[0122] The formula is as follows:
[0123] Score=a*s0+b*s1+c*s2 (3),
[0124] a+b+c=1 (4),
[0125]
[0126] σ represents the Gaussian smoothing factor. Let σ = 1, a:b:c = G(-1):G(0):G(1). Substituting into the formula, we get a = 0.28, b = 0.44, c = 0.28. Then, Score = 0.28*s0 + 0.44*s1 + 0.28*s2.
[0127] Step 84: Compare the liveness score (Score) with the real / fake classification threshold (TH). If Score > TH, the judgment result is that the face image in the current frame is a real face. If Score ≤ TH, the judgment result is that the face image in the current frame is a fake face.
[0128] like Figure 5 As shown, this embodiment of the invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the above-described liveness detection method based on facial recognition.
[0129] like Figure 6 As shown, this embodiment of the invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the above-described liveness detection method based on facial recognition.
[0130] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention.
[0131] To those skilled in the art, the present invention can be modified and varied in many ways. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A liveness detection method based on facial recognition, characterized in that, Includes the following steps: Step 1: Obtain and classify multiple face images of different types, and divide all face images into training set and test set according to a set ratio; Step 2: Normalize the classified face images in the training set and generate face image proxies for each category. Construct triplet data pairs for each face image based on these face image proxies. Specifically, this includes: The classified face images in the training set are normalized, and face image proxies P are generated for each type of face image using normal distribution filtering. j , where P j Let represent the face image proxy of the j-th class, and 1≤j≤k, where k represents the number of classes and j is a positive integer; According to the facial image proxy P j Construct triplet data pairs (p) for each face image ij P j P h ), where p ij Let P represent the i-th face image sample that is proxies the j-th face image, where 1 ≤ i ≤ n, and n represents the total number of face image samples in the j-th class, where n is a positive integer; h Let h represent the face image proxy of class h, where 1 ≤ h ≤ k, k represents the number of classes, h is a positive integer, and h ≠ j; Step 3: Construct a backbone network based on the residual network, and build a high-dimensional neural network model for silent face liveness detection based on the backbone network, integrating the face recognition loss function and the classification loss function; Step 4: Each time, input the triplet data pairs and liveness data of a face image from the training set into the high-dimensional silent face liveness detection neural network model, and output the model score of the face image. Train and optimize the high-dimensional silent face liveness detection neural network model through the input and output process. Step 5: Input the face images in the test set into the high-dimensional silent liveness detection neural network model for testing. Obtain the prediction results according to different prediction thresholds. Determine the true positive rate and false positive rate based on the prediction results and the actual results. Determine the true and false classification thresholds based on the true positive rate and false positive rate. Step 6: When performing face detection, acquire a face image of the current frame; Step 7: Input the current frame face image into the trained high-dimensional silent face liveness detection neural network model, output the model score of the current frame face image, obtain the liveness score based on the model score of the current frame face image, the model score of the previous frame face image, and the model score of the next frame face image, compare the liveness score with the true / false classification threshold, and obtain the judgment result.
2. The liveness detection method based on facial recognition according to claim 1, characterized in that, Before step 1, the following also applies: Step 11: Collect multiple human images of different types using the device or download multiple human images of different types from the cloud. The multiple human images of different types constitute a liveness dataset. Step 12: Classify the obtained live dataset into categories such as real humans, printed paper, electronic screens, 2D masks, and 3D masks. Step 13: Crop the face image from each of the human body images.
3. The liveness detection method based on facial recognition according to claim 2, characterized in that, Step 13 specifically includes: The face detection algorithm detects facial key points and face bounding boxes in each human body image. The aligned face images are cropped by affine transformation of the key points. All face images constitute a live face dataset. All face images in the live face dataset are divided into training set and test set according to a set ratio.
4. The liveness detection method based on facial recognition according to claim 1, characterized in that, Step 3 specifically includes: Step 31: Constructing a backbone network based on residual networks specifically includes: the backbone network consists of 8 residual blocks, extracts feature information and cross-channel information of face images through convolutional layers, increases network depth by using 1x1 convolutional layers, and places downsampling operations in non-1×1 convolutional layers to avoid losing feature information, and uses the swish activation function as the activation function of the backbone network to improve network performance. Step 32: Constructing a high-dimensional silent liveness detection neural network model integrating face recognition loss function and classification loss function based on the backbone network specifically includes: inputting the triplet data into the backbone network for processing, extracting face features f1 through the face recognition loss function, inputting the liveness data of the face image into the backbone network to extract liveness features f2, f1 and f2 for feature fusion, and obtaining the liveness score of the face image frame after processing through a fully connected layer and a classification loss function in sequence.
5. The liveness detection method based on facial recognition according to claim 1, characterized in that, Step 4 specifically includes: Step 41: Obtain the triplet data pairs and liveness data of the first face image in the training set, and input them into the high-dimensional silent face liveness detection neural network model; Step 42: After the triplet data is input into the backbone network for processing, the face features f1 are extracted through the face recognition loss function; Step 43: Input the live data into the backbone network to extract the live feature f2; Step 44: Fuse features f1 and liveness features f2, and then process them through a fully connected layer and a classification loss function to obtain the liveness score of the face image in that frame. Step 45: Continue to obtain the triplet data pairs and liveness data of the next face image in the training set and repeat the operations of steps 51-54 until all face images in the training set have been traversed. Step 46: Train and optimize the high-dimensional silent face liveness detection neural network model by inputting and outputting all face images in the training set.
6. The liveness detection method based on facial recognition according to claim 1, characterized in that, Step 5 specifically includes: Step 51: Input the face images in the test set into the high-dimensional silent face liveness detection neural network model for testing; Step 52: The prediction threshold range is 0 to 1. Iterate through all possibilities from 0 to 1 and obtain different prediction results based on different prediction thresholds. Step 53: Determine the true positive rate and false positive rate based on the predicted results and the actual results; The formula is as follows: Wherein, TPR represents the true positive rate; TP means the predicted result is positive and the actual result is positive; FN means the predicted result is negative and the actual result is positive; FPR represents the false positive rate; FP means the predicted result is positive and the actual result is negative; TN means the predicted result is negative and the actual result is negative. Step 54: Find the true positive rate (TPR) and prediction threshold when the false positive rate (FPR) = 0.1%. If the true positive rate (TPR) > 95%, then determine the prediction threshold as the true / false classification threshold (TH). Otherwise, do not process it.
7. The liveness detection method based on facial recognition according to claim 1, characterized in that, Step 7 specifically includes: Step 71: Input the current frame face image into the trained high-dimensional face silent liveness detection neural network model and output the model score s1 of the current frame face image; Step 72: Calculate the model score s0 of the previous frame face image and the model score s2 of the next frame face image. Step 73: Obtain the liveness score based on the model score s1 of the current frame face image, the model score s0 of the previous frame face image, and the model score s2 of the next frame face image. The formula is as follows: Score=a*s0+b*s1+c*s2 (3), a+b+c=1 (4), σ represents the Gaussian smoothing factor. Let σ = 1, a:b:c = G(-1):G(0):G(1). Substituting into the formula, we get a = 0.28, b = 0.44, c = 0.
28. Then, Score = 0.28*s0 + 0.44*s1 + 0.28*s2. Step 74: Compare the liveness score (Score) with the real / fake classification threshold (TH). If Score > TH, the judgment result is that the face image in the current frame is a real face. If Score ≤ TH, the judgment result is that the face image in the current frame is a fake face.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements a liveness detection method based on facial recognition as described in any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements a liveness detection method based on facial recognition as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Multidimensional characteristic passenger re-identification method, device, storage medium and processor
CN107657249A
A feature fusion living body detection method
CN109558840A
Pedestrian re-recognition model training method and a pedestrian re-recognition method and system
CN113869193A