An adaptive face living body detection method and device based on feature comparison, equipment and storage medium
By constructing a live face anchor point library and replacing the traditional classification layer output with feature comparison, the problem of liveness detection threshold failure in cross-domain scenarios is solved, and stable and accurate liveness detection is achieved in different environments.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- RINGSLINK XIAMEN NETWORK COMM TECH
- Filing Date
- 2026-01-12
- Publication Date
- 2026-05-29
AI Technical Summary
Existing face liveness detection methods suffer from threshold failure and decreased detection performance in cross-domain scenarios due to their reliance on classification layer output.
By constructing a live face anchor point library and replacing the traditional classification layer output with feature comparison, using cosine similarity to measure the consistency of feature directions, and combining an online update mechanism and a difficulty-adaptive MixUp training method, the detection stability in cross-domain scenarios is improved.
Maintaining the stability of liveness scoring in cross-domain scenarios effectively preserves the validity of threshold discrimination, thereby improving the accuracy and adaptability of detection.
Smart Images

Figure CN122116489A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of face liveness detection, and in particular to an adaptive face liveness detection method, apparatus, device, and storage medium based on feature comparison. Background Technology
[0002] Face liveness detection is a key technology in facial recognition systems used to distinguish real faces from forged attacks. With the widespread application of facial recognition in fields such as financial payments and identity authentication, liveness detection faces increasingly complex attack methods, including physical attacks such as photo printing and video playback, as well as digital attacks such as deepfakes and adversarial examples.
[0003] In practical applications, liveness detection systems typically need to be trained in a specific environment before being deployed to new scenarios that differ from the training environment. For example, a model might be trained on data collected by the front-facing camera of a particular brand of mobile phone, but in actual deployment, it needs to process face images collected from devices of different brands and under different lighting conditions. This difference in distribution between the training and testing domains constitutes a cross-domain generalization problem.
[0004] In existing technologies, mainstream liveness detection methods employ deep neural networks for feature extraction and use the probability values output by the classification layer as the basis for liveness determination. However, this discrimination method based on the output of the classification layer has inherent flaws: the parameters of the classification layer are deeply coupled with the data distribution of the training domain during training. When the input data comes from test domains with different distributions, the probability values output by the classification layer will systematically drift, causing the pre-set discrimination threshold to fail. Specifically, the same real face may obtain a liveness score of 0.95 in the training domain, but may only obtain a score of 0.6 in the test domain, while the score distribution of fake samples will also shift accordingly, making it impossible for a fixed threshold to effectively distinguish between the two types of samples.
[0005] In view of the above, this application is hereby submitted. Summary of the Invention
[0006] This invention discloses an adaptive face liveness detection method, apparatus, device, and storage medium based on feature comparison, aiming to solve the problem that existing face liveness detection methods suffer from threshold failure and decreased detection performance in cross-domain scenarios due to reliance on classification layer output.
[0007] The first embodiment of the present invention provides an adaptive face liveness detection method based on feature comparison, comprising: Enhancement processing is performed on the face sample to be detected to obtain the original image and the enhanced image of the face sample to be detected; the original image and the enhanced image are respectively input into a pre-trained feature extraction network for feature extraction, and the mean of the two extracted features is calculated as the representative feature of the face sample to be detected; The cosine similarity between the representative features of the face sample to be detected and each live face anchor point in the live face anchor point database is calculated. The highest cosine similarity is selected as the liveness score. The liveness score is compared with a preset threshold to determine whether the face sample to be detected is a real face. The construction process of the live face anchor library is as follows: Real face samples in the validation set are enhanced one by one to obtain the original image and its enhanced image for each real face sample; the original image and the enhanced image are respectively input into the pre-trained feature extraction network for feature extraction, and the mean of the two extracted features is calculated as the representative feature of the real face sample; the representative features of all real face samples in the validation set are clustered to obtain K cluster centers as live face anchors, and the K live face anchors constitute the live face anchor library.
[0008] Preferably, the method further includes online updating of the live face anchor point library, specifically: For face samples to be detected whose liveness score is higher than the preset reliability threshold, the liveness anchor points with the highest cosine similarity in the liveness anchor point library are updated exponentially using their representative features.
[0009] Preferably, the calculation method for the exponential sliding update is as follows: Anchor_k'=(1-η)×f+η×Anchor_k Where f is the representative feature of the face sample to be detected, Anchor_k is the live face anchor point to be updated, Anchor_k' is the updated live face anchor point, and η is the update coefficient.
[0010] Preferably, the feature extraction network is a convolutional neural network, and its training process is as follows: The training dataset is subjected to class balancing, oversampling is applied to classes with fewer samples, and data augmentation is performed on the training samples to obtain a balanced training dataset. We employ a difficulty-adaptive MixUp training method, using a balanced training dataset to train the feature extraction network.
[0011] Preferably, the difficulty-adaptive MixUp training method includes: Select the first sample and its corresponding first label, and the second sample and its corresponding second label from the balanced training dataset; The first sample and the second sample are input into the feature extraction network to obtain the first prediction confidence of the first sample to the first label and the second prediction confidence of the second sample to the second label. Calculate the first difficulty coefficient of the first sample based on the first prediction confidence level, and calculate the second difficulty coefficient of the second sample based on the second prediction confidence level; The mixing coefficient is calculated based on the first difficulty coefficient and the second difficulty coefficient; The pixel values of the first and second samples are linearly mixed using a mixing coefficient to obtain a mixed sample; the first label and the second label are linearly mixed to obtain a mixed label. The feature extraction network is trained using cross-entropy weighted sum as the optimization objective and mixed samples and mixed labels.
[0012] Preferably, the first difficulty coefficient d i Second difficulty level d j The calculation method is as follows: d i =1-p i d j =1-p j ; Where, p i p represents the first prediction confidence level. j For the second prediction confidence level Preferably, the mixing coefficient λ is calculated as follows: λ=clip(d i / (d i + d j ),λ min ,λ max ); Where, λ min and λ max These are the lower and upper bounds of the mixing coefficient, respectively.
[0013] The second embodiment of the present invention provides an adaptive face liveness detection device based on feature comparison, comprising: The feature extraction module for the sample to be detected is used to enhance the face sample to be detected, and obtain the original image and the enhanced image of the face sample to be detected; the original image and the enhanced image are respectively input into a pre-trained feature extraction network for feature extraction, and the mean of the two extracted features is calculated as the representative feature of the face sample to be detected; An adaptive anchor point comparison module is used to calculate the cosine similarity between the representative features of the face sample to be detected and each live face anchor point in the live face anchor point library. The highest cosine similarity is selected as the liveness score. The liveness score is compared with a preset threshold to determine whether the face sample to be detected is a real face. The construction process of the live face anchor library is as follows: Real face samples in the validation set are enhanced one by one to obtain the original image and its enhanced image for each real face sample; the original image and the enhanced image are respectively input into the pre-trained feature extraction network for feature extraction, and the mean of the two extracted features is calculated as the representative feature of the real face sample; the representative features of all real face samples in the validation set are clustered to obtain K cluster centers as live face anchors, and the K live face anchors constitute the live face anchor library.
[0014] The third embodiment of the present invention provides an adaptive face liveness detection device based on feature comparison, including a memory and a processor. The memory stores a computer program, which can be executed by the processor to implement an adaptive face liveness detection method based on feature comparison as described in any of the above embodiments.
[0015] The fourth embodiment of the present invention provides a computer-readable storage medium, characterized in that it stores a computer program, which can be executed by the processor of the device in which the computer-readable storage medium is located, to implement an adaptive face liveness detection method based on feature comparison as described in any of the above claims.
[0016] Based on the adaptive face liveness detection method, apparatus, device, and storage medium provided by this invention, a liveness detection method is used to replace the traditional classification layer output by constructing a liveness anchor point library and employing feature comparison for liveness determination. Specifically, after enhancing real face samples in the validation set, features are extracted and clustered to obtain multiple liveness anchor points representing feature distributions in different domains. During detection, the samples to be detected are similarly enhanced, and representative features are extracted. The liveness score is obtained by calculating the cosine similarity between these representative features and each anchor point. Since cosine similarity measures the consistency of feature direction rather than absolute value, and multiple anchor points cover the real face feature distributions in different domains, the liveness score remains stable in cross-domain scenarios, and the effectiveness of threshold discrimination is maintained. Attached Figure Description
[0017] Figure 1 This is a flowchart illustrating an adaptive face liveness detection method based on feature comparison provided in the first embodiment of the present invention. Figure 2 This is a schematic diagram of a module of an adaptive face liveness detection device based on feature comparison provided in the second embodiment of the present invention. Detailed Implementation
[0018] 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 some embodiments of the present invention, and not all embodiments. 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.
[0019] To better understand the technical solution of the present invention, the embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0020] This invention discloses an adaptive face liveness detection method, apparatus, device, and storage medium based on feature comparison, aiming to solve the problem that existing face liveness detection methods suffer from threshold failure and decreased detection performance in cross-domain scenarios due to reliance on classification layer output.
[0021] The first embodiment of the present invention provides an adaptive face liveness detection method based on feature comparison, which can be executed by an adaptive face liveness detection device based on feature comparison (hereinafter referred to as the detection device or system), specifically, by one or more processors within the detection device, to at least implement the following steps: S101, perform enhancement processing on the face sample to be detected to obtain the original image and the enhanced image of the face sample to be detected; input the original image and the enhanced image into a pre-trained feature extraction network for feature extraction, and calculate the mean of the two extracted features as the representative feature of the face sample to be detected. In this embodiment, the detection device can be a desktop computer, laptop computer, server, or other terminal with data processing capabilities. The detection device can be equipped with a corresponding operating system and application software, and the functions required in this embodiment can be realized through the combination of the operating system and application software.
[0022] It should be noted that when performing liveness detection on the face sample to be detected, the sample is first enhanced to improve the stability of feature extraction. Specifically, the original image of the face sample to be detected is horizontally flipped to obtain an enhanced image that is a mirror image of the original image, thus forming an image pair of the original image and the enhanced image. Subsequently, the original image and the enhanced image are respectively input into a pre-trained feature extraction network for feature extraction. This feature extraction network can be implemented using a convolutional neural network, such as ResNet34. The original image outputs a first feature vector after passing through the feature extraction network, and the enhanced image outputs a second feature vector after passing through the same feature extraction network. The two feature vectors have the same dimension. Finally, the first feature vector and the second feature vector are summed element-wise and divided by two to obtain the mean vector. The calculated mean vector is used as the representative feature of the face sample to be detected. By extracting features from the original image and its horizontally flipped enhanced image separately and taking the mean, the feature bias caused by the left-right asymmetry of the face can be eliminated, making the representative features extracted from the same face under different poses more consistent, thereby improving the stability and accuracy of subsequent similarity comparison with live face anchor points.
[0023] S102, calculate the cosine similarity between the representative features of the face sample to be detected and each live face anchor point in the live face anchor point library, select the highest cosine similarity as the live score, and compare the live score with a preset threshold to determine whether the face sample to be detected is a real face. In this embodiment, the construction process of the live face anchor library is as follows: First, a validation set containing multiple real face samples is prepared. The real face samples in this validation set should cover as many different acquisition conditions as possible, including different lighting environments, different skin tones, and different acquisition devices, to ensure that the constructed anchor library can cover multiple domain distribution features. Each real face sample in the validation set is then augmented. Specifically, the original image of the real face sample is horizontally flipped to obtain an augmented image, forming an image pair of the original and augmented images. The original and augmented images are then input into a pre-trained feature extraction network for feature extraction, obtaining a first feature vector corresponding to the original image and a second feature vector corresponding to the augmented image. The average of the two feature vectors is then calculated to obtain the representative features of the real face sample. This process is repeated for all real face samples in the validation set to obtain a representative feature set equal in number to the number of samples in the validation set. Subsequently, a clustering algorithm, such as K-means clustering, is performed on the representative feature set to divide all representative features into K clusters. Each cluster corresponds to a typical distribution pattern of real facial features. For example, one cluster may contain real facial features collected under strong lighting conditions, while another cluster may contain real facial features of people with dark skin. The cluster center of each cluster is calculated, and the K cluster centers are used as live face anchors. These K live face anchors together constitute a live face anchor library and are stored for subsequent liveness detection. By constructing an anchor library containing multiple anchors through clustering, real faces under different domain conditions can find anchors with similar feature distributions in the anchor library, thus providing a robust comparison benchmark for liveness detection in cross-domain scenarios.
[0024] After obtaining the representative features of the face sample to be detected, it is necessary to compare its similarity with each live face anchor in the live face anchor database to complete the liveness determination. Specifically, K live face anchors are read sequentially from the live face anchor database, and the cosine similarity between the representative features of the face sample to be detected and each live face anchor is calculated. The cosine similarity is calculated by performing a dot product operation between the representative feature vector of the face sample to be detected and the vector of the live face anchor, and then dividing by the product of the magnitudes of the two vectors. The result ranges from negative one to positive one. The closer the value is to positive one, the more consistent the directions of the two feature vectors are, that is, the more similar the face sample to the real face represented by the live face anchor is. After completing the cosine similarity calculation between the representative features of the face sample to be detected and all K live face anchors, the maximum value among the K cosine similarity values is selected as the liveness score of the face sample to be detected. The reason for selecting the highest cosine similarity is that the K anchors in the live face anchor library represent the distribution of real face features under different domain conditions. If the sample to be detected is a real face, its representative feature should have a high similarity with at least one of the anchors; while if the sample to be detected is a forgery, its representative feature should have a low similarity with all anchors. Finally, the liveness score is compared with a preset threshold. If the liveness score is greater than or equal to the preset threshold, the face sample to be detected is determined to be a real face; if the liveness score is less than the preset threshold, the face sample to be detected is determined to be a forgery. The preset threshold can be determined by optimizing the detection performance on the validation set, for example, selecting a threshold value that achieves the best balance between the pass rate of real faces and the rejection rate of forgeries.
[0025] In one possible implementation of the present invention, to enable the live face anchor library to adapt to the new domain data distribution encountered during the testing phase, this embodiment may further include a step of online updating the live face anchor library. After completing the liveness determination of the face sample to be detected, for the face sample to be detected with a liveness score higher than a preset confidence threshold, it is regarded as a high-confidence real face sample, and the live face anchor library is updated online using the representative features of the sample. The preset confidence threshold should be set higher than the preset threshold used for liveness determination to ensure that only samples that are highly certain to be real faces participate in the anchor library update, avoiding the incorrect integration of features of fake attack samples into the anchor library. Specifically, the update process is as follows: first, determine which live face anchor in the live face anchor library has the highest cosine similarity between the representative features of the high-confidence face sample to be detected and the live face anchor. This anchor is then determined as the live face anchor to be updated. Subsequently, the live face anchor point is updated using an exponential sliding update method. The calculation formula is Anchor_k'=(1-η)×f+η×Anchor_k, where f is the representative feature of the face sample to be detected, Anchor_k is the live face anchor point to be updated, Anchor_k' is the updated live face anchor point, and η is the update coefficient. The update coefficient η is usually set to a small value, such as 0.9999, so that the original anchor point still occupies the dominant weight in the updated anchor point, while the representative features of the new sample are only incorporated in a small proportion, thus ensuring the stability of the anchor point library update process. Through the online update mechanism, the live face anchor point library can gradually absorb the real face features of the new domain that appear in the testing phase, so that the position of each anchor point is finely adjusted in the distribution direction of the current test data, further improving the adaptability and accuracy of liveness detection in cross-domain scenarios.
[0026] In one possible implementation of the present invention, the feature extraction network can be a convolutional neural network, such as a ResNet34 network, whose training process includes two stages: data preprocessing and difficulty-adaptive MixUp training.
[0027] In the data preprocessing stage, the training dataset is first balanced. Due to the high cost of collecting real-world face samples and physical attack samples, their numbers are limited, while digital attack samples are easily synthesized, resulting in a large number of samples across different categories in the training dataset. To alleviate this class imbalance, an oversampling strategy is implemented for the categories with fewer samples. This involves repeatedly sampling real-world face samples and physical attack samples to ensure their frequency of occurrence during training is comparable to that of digital attack samples. Simultaneously, data augmentation operations are performed on all training samples, including color jitter, random cropping, and horizontal flipping, to expand the diversity of the training data and improve the model's generalization ability. After these processes, a balanced training dataset is obtained.
[0028] During the model training phase, a difficulty-adaptive MixUp training method is used to train the feature extraction network. Traditional MixUp methods randomly select two samples for a fixed-ratio linear mixture, while the difficulty-adaptive MixUp method proposed in this invention dynamically adjusts the mixing ratio based on the learning difficulty of the samples, enabling the model to learn more about the decision boundaries near difficult samples. The specific training process is as follows: A first sample and its corresponding first label, and a second sample and its corresponding second label are selected from the balanced training dataset, where the first sample preferably comes from a minority category, such as real faces or physical attack categories. The first and second samples are input into the current state of the feature extraction network for forward inference to obtain the first prediction confidence p of the first sample to the first label. i And the second prediction confidence p of the second sample to the second label j Prediction confidence represents the network's predicted probability that a sample belongs to its true label. The difficulty coefficient for each sample is calculated based on the prediction confidence, with the first difficulty coefficient being d. i The calculation method is d i =1-p i The second difficulty level is d. j The calculation method is d j =1-p j A lower prediction confidence level indicates greater difficulty for the network in judging the sample, corresponding to a higher difficulty coefficient. The mixing coefficient λ is calculated based on the first and second difficulty coefficients, using the formula λ = clip(d i / (d i +d j ),λ min ,λ max The `clip` function restricts the calculation results to a range between a lower bound of `λmin` and an upper bound of `λmax`. Samples with higher difficulty coefficients account for a larger proportion during blending. A linear blending of the pixel values of the first and second samples is performed using a blending coefficient λ. The blended sample is calculated as x... mix =λ×x i +(1-λ)×x j Simultaneously, a linear blending is performed on the first and second labels, and the blended label is calculated using y. mix =λ×y i +(1-λ)×y j The mixed samples are input into the feature extraction network for forward inference to obtain the predicted output. The cross-entropy weighted sum between the predicted output and the mixed labels is used as the loss function, and the parameters of the feature extraction network are updated through backpropagation. By using a difficulty-adaptive MixUp training method, the model's decision boundary is smoother, and its sensitivity to input perturbations is reduced, thereby improving the reliability of distinguishing forged samples that are highly similar to real human faces.
[0029] The second embodiment of the present invention provides an adaptive face liveness detection device based on feature comparison, comprising: The feature extraction module 201 for the sample to be detected is used to enhance the face sample to be detected, and obtain the original image and the enhanced image of the face sample to be detected; the original image and the enhanced image are respectively input into a pre-trained feature extraction network for feature extraction, and the mean of the two extracted features is calculated as the representative feature of the face sample to be detected; The adaptive anchor point comparison module 202 is used to calculate the cosine similarity between the representative features of the face sample to be detected and each live face anchor point in the live face anchor point library, select the highest cosine similarity as the liveness score, and compare the liveness score with a preset threshold to determine whether the face sample to be detected is a real face. The construction process of the live face anchor library is as follows: Real face samples in the validation set are enhanced one by one to obtain the original image and its enhanced image for each real face sample; the original image and the enhanced image are respectively input into the pre-trained feature extraction network for feature extraction, and the mean of the two extracted features is calculated as the representative feature of the real face sample; the representative features of all real face samples in the validation set are clustered to obtain K cluster centers as live face anchors, and the K live face anchors constitute the live face anchor library.
[0030] The third embodiment of the present invention provides an adaptive face liveness detection device based on feature comparison, including a memory and a processor. The memory stores a computer program, which can be executed by the processor to implement an adaptive face liveness detection method based on feature comparison as described in any of the above embodiments.
[0031] The fourth embodiment of the present invention provides a computer-readable storage medium, characterized in that it stores a computer program, which can be executed by the processor of the device in which the computer-readable storage medium is located, to implement an adaptive face liveness detection method based on feature comparison as described in any of the above claims.
[0032] Based on the adaptive face liveness detection method, apparatus, device, and storage medium provided by this invention, a liveness detection method is used to replace the traditional classification layer output by constructing a liveness anchor point library and employing feature comparison for liveness determination. Specifically, after enhancing real face samples in the validation set, features are extracted and clustered to obtain multiple liveness anchor points representing feature distributions in different domains. During detection, the samples to be detected are similarly enhanced, and representative features are extracted. The liveness score is obtained by calculating the cosine similarity between these representative features and each anchor point. Since cosine similarity measures the consistency of feature direction rather than absolute value, and multiple anchor points cover the real face feature distributions in different domains, the liveness score remains stable in cross-domain scenarios, and the effectiveness of threshold discrimination is maintained.
[0033] Exemplary examples show that the computer program described in the third and fourth embodiments of the present invention can be divided into one or more modules, which are stored in the memory and executed by the processor to complete the present invention. The one or more modules can be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of the computer program in implementing a feature-contrast-based adaptive face liveness detection device. For example, the apparatus described in the second embodiment of the present invention.
[0034] The processor referred to can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor. This processor is the control center of the aforementioned feature-contrast-based adaptive face liveness detection method, connecting various parts of the method through various interfaces and lines.
[0035] The memory can be used to store the computer program and / or modules. The processor, by running or executing the computer program and / or modules stored in the memory, and by calling the data stored in the memory, implements various functions of an adaptive face liveness detection method based on feature comparison. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, text conversion function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, text message data, etc.). In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0036] If the implemented module is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.
[0037] It should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.
[0038] The above description is merely a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. An adaptive face liveness detection method based on feature comparison, characterized in that, include: Enhancement processing is performed on the face sample to be detected to obtain the original image and the enhanced image of the face sample to be detected; the original image and the enhanced image are respectively input into a pre-trained feature extraction network for feature extraction, and the mean of the two extracted features is calculated as the representative feature of the face sample to be detected; The cosine similarity between the representative features of the face sample to be detected and each live face anchor point in the live face anchor point database is calculated. The highest cosine similarity is selected as the liveness score. The liveness score is compared with a preset threshold to determine whether the face sample to be detected is a real face. The construction process of the live face anchor library is as follows: one by one, real face samples in the verification set are enhanced to obtain the original image and the enhanced image of each real face sample; the original image and the enhanced image are respectively input into the pre-trained feature extraction network for feature extraction, and the mean of the two extracted features is calculated as the representative feature of the real face sample. Clustering is performed on the representative features of all real face samples in the verification set to obtain K cluster centers as live face anchor points, and the K live face anchor points constitute a live face anchor point library.
2. The adaptive face liveness detection method based on feature comparison according to claim 1, characterized in that, This also includes online updates to the live face anchor point library, specifically: For face samples to be detected whose liveness score is higher than the preset reliability threshold, the liveness anchor points with the highest cosine similarity in the liveness anchor point library are updated exponentially using their representative features.
3. The adaptive face liveness detection method based on feature comparison according to claim 1, characterized in that, The calculation method for the exponential sliding update is as follows: Anchor_k'=(1-η)×f+η×Anchor_k Where f is the representative feature of the face sample to be detected, Anchor_k is the live face anchor point to be updated, Anchor_k' is the updated live face anchor point, and η is the update coefficient.
4. The adaptive face liveness detection method based on feature comparison according to claim 1, characterized in that, The feature extraction network is a convolutional neural network, and its training process is as follows: The training dataset is subjected to class balancing, oversampling is applied to classes with fewer samples, and data augmentation is performed on the training samples to obtain a balanced training dataset. We employ a difficulty-adaptive MixUp training method, using a balanced training dataset to train the feature extraction network.
5. The adaptive face liveness detection method based on feature comparison according to claim 1, characterized in that, Difficulty-adaptive MixUp training methods include: Select the first sample and its corresponding first label, and the second sample and its corresponding second label from the balanced training dataset; The first sample and the second sample are input into the feature extraction network to obtain the first prediction confidence of the first sample to the first label and the second prediction confidence of the second sample to the second label. Calculate the first difficulty coefficient of the first sample based on the first prediction confidence level, and calculate the second difficulty coefficient of the second sample based on the second prediction confidence level; The mixing coefficient is calculated based on the first difficulty coefficient and the second difficulty coefficient; The pixel values of the first and second samples are linearly mixed using a mixing coefficient to obtain a mixed sample; the first label and the second label are linearly mixed to obtain a mixed label. The feature extraction network is trained using cross-entropy weighted sum as the optimization objective and mixed samples and mixed labels.
6. The adaptive face liveness detection method based on feature comparison according to claim 5, characterized in that, The first difficulty coefficient d i Second difficulty level d j The calculation method is as follows: d i =1-p i ,d j =1-p j ; Where, p i p represents the first prediction confidence level. j This represents the second prediction confidence level.
7. The adaptive face liveness detection method based on feature comparison according to claim 6, characterized in that, The mixing coefficient λ is calculated as follows: λ=clip(d i / (d i +d j ),l min ,l max ); Where, λ min and λ max These are the lower and upper bounds of the mixing coefficient, respectively.
8. An adaptive face liveness detection device based on feature comparison, characterized in that, include: The feature extraction module for the sample to be detected is used to enhance the face sample to be detected, and obtain the original image and the enhanced image of the face sample to be detected; the original image and the enhanced image are respectively input into a pre-trained feature extraction network for feature extraction, and the mean of the two extracted features is calculated as the representative feature of the face sample to be detected; An adaptive anchor point comparison module is used to calculate the cosine similarity between the representative features of the face sample to be detected and each live face anchor point in the live face anchor point library. The highest cosine similarity is selected as the liveness score. The liveness score is compared with a preset threshold to determine whether the face sample to be detected is a real face. The construction process of the live face anchor library is as follows: one by one, real face samples in the verification set are enhanced to obtain the original image and the enhanced image of each real face sample; the original image and the enhanced image are respectively input into the pre-trained feature extraction network for feature extraction, and the mean of the two extracted features is calculated as the representative feature of the real face sample. Clustering is performed on the representative features of all real face samples in the verification set to obtain K cluster centers as live face anchor points, and the K live face anchor points constitute a live face anchor point library.
9. An adaptive face liveness detection device based on feature comparison, characterized in that, The method includes a memory and a processor, wherein the memory stores a computer program that can be executed by the processor to implement an adaptive face liveness detection method based on feature comparison as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The device contains a computer program that can be executed by a processor of the device in which the computer-readable storage medium is located, to implement an adaptive face liveness detection method based on feature comparison as described in any one of claims 1 to 4.