Face living body detection method and system based on scene optimization, medium and product

By training the teacher model using physics-driven transformation and scene contrast loss, and combining scene-aware knowledge distillation and real-time attention adjustment, a lightweight face liveness detection model suitable for specific scenarios is generated. This solves the performance degradation problem of lightweight models in specific scenarios and achieves high-precision and robust liveness detection.

CN121096033AActive Publication Date: 2025-12-09SHENZHEN UNION TIMMY TECH CO LTD

Patent Information

Application Number
CN202511630383.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-10
Publication Date
2025-12-09
Estimated Expiration
2045-11-10

AI Technical Summary

Technical Problem

Existing lightweight face liveness detection models suffer from performance degradation in specific deployment scenarios, particularly their insufficient ability to distinguish between interfering or attack samples in certain scenarios, leading to increased false positive or false negative rates.

Method used

The teacher model is trained by physical-driven transformation and scene contrast loss to learn scene-independent liveness features. Scene representation capabilities are used to select a data subset that highly matches the target deployment scene. A lightweight model is generated by scene-aware knowledge distillation. A dual-branch architecture is constructed to decouple the independent feature representations of scene information and liveness information. After the model is deployed, the model weights are adjusted by real-time attention mask.

Benefits of technology

It significantly improves the accuracy and robustness of the model in the target scene for liveness detection. It can actively perceive environmental changes and perform self-optimization, avoid the performance degradation of static models, reduce the cost of expensive manual retraining and deployment, and ensure the high detection performance and stability of the system throughout its life cycle.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121096033A_ABST
    Figure CN121096033A_ABST
Patent Text Reader

Abstract

The invention discloses a face in-vivo detection method and system based on scene optimization, a medium and a product, and relates to the field of computer systems based on a specific calculation model, and the method comprises the steps: extracting a mixed image sample, and applying physical drive transformation to obtain an enhanced image sample; scene comparison loss is calculated; based on living body classification loss and scene comparison loss, training the basic model to obtain a teacher model; inputting the scene sample into a scene branch of the teacher model to obtain a scene target vector; inputting the mixed image sample into a scene branch to obtain a scene vector set; calculating the vector similarity between the scene target vector and the vector in the scene vector set, screening out a corresponding image sample, and obtaining a scene matching data subset; taking the teacher model as supervision, executing knowledge distillation, and generating a living body detection model; and inputting a to-be-detected face image to the living body detection model to obtain a classification result. By implementing the method, the living body detection performance of the model in a specific deployment scene can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of computer systems based on specific computing models, and in particular to a face liveness detection method and system based on scene optimization, a medium and a product. BACKGROUND

[0002] Face liveness detection technology is a key link in the biological recognition security system, aiming to distinguish whether the face in front of the camera is from the real user himself or from a photo, video or mask attack. At present, financial payment, intelligent access control and social security authentication applications are migrating to mobile terminals and various edge devices. These edge devices have strict limitations on computing power, power consumption and memory, and can only deploy lightweight models. Therefore, it is very important to deploy a lightweight and high-performance liveness detection model on a resource-constrained platform.

[0003] In related technologies, to realize the deployment of a lightweight model on an edge device, a knowledge distillation technology is generally used. First, a teacher model with complex structure and huge number of parameters is trained on a large general dataset. The dataset usually contains a large number of real human images and various attack samples from different scenes (such as indoor, outdoor, different light, different background), to ensure that the teacher model has strong generalization ability and high detection accuracy. Then, a student model with simple structure and small calculation amount is designed and trained on the same general dataset. During the training process, the student model not only learns to fit the real label of the data, but also imitates the output probability distribution of the teacher model through an additional distillation loss function, so as to transfer the knowledge of the teacher model to the student model, and to inherit the performance of the teacher model while keeping small size.

[0004] However, due to the domain shift between the distribution of the training data (source domain) and the real data distribution of the specific deployment scene (target domain), in related technologies, the performance of the student model in the specific deployment scene (such as the front camera of a certain bank ATM or a certain brand of mobile phone) has the risk of performance degradation, that is, the student model has insufficient discrimination ability for the interference or attack samples specific to the specific scene, which will cause the false recognition rate or the missed rate to rise. SUMMARY

[0005] The present application provides a face liveness detection method and system based on scene optimization, a medium and a product, for improving the liveness detection performance of the model in the specific deployment scene.

[0006] In a first aspect, the present application provides a face liveness detection method based on scene optimization, applied to a face liveness detection system. The method comprises: extracting mixed image samples in a mixed training data set of a basic model, applying physical driving transformation to the mixed image samples to obtain enhanced image samples; taking the enhanced image samples derived from the same image sample as positive sample pairs and the enhanced image samples derived from different image samples as negative sample pairs, and calculating a scene contrast loss; taking the liveness classification loss of the mixed image samples and the scene contrast loss to form a total loss function, training the basic model to obtain a teacher model; inputting scene samples in a predefined target scene sample set into a scene branch of the teacher model, extracting and aggregating the features of the scene samples to obtain a scene target vector; inputting each mixed image sample in the mixed training data set into the scene branch of the teacher model one by one, extracting multiple scene feature vectors to form a scene vector set; calculating the vector similarity of the scene target vector and each vector in the scene vector set, and filtering out corresponding image samples from the mixed training data set according to the vector similarity to obtain a scene matching data subset; taking the teacher model as supervision, performing knowledge distillation on the scene matching data subset, and generating a liveness detection model by modulating the distillation loss with the attention mask output by the scene branch of the teacher model; inputting a face image to be detected into the liveness detection model for forward propagation calculation to obtain a classification result representing the liveness confidence.

[0007] In the above embodiment, the face liveness detection system uses the teacher model trained by the physical driving transformation and contrast learning to learn scene-independent liveness features. Then, the scene representation capability is used to accurately filter out a data subset highly matched with the target deployment scene from a large amount of mixed data. Finally, through scene-aware knowledge distillation, a lightweight model optimized for a specific scene is generated, which significantly improves the liveness detection accuracy and robustness of the model in the target scene.

[0008] In combination with some embodiments of the first aspect, in some embodiments, the step of taking the liveness classification loss of the mixed image samples and the scene contrast loss to form a total loss function, training the basic model to obtain a teacher model, specifically comprises: decomposing the basic model into a shared encoder, a scene branch and a liveness branch; inputting the mixed image samples into the shared encoder to obtain shared feature representations; inputting the shared feature representations into the scene branch to determine a scene loss component in combination with the scene contrast loss; inputting the shared feature representations into the liveness branch to determine a liveness loss component in combination with the liveness classification loss of the mixed image samples; calculating the correlation of the scene loss component and the liveness loss component to obtain a decoupling regularization component; determining the total loss function according to the scene loss component, the liveness loss component and the decoupling regularization component to adjust the model parameters of the basic model and obtain the teacher model.

[0009] In the above embodiment, the face living body detection system adopts the technical solution, constructs a double-branch architecture, and introduces a decoupling regularization term to force the model to learn independent feature representations that distinguish scene information and living body information. This avoids the model from misjudging specific background or lighting as living body clues, allowing the teacher model to understand the essence of the living body more purely, thereby providing a high-quality and unambiguous knowledge source for subsequent knowledge distillation, and ensuring the reliability of the final generated model.

[0010] In combination with some embodiments of the first aspect, in some embodiments, the step of generating the living body detection model supervised by the teacher model and performing knowledge distillation on the scene matching data subset with the attention mask output by the scene branch of the teacher model modulating the distillation loss, specifically includes: inputting a predefined target scene sample set into the scene branch of the teacher model to obtain a reference attention mask; inputting samples in the scene matching data subset into the scene branch of the teacher model to obtain a real-time attention mask; fusing the real-time attention mask and the reference attention mask to obtain a modulation mask; applying the modulation mask to the calculation process of the distillation loss to obtain a modulated distillation loss, and performing knowledge distillation based on the modulated distillation loss to generate the living body detection model.

[0011] In the above embodiment, the face living body detection system adopts the technical solution, uses the scene branch of the teacher model to generate an attention mask to guide the distillation process, so that the student model can focus on the most critical areas in the image for living body judgment in a specific scene like the teacher, improving the efficiency and accuracy of knowledge transfer.

[0012] In combination with some embodiments of the first aspect, in some embodiments, after the step of applying the modulation mask to the calculation process of the distillation loss to obtain a modulated distillation loss, and performing knowledge distillation based on the modulated distillation loss to generate the living body detection model, the method further includes: calculating a distribution difference measure between the reference attention mask and the real-time attention mask to obtain a scene drift indicator; when the scene drift indicator exceeds a preset drift threshold, extracting key scene feature components based on a preset high activation area in the modulation mask; performing similarity calculation on the key scene feature components and a pre-stored target scene feature template to generate a scene consistency evaluation report; and adjusting the weight parameters of the scene-related layers in the living body detection model according to the deviation degree in the scene consistency evaluation report.

[0013] In the above embodiment, the face living body detection system adopts the technical solution, can actively perceive changes in the deployment environment and make precise and small-range weight adjustments before performance degradation, can maintain high peak performance in a dynamically changing environment for a long time, and avoid performance degradation after static model deployment.

[0014] In some embodiments of the first aspect, before the step of calculating the scene drift index by calculating a distribution difference measure between the reference attention mask and the real-time attention mask, the method further comprises: performing clustering analysis on the target scene sample set to obtain a plurality of typical scene subcategories, and constructing a corresponding reference attention mask template for each typical scene subcategory; calculating the matching degree between the attention mask corresponding to each sample in the scene matching data subset and each reference attention mask template to determine the best matching scene category; dividing the scene matching data subset into a plurality of scene subsets based on the best matching scene category and the matching degree; and calculating the attention mask mean of each scene subset as an adaptive reference mask of the best matching scene category to replace the reference attention mask for scene drift detection.

[0015] In the above embodiments, the face liveness detection system, by adopting the technical solutions described above, divides the target scene into subcategories with finer granularity, making the detection reference of scene drift more flexible and accurate, and enabling the system to distinguish between normal fluctuations within the scene (such as changes in light levels between morning and evening) and real environmental changes, thereby avoiding unnecessary model updates and improving the stability and efficiency of the adaptive mechanism.

[0016] In some embodiments of the first aspect, before the step of extracting mixed image samples in the mixed training data set of the base model, applying physical driving transformations to the mixed image samples to obtain enhanced image samples, the method further comprises: performing feature extraction on a pre-defined target scene sample set to obtain scene environment parameters, and constructing a generation network based on the scene environment parameters; inputting a pre-set attack image into the generation network for conversion processing to obtain a synthetic attack sample, and supplementing the synthetic attack sample to the mixed training data set.

[0017] In the above embodiments, the face liveness detection system, by adopting the technical solutions described above, generates synthetic attack samples that are highly consistent with the target scene environment features, greatly enriching the high-difficulty negative samples in the training data, enabling the system to anticipate and defend against the most likely and deceptive attack methods that may occur in specific scenes, thereby significantly enhancing the security and anti-forgery capabilities of the model.

[0018] In some embodiments of the first aspect, after the step of inputting the face image to be detected into the liveness detection model for forward propagation calculation to obtain a classification result representing the liveness confidence, the method further comprises: when the liveness confidence is in an uncertainty interval range, re-inputting the face image to be detected into the liveness detection model for multiple forward propagation calculations to obtain multiple re-classification results; calculating a consistency index of the multiple re-classification results, and determining the liveness detection result according to the consistency index.

[0019] In the above embodiment, the face living body detection system, by using the technical solution, for the fuzzy sample with low model output confidence, through multiple calculations and evaluation of the consistency of the results, the system can make more prudent and reliable judgment on these boundary conditions, effectively reducing the security risk caused by single misjudgment.

[0020] In a second aspect, the embodiments of the present application provide a face living body detection system, comprising: one or more processors and a memory; the memory is coupled with the one or more processors, and the memory is used to store computer program code, the computer program code comprises computer instructions, and the one or more processors invoke the computer instructions to enable the face living body detection system to perform the method described in the first aspect and any possible implementation manner of the first aspect.

[0021] In a third aspect, the embodiments of the present application provide a computer program product comprising instructions, which, when executed on a face living body detection system, enable the face living body detection system to perform the method described in the first aspect and any possible implementation manner of the first aspect.

[0022] In a fourth aspect, the embodiments of the present application provide a computer readable storage medium comprising instructions, which, when executed on a face living body detection system, enable the face living body detection system to perform the method described in the first aspect and any possible implementation manner of the first aspect.

[0023] It can be understood that the face living body detection system provided in the above second aspect, the computer program product provided in the third aspect and the computer storage medium provided in the fourth aspect are all used to execute the method provided in the embodiments of the present application. Therefore, the beneficial effects that can be achieved are referred to the beneficial effects in the corresponding method, which will not be repeated here.

[0024] The one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages: 1. The technical solution of the method comprises the following steps: firstly, a teacher model capable of decoupling scene and living body features is trained through physical driving transformation and scene contrast loss; secondly, a scene branch of the teacher model is used to screen a data subset highly matched with a specific deployment scene from a mass of mixed data sets; and finally, a lightweight living body detection model is generated through scene attention guided knowledge distillation on the data subset. Therefore, the method can ensure that the finally generated model is customized for a specific scene. The method effectively solves the performance degradation problem of a general lightweight model caused by domain drift between training data and actual deployment scene in the prior art, and the problem of low knowledge transfer efficiency caused by lack of scene specificity in the traditional knowledge distillation process, thereby realizing deployment of a living body detection model with high detection precision and robustness for a specific scene on a resource-limited edge device, and improving user experience and security level in actual application.

[0025] 2. The technical solution of the method comprises the following steps: a basic model is decomposed into a shared encoder, a scene branch and a living body branch, and a total loss function is introduced. Therefore, the model is explicitly guided to learn two groups of independent features during the training process: one group is used to identify environmental factors such as light and background, and the other group is used to identify physiological clues such as micro-expression and texture. The method effectively solves the problem that the model in the prior art easily learns false correlations between scenes and living bodies, such as the false correlation between a specific indoor light and a real person, which leads to poor generalization ability and easy interference of scene changes. The knowledge transferred to the student model is more accurate and reliable, thereby fundamentally improving the robustness and reliability of the final living body detection model.

[0026] 3. The technical solution of the method comprises the following steps: after the model is deployed, the distribution difference between the attention mask of the real-time input and the benchmark attention mask is calculated to obtain a scene drift index, and when the index exceeds a threshold, a closed-loop update strategy of adjusting the scene-related layer weight of the model is triggered. Therefore, the system has the ability to actively perceive environmental changes and optimize itself. The method effectively solves the problem that the performance of a static model in the prior art gradually decreases (i.e., model aging) over time and with environmental changes after deployment, thereby eliminating the cost of expensive manual retraining and deployment, and ensuring that the system can maintain high detection performance and stability throughout its life cycle. BRIEF DESCRIPTION OF DRAWINGS

[0027] Figure 1 is a flowchart of a face living body detection method based on scene optimization in the embodiment of the application; Figure 2 is a topological structure diagram of a face living body detection system in the embodiment of the application; Figure 3 is another flowchart of a face living body detection method based on scene optimization in the embodiment of the application; Figure 4 is a schematic diagram of an entity device structure of a face living body detection system in an embodiment of the present application. DETAILED DESCRIPTION

[0028] The terminology used in the following embodiments of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the present application. As used in the description of the application, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "and / or," as used herein, refers to

[0029] Hereinafter, the terms "first", "second", etc. are used only for the purpose of description, and cannot be understood as implying or suggesting relative importance or implicitly indicating the number of the technical features indicated. Therefore, the features defined with "first", "second" can explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, the meaning of "a plurality of" is two or more, unless otherwise stated.

[0030] In the overall technical solution of the present application, the core logic is to understand and deconstruct complex real world through a powerful teacher model, and then refine a small and precise student model for a specific task and specific environment using this understanding. Among them, the basic model usually refers to a large-scale pre-trained visual model such as Vision Transformer (ViT) or ConvNeXt, which has strong general feature extraction capability and is the starting point of the whole process. Physical driven transformation is a series of enhancement operations on images to simulate real-world changes, such as adjusting brightness and contrast to simulate different light periods, replacing the background to simulate different locations, and rotating and scaling to simulate different shooting angles and distances. The purpose is to let the model learn to recognize the image content itself rather than the environment. Scene contrast loss is a self-supervised learning method that drives the model to bring the features of different physical transformations but derived from the same picture (positive sample pair) closer in the feature space, and pushes the features derived from different pictures (negative sample pair) away, so as to learn a stable feature representation that is not sensitive to scene changes. The teacher model obtained after this stage of training has strong scene understanding and living body discrimination ability, and the scene branch inside the teacher model is specially designed to output scene-related features, while the living body branch is responsible for judging true and false. When deploying the model for a specific scene (such as an ATM machine of a certain bank), a small number of target scene samples of the scene will be collected, and the features of the samples will be extracted through the scene branch of the teacher model, and aggregated into a scene target vector representing the scene. Then, this vector will act as a probe to fish out the most similar images to the target scene in the large mixed training data set by calculating the vector similarity (such as cosine similarity), forming a scene matching data subset. The last stage is knowledge distillation, the teacher model transfers knowledge to a lightweight living body detection model (student model), especially, the scene branch of the teacher model will generate an attention mask to tell the student model which areas of the image should be focused on when learning, achieving scene-aware knowledge transfer.

[0031] The method provided by the present embodiment is described in the following flow. Please refer to Figure 1 , which is a flowchart of the face living body detection method based on scene optimization in the embodiment of the present application.

[0032] S101, extract the mixed image samples in the mixed training data set of the basic model, and apply physical driven transformation to the mixed image samples to obtain enhanced image samples.

[0033] wherein the mixed training dataset represents a collection of a large number of face images, which are sourced from a wide range of scenarios, illuminations, races and attack types, but usually only have coarse-grained labels of real or fake. The physics-driven transformation refers to a series of image processing operations simulating changes in real-world physical environment for data augmentation. The augmented image sample refers to an image obtained by applying a physics-driven transformation to an original mixed image sample.

[0034] Specifically, a topological structure diagram of a face liveness detection system in an embodiment of the present application is shown in FIG. 1. Figure 2 The feature decoupling fine-tuning unit module in FIG. 1 performs this step. The face liveness detection system first loads the mixed training dataset from storage. For each mixed image sample x in the dataset, the system applies multiple physics-driven transformations T(x) to it, which are represented as physics-driven transformations in FIG. 1. These transformations aim to simulate changes in the real world that are irrelevant to liveness judgment, such as illumination disturbance (brightness adjustment ± 30%, contrast adjustment ± 25%), background replacement (e.g., randomly selecting a background from the COCO dataset and fusing it with the face), and geometric distortion (rotation ± 15°, scaling ± 20%). By applying at least two different transformations to an original image, one or more pairs of augmented image samples can be generated, such as (T1(x), T2(x)). Figure 2

[0035] In some embodiments, this step can be implemented in various ways to enhance the authenticity and diversity of the transformations: optionally, physics-based rendering-based transformations are introduced, which first reconstruct the face in 3D, then adjust the position, angle and light source parameters of the virtual camera in the virtual three-dimensional space, and finally render it into a 2D image; optionally, a style transfer technique based on a generative adversarial network (GAN) is used to transfer the style of the target scene (such as the noise pattern of a specific camera, the color style) to the original image. It can be understood that other ways of image augmentation can also be used, such as elastic deformation, adding artifacts, etc., which are not limited here.

[0036] During the implementation of this step, a possible problem that may be encountered is that the parameter range of the physics-driven transformation is not properly set, resulting in the generated augmented samples being too distorted or too different from the real scene, which in turn damages the model learning. To this end, a small number of target scene samples can be analyzed before transformation to statistically analyze the distribution of key environmental parameters (such as average brightness, contrast range, background complexity, etc.), and then the parameter range of the physics-driven transformation is dynamically adjusted according to the distribution to ensure that the generated data augmentation samples are consistent with the target scene in statistical characteristics, thereby improving the effectiveness of data augmentation.

[0037] ​S102. Using enhanced image samples from the same image sample as positive sample pairs and enhanced image samples from different image samples as negative sample pairs, calculate the scene contrast loss.

[0038] In this context, a positive sample pair refers to two enhanced image samples generated from the same original image through different physical driving transformations. A negative sample pair refers to enhanced image samples generated from two different original images. Scene contrast loss is a loss function whose goal is to make the features of positive sample pairs as similar as possible, while the features of negative sample pairs are as different as possible in the feature vector output by the model.

[0039] For details, please refer to Figure 2 This is a schematic diagram of the topology of the face liveness detection system in an embodiment of this application. Step S102 is... Figure 2 This is accomplished in the feature decoupling fine-tuning unit module, whose core is learning scene invariance. In a training batch, assuming there are N different original images, each image generates two augmented samples, resulting in a total of 2N augmented images. For any augmented sample xi, its homologous samples xj (from the same original image) form a positive sample pair (xi, xj), while the remaining 2(N-1) samples xk from other original images form a negative sample pair (xi, xk). The model (the scene branch of the base model) outputs a scene feature vector for each sample. Scene contrast loss (such as InfoNCEloss) is calculated based on these vectors, optimizing the model parameters by maximizing the mutual information (or similarity) of the features in positive sample pairs and minimizing the mutual information of the features in negative sample pairs.

[0040] A key issue in this step is the problem of pseudo-negative samples. This means that among the randomly sampled negative samples, there may be samples that are extremely similar to the current sample in terms of scene but have different labels. Treating these as negative samples can mislead the model. To address this, a filtering mechanism can be introduced when constructing negative sample pairs. For example, a pre-trained, weak scene classifier can be used to initially classify candidate negative samples. If a candidate negative sample is classified into the same scene category as the current sample, its weight as a negative sample is reduced, or it is directly removed from the negative sample set, thus ensuring the purity of the negative samples.

[0041] S103. The total loss function is composed of the liveness classification loss and scene contrast loss of the mixed image samples to complete the training of the basic model and obtain the teacher model.

[0042] wherein the live classification loss refers to a loss used for the supervised model live branch to perform the real-fake binary classification, usually Cross-Entropy Loss. The total loss function is a weighted sum of multiple loss components, used to guide the optimization of the whole model together. The teacher model is the base model with huge parameter amount but strong performance obtained after sufficient training in this stage.

[0043] Specifically, please refer to Figure 2 , which is a topological structure diagram of the face live body detection system in the embodiments of the present application. Step S103 is Figure 2 The final goal of the feature decoupling fine-tuning unit module. As Figure 2 shown, the features from the visual encoder are sent to the live branch and the scene branch, and their respective losses and decoupling constraints jointly constitute the joint optimization goal. In each training step, the model not only calculates the aforementioned scene contrast loss L_scene, but also calculates the live classification loss L_live. The live classification loss is calculated by comparing the classification probability p_live output by the model live branch for the enhanced image sample and its original real-fake label y_true. The total loss function L_total is usually a weighted sum of the two: L_total=L_live+λ*L_scene, where λ is a hyperparameter used to balance the importance of the two tasks. The weights of the model (including the shared encoder, the scene branch, and the live branch) are updated by backpropagating this total loss function until the model converges, and finally the teacher model is obtained.

[0044] In some embodiments, the total loss function can be constructed in various ways to achieve more refined training goals: optionally, a decoupling regularization term L_decouple is introduced, which penalizes the sensitivity of the output of the live branch to the changes in scene features, and its calculation method can be the dot product between the scene feature gradient and the live classification loss gradient, the goal is to make them orthogonal; optionally, the uncertainty weighting method in multi-task learning is adopted, dynamically adjusting λ, so that the model automatically learns the optimal weight of the two tasks. It can be understood that other regularization terms can also be introduced or different multi-task optimization strategies can be adopted, which are not limited here.

[0045] During the implementation of this step, a key challenge is the potential conflict between the live classification task and the scene feature learning task, i.e. the model may damage the performance of one task in order to optimize the other task. For this, gradient clipping or gradient orthogonalization techniques can be used. For example, during backpropagation, after calculating the gradients of L_live and L_scene, the gradient of L_scene is projected onto the orthogonal space of the L_live gradient, and then updated. This can ensure that the learning of scene features does not negatively affect the live classification task, achieving the collaborative optimization of the two tasks.

[0046] S104, input the scene samples in the predefined target scene sample set to the scene branch of the teacher model, extract and aggregate the features of the scene samples to obtain a scene target vector.

[0047] The predefined target scene sample set refers to a small number of samples collected in a real environment where the model needs to be finally deployed, for example, face images taken in front of a camera of a certain model of mobile phone or in the environment of an ATM machine of a certain bank. The scene target vector is a condensed vector that can represent the characteristics of the specific scene environment.

[0048] For details, please refer to Figure 2 , which is a topological structure diagram of the face living body detection system in the embodiments of the present application. Step S104 corresponds to the input stage of the scene data screening module in Figure 2 , that is, the teacher model (i.e. the fine-tuned model) trained in Figure 2 . Then, a small number (for example, dozens to hundreds) of target scene samples (i.e. the scene data set in Figure 2 ) collected are input one by one to the scene branch of the teacher model, to obtain the scene feature vector v_s of each sample. In order to obtain a single vector that can stably represent the entire scene, the system will perform aggregation operation on these vectors. The simplest aggregation method is to calculate the mean of all feature vectors: v_target = mean ({v_s}). The aggregated v_target is the scene target vector.

[0049] In the implementation process of this step, a potential problem is that the collected target scene sample set may have bias, for example, only collected during the day and ignored at night, resulting in an incomplete scene target vector. To this end, an active learning strategy can be introduced. After calculating the initial scene target vector, it is used to mix the data set to screen samples, and the screening results are manually evaluated. If it is found that the screened samples have obvious scene bias, the operator is prompted to collect samples of missing scene types (such as night samples), and add them to the target scene sample set, iteratively update the scene target vector until it has sufficient representativeness.

[0050] S105, input each mixed image sample in the mixed training data set to the scene branch of the teacher model, extract multiple scene feature vectors to form a scene vector set.

[0051] The scene feature vector is a high-dimensional vector output by the scene branch of the teacher model for a single image. The scene vector set is a set of scene feature vectors corresponding to all images in the mixed training data set.

[0052] For details, please refer to Figure 2This is a schematic diagram of the topology of the face liveness detection system in an embodiment of this application. Step S105 is... Figure 2 This is executed in the scene data screening module, aiming to establish a searchable feature library for subsequent screening. Figure 2 The database icon in the image. The face liveness detection system traverses the entire large-scale hybrid training dataset (i.e., ...). Figure 2 (The dataset contains a mixed dataset). For each image in the dataset, the system performs a forward propagation, but only through the scene branch of the teacher model, extracting its output scene feature vector. This process generates millions or even more feature vectors. To facilitate subsequent fast retrieval, the system stores these vectors along with their corresponding image indices in a specially constructed feature library. This feature library is the set of scene vectors.

[0053] In some embodiments, this massive set of scene vectors can be efficiently constructed and managed in several ways: Optionally, a specialized Approximate Nearest Neighbor (ANN) search library, such as FAISS (Facebook AI SimilaritySearch) or ScaNN (Scalable Nearest Neighbors), can be used to construct a feature index, which can reduce the subsequent similarity search time from linear complexity to logarithmic complexity; alternatively, before storing the feature vectors, dimensionality reduction techniques such as PCA (Principal Component Analysis) can be used to compress the vectors to reduce storage space and accelerate computation while retaining most of the information. It is understood that other databases or indexing techniques can also be used to manage these features, and this is not limited here.

[0054] A practical challenge in implementing this step is handling the computational overhead of such a large-scale dataset. To address this, a distributed computing framework (such as Apache Spark) can be employed. The mixed training dataset is sharded and distributed across multiple computing nodes, with each node extracting features from its own shard in parallel. Finally, the feature vectors extracted from all nodes are aggregated to build a global feature index. This parallel processing can significantly reduce the time required to construct the scene vector set.

[0055] S106. Calculate the vector similarity between the scene target vector and each vector in the scene vector set, and select the corresponding image samples from the mixed training dataset based on the vector similarity to obtain a scene matching data subset.

[0056] Vector similarity is an indicator that measures how close two vectors are in a direction; cosine similarity is commonly used. Scene matching data subsets are small subsets of data selected from a large mixed dataset that are highly consistent with the characteristics of the target deployment scene environment.

[0057] For details, please refer to Figure 2 This is a schematic diagram of the topology of the face liveness detection system in an embodiment of this application. Step S106 is... Figure 2 The core function of the scene data screening module is to perform matching and screening using a feature library. The face liveness detection system utilizes the feature library built in the previous step, using the scene target vector v_target obtained in step S104 as the query vector. The system calculates the cosine similarity between v_target and each scene feature vector v_sample in the feature library: Similarity = (v_target * v_sample) / (||v_target|| * ||v_sample||). Then, a similarity threshold is set (e.g., 0.85), and the image indices of all samples with similarity greater than this threshold are recorded. Finally, based on these indices, the corresponding images and their labels are extracted from the original mixed training dataset to form a subset of the scene matching data.

[0058] In some embodiments, the screening process can be optimized in several ways to ensure the quality and diversity of the subset: Optionally, instead of using a fixed threshold, the top K samples with the highest similarity can be selected to ensure a fixed subset size; alternatively, a diversity guarantee step can be added after screening, such as clustering the features of the selected samples again and sampling proportionally from each cluster to avoid the selected samples having overly homogeneous scenarios (e.g., all with the same background). It is understood that other screening criteria, such as the distribution of liveness labels on the samples, can also be combined to construct the final data subset, which is not limited here.

[0059] A key issue in this step is the selection of the similarity threshold. If the threshold is too high, the selected data subset is too small, leading to insufficient model training; if the threshold is too low, the subset contains too much noisy data irrelevant to the scene. To address this, an adaptive threshold strategy can be employed. First, a core subset is selected using a relatively high initial threshold, and a student model is initially trained using this subset. Then, the model's performance is evaluated on the validation set, and the threshold is dynamically adjusted based on performance feedback (such as signs of underfitting or overfitting). Multiple rounds of selection and training are performed until the optimal threshold is found.

[0060] S107. Using the teacher model as supervision, perform knowledge distillation on a subset of scene matching data, modulate the distillation loss with the attention mask output by the scene branch of the teacher model, and generate a liveness detection model.

[0061] wherein knowledge distillation is a model compression technique that lets a small student model learn to mimic the behavior of a large teacher model. Attention mask is usually a matrix of the same size as the feature map, whose values represent the degree of attention that the model pays to the feature at that position. The live detection model is a lightweight student model that is finally deployed to the edge device.

[0062] In particular, please refer to Figure 2 , which is a topological structure diagram of the face live detection system in the embodiments of the present application. Step S107 is executed by Figure 2 the scene-specific distillation compression module. As shown in Figure 2 , this module uses a teacher model (composed of a visual encoder and a live branch) to supervise a mobile model (i.e., a student model) and transfers knowledge by calculating a distillation loss. The face live detection system selects a lightweight network structure (such as MobileNetV3) as the student model. During the training process, the teacher model and the student model will process each image x in the scene matching data subset. The traditional distillation loss will force the output probability distribution of the student model to approximate the output probability distribution of the teacher model. On this basis, the present method introduces modulation: the scene branch ϕ_scene(x) of the teacher model will output one or more intermediate layer feature maps, which can form an attention mask A_teacher after processing. This mask will be applied to the distillation loss, so that the student model pays more attention to the areas considered important by the teacher model when learning.

[0063] In some embodiments, scene-aware knowledge distillation can be achieved in various ways: optionally, not only the final output but also the intermediate layer feature representation is distilled, and an attention mask is used to weight the importance of different position features; optionally, the attention mask itself is also taken as a distillation target, i.e., an additional loss term is added to let the student model learn to generate an attention mask similar to that of the teacher model. It can be understood that more complex distillation loss functions can be designed to combine multiple forms of knowledge for transmission, which are not limited here.

[0064] During the implementation of this step, a challenge is how to balance the standard classification loss (student model and real label) and the distillation loss (student model and teacher model). For this, the strategy of curriculum learning can be adopted. In the early stage of training, a higher weight is given to the distillation loss, so that the student model first quickly mimics the overall behavior of the teacher model; as the training progresses, the weight of the classification loss of the student model and the real label is gradually increased, so that the student model is fine-tuned and corrected on the basis of imitation, thereby achieving better results than pure imitation.

[0065] S108, input the face image to be detected to the living body detection model for forward propagation calculation to obtain a classification result representing living body confidence.

[0066] The face image to be detected refers to a face picture that needs to be judged for authenticity in actual application. The forward propagation calculation refers to a complete calculation process of data in a neural network from an input layer to an output layer. The living body confidence is a probability value output by the model, indicating how likely the model thinks that the face is a real person.

[0067] Specifically, refer to Figure 2 , which is a topological structure diagram of the face living body detection system in the embodiments of the present application. Step S108 is Figure 3 The final application stage of the whole process is the mobile terminal model generated by the scene customized distillation compression module. After the trained lightweight living body detection model is deployed on an edge device (such as a mobile phone or an access control machine), when living body detection is needed, a camera captures a frame of face image. After the image is preprocessed (such as cropping and normalization), it is input to the living body detection model. The model performs a forward propagation calculation, and the final output layer (usually a Softmax layer) outputs a two-dimensional vector, for example, [0.1, 0.9], representing the probabilities of the model predicting that the image is a fake body and a real person, respectively. According to a preset decision threshold (such as 0.5), the system takes the class with higher probability as the final classification result and outputs the living body confidence (such as 0.9).

[0068] In some embodiments, the inference process can be optimized in various ways to improve speed and energy efficiency: optionally, the model is subjected to a quantization-aware training before deployment, and the model weights are converted from 32-bit floating-point numbers (FP32) to 8-bit integers (INT8) to take advantage of the INT8 acceleration unit of the hardware; optionally, the model is subjected to channel pruning, and redundant channels that do not contribute much to the final result are removed to further reduce the amount of calculation. It can be understood that other model compression and acceleration techniques can also be used, such as weight sharing, low-rank decomposition, etc., which are not limited here.

[0069] During the implementation of this step, a common problem is the trade-off between processing speed and accuracy. In some scenarios where real-time performance is extremely important, even a lightweight model may not be fast enough. To this end, a cascaded detection framework can be designed. First, a very small and fast model is used for preliminary screening, which filters out only very obvious fake body attacks. For samples that cannot be decided, a more complex but more accurate living body detection model described in the present step is called again for secondary judgment. This hierarchical processing method can greatly improve the average processing speed while ensuring high accuracy.

[0070] The method provided in the present embodiment is further described in more detail below. Please refer toFigure 4 , as another flowchart of the face liveness detection method based on scene optimization in the embodiments of the present application.

[0071] S301, feature extraction is performed on a pre-defined target scene sample set to obtain scene environment parameters, and a generation network is constructed based on the scene environment parameters.

[0072] Among them, the target scene sample set represents a small part of representative images collected in the actual deployment environment; the scene environment parameters are quantitative indicators extracted from these images that can describe the characteristics of the environment, such as light intensity distribution, color saturation, noise level, etc.; the generation network is usually a deep learning model, such as a generative adversarial network (GAN), used to synthesize new images according to given parameters.

[0073] Specifically, this step is the preparation stage of data augmentation, aiming to create more high-quality training samples highly related to the target scene, especially attack samples. The face liveness detection system first performs detailed image analysis on dozens to hundreds of target scene samples collected. It calculates a series of statistical features to quantify the scene environment, for example: using histogram analysis to obtain the distribution range of brightness and contrast; Fourier transform is used to analyze the frequency characteristics of the image to evaluate the noise mode and intensity; color analysis tools are used to analyze the dominant color and white balance offset. These extracted scene environment parameters are then used to configure or fine-tune a generation network. For example, a pre-trained StyleGAN model can be fine-tuned to make the generated face images naturally carry the light and shadow effects and color styles unique to the target scene.

[0074] In some embodiments, the construction of this generation network can be achieved in various ways: optionally, a non-GAN method is used to construct an image processing pipeline containing multiple adjustable parameters, which are directly set by the extracted scene environment parameters (such as gamma correction value, Gaussian noise standard deviation, lens blur kernel); optionally, use flow-based generation models or variational autoencoders (VAEs) to guide the image generation process by inputting the scene environment parameters as conditional inputs, which can usually provide better generation diversity. It can be understood that other advanced generation models or image-to-image translation techniques can also be used to achieve this function, which is not limited here.

[0075] A core problem that may be encountered during the implementation of this step is that a small number of target scene samples may not be sufficient to comprehensively capture all changes of the scene (such as light at different times of the day), resulting in insufficient sample diversity generated. In order to solve this problem, parameter interpolation and extrapolation techniques can be introduced. After extracting the scene environment parameters of different samples, the system does not only use these discrete parameter points, but also performs smooth interpolation between these points, or even extrapolation within a reasonable range, thereby generating a series of continuously changing parameter sets. For example, interpolation between the two parameter points of "day" and "dusk" can generate parameters under "afternoon" light. Using these interpolated / extrapolated parameters to generate the network can synthesize samples covering a wider range of scene changes, thereby improving the comprehensiveness of data augmentation.

[0076] S302, input the preset attack image to the generation network for conversion processing to obtain a synthesized attack sample, and supplement the synthesized attack sample to the mixed training data set.

[0077] Wherein, the preset attack image refers to a general image library containing various types of attack methods, such as high-definition printed photos, screenshots of face videos played on different display screens, and photos of three-dimensional masks; the conversion processing refers to the process of stylizing or environment feature rendering of these general attack images through the generation network constructed in the previous step; the synthesized attack sample is a new image that retains the original attack characteristics and superimposes the target scene environment features after conversion processing.

[0078] Specifically, this step aims to inject highly targeted high-order negative samples into the training data set. The face liveness detection system selects samples from its preset attack image library, and then inputs these samples one by one into the generation network constructed in step S301. The generation network processes the input attack images, such as superimposing low light and high ISO noise specific to the target scene on a printed photo, or simulating glare and moire specific to the target scene camera on a screen capture attack sample. The synthesized attack samples generated in this way, in the view of the model, are as if the attack behavior actually occurred in the target deployment environment. Finally, the system adds these high-quality synthesized attack samples together with their prosthetic labels to the mixed training data set, thereby greatly enriching the data set and making subsequent training more challenging and targeted.

[0079] In some embodiments, the replenishment process of this sample can be implemented in various ways: optionally, replenish in proportion control, generate and replenish synthetic attack samples of specific types with emphasis according to the prediction of the types of attacks that the target scene may face, for example, if it is judged that screen attack is the main threat, more synthetic screen attack samples are generated; optionally, implement online generation and enhancement, integrate the generation network into the trained data loader, dynamically generate synthetic attack samples in each training batch, and perform additional conventional data enhancement (such as random cropping and flipping) on them, further improving the diversity of data. It can be understood that other strategies can also be used to optimize the composition of the data set, which are not limited here.

[0080] During the implementation of this step, a problem that may be encountered is that the generation network may inadvertently weaken or destroy some key attack clues (for example, the screen of a printed photo or the pixels of a screen) in the original attack image. To this end, an attention mechanism-based fusion strategy can be introduced. When the generation network converts the image, it does not directly output the final result, but generates a scene style layer and a content preservation layer. At the same time, another network branch will predict the key clue area (attack saliency map) in the original attack image. Finally, according to this saliency map, the scene style layer and the content preservation layer are weighted and fused to ensure that the original attack clues are maximally preserved while adding scene features, so that the synthetic sample is both real and effective.

[0081] S303, extract the mixed image sample in the mixed training data set of the basic model, and apply a physical driving transformation to the mixed image sample to obtain an enhanced image sample.

[0082] Reference step S101, which is not repeated here.

[0083] S304, take the enhanced image sample derived from the same image sample as the positive sample pair and the enhanced image sample derived from different image samples as the negative sample pair, and calculate the scene contrast loss.

[0084] Reference step S102, which is not repeated here.

[0085] S305, the total loss function is composed of the live classification loss of the mixed image sample and the scene contrast loss, the training of the basic model is completed, and the teacher model is obtained.

[0086] Among them, the liveness classification loss of mixed image samples usually refers to the cross-entropy loss, which is used to measure the model's performance on the true / false classification task; the scene contrast loss is a self-supervised loss, which is used to drive the model to learn feature representations that are insensitive to scene changes; the total loss function is the weighted sum of these two (or more) loss components, which is used to guide the parameter updates of the entire model; the teacher model is a large model that has been trained at this stage and has powerful feature extraction and discrimination capabilities.

[0087] Specifically, in each training iteration, the face liveness detection system takes a batch of data from the augmented mixed training dataset. For each image in the batch, the model computes two main losses in parallel. First, the image is processed by the shared encoder and the liveness branch to produce a classification prediction, which is compared with the image's ground truth label (real person or fake person) to compute the liveness classification loss L_live. Second, augmented sample pairs generated from the same original image are processed by the shared encoder and the scene branch to compute their scene feature vectors, and scene contrast loss L_scene is computed based on these vectors to bring positive sample pairs closer together and push negative sample pairs further apart. Finally, the total loss function is defined as the weighted sum of these two losses: L_total = α * L_live + β * L_scene. By backpropagating this total loss function, the gradient is computed and the weights of the entire teacher model (shared encoder, liveness branch, scene branch) are updated. This process continues until the model's performance on the validation set no longer improves, at which point training is complete, and the resulting model is the teacher model.

[0088] During this step, there may be conflicts in the optimization objectives between the scene contrastive learning task and the liveness classification task, leading to unstable training or poor performance. For example, some subtle texture features crucial for liveness detection may be treated as scene changes in physically driven transformations and suppressed by the contrastive loss. To address this, a hierarchical feature decoupling strategy can be designed. In terms of network structure, the shallow part of the shared encoder is primarily driven by the liveness classification loss to preserve all details; the deeper part is affected by both losses simultaneously, achieving a higher level of semantic decoupling. In terms of the loss function, a mask modulated by the liveness branch attention map can be applied to the scene contrastive loss to prevent the contrastive learning process from suppressing key liveness-related regions.

[0089] S306. Input the scene samples from the predefined target scene sample set into the scene branch of the teacher model, extract and aggregate the features of the scene samples to obtain the scene target vector.

[0090] Refer to step S104, which will not be repeated here.

[0091] S307, input each mixed image sample in the mixed training dataset to the scene branch of the teacher model one by one, and extract a plurality of scene feature vectors to form a scene vector set.

[0092] Reference step S105, not described here.

[0093] S308, calculate the vector similarity between the scene target vector and each vector in the scene vector set, and filter out the corresponding image sample from the mixed training dataset according to the vector similarity to obtain a scene matching data subset.

[0094] Reference step S106, not described here.

[0095] S309, input the predefined target scene sample set to the scene branch of the teacher model to obtain a benchmark attention mask.

[0096] Among them, the scene branch of the teacher model is the part of the teacher model that is specially used to extract scene-related features; the benchmark attention mask is an aggregated spatial weight map that can represent the typical visual focus area of the target scene.

[0097] Specifically, this step is the preparation work of scene perception distillation, and the purpose is to establish a scene focus benchmark for subsequent knowledge transfer. The face liveness detection system loads the trained teacher model, and inputs all the images in the target scene sample set into the model one by one. For each image, the system does not care about its final output, but intercepts the feature map produced by it in the scene branch at one or more intermediate layers. The activation values of these feature maps reflect the degree of attention of the model to different spatial positions when understanding the scene of the image. The system aligns and aggregates these feature maps produced by all target scene samples, usually performing element-wise average calculation. After aggregation, the average feature map obtained after normalization (for example, scaled to the range [0, 1]) forms a benchmark attention mask. This mask can be regarded as a summary of the visual habits of the teacher model for this particular deployment scene.

[0098] In some embodiments, this baseline mask can be generated in several ways: Optionally, Gradient Weighted Class Activation Mapping (Grad-CAM) is used. For each target scene sample, the gradient of the final output of the scene branch relative to the intermediate feature map is calculated, and this gradient is used to weight the feature map to generate a more semantically oriented attention map. Finally, these attention maps are averaged. Optionally, outlier removal is performed before aggregation. First, the similarity between all pairs of attention maps is calculated, and samples that differ too much from other maps are removed (e.g., someone passes by the background at the moment of shooting). Then, the remaining samples are averaged to obtain a more stable and robust baseline mask. It is understood that other attention extraction and aggregation techniques can also be used, and are not limited here.

[0099] One potential issue during this step is that if the target scene itself contains several significantly different sub-scenes (e.g., a room has two common locations: a window and a corner), forcibly averaging the attention maps of all samples might result in a blurry baseline mask that fails to highlight any key elements. To address this, unsupervised clustering (e.g., K-Means clustering) can be performed on the attention maps of the target scene samples. This automatically categorizes the samples into several sub-scene classes (e.g., window scene, corner scene). Then, an independent and clear baseline attention mask is calculated for each class. In subsequent distillation processes, the corresponding baseline mask can be dynamically selected based on the sub-scene class to which the image to be processed belongs.

[0100] S310. Input the samples from the scene matching data subset into the scene branch of the teacher model to obtain the real-time attention mask.

[0101] Here, the scene matching data subset refers to the set of images that are highly similar to the environmental features of the target scene, selected from the massive mixed dataset in step S308; the scene branch of the teacher model is the part of the teacher model responsible for extracting scene features; and the real-time attention mask refers to the instantaneous visual attention region map generated by the teacher model for the single training image currently being processed.

[0102] Specifically, this step is performed in the training loop of the knowledge distillation, aiming to obtain the teacher model's instant focus on each specific training sample. When the face liveness detection system takes an image from the scene matching data subset for training, the image will be sent to the scene branch of the teacher model. Similar to step S309, the system will intercept and process the intermediate layer feature map inside the scene branch to generate a spatial attention mask. However, unlike S309, this mask is generated instantaneously for the current image and will not be aggregated with the masks of other images. Therefore, it is called a real-time attention mask. This mask reflects how the teacher model's attention is attracted by specific content in the image (such as face posture, specific background elements) when analyzing this particular image.

[0103] In some embodiments, the generation of this real-time mask can be implemented in various ways to improve its quality: optionally, use self-attention mechanism, directly extract self-attention maps from the Transformer layer of the teacher model (if the teacher model is based on Transformer), these maps naturally represent the model's attention to the relationship between different parts of the image, which can be used as a high-quality real-time attention mask; optionally, smooth the generated real-time mask, for example, use a small Gaussian filter to convolve it, to reduce high-frequency noise, making the mask more continuous and stable in space. It can be understood that a multi-scale real-time attention mask can also be generated by combining various methods to capture attention information at different levels, which is not limited here.

[0104] During the implementation of this step, a problem that may be encountered is that for some images in the scene matching data subset, their actual content may have subtle but critical differences from the target scene, causing the real-time attention mask generated by the teacher model to deviate greatly from the expected scene focus (i.e., the reference mask). This deviation may be useful information or noise. In order to effectively utilize this deviation information, the system can calculate the difference map between the real-time mask and the reference mask (e.g., element-wise subtraction and absolute value). This difference map can be used as an additional distillation signal to guide the student model to not only learn the teacher's common focus, but also learn how the teacher's attention is adjusted instantaneously when encountering samples deviating from the regular scene, thereby improving the student model's adaptability.

[0105] S311, fuse the real-time attention mask and the reference attention mask to obtain a modulated mask.

[0106] Wherein, the real-time attention mask is the immediate attention map of the teacher model to the current training sample; the benchmark attention mask is the average attention map of the teacher model to the entire target scene; the fusion refers to combining the two masks through mathematical operation; and the modulation mask is the composite attention map obtained after the fusion and finally used to guide the distillation process.

[0107] Specifically, this step aims to combine commonality and individuality to generate a more comprehensive and effective guidance signal. The face liveness detection system now has a benchmark attention mask representing the commonality of the scene and a real-time attention mask representing the individuality of the current sample. In order to enable the student model to focus on the key areas of the target scene and also take into account the uniqueness of each sample, the system needs to fuse the two masks. A common fusion method is element-wise multiplication, which highlights the areas considered important by both the benchmark mask and the real-time mask. Another method is weighted summation, which can control whether to give priority to the commonality guidance of the scene or the individuality guidance of the sample by adjusting the weight. This finally generated modulation mask will be the core of the next step of modulating the distillation loss.

[0108] In some embodiments, the fusion of this mask can be achieved in various ways: optionally, a logical OR operation is used for fusion, that is, after binarizing the two masks, their union is taken, which can ensure that any area considered important by either mask will be retained, which is suitable for scenes where the student model is expected to learn more general features; optionally, a learnable fusion module is introduced, for example, a small convolutional network that takes the benchmark mask and the real-time mask as input and adaptively learns how to combine them into the optimal modulation mask, and the parameters of this small network are trained end-to-end with the student model. It can be understood that more complex nonlinear fusion functions can also be designed according to specific task requirements, which are not limited here.

[0109] During the implementation of this step, the optimal fusion strategy and parameters (such as the weight of weighted summation) need to be determined. A fixed strategy may not be suitable for all cases. For this purpose, the idea of meta-learning can be introduced. The system can reserve a small part of the validation data during training. After each training step, use different fusion parameters to generate the modulation mask and calculate the distillation loss on the validation data. Then, this loss is used as the optimization target of meta-learning, and the parameters of the fusion strategy are updated through backpropagation. In this way of learning how to learn, the system can automatically find a dynamic fusion strategy that best suits the current training stage and the characteristics of the data, thereby maximizing the distillation efficiency.

[0110] S312, apply the modulation mask to the calculation process of the distillation loss to obtain a modulated distillation loss, and perform knowledge distillation based on the modulated distillation loss to generate a liveness detection model.

[0111] wherein the modulation mask is the composite attention map obtained in the previous step; the distillation loss is a loss function measuring the difference between the student model and the teacher model; the knowledge distillation is a model compression method; and the live detection model is the final generated lightweight student model ready for deployment.

[0112] Specifically, this is the core execution step of the scene-aware knowledge distillation. In the process of training the student model, the face live detection system will not only calculate the classification loss (such as cross-entropy loss) between the student model prediction result and the real label, but also calculate a special distillation loss. This distillation loss aims to make the student model imitate the thinking process of the teacher model. For example, the difference between the student model and the teacher model at some intermediate layer feature map can be calculated. The key is that this difference is calculated by modulation: the system will use the modulation mask generated in step S311 to weight the feature map difference. For example, the weighted mean square error is calculated as follows: L_distill_feature=Σ[M*(F_teacher-F_student) 2 ] / ΣM, wherein M is the modulation mask and F is the feature map. In this way, the student model will be forced to prioritize learning the features that match the teacher model in the highlighted areas of the modulation mask. The final total training loss is the weighted sum of the classification loss and this modulated distillation loss. By optimizing this total loss, the student model is trained to be a lightweight live detection model that not only knows right from wrong, but also knows how to focus on certain scenarios like the teacher.

[0113] In some embodiments, this modulation distillation process can be implemented in various ways: optionally, the modulation distillation is applied to the logit level, i.e. the logit difference of different categories is weighted by the modulation mask, if the mask has some correspondence with the categories; optionally, relational knowledge distillation is used, the relationships (such as distance or angle) between different positions in the teacher model feature map are calculated, and the loss of these relationship differences is weighted by the modulation mask, so that the student learns higher-order structured knowledge. It can be understood that various forms of attention-guided distillation loss can also be designed to transfer different levels of knowledge, which are not limited here.

[0114] S313, input the face image to be detected into the live detection model for forward propagation calculation to obtain a classification result representing the live confidence.

[0115] Reference is made to step S108, which will not be repeated here.

[0116] In some embodiments, the face liveness detection system will perform feature decoupling operation when training the teacher model to ensure effective separation of scene features and liveness features, that is, the face liveness detection system will decompose the base model into a shared encoder, a scene branch and a liveness branch; input the mixed image sample into the shared encoder to obtain a shared feature representation; input the shared feature representation into the scene branch to determine a scene loss component in combination with the scene contrast loss; input the shared feature representation into the liveness branch to determine a liveness loss component in combination with the liveness classification loss of the mixed image sample; calculate the correlation of the scene loss component and the liveness loss component to obtain a decoupling regularization component; determine a total loss function according to the scene loss component, the liveness loss component and the decoupling regularization component to adjust the model parameters of the base model to obtain the teacher model.

[0117] wherein the feature decoupling operation refers to a specific model structure design and loss function constraint, so that the feature representations learned by the model for different tasks are mathematically independent or irrelevant to each other, so as to avoid negative interference between tasks; the shared encoder represents the public network part of the model responsible for extracting general bottom and middle layer features from the input image, for example, the first few layers of a ResNet; the shared feature representation is the output of the shared encoder, which is a high-dimensional vector or tensor that theoretically contains all the original information for scene and liveness judgment; the scene loss component and the liveness loss component respectively represent the loss values calculated on the scene recognition task and the liveness classification task, which are used to guide the optimization of the respective branch; the decoupling regularization component is an additional penalty term, the value of which is proportional to the correlation of the scene features and the liveness features, which is used to suppress this correlation in the total loss function; the total loss function is the final objective function that guides the update of the model parameters, which is a weighted combination of the above loss components.

[0118] Specifically, the feature decoupling operation occurs in the offline training phase of the teacher model, and the core goal is to cultivate an expert-level teacher model with strong judgment ability for living features, and the judgment basis is completely independent of scene factors such as illumination, background, and camera model. In each training iteration, the face liveness detection system takes a batch of images from the mixed training dataset and inputs them into the decomposed base model. First, the shared encoder converts each image into a shared feature representation. Then, the representation is simultaneously input into two parallel branches: the scene branch uses a scene contrast loss (such as InfoNCELoss) to learn to distinguish features of different scenes and calculate a scene loss component; the liveness branch uses a classification loss such as cross-entropy to learn to distinguish features of real people and fake bodies and calculate a liveness loss component. The key decoupling step occurs here: the face liveness detection system will design a way to quantify the statistical correlation between the output (or internal features) of the liveness branch and the output (or internal features) of the scene branch. For example, by calculating the sum of the off-diagonal elements of the covariance matrix of the two branch feature vectors, or by training an auxiliary discriminator to try to predict scene information with liveness features, and using the discriminator's loss as a correlation measure. This measure value constitutes the decoupling regularization component. Finally, the total loss function is defined as the weighted sum of the liveness loss, the scene loss, and the decoupling regularization component. By minimizing this total loss through backpropagation, the face liveness detection system forces the model to actively cut off the connection between the task feature representations of liveness classification and scene recognition while optimizing the ability of both tasks, ultimately obtaining a highly decoupled teacher model.

[0119] In some embodiments, the feature decoupling process can be implemented in various ways to enhance the effect: optionally, the Gradient Reversal Layer (GRL) method is used to realize the adversarial decoupling. The specific steps are as follows: first, an auxiliary scene classifier is additionally attached on the living body features extracted by the living body branch; second, a gradient reversal layer is inserted between the living body features and the auxiliary classifier, which keeps the input unchanged during forward propagation, but multiplies the gradient from the auxiliary classifier by a negative constant during backward propagation; finally, the face liveness detection system optimizes the living body branch to minimize the living body classification loss and optimizes the auxiliary scene classifier to minimize the scene classification loss during training. Due to the existence of GRL, the gradient of optimizing the auxiliary classifier is reversed when it is transmitted back to the living body branch, which is equivalent to making the living body branch learn a feature representation that can make the auxiliary scene classifier most confused, so that the living body features do not contain any information that can be used to judge the scene. Optionally, the method of orthogonal constraint is used for decoupling. The specific steps are as follows: first, the face liveness detection system flattens the feature maps output by the living body branch and the scene branch at a certain layer into feature vector matrices F live and F scene; second, the product F liveT*F scene of the two matrices is calculated. Under ideal conditions, if the features are orthogonal, the off-diagonal elements of the product matrix should tend to zero; finally, the L1 or L2 norm of the off-diagonal elements of the product matrix is added as a regularization term to the total loss function, directly punishing the linear correlation between the feature vectors in mathematics, forcing the model to learn two sets of orthogonal feature bases. It can be understood that other more advanced decoupling techniques such as mutual information minimization can also be used to achieve the same purpose, which is not limited here. It is supplemented that the difficulty of decoupling lies in that the living body clues (such as skin texture) and scene features (such as illumination) are naturally coupled at the pixel level, and the above methods aim to force the model to abstract independent and more essential semantic features from this coupled appearance.

[0120] In some embodiments, the face liveness detection system will start the scene drift detection and adaptive update mechanism after the model is deployed to cope with environmental changes, that is, the face liveness detection system will calculate the distribution difference between the baseline attention mask and the real-time attention mask to obtain the scene drift index; when the scene drift index exceeds the preset drift threshold, the key scene feature components are extracted based on the preset high activation area in the modulation mask; the similarity calculation is performed between the key scene feature components and the pre-stored target scene feature template to generate a scene consistency evaluation report; according to the deviation degree in the scene consistency evaluation report, the weight parameters of the scene related layers in the liveness detection model are adjusted.

[0121] Among them, the scene drift detection and adaptive update mechanism is an automatic process deployed on the edge device to maintain the long-term performance stability of the model; the reference attention mask refers to a template pre-calculated and stored on the device, representing the attention pattern that the model should have in the ideal target scene; the real-time attention mask is the attention map generated by the model in real time when processing the current real-time video frame; the distribution difference measure is a mathematical tool, such as KL divergence or Wasserstein distance, for quantifying the difference between two attention masks (as probability distributions); the scene drift indicator is the specific value calculated by the measure; the key scene feature component is the feature extracted from the current scene image that best reflects its difference from the original target scene; the target scene feature template is a set of more detailed scene descriptors stored in the cloud or locally than the attention mask; the scene consistency evaluation report is a structured analysis result detailing the type and extent of drift; the scene-related layer refers to the network layer in the model that is mainly responsible for processing environmental and background information, such as shallow convolutional layers or normalization layers.

[0122] Specifically, this mechanism continues to run after the live detection model is deployed in the actual scene (such as an access control machine or a mobile phone APP), aiming to solve the problem of gradual decline in model performance due to environmental changes (such as seasonal replacement, indoor decoration, and device aging). The face live detection system on the edge device uses a lightweight model or a special module to periodically (e.g., every minute) or event-triggered (e.g., after continuous low confidence judgment for multiple times) scene analysis on the captured video stream. For each image at the analysis time, the system calculates its real-time attention mask. Then, the system compares this real-time mask with the reference attention mask fixed in the device, and obtains a scene drift indicator by calculating the distribution difference measure. The system maintains a time series of this indicator. When the indicator continuously exceeds a preset drift threshold (e.g., 5 consecutive sampling values exceed the threshold), the system determines that a scene drift has occurred. At this time, the adaptive update process is activated: the system first analyzes the current attention mask, locks the high activation areas with the largest difference from the reference mask, and extracts more detailed key scene feature components (such as color histogram, LBP texture feature) from these areas of the original image. Then, the system matches these feature components with the stored target scene feature template to generate a scene consistency evaluation report. This report may indicate that the current scene brightness has decreased by 30% compared to the reference, and the color temperature is blue. Finally, according to the conclusion of the report, the system performs a small-scale, targeted model update, such as slightly increasing the weights of the first few convolution kernels of the model to enhance the sensitivity to dark details, or adjusting the parameters of the batch normalization layer to compensate for color changes, so that the model quickly adapts to the new environment.

[0123] In some embodiments, this adaptive updating mechanism can be implemented in various ways to improve its efficiency and robustness: optionally, a statistical process control (SPC) approach can be adopted for drift detection. The specific steps are as follows: first, instead of simply using a fixed threshold, the face liveness detection system regards the scene drift indicator as a quality control parameter in a production process; second, the system uses control charts such as cumulative sum (CUSUM) or exponentially weighted moving average (EWMA) to monitor the time series of this indicator; finally, these control charts are more sensitive to small but persistent systematic shifts (e.g. a camera lens gradually covered with dust leading to a slow decline in clarity) than a single threshold method, and can issue a drift alert earlier. Optionally, a model committee-based drift detection method can be adopted. The specific steps are as follows: first, the face liveness detection system deploys a committee on the edge device, which is composed of multiple (e.g. 3-5) lightweight models with slightly different structures or slightly different training data; second, during normal operation, these models should have highly consistent attention masks or prediction results for the same input. When the scene drifts, the disagreement between them will increase significantly due to their different sensitivities to changes; finally, the system takes this disagreement as a scene drift indicator, and when the disagreement exceeds a certain level, it triggers the updating mechanism. It can be understood that more complex online learning or meta-learning frameworks can also be used to implement the adaptation of the model, which is not limited here. It is noted that adaptive updating is usually fine-tuning, and if the evaluation report indicates that the scene has undergone a revolutionary change (e.g. from indoor to outdoor), the mechanism may trigger a large version update process to download a completely new model from the cloud.

[0124] In some embodiments, to improve the accuracy of scene drift detection, the face liveness detection system can use a more refined adaptive benchmark, i.e. the face liveness detection system will perform cluster analysis on the target scene sample set to obtain multiple typical scene subcategories, and construct a corresponding reference attention mask template for each typical scene subcategory; calculate the matching degree between the attention mask corresponding to each sample in the scene matching data subset and each reference attention mask template, determine the best matching scene category; based on the best matching scene category and the matching degree, divide the scene matching data subset into multiple scene subsets; calculate the attention mask mean of each scene subset respectively as the adaptive benchmark mask of the best matching scene category, to replace the reference attention mask for scene drift detection.

[0125] Wherein, the adaptive reference means that the reference line for comparison is not fixed, but can be dynamically selected or generated according to the current situation; the cluster analysis is an unsupervised learning method for automatically grouping data points according to similarity, such as the K-Means algorithm; the typical scene subcategory means a stable microenvironment with significant differences in a macro deployment scene, such as the window sunlight area, the internal light area and the corridor dim area in an office; the reference attention mask template is an average mask pre-calculated for each subcategory, representing the ideal attention pattern of the sub-scene; the matching degree is a score for measuring the similarity between a real-time mask and a template; the best matching scene category is the subcategory that is most similar to the current real-time mask; and the adaptive reference mask is the reference that is most matched to the current situation and is finally used for drift detection.

[0126] In particular, the fine-grained adaptive reference strategy is mainly applied to deployment scenes with complex and variable environments to solve the problem that a single global reference cannot accurately represent all normal working states. In the initial deployment or calibration phase, the face liveness detection system first extracts features from the collected target scene sample set, and performs cluster analysis on these features (or the attention masks generated therefrom). Assuming that the cluster result divides the samples into 3 typical scene subcategories. Then, the face liveness detection system calculates the average value of the attention masks for all samples in each subcategory, thereby obtaining 3 independent reference attention mask templates, and stores this set of templates in the edge device. In the subsequent real-time running process, when the face liveness detection system captures a new image and calculates its real-time attention mask, it does not immediately compare it with a certain fixed global reference. Instead, it calculates the matching degree (such as cosine similarity) of the real-time mask with all 3 stored reference templates. The subcategory corresponding to the highest matching degree is identified as the best matching scene category. At this time, the adaptive reference mask used for scene drift detection is dynamically determined as the reference template of the best matching category. The subsequent drift index calculation is based on the difference between the real-time mask and the dynamically selected, most relevant reference template, thereby greatly improving the accuracy of detection and avoiding false positives caused by scene switching between several normal subcategories.

[0127] In some embodiments, the construction and application of this adaptive baseline can be achieved in various ways: optionally, an online clustering and template dynamic updating strategy can be adopted. The specific steps are as follows: first, the face liveness detection system starts with the reference templates obtained by initial clustering; second, the system continuously collects new real-time attention masks that are judged to be normal during operation and caches them; finally, the system periodically (for example, every morning) merges the new data with the old data and re-runs the clustering algorithm. This enables the system to automatically discover new stable scenes that appear in the environment (for example, a new floor lamp is added to the office), or to merge / split existing scene categories, and accordingly update the reference attention mask template library, achieving lifelong learning of the baseline. Optionally, a hierarchical baseline matching strategy can be adopted. The specific steps are as follows: first, the face liveness detection system organizes the scene templates into a tree-like hierarchical structure, for example, the top layer is the office, under which there are two child nodes of day and night, and under the day node there are two leaf nodes of sunny and cloudy; second, when matching the real-time mask, the system starts from the root node and performs hierarchical matching from coarse to fine; finally, the system first determines whether it is day or night, and then further subdivides in the determined branch. This hierarchical search and matching is more efficient than traversing all templates in a flat manner, and is also more consistent with human cognitive logic of scenes. It can be understood that a more flexible Gaussian Mixture Model (GMM) can also be used to model the scene distribution to determine the probability of the current scene belonging to each subcategory, which is not limited here.

[0128] During the implementation of this step, the determination of the scene transition state is required. When the environment is slowly transitioning from one typical sub-scene to another (for example, from day to dusk), the real-time attention mask may not be highly matched with any one reference template, or the matching degrees with two templates are similar. If one of them is forcibly selected as the baseline, a false high drift indicator will be generated due to incomplete matching. For this, the face liveness detection system can adopt a probabilistic baseline fusion strategy. Specifically, after calculating the matching degrees of the real-time mask with all reference templates, the system does not only select the highest score, but converts all matching degree scores into a probability distribution through a Softmax function. For example, the probability of the current scene belonging to the day template is 0.6, and the probability of belonging to the night template is 0.4. At this time, the system does not select any template, but dynamically synthesizes a new adaptive baseline mask according to this probability distribution, and the calculation method is as follows: fusion baseline = 0.6*day template + 0.4*night template. This fused baseline perfectly represents the attention pattern of the current dusk transition state. Using this dynamically synthesized baseline for drift detection can greatly improve the stability and accuracy of the system during the smooth transition of the scene.

[0129] In some embodiments, the face liveness detection system will use a multiple inference verification strategy to handle samples with high uncertainty when making the final liveness decision. That is, when the liveness confidence is in the uncertainty interval, the face liveness detection system will re-input the face image to the liveness detection model for multiple forward propagation calculations to obtain multiple re-classification results. The consistency index of the multiple re-classification results is calculated, and the liveness detection result is determined according to the consistency index.

[0130] wherein the sample with high uncertainty refers to the input image that the model is difficult to clearly distinguish as a real person or a fake body, and its characteristic is that the confidence score output by the model is close to the decision boundary (for example, 0.5); the multiple inference verification strategy is a method for enhancing the reliability of decision by performing multiple independent model inferences on the same sample; the uncertainty interval is a pre-defined confidence score range, for example, [0.4, 0.6], and the sample falling into this interval will trigger the strategy; the re-classification result refers to the classification score obtained by each independent forward propagation calculation in the multiple inference process; and the consistency index is a statistical quantity, such as variance, standard deviation or information entropy, which is used to quantify the consistency or dispersion degree between multiple re-classification results.

[0131] Specifically, the strategy is triggered in the final decision link of the single liveness detection process, and it plays a role of expert consultation for handling difficult samples. After the face image of the user is captured and the first forward propagation of the liveness detection model is performed, the face liveness detection system obtains an initial liveness confidence. The system immediately checks whether the confidence falls into the pre-defined uncertainty interval. If the confidence is 0.9 (clearly a real person) or 0.1 (clearly a fake body), the result is directly output. But if the confidence is 0.52, falling into the interval [0.4, 0.6], the system will pause the decision and start multiple inferences. An effective implementation is to use Monte Carlo Dropout: the system keeps the Dropout layer in the model active during inference (usually it is turned off during inference), and then repeatedly inputs the same face image into the model for, for example, 20 times of forward propagation. Due to the randomness of Dropout, each propagation calculation path is slightly different, resulting in 20 re-classification results that are not exactly the same. Subsequently, the face liveness detection system calculates the consistency index of the 20 results, for example, their variance. If the variance is very small, it means that although the model is uncertain in the first judgment, the conclusion is highly consistent after multiple thinking, and the system can adopt the average value of the 20 results as the final and more reliable judgment. On the contrary, if the variance is large, it means that the model's judgment is very unstable and extremely sensitive to slight perturbations of the input, which itself is a strong signal of high uncertainty, and the system can output that it cannot be determined and request the user to perform interactive verification (such as making specified actions).

[0132] In some embodiments, this multiple inference process can be implemented in various ways to adapt to different hardware and performance requirements: optionally, a strategy of Test-Time Augmentation (TTA) is adopted. The specific steps are as follows: first, when an uncertain sample is detected, the face liveness detection system does not repeat the input of the original image, but performs a series of slight, semantically invariant transformations on the original image to generate a set of images, for example, containing slight rotation, cropping, scaling and horizontal flip; second, the system inputs each of the augmented images in the set into the model once (Dropout can be turned off at this time) to obtain a set of reclassification results; finally, the final decision is made by calculating the mean and variance of the set of results. This method simulates observing the same face from different angles, which helps the model overcome excessive sensitivity to specific poses or perspectives. Optionally, a strategy of quantized model ensemble is adopted. The specific steps are as follows: first, the face liveness detection system does not only deploy one model of FP32 precision when deployed, but also deploys multiple versions of the same model quantized to different precisions (such as INT8, INT4); second, when an uncertain sample is encountered, the system inputs the sample into all models of different precisions for inference; finally, since quantization introduces slight calculation differences, the outputs of different precision models will form a set of reclassification results, and the system can make a judgment based on the consistency of the set of results. This method is particularly efficient on hardware that supports mixed precision calculation. It can be understood that a combination of multiple methods can also be used, for example, MCDropout inference is performed on each image generated by TTA to obtain more rich uncertainty information, which is not limited here.

[0133] In the implementation of this step, the problem of delay penalty needs to be solved. Although the multiple reasoning strategy can improve the reliability of decision-making, the cost is to significantly increase the calculation time and response delay when dealing with uncertain samples. For scenarios that pursue extreme user experience (such as millisecond-level unlocking), such delay may be unacceptable. In this regard, the face liveness detection system can implement an optimization scheme of progressive reasoning and early exit. Specifically, the system does not perform all (for example, 20 times) reasoning at once, but adopts a step-by-step approach. The system first performs a small number (for example, 5 times) of reasoning, and then immediately calculates the consistency index. The system will preset several consistency thresholds: if the variance after 5 times of reasoning is already very low or very high, it means that the conclusion is already very clear, and there is no need for further verification, the system can exit the loop early and make a decision immediately. Only when the consistency index itself is also in an ambiguous middle range, the system will continue to perform the next batch (for example, another 5 times) of reasoning and evaluate again. This process can be repeated until the maximum number of reasoning is reached or the consistency index falls into a decidable interval. In this way, most uncertain samples can be solved in fewer reasoning times, and only the most difficult samples will bear the maximum delay penalty, thereby achieving a dynamic balance between reliability and response speed.

[0134] In the embodiments of the present application, since the scene feature decoupling and data screening based on large model self-supervised learning are adopted, combined with the closed-loop technical scheme of scene-aware knowledge distillation and dynamic adaptive update, a highly optimized lightweight liveness detection model can be customized for specific edge devices and deployment scenarios from massive mixed data with coarse labels, effectively solving the contradiction between model generalization ability and scene specificity, low data utilization efficiency and performance degradation after deployment in traditional methods, and further realizing high-precision, high-robustness and continuously adaptive liveness detection capability on resource-constrained edge devices, which has both innovation and great practical application value.

[0135] Next, the face liveness detection system in the embodiments of the present application is described from the perspective of hardware processing. Please refer to Figure 4 , which is a schematic diagram of an entity device structure of the face liveness detection system in the embodiments of the present application.

[0136] It should be noted that Figure 4 The structure of the face liveness detection system shown is only an example and should not impose any limitation on the functions and use range of the embodiments of the present application.

[0137] As ​As shown, the face living body detection system includes a CPU 401 which can perform various appropriate actions and processes in accordance with a program stored in a ROM 402 or a program loaded into a RAM 403 from the storage section 408, for example, the method described in the above-described embodiments. In the RAM 403, various programs and data required for the operation of the system are also stored. The CPU 401, the ROM 402, and the RAM 403 are connected to each other through a bus 404. An I / O interface 405 is also connected to the bus 404.

[0138] Connected to the I / O interface 405 are an input section 406 including an audio input device, a push button switch, and the like; an output section 407 including a Liquid Crystal Display (LCD), an audio output device, an indicator, and the like; a storage section 408 including a hard disk and the like; and a communication section 409 including a network interface card such as a LAN (Local Area Network) card, a modem, and the like. The communication section 409 performs communication processing via a network such as the Internet. A drive 410 is also connected to the I / O interface 405 as necessary. A removable medium 411 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, and the like is mounted on the drive 410 as necessary so that a computer program read therefrom is installed in the storage section 408 as necessary.

[0139] In particular, in accordance with embodiments of the present application, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, embodiments of the present application include a computer program product comprising a computer program carried on a computer readable medium, the computer program containing computer programs for executing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network by the communication section 409 and / or from the removable medium 411. When the computer program is executed by the CPU 401, various functions defined in the present application are performed.

Claims

1. A face liveness detection method based on scene optimization, characterized in that, The method, applied to a face liveness detection system, includes: Extract hybrid image samples from the hybrid training dataset of the base model, and apply a physical-driven transformation to the hybrid image samples to obtain enhanced image samples; The scene contrast loss is calculated by using enhanced image samples from the same image sample as positive sample pairs and enhanced image samples from different image samples as negative sample pairs. The liveness classification loss of the mixed image samples and the scene contrast loss are combined to form a total loss function, which is used to train the base model and obtain the teacher model. The scene samples from the predefined target scene sample set are input into the scene branch of the teacher model, and the features of the scene samples are extracted and aggregated to obtain the scene target vector; Each mixed image sample in the mixed training dataset is input into the scene branch of the teacher model one by one, and multiple scene feature vectors are extracted to form a scene vector set; Calculate the vector similarity between the scene target vector and each vector in the scene vector set, and select the corresponding image samples from the mixed training dataset based on the vector similarity to obtain a scene matching data subset; Using the teacher model as supervision, knowledge distillation is performed on the scene matching data subset, and the distillation loss is modulated with the attention mask output by the scene branch of the teacher model to generate a liveness detection model. The face image to be detected is input into the liveness detection model for forward propagation calculation to obtain the classification result representing the liveness confidence.

2. The method according to claim 1, characterized in that, The step of training the base model to obtain the teacher model by using the liveness classification loss of the mixed image samples and the scene contrast loss as the total loss function specifically includes: The basic model is decomposed into a shared encoder, a scene branch, and a liveness branch; The hybrid image samples are input into the shared encoder to obtain shared feature representations; The shared feature representation is input into the scene branch, and the scene loss component is determined by combining the scene contrast loss. The shared feature representation is input into the liveness branch, and the liveness loss component is determined by combining the liveness classification loss of the mixed image samples; The correlation between the scene loss component and the liveness loss component is calculated to obtain the decoupled regularization component; The total loss function is determined based on the scene loss component, the liveness loss component, and the decoupling regularization component to adjust the model parameters of the base model, thereby obtaining the teacher model.

3. The method according to claim 1, characterized in that, The step of performing knowledge distillation on the scene matching data subset using the teacher model as supervision, and modulating the distillation loss with the attention mask output by the scene branch of the teacher model to generate a liveness detection model, specifically includes: The predefined target scene sample set is input into the scene branch of the teacher model to obtain the baseline attention mask; The samples from the scene matching data subset are input into the scene branch of the teacher model to obtain the real-time attention mask; The real-time attention mask and the baseline attention mask are fused to obtain a modulation mask; The modulation mask is applied to the calculation of distillation loss to obtain the modulated distillation loss, and knowledge distillation is performed based on the modulated distillation loss to generate a liveness detection model.

4. The method according to claim 3, characterized in that, After the steps of applying the modulation mask to the calculation of distillation loss to obtain the modulated distillation loss, and performing knowledge distillation based on the modulated distillation loss to generate a liveness detection model, the method further includes: Calculate the distribution difference measure between the baseline attention mask and the real-time attention mask to obtain the scene drift index; When the scene drift index exceeds a preset drift threshold, key scene feature components are extracted based on the preset high activation region in the modulation mask. The key scene feature components and the pre-stored target scene feature template are used to calculate similarity, and a scene consistency assessment report is generated. Based on the degree of deviation in the scene consistency assessment report, adjust the weight parameters of the scene-related layer in the liveness detection model.

5. The method according to claim 4, characterized in that, Before the step of calculating the distribution difference measure between the baseline attention mask and the real-time attention mask to obtain the scene drift index, the method further includes: Cluster analysis is performed on the target scene sample set to obtain multiple typical scene subcategories, and a corresponding reference attention mask template is constructed for each typical scene subcategory. Calculate the matching degree between the attention mask corresponding to each sample in the scene matching data subset and each of the reference attention mask templates to determine the best matching scene category; Based on the best matching scenario category and the matching degree, the scenario matching data subset is divided into multiple scenario subsets; The mean of the attention mask for each scene subset is calculated and used as the adaptive baseline mask for the best matching scene category, in place of the baseline attention mask for scene drift detection.

6. The method according to claim 1, characterized in that, Before the steps of extracting hybrid image samples from the hybrid training dataset of the base model and applying a physical-driven transformation to the hybrid image samples to obtain enhanced image samples, the method further includes: Feature extraction is performed on the predefined target scene sample set to obtain scene environment parameters, and a generative network is constructed based on the scene environment parameters; The preset attack image is input into the generation network for transformation processing to obtain a synthetic attack sample, and the synthetic attack sample is added to the hybrid training dataset.

7. The method according to claim 1, characterized in that, After the step of inputting the face image to be detected into the liveness detection model for forward propagation calculation to obtain the classification result representing the liveness confidence, the method further includes: When the liveness confidence is within the uncertainty range, the face image to be detected is re-inputted into the liveness detection model to perform multiple forward propagation calculations to obtain multiple reclassification results; Calculate the consistency index of the multiple reclassification results, and determine the liveness detection result based on the consistency index.

8. A face liveness detection system, characterized in that, The face liveness detection system includes: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to cause the face liveness detection system to perform the method as described in any one of claims 1-7.

9. A computer-readable storage medium comprising instructions, characterized in that, When the instructions are executed on the face liveness detection system, the face liveness detection system performs the method as described in any one of claims 1-7.

10. A computer program product, characterized in that, When the computer program product is run on the face liveness detection system, the face liveness detection system performs the method as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Living body face detection model training method and device, apparatus and storage medium

    CN113052144A

  • Living body detection method and system

    CN116189315A

  • Needs-matching navigator system

    US20170019496A1

  • Living-body detection method, device and storage medium

    US20190095701A1

  • Face Anti-spoofing recognition method and apparatus, and electronic device and storage medium

    WO2024198475A1

Cited By

  • Perpetual visual language navigation method and system based on prototype evolution

    CN122192335A