Face anti-spoofing detection method and system based on enhanced adapter fine tuning

By integrating the ViT target detection network model of EAS-Adapter and combining multi-branch feature extraction and attention mechanisms, the problems of insufficient generalization ability and single feature fusion of face recognition systems in cross-domain scenarios are solved, and high-precision and low-overhead cross-domain face authenticity recognition is achieved.

CN121768086APending Publication Date: 2026-03-31HANGZHOU DIANZI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-31
Publication Date
2026-03-31

AI Technical Summary

Technical Problem

Existing face recognition systems lack generalization ability in cross-domain scenarios, have a large number of model parameters, high training costs, and a single feature fusion method, making it difficult to capture fine-grained forged features such as texture, frequency, or edge anomalies.

Method used

We employ an enhanced adapter-based fine-tuning approach, integrating the ViT target detection network model with EAS-Adapter, and combining frequency domain analysis, edge detection, texture analysis, and cross-domain alignment branches to extract multi-dimensional deception cues. We also achieve information fusion through an attention mechanism.

Benefits of technology

It achieves high-precision face authenticity recognition in cross-domain scenarios, with low training overhead, strong generalization ability, and the ability to explicitly capture complementary deception cues, thereby improving the robustness and cross-domain adaptability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121768086A_ABST
    Figure CN121768086A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of artificial intelligence and computer vision, and particularly relates to a face anti-cheating detection method and system based on enhanced adapter fine tuning, and the method comprises the following steps: collecting a face image data set, carrying out the data preprocessing, and dividing the obtained data set into a source domain and a target domain; respectively training and verifying the ViT target detection network model of the integrated enhanced anti-spoofing adapter EAS-Adapter by using the source domain and the target domain to obtain a face anti-spoofing detection model; wherein the ViT target detection network model is that an EAS-Adapter is integrated on each Transform coding layer of a Transform coder in the ViT network, and the EAS-Adapter is integrated on each Transform coding layer of the Transform coder in the ViT network; and performing data preprocessing on a to-be-detected face image, and inputting the to-be-detected face image into the face anti-deception detection model to obtain a face authenticity identification result. According to the invention, each Transform encoding layer of the Transform encoder is integrated with the EAS-Adapter to capture complementary deception clues, and high-precision face authenticity identification in a cross-domain scene is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of artificial intelligence and computer vision technology, specifically relating to a face anti-spoofing detection method and system based on enhanced adapter fine-tuning, used to achieve high-precision face authenticity recognition in cross-domain scenarios. Background Technology

[0002] With the widespread application of facial recognition systems in fields such as financial payments, access control security, and identity authentication, their security issues have received increasing attention. Deception attacks targeting facial recognition systems are constantly emerging, commonly including printed photo attacks, video replay attacks, 3D mask attacks, and deepfake attacks. These attacks can cause the system to mistakenly identify forged faces as real faces, thus posing security risks.

[0003] Traditional face deception prevention methods are mostly based on manual feature extraction, such as Local Binary Pattern Reduction (LBP) and Histogram of Oriented Gradients (HOG). However, these methods struggle to cope with variations in lighting, device differences, and scene complexity. In recent years, deep learning methods have been widely adopted in this field, and face deception prevention models based on convolutional neural networks or Vision Transformers have achieved significant improvements in feature representation capabilities. However, existing models still have shortcomings in the following aspects: (1) The model has a large number of parameters and high training cost; (2) The model has insufficient generalization ability in cross-domain scenarios; (3) The feature fusion method is simple and it is difficult to capture fine-grained forgery features, such as texture, frequency or edge anomalies.

[0004] Therefore, there is an urgent need in this field to develop a lightweight, highly robust face anti-spoofing detection scheme with cross-domain generalization capabilities. Summary of the Invention

[0005] Based on the aforementioned shortcomings and deficiencies in the prior art, one of the objectives of this invention is to at least solve one or more of the aforementioned problems in the prior art. In other words, one of the objectives of this invention is to provide a cross-domain face anti-spoofing detection method and system based on enhanced adapter fine-tuning that meets one or more of the aforementioned requirements.

[0006] To achieve the above-mentioned objectives, the present invention adopts the following technical solution: A face anti-spoofing detection method based on enhanced adapter fine-tuning includes the following steps: S1. Collect a dataset of face images and perform data preprocessing. The resulting dataset is divided into a source domain and a target domain. S2. The ViT target detection network model integrating the enhanced anti-spoofing adapter EAS-Adapter is trained and validated using the source domain and target domain respectively to obtain the face anti-spoofing detection model. The ViT object detection network model integrates EAS-Adapter for each Transformer coding layer of the Transformer encoder in the ViT network. S3. After preprocessing the face image to be detected, input it into the face anti-spoofing detection model to obtain the face authenticity recognition result.

[0007] As a preferred embodiment, the data preprocessing includes face detection, alignment, cropping, and normalization of the face image.

[0008] As a preferred embodiment, step S2 includes the following steps: S21. Divide the face image in the source domain into blocks to obtain non-overlapping image blocks and flatten them to obtain image block vectors; S22. Input the image patch vector into the embedded encoder, convert it into a token sequence, then concatenate the category token at the beginning of the token sequence and add it to the position code to obtain the input of the Transformer encoder. S23. The token sequence output by the embedded encoder is input to a Transformer encoder consisting of L cascaded Transformer coding layers. The token sequence is processed by each Transformer coding layer integrated with EAS-Adapter to obtain the enhanced token sequence. S24. The enhanced token sequence is input into the classification head MLP to output unnormalized scores corresponding to the real and fraud categories, respectively. Finally, the Sigmoid function is applied to obtain the final prediction output in probabilistic form.

[0009] As a preferred embodiment, in step S23, the processing procedure of each Transformer encoding layer integrating EAS-Adapter is the same; The processing of the l-th Transformer coding layer includes the following steps: S231, For the input sequence Perform layer normalization (LN), and the normalized sequence Y l-1 The input is processed by the Multi-Head Self-Attention (MHSA) module, and the output is... The output is the same as the input X. l-1 Perform residual connections and insert the anti-spoofing adapter EAS-Adapter in parallel to obtain the sum of the outputs. : ; S232, Output Layer normalization (LN) is performed again, and the normalized sequence is input into the feedforward network (FFN), outputting... and Perform residual connections and insert the anti-spoofing adapter EAS-Adapter in parallel to form the final output of layer l. : .

[0010] As a preferred embodiment, the processing procedure of the anti-spoofing adapter EAS-Adapter includes the following steps: (1) For Token sequences First, ignore the category token and proceed with the space token. By using a linear downprojection layer, its feature dimension is compressed from D to a lower dimension. ,get ; then, Remodeling into two-dimensional spatial features ,in, and For spatial dimensions; (2) Input the reconstructed two-dimensional spatial features into the frequency domain analysis branch, edge detection branch, texture analysis branch, and cross-domain alignment branch respectively to extract frequency domain features, edge features, texture features, and alignment features. ; (3) The two-dimensional spatial features, frequency domain features, edge features, and texture features are spliced ​​along the channel dimension to obtain the comprehensive features. Then, it is integrated through the bottleneck structure fusion module to output... Next, the input is fed into the attention module, which outputs the attention-weighted features. ; (4) Output via residual enhancement module ; (5) According to preset weights Weighted fusion is performed to obtain the final features. ; (6) Reshape the final features back into the Token sequence format. And by using a linear projection layer, its feature dimensions are reduced from... By restoring to the original dimension D, we obtain the enhanced spatial token sequence. They are then recombine with category tokens to form an enhanced token sequence.

[0011] As a preferred embodiment, the extraction process of the frequency domain analysis branch includes: The spatial features are transformed into the frequency domain using two-dimensional discrete cosine transform (DCT). Let the reshaped two-dimensional feature map be... The coefficients after its two-dimensional DCT transformation ; ; Where x(h,w) is the pixel value of the input image, h,w are the coordinates of the pixel in the spatial domain F'; k1, k2 are the coordinates of the frequency components in the frequency domain. k1 and k2 represent the frequency indices in the vertical and horizontal directions, respectively; X f (k1,k2) is the DCT coefficient matrix at frequency (k1,k2); The orthogonally normalized two-dimensional DCT is: ; Among them, the normalization factor Defined as: ; When k=k1, K=H'; when k=k2, K=W'; When the input is a multi-channel 2D feature map The channel dimension is converted to n through 1×1 convolution, batch normalization, and Gelu activation. Then, the two-dimensional DCT transformation is applied independently to each channel to convert it into frequency domain features. .

[0012] As a preferred embodiment, the process of extracting the edge detection branch includes: Edge features are extracted in parallel using four 3×3 grouped convolutions, three of which are initialized with classical operators and one is randomly initialized to learn a specific edge pattern: ; The input features F are processed separately, and the outputs are concatenated by channel. Finally, all branch outputs are concatenated by channel to obtain the edge features. .

[0013] As a preferred embodiment, the extraction process of the texture analysis branch includes: The input feature F is processed in parallel using a set of 3×3 dilated convolutions with dilation rates of 1, 2, and 4, and the outputs are concatenated by channel to obtain multi-scale texture features. .

[0014] As a preferred embodiment, the processing procedure for cross-domain alignment branches includes: Input features are processed by a network consisting of 1×1 convolutions, group normalization, Gelu activation, and 1×1 convolutional layers. The processed output features are the same as the input features. Perform residual connections to obtain alignment features. .

[0015] This invention also provides a face anti-spoofing detection system based on enhanced adapter fine-tuning, applying the face anti-spoofing detection method as described in any of the preceding solutions, wherein the face anti-spoofing detection system includes: The acquisition module is used to acquire face image datasets and face images to be detected; The preprocessing module is used to perform data preprocessing; The partitioning module is used to divide the dataset into a source domain and a target domain; The training module is used to train and validate the ViT target detection network model with integrated enhanced anti-spoofing adapter EAS-Adapter using the source domain and target domain respectively, so as to obtain the face anti-spoofing detection model. The detection module is used to preprocess the face image to be detected and then input it into the face anti-spoofing detection model to obtain the face authenticity recognition result.

[0016] Compared with the prior art, the beneficial effects of this invention are: The present invention relates to a cross-domain face anti-spoofing detection method and system based on enhanced adapter fine-tuning. Through multi-branch feature extraction design, it can explicitly capture complementary deception cues from multiple dimensions such as frequency domain, edge response and multi-scale texture, and achieve effective information fusion through attention mechanism. It has low training overhead and strong generalization ability, and can achieve high-precision face authenticity recognition in cross-domain scenarios. Attached Figure Description

[0017] Figure 1 This is a diagram illustrating the overall architecture of cross-domain face anti-spoofing detection based on enhanced adapter fine-tuning according to an embodiment of the present invention. Figure 2 This is a schematic diagram of the enhanced anti-spoofing adapter EAS-Adapter according to an embodiment of the present invention. Detailed Implementation

[0018] To more clearly illustrate the embodiments of the present invention, specific implementation methods will be described below with reference to the accompanying drawings. Obviously, the drawings described below are merely some embodiments of the present invention. For those skilled in the art, other drawings and other implementation methods can be obtained based on these drawings without any creative effort.

[0019] like Figure 1 and Figure 2 As shown in the figure, the cross-domain face anti-spoofing detection method based on enhanced adapter fine-tuning in this embodiment includes three main steps: data acquisition and preprocessing, training and verification, and testing. The specific details of each step are as follows: (1) Data acquisition and preprocessing; Video frames containing real faces and various spoofing attacks were collected from multiple publicly available face anti-spoofing datasets (such as CASIA-FASD (C), IDIAP REPLAY ATTACK (I), MSU MFSD (M), OULU-NPU (O)). Face detection and alignment were then performed using a face detection model, Multi-Task Convolutional Neural Network (MTCNN) or dlib tool to ensure that effective face regions were located and cropped. The frames were then uniformly scaled to a resolution of 224×224 pixels to adapt to the standardized input of the ViT backbone network.

[0020] The datasets are divided according to internationally accepted anti-spoofing assessment protocols, and different division strategies are adopted according to the assessment objectives: when conducting intra-domain assessments, the source domain and target domain are divided according to the official protocols of each dataset; when conducting cross-domain assessments, the datasets are divided according to different datasets, with some datasets set as the source domain and the rest set as the target domain.

[0021] Each training batch is constructed as follows: An equal number of real and deceptive samples are uniformly sampled from all source domains, and these samples from different source domains are then combined to form a single training batch. This allows the model to learn common features across domains with each parameter update.

[0022] (2) Training and verification; The overall architecture involved in this step is based on the ImageNet pre-trained backbone network ViT (Dosovitskiy, A., Beyer, L., Kolesnikov, A., Weissenborn, D., Zhai, X., Unterthiner, T., Dehghani, M., Minderer, M., Heigold, G., Gelly, S., et al.: An image is worth 16x16 words: Transformers for image recognition at scale. In: International Conference on Learning Representations (ICLR) (2021)) and integrates EAS-Adapter in the Transformer encoder. During the fine-tuning stage, the embedded encoder and the FFN and MHSA in the Transformer encoder are frozen, while the remaining modules can be trained. The pre-processed source domain image is fed into the network model for training until convergence, and the model's weights and face classification performance are obtained through target domain validation. The specific process of this step is as follows: 1) Image input and feature embedding; Preprocessed face images are batch-inputted with dimensions (B, 3, H, W), where B is the batch size, 3 represents the RGB channels of the image, and H and W are the height and width of the input image, respectively. First, the input image is segmented into a series of non-overlapping image patches of fixed size P×P. Each patch has dimensions (3, P, P), resulting in a total of N = (H / P)×(W / P) patches. Then, each (3, P, P) patch is flattened into a vector of length 3×P×P. Next, an embedding encoder maps each flattened patch vector to a high-dimensional embedding space. The embedding encoder projects each vector from length 3×P×P to dimension D. This step converts the entire input image into a token sequence, with an output dimension of (B, N, D). Simultaneously, a learnable class token is appended to the beginning of this token sequence, resulting in the final complete token sequence output by the embedding encoder. The dimensions are (B, N+1, D). This sequence, added to the positional encoding, will be used as the input to the subsequent Transformer encoder.

[0023] 2) ViT network forward propagation and EAS-Adapter injection; 2.1 Forward propagation in ViT networks; Embedded encoder output token sequence The input is fed into a ViT backbone network consisting of L cascaded Transformer coding layers. Each layer has the same structure, with the Lth layer being the first... For example, layers: First, for the input sequence Perform layer normalization. The normalized sequence. The data is fed into the Multi-Head Self-Attention (MHSA) module. Using a projection matrix, the D-dimensional features of each token are mapped to the query Q, key K, and value vector V. Assuming there are h attention heads, each head has a dimension of d = D / h. The projected dimensions of Q, K, and V are all (B, N+1, h, d). Then, the attention weights are obtained by calculating the dot product of Q and K, applying the Softmax function, and summing them with the value vector V. Each attention head is calculated independently, with an output dimension of (B, N+1, d). The outputs of all heads are concatenated along the last dimension to restore the D-dimensional data. This is the final output of the MHSA module. The output will be compared with the input. Perform residual connections; additionally, insert EAS-Adapter modules in parallel to obtain the sum of the outputs. : ; Then, output Layer normalization is performed again. The normalized sequence is then fed into a feedforward network (FFN) composed of an MLP. The output of the feedforward network... and Perform residual connections and insert them in parallel into the EAS-Adapter to form the final output of this Transformer coding layer. : ; All L Transformer encoding layers are processed according to the above process, and their input and output dimensions remain consistent throughout.

[0024] 2.2 EAS-Adapter; The EAS-Adapter is the core module of this invention, and its specific description is as follows: 2.2.1 Input projection and feature compression; For Token Sequence (Number of layers omitted), perform the following operations in sequence: First, ignore the category token and perform operations on the space token. It compresses its feature dimension from D to a lower dimension through a linear downprojection layer. ,get This operation significantly reduces subsequent computational overhead. Then, Remodeling into two-dimensional spatial features In order to perform spatial and frequency domain analysis, where and This refers to the spatial dimensions.

[0025] 2.2.2 Multi-branch feature extraction unit; Reshape the two-dimensional spatial features The input consists of four parallel branches that explicitly extract complementary deception clues; Frequency domain analysis branch: This branch uses the two-dimensional discrete cosine transform (DCT) to convert spatial features to the frequency domain. Assume a compressed and reconstructed two-dimensional feature map is given. (Considering a single channel here), its coefficients after two-dimensional DCT transformation Defined by the following formula: ; in, It is the input image pixel value ( It is a spatial domain (coordinates of the middle pixel) These are the coordinates of the frequency components in the frequency domain. , These represent frequency indices in the vertical and horizontal directions, respectively. At frequency The DCT coefficient matrix on the matrix. The orthogonally normalized two-dimensional DCT is: ; Among them, the normalization factor Defined as: ; when hour, ;when hour, ; Therefore, when the input is a multi-channel 2D feature map By using 1×1 convolution, batch normalization, and Gelu activation, the channel dimension is transformed to n. Then, the above two-dimensional DCT transformation is applied independently to each channel to convert it into a frequency domain representation. .

[0026] Learnable edge detection branch: This branch uses four 3×3 grouped convolutions in parallel to extract edge features, three of which are initialized with classical operators (Sobel-X for horizontal gradient detection, Sobel-Y for vertical gradient detection, and Laplacian for second-order gradient detection), and one is randomly initialized to learn specific edge patterns. ; Process input features separately The output (each edge feature has a channel dimension of ) will be displayed. / 4) Concatenate by channel: Finally, concatenate all branch outputs by channel to obtain the edge feature map. .

[0027] Multi-scale texture analysis branch: A set of 3×3 dilated convolutions with dilation rates of 1, 2, and 4 are used to process the input features in parallel. The output (the output channel dimension of dilated convolutions with dilation rates of 1 and 2) is... / 4, the output channel dimension of a dilated convolution with an inflation rate of 4 is / 2) By channel splicing, multi-scale texture features are obtained. .

[0028] 2.2.3 Feature Fusion and Attention Module; Original features and the extracted frequency domain features Edge features and texture features By stitching along the channel dimension, a comprehensive feature is obtained. This feature is integrated through a bottleneck-structured fusion module (1×1 convolution + batch normalization + Gelu activation + 1×1 convolution), outputting... Subsequently, Input to adaptive dual attention mechanism: A spatial weight map is generated through a 7×7 convolutional layer and a sigmoid function. Channel weight maps are generated using adaptive average pooling, 1×1 convolution, ReLU activation, 1×1 convolution, and the Sigmoid function. Finally, and and Element-wise multiplication yields the attention-weighted features. .

[0029] 2.2.4 Feature optimization and output projection; first, Through a residual enhancement module (3×3 convolution + batch normalization + Gelu activation + 1×1 convolution), the output is... .

[0030] Furthermore, a cross-domain alignment branch is introduced to reduce statistical differences between different domains. Specifically, the input features are processed by a network consisting of 1×1 convolutional layers, group normalization, Gelu activation, and 1×1 convolutional layers. The processed output and input Perform residual joins to obtain aligned features. Next, , , According to preset weights : : Weighted fusion is performed to obtain the final features. .

[0031] Finally, Reconstructing back to the token sequence format And by using a linear projection layer, its feature dimensions are changed from... By restoring to the original dimension D, we obtain the enhanced spatial token sequence. The output of this module is recombined with the category tokens to form a complete enhanced token sequence (B, N+1, D), which is then fed into subsequent layers of the ViT backbone network for further processing.

[0032] 3) Forward propagation after the Transformer encoder; After processing through all L Transformer encoding layers, the final Token sequence is obtained. Its dimensions remain (B, N+1, D); the final sequence Category Token It aggregates global contextual information as a representation of the entire image, and extracts it from the sequence using a formula: ; Extracted The data is fed into a trainable MLP classification head, which typically consists of one or more fully connected layers. After passing through the MLP, a two-dimensional vector is obtained, corresponding to the unnormalized scores of the "true" and "false" categories, respectively. To obtain the probabilistic prediction output, a sigmoid function is applied to obtain the final output. During the training phase, this output is compared with the true labels to calculate the classification loss. (Classification Loss) Cross-entropy loss sum domain invariant constraint loss The composition and calculation formula are as follows: ; Cross-entropy loss Defined by the formula: ; in, =B / 2 represents the sample size (the number of true deception sample pairs in each source domain). Indicates the number of source domains; Represents the i-th source domain. Let j represent the j-th real sample. This represents the j-th deception sample; Let represent the label value of the j-th real sample in source domain i. This represents the predicted value of the j-th real sample in source domain i; Let represent the label value of the j-th deception sample in source domain i. Let represent the predicted value of the j-th deception sample in source domain i.

[0033] Domain Invariant Constraint Loss Defined by the formula: ; in, Let i represent the i-th sample. Represents the real sample set, It is an indicator function that indicates when a sample belongs to the true sample set. The value is 1 if it is true, and 0 otherwise. It is a feature embedding extracted from the ViT network. For the output of the previous layer of the ViT MLP classifier (the overall dimensions are (B, N, D), when the first dimension is i and the second dimension is j), ... The dimension is (1, 1, D). The L1 norm is used to measure the sparsity and compactness of feature vectors. In implementation, a mask `dr_mask` is first generated based on the labels to indicate which samples belong to the true class. Then, for each sample, the L1 norm is calculated... The average value in the second dimension Then, calculate the L1 norm of this average. Finally, by multiplying the L1 norm by the mask and taking the mean over all samples, the final result is obtained. Loss value.

[0034] In the training and validation step, the model is trained until convergence, the classification metric is calculated and output, and the model is evaluated in the target domain.

[0035] (3) Testing; Used to load the trained model weights and perform feature extraction and authenticity determination on the input face image. In this step, to evaluate the effectiveness of the embodiments of the present invention, the methods of the present invention EAS-Adapter and CDCN++ (Z. Yu et al., “Searching central difference convolutional networks for face anti-spoofing,” in Proc. IEEE Conf. Comput. Vis. Pattern Recognit., 2020, pp.5294–5304.), EPCR (Z. Wang, Z. Yu, X. Wang, Y. Qin, J. Li, C. Zhao, X. Liu, and Z. Lei, “Consistency regularization for deep face anti-spoofing,” IEEE Transactions on Information Forensics and Security, vol. 18, pp. 1127–1140, 2023.), and TTN-S (Z. Wang, Q. Wang, W. Deng, and G. Guo, “Learning multi-granularity temporal characteristics for face anti-spoofing,” IEEE Trans. Inf. Forensics Security, vol. 17, are compared. Comparative experiments were conducted on the OULU-NPU dataset (within the domain) using the S-Adapter (Cai R, Yu Z, Kong C, et al. S-adapter: Generalizing vision transformer for face anti-spoofing with statistical tokens[J]. IEEE Transactions on InformationForensics and Security, 2024, 19: 8385-8397.). The experimental results show the Attack Classification Error Rate (APCER), which is the probability of identifying a deceptive sample as a real sample; the True Classification Error Rate (BPCER), which is the probability of identifying a real sample as a deceptive sample; and the Average Classification Error Rate (ACER), which is the average of APCER and BPCER.

[0036] Table 1 shows the intra-domain comparison experiments on four protocols of the OULU-NPU dataset. ; As shown in Table 1, the EAS-Adapter of the present invention achieved the best performance in ACER of all four protocols of OULU-NPU. In particular, in the more complex and challenging P3 and P4 protocols, its low error rate and low variance fully demonstrate the effectiveness and stability of the proposed method in the domain setting.

[0037] Furthermore, to verify the generalization ability of the EAS-Adapter used in this invention in unknown domains, a dataset was randomly selected as the target domain for testing, while the other three were used as source domains for training. Therefore, a total of four cross-domain benchmarks were obtained: O&C&I to M, O&M&I to C, O&C&M to I, and I&C&M to O. According to this agreement, the EAS-Adapter method of this invention is compared with several advanced methods, including the domain generalization method (SSAN-R (Z. Wang, Z. Wang, Z. Yu, W. Deng, J. Li, T. Gao, and Z. Wang, “Domain Generalization via ShuffledStyle Assembly for Face Anti-Spoofing,” in Proceedings of the IEEE / CVF Conference on Computer Vision and Pattern Recognition, pp. 4123–4133, 2022.), SA-FAS (Sun Y, Liu Y, Liu X, et al. Rethinking domain generalization for face anti-spoofing: Separability and alignment[C] / / Proceedings of the IEEE / CVF Conference on computer vision and pattern recognition. 2023: 24563-24574.)), and the adapter-based fine-tuning method (Ensemble Adapter (H.-P. Huang, D. Sun, Y. Liu, W.-S.). Chu, T. Xiao, J. Yuan, H. Adam, and M.-H. Yang, “Adaptive transformers for robustfew-shot cross-domain face anti-spoofing,” in Computer Vision–ECCV 2022: 17thEuropean Conference, Tel Aviv, Israel, October 23–27, 2022, Proceedings, PartXIII, pp. 37–54, Springer, 2022.(This refers to several research papers, including S-Adapter (Cai R, Yu Z, Kong C, et al. S-adapter: Generalizing vision transformer for face anti-spoofing with statistical tokens[J]. IEEE Transactions on Information Forensics and Security, 2024, 19: 8385-8397.)) and a generative diffusion model-based method (DiffFAS (Ge X, Liu X, Yu Z, et al. Difffas: face anti-spoofing via generative diffusion models[C] / / European Conference on Computer Vision. Cham: Springer Nature Switzerland, 2024: 144-161.)).

[0038] Table 2 Results of cross-domain comparison experiment ; As shown in Table 2, EAS-Adapter achieved state-of-the-art performance on most benchmarks, demonstrating significant improvements in HTER (half-total error rate) and AUC (area under the ROC curve). This indicates that the proposed method can effectively adjust the feature distribution of the pre-trained model, thereby improving generalization performance in unknown target domains. Notably, EAS-Adapter only slightly underperforms recent best methods in the "O&C&I to M" scenario, but significantly outperforms the comparison methods in the other three benchmarks, fully demonstrating its robustness and superiority in complex cross-domain scenarios.

[0039] Based on the above-mentioned cross-domain face anti-spoofing detection method based on enhanced adapter fine-tuning, this embodiment of the invention also provides a cross-domain face anti-spoofing detection system based on enhanced adapter fine-tuning, including the following functional modules: acquisition module, preprocessing module, segmentation module, training module and detection module; The aforementioned acquisition module is used to acquire face image datasets and face images to be detected; The aforementioned preprocessing module is used to perform data preprocessing; The aforementioned partitioning module is used to divide the dataset into a source domain and a target domain; The training module described above is used to train and validate the ViT target detection network model with integrated enhanced anti-spoofing adapter EAS-Adapter using the source domain and target domain respectively, so as to obtain a face anti-spoofing detection model; The above detection module is used to preprocess the face image to be detected and then input it into the face anti-spoofing detection model to obtain the face authenticity recognition result; The specific processing procedures of the above functional modules can be found in the detailed description of the cross-domain face anti-spoofing detection method, which will not be repeated here.

[0040] In summary, this invention proposes a cross-domain face anti-spoofing detection method and system based on enhanced adapter fine-tuning. Through a multi-branch feature extraction design, it can explicitly capture complementary spoofing cues from multiple dimensions, including frequency domain, edge response, and multi-scale texture, and achieve effective information fusion through an attention mechanism. Extensive experiments have verified the effectiveness of this method. Intra-domain tests show that the EAS-Adapter achieves optimal performance, demonstrating strong basic discrimination capabilities. In the more challenging cross-domain generalization evaluation, this method significantly outperforms several state-of-the-art methods in cross-domain scenarios, proving its excellent adaptability and generalization. This overcomes the shortcomings of previous face anti-spoofing methods, such as insufficient generalization ability in cross-domain scenarios and a single feature fusion method.

[0041] The above description is merely a detailed explanation of preferred embodiments and principles of the present invention. For those skilled in the art, there may be changes in specific implementation methods based on the ideas provided by the present invention, and these changes should also be considered within the scope of protection of the present invention.

Claims

1. A face anti-spoofing detection method based on enhanced adapter fine-tuning, characterized in that, Includes the following steps: S1. Collect a dataset of face images and perform data preprocessing. The resulting dataset is divided into a source domain and a target domain. S2. The ViT target detection network model integrating the enhanced anti-spoofing adapter EAS-Adapter is trained and validated using the source domain and target domain respectively to obtain the face anti-spoofing detection model. The ViT object detection network model integrates EAS-Adapter for each Transformer coding layer of the Transformer encoder in the ViT network. S3. After preprocessing the face image to be detected, input it into the face anti-spoofing detection model to obtain the face authenticity recognition result.

2. The face anti-spoofing detection method according to claim 1, characterized in that, The data preprocessing includes face detection, alignment, cropping, and normalization of the face images.

3. The face anti-spoofing detection method according to claim 1, characterized in that, In step S2, the training includes the following steps: S21. Divide the face image in the source domain into blocks to obtain non-overlapping image blocks and flatten them to obtain image block vectors; S22. Input the image patch vector into the embedded encoder, convert it into a token sequence, then concatenate the category token at the beginning of the token sequence and add it to the position code to obtain the input of the Transformer encoder. S23. The token sequence output by the embedded encoder is input to a Transformer encoder consisting of L cascaded Transformer coding layers. The token sequence is processed by each Transformer coding layer integrated with EAS-Adapter to obtain the enhanced token sequence. S24. The enhanced token sequence is input into the classification head MLP to output unnormalized scores corresponding to the real and fraud categories, respectively. Finally, the Sigmoid function is applied to obtain the final prediction output in probabilistic form.

4. The face anti-spoofing detection method according to claim 3, characterized in that, In step S23, the processing procedure of each Transformer encoding layer integrating EAS-Adapter is the same; The processing of the l-th Transformer coding layer includes the following steps: S231, For the input sequence Perform layer normalization (LN), and the normalized sequence Y l-1 The input is processed by the Multi-Head Self-Attention (MHSA) module, and the output is... The output is the same as the input X. l-1 Perform residual connections and insert the anti-spoofing adapter EAS-Adapter in parallel to obtain the sum of the outputs. : ; S232, Output Layer normalization (LN) is performed again, and the normalized sequence is input into the feedforward network (FFN), outputting... and Perform residual connections and insert the anti-spoofing adapter EAS-Adapter in parallel to form the final output of layer l. : 。 5. The face anti-spoofing detection method according to claim 4, characterized in that, The processing procedure of the anti-spoofing adapter EAS-Adapter includes the following steps: (1) For Token sequences First, ignore the category token and proceed with the space token. By using a linear downprojection layer, its feature dimension is compressed from D to a lower dimension. ,get ; then, Remodeling into two-dimensional spatial features ,in, and For spatial dimensions; (2) Input the reconstructed two-dimensional spatial features into the frequency domain analysis branch, edge detection branch, texture analysis branch, and cross-domain alignment branch respectively to extract frequency domain features, edge features, texture features, and alignment features. ; (3) The two-dimensional spatial features, frequency domain features, edge features, and texture features are spliced ​​along the channel dimension to obtain the comprehensive features. Then, it is integrated through the bottleneck structure fusion module to output... Next, the input is fed into the attention module, which outputs the attention-weighted features. ; (4) Output via residual enhancement module ; (5) According to preset weights Weighted fusion is performed to obtain the final features. ; (6) Reshape the final features back into the Token sequence format. And by using a linear projection layer, its feature dimensions are reduced from... By restoring to the original dimension D, we obtain the enhanced spatial token sequence. They are then recombine with category tokens to form an enhanced token sequence.

6. The face anti-spoofing detection method according to claim 5, characterized in that, The extraction process of the frequency domain analysis branch includes: The spatial features are transformed into the frequency domain using two-dimensional discrete cosine transform (DCT). Let the reshaped two-dimensional feature map be... The coefficients after its two-dimensional DCT transformation ; ; Where x(h,w) is the pixel value of the input image, h,w are the coordinates of the pixel in the spatial domain F'; k1, k2 are the coordinates of the frequency components in the frequency domain. k1 and k2 represent the frequency indices in the vertical and horizontal directions, respectively; X f (k1,k2) is the DCT coefficient matrix at frequency (k1,k2); The orthogonally normalized two-dimensional DCT is: ; Among them, the normalization factor Defined as: ; When k=k1, K=H'; when k=k2, K=W'; When the input is a multi-channel 2D feature map The channel dimension is converted to n through 1×1 convolution, batch normalization, and Gelu activation. Then, the two-dimensional DCT transformation is applied independently to each channel to convert it into frequency domain features. .

7. The face anti-spoofing detection method according to claim 5, characterized in that, The process of extracting the edge detection branches includes: Edge features are extracted in parallel using four 3×3 grouped convolutions, three of which are initialized with classical operators and one is randomly initialized to learn a specific edge pattern: ; The input features F are processed separately, and the outputs are concatenated by channel. Finally, all branch outputs are concatenated by channel to obtain the edge features. .

8. The face anti-spoofing detection method according to claim 5, characterized in that, The extraction process of the texture analysis branch includes: The input feature F is processed in parallel using a set of 3×3 dilated convolutions with dilation rates of 1, 2, and 4, and the outputs are concatenated by channel to obtain multi-scale texture features. .

9. The face anti-spoofing detection method according to claim 5, characterized in that, The process of processing the cross-domain alignment branches includes: Input features are processed by a network consisting of 1×1 convolutions, group normalization, Gelu activation, and 1×1 convolutional layers. The processed output features are the same as the input features. Perform residual connections to obtain alignment features. .

10. A face anti-spoofing detection system based on enhanced adapter fine-tuning, employing the face anti-spoofing detection method as described in any one of claims 1-9, characterized in that, The face deception detection system includes: The acquisition module is used to acquire face image datasets and face images to be detected; The preprocessing module is used to perform data preprocessing; The partitioning module is used to divide the dataset into a source domain and a target domain; The training module is used to train and validate the ViT target detection network model with integrated enhanced anti-spoofing adapter EAS-Adapter using the source domain and target domain respectively, so as to obtain the face anti-spoofing detection model. The detection module is used to preprocess the face image to be detected and then input it into the face anti-spoofing detection model to obtain the face authenticity recognition result.