Face living body detection method, device and equipment and storage medium
By generating and fusing deceptive cue images with the same size and resolution as the face image to be detected, and combining them with a liveness detection model that incorporates a pre-set generator and an auxiliary classifier, the problems of insufficient generalization ability and high deployment cost in existing technologies are solved, and efficient liveness detection is achieved on ordinary RGB camera devices.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HANGZHOU DAYUE ZHIQING TECHNOLOGY CO LTD
- Filing Date
- 2026-01-28
- Publication Date
- 2026-05-01
AI Technical Summary
Existing face liveness detection methods lack generalization ability when facing complex and ever-changing real-world attack scenarios, and have high deployment costs, making them difficult to apply effectively on mobile devices or low-cost terminal devices equipped with only ordinary RGB cameras.
A liveness detection model with a pre-defined generator and an auxiliary classifier is adopted. A deception cue image with the same size and resolution as the face image to be detected is generated and fused with the original image before being input into the auxiliary classifier for judgment. The encoder and decoder in the model are connected by skip connections and trained using L1 loss function, triplet loss function and cross-entropy loss function.
It improves the accuracy and efficiency of liveness detection, reduces costs, solves the problem of insufficient generalization ability across devices and scenarios, and enables effective application on ordinary RGB camera devices.
Smart Images

Figure CN121963323A_ABST
Abstract
Description
A method, apparatus, device and storage medium for face liveness detection Technical Field
[0001] This application relates to the field of liveness detection technology, and in particular to a method, apparatus, device and storage medium for human face liveness detection. Background Technology
[0002] Currently, facial recognition technology is widely used in fields such as identity verification and financial security. At the same time, various spoofing attacks are emerging, such as presentation attacks (PA), which typically use printed photos, digital image / video replay attacks, and 3D face masks for facial authentication. Therefore, liveness detection technology is needed to ensure the security of facial recognition systems.
[0003] Traditional liveness detection methods typically employ manually extracted features, such as LBP (Local Binary Patterns), HOG (Histogram of Oriented Gradients), and SIFT (Scale Invariant Feature Transform), to represent image texture. Alternatively, features are extracted from different color spaces (such as HSV (Hue Saturation Value) and YCbCr), and then binary classification is performed using traditional machine learning classifiers like SVM (Support Vector Machine) to resist certain fraudulent attacks. However, these handcrafted features are only effective for limited attack scenarios and lack robustness under varying lighting conditions and different attack vectors. Additionally, some liveness detection methods are applied to video scenes with temporal information, using motion cues (such as blinking and head movements) for liveness detection. However, the performance of these methods degrades significantly when facing video playback attacks.
[0004] At present, although deep learning-based face liveness detection methods have achieved significant results, in practical applications, especially when dealing with complex and ever-changing real attack scenarios, the following problems still exist: (1) Insufficient generalization ability for unknown deception attacks: Most current solutions model liveness detection as a binary classification problem in a closed world, aiming to learn decision boundaries for known attack types (such as specific printing paper, screen) that appear in the training set. However, in practical applications, deception attack methods are diverse (such as new material masks, high-fidelity video playback, etc.), forming an open set. When the model faces these attack types that have not been seen during training, the performance drops sharply due to the failure of decision boundaries, resulting in weak generalization ability and failing to meet the needs of high-security applications; (2) High deployment cost: In order to improve performance and robustness, current detection methods rely on additional supervision information (such as depth maps and infrared information that require expensive equipment to collect) or temporal information (multi-frame video). This greatly limits its application and deployment on mobile terminals or low-cost terminal devices equipped only with ordinary RGB (Red Green Blue) cameras, thereby increasing the overall detection cost and complexity. Summary of the Invention
[0005] In view of this, the purpose of this application is to provide a face liveness detection method, apparatus, device, and storage medium, which can save the cost of liveness detection and improve the accuracy and efficiency of liveness detection. The specific solution is as follows:
[0006] Firstly, this application discloses a face liveness detection method, including:
[0007] Obtain the current target face image to be detected;
[0008] The target face image is input into the trained face liveness detection model; wherein, the face liveness detection model is a model obtained by training an initial model containing a preset generator and an auxiliary classifier using a historical face image dataset; the preset generator is a generator for generating images containing deception cues, the preset generator contains an encoder and a decoder, and the encoder and the decoder are connected by a skip connection;
[0009] The preset generator generates a target image with the same size and resolution as the target face image, and then merges the target generated image with the target face image to obtain the current merged image;
[0010] The auxiliary classifier processes the current fused image to output a liveness detection result, indicating whether the face in the target face image is a live person.
[0011] Optionally, before acquiring the target face image to be detected, the method further includes:
[0012] Collect live sample images containing real human face images and attack sample images containing fake human face images to obtain a historical human face image dataset;
[0013] The historical face image dataset is input into a preset generator built based on an encoder and a decoder to generate historical generated images that are consistent with the size and resolution of different sample images in the historical face image dataset; the encoder adopts a convolutional neural network.
[0014] The historical generated image is fused with the corresponding sample image by means of residual connection to obtain the historical fused image. The historical fused image is then input into the auxiliary classifier to train the auxiliary classifier and the preset generator, thereby obtaining the face liveness detection model containing the trained auxiliary classifier and the preset generator.
[0015] Optionally, generating historical images that are identical in size and resolution to different sample images in the historical face image dataset includes:
[0016] The encoder in the preset generator extracts visual features at different levels from different sample images in the historical face image dataset to obtain historical visual feature maps corresponding to each level.
[0017] The historical visual feature maps corresponding to each level are input into the corresponding upsampling blocks in the decoder to perform upsampling operations on each historical visual feature map, generating historical generated images that are consistent with the size and resolution of different sample images.
[0018] Optionally, the face liveness detection method further includes:
[0019] The loss values for the preset generator are calculated using the L1 loss function and the triplet loss function, respectively, to obtain the regression loss value and the metric loss value.
[0020] The regression loss value and the measurement loss value are superimposed according to preset weights to obtain the total loss value of the preset generator;
[0021] The historical fused image and the corresponding sample image are superimposed to obtain the superimposed image. The superimposed image is then input into an auxiliary classifier to calculate the loss value of the auxiliary classifier using the cross-entropy loss function, thereby obtaining the cross-entropy loss value.
[0022] Based on the total loss value and the cross-entropy loss value, the parameters of the preset generator and the auxiliary classifier are optimized and adjusted through backpropagation.
[0023] The L1 loss function is used to regress the historical generated images of each live sample image to an all-zero image.
[0024] The triplet loss function is used to increase the distance between the first set of all live sample images and the second set of all attack sample images.
[0025] Optionally, the mathematical expression of the L1 loss function is:
[0026] ;
[0027] In the formula, The loss value of the L1 loss function. Live sample images from the historical face image dataset Quantity, Images of live samples The corresponding historical generated images; the objective of the L1 loss function is to make all live sample images The historical generated images regress to the all-zero graph.
[0028] Optionally, the mathematical expression for the triplet loss function is:
[0029] ;
[0030] In the formula, Let be the loss value of the triplet loss function, d be the Euclidean distance between the two L2-normalized feature vectors, and T be the set of feature vectors of all the live sample images. This represents the feature vector of the i-th live sample image. This represents the feature vector of another live sample image besides the i-th live sample image. represents the feature vector of the i-th attack sample image; m is a parameter used to control the distance between the live sample image and the attack sample image.
[0031] Optionally, generating a target image with the same size and resolution as the target face image using the preset generator includes:
[0032] The encoder in the preset generator extracts visual features at different levels from the target face image to obtain the current visual feature map corresponding to each level.
[0033] The current visual feature map corresponding to each level is input into the corresponding upsampling block in the decoder to perform upsampling operation on each current visual feature map, thereby generating a target generated image that is consistent with the target face image in terms of size and resolution.
[0034] Accordingly, fusing the generated target image with the target face image to obtain the current fused image includes:
[0035] The target generated image and the target face image are added pixel by pixel using a residual connection method to obtain the current fused image.
[0036] Secondly, this application discloses a face liveness detection device, comprising:
[0037] The image acquisition module is used to acquire the target face image to be detected.
[0038] An input module is used to input the target face image into a trained face liveness detection model; wherein, the face liveness detection model is a model obtained by training an initial model containing a preset generator and an auxiliary classifier using a historical face image dataset; the preset generator is a generator used to generate images containing deception clues, the preset generator contains an encoder and a decoder, and the encoder and the decoder are connected by a skip connection;
[0039] The generation module is used to generate a target image with the same size and resolution as the target face image through the preset generator;
[0040] The fusion module is used to fuse the target generated image with the target face image to obtain the current fused image;
[0041] The liveness detection module is used to process the current fused image through the auxiliary classifier to output a liveness detection result as to whether the face in the target face image is a live person.
[0042] Thirdly, this application discloses an electronic device, including a processor and a memory; wherein, when the processor executes a computer program stored in the memory, it implements the aforementioned face liveness detection method.
[0043] Fourthly, this application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned face liveness detection method.
[0044] As can be seen, this application first acquires the target face image to be detected, and then inputs the target face image into a trained face liveness detection model. The face liveness detection model is a model obtained by training an initial model containing a preset generator and an auxiliary classifier using a historical face image dataset. The preset generator is a generator used to generate images containing deception cues, and it includes an encoder and a decoder, with the encoder and decoder connected via a skip connection. Next, a target generated image with the same size and resolution as the target face image is generated by the preset generator, and the target generated image is fused with the target face image to obtain a current fused image. Finally, the auxiliary classifier processes the current fused image to output a liveness detection result indicating whether the face in the target face image is alive.
[0045] This application pre-creates a face liveness detection model that includes a preset generator and an auxiliary classifier. The preset generator contains an encoder and a decoder connected by skip connections. The preset generator can generate a generated image with deceptive cues that has the same size and resolution as the face image to be detected. Then, the generated image is fused with the face image to be detected, and the fused image is input into the auxiliary classifier to obtain the liveness detection result of the face image to be detected. It can be seen that this application does not rely on additional information for liveness detection, thereby saving the cost of liveness detection. In addition, the skip connection method can improve the accuracy and efficiency of liveness detection. Furthermore, it solves the problem of insufficient generalization ability of traditional liveness detection methods under cross-device, cross-scene and unknown attack conditions. Attached Figure Description
[0046] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0047] Figure 1 is a flowchart of a face liveness detection method disclosed in this application;
[0048] Figure 2 is a schematic diagram of a specific preset generator structure disclosed in this application;
[0049] Figure 3 is a schematic diagram of a specific face liveness detection process disclosed in this application;
[0050] Figure 4 is a schematic diagram of the structure of a face liveness detection device disclosed in this application;
[0051] Figure 5 is a structural diagram of an electronic device disclosed in this application. Detailed Implementation
[0052] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0053] This application discloses a face liveness detection method, as shown in Figure 1. The method includes:
[0054] Step S11: Obtain the target face image to be detected.
[0055] It should be noted that the face liveness detection solution proposed in this application can be applied to scenarios such as mobile phone face unlocking, access control and attendance, remote identity authentication, and financial transaction risk control. In these scenarios, face liveness detection devices usually only have ordinary RGB cameras, and the types of attacks they face are complex and unpredictable.
[0056] In this embodiment, no additional timing information or sensor data is required. It is only necessary to acquire the target face image to be detected, such as the single-frame RGB face image of the current user captured in real time by the terminal camera (such as a mobile phone camera) in a face unlock scenario. Since the liveness detection is performed on the facial region of the face, face recognition is required after the image is acquired. Only when a face is recognized and the facial region is complete is it used as the target face image to be detected.
[0057] Step S12: Input the target face image into the trained face liveness detection model; wherein, the face liveness detection model is a model obtained by training an initial model containing a preset generator and an auxiliary classifier using a historical face image dataset; the preset generator is a generator used to generate images containing deception clues, the preset generator contains an encoder and a decoder, and the encoder and the decoder are connected by a skip connection.
[0058] In this embodiment, after obtaining the target face image to be detected, image preprocessing and feature extraction operations can be performed on it. For example, alignment, cropping, background removal, and feature mapping operations can be performed on the target face image. Then, the processed face image is input into the face liveness detection model obtained by training an initial model containing a preset generator and an auxiliary classifier using a historical face image dataset. The preset generator contains an encoder and a decoder using a U-Net structure, and the encoder and decoder are connected by skip connections. Furthermore, the preset generator and the auxiliary classifier adopt a residual learning framework.
[0059] In this embodiment, before performing real-time face liveness detection, a face liveness detection model needs to be created. The specific training process includes: acquiring liveness sample images containing real face images and attack sample images containing forged face images to obtain a historical face image dataset; inputting the historical face image dataset into a preset generator built based on an encoder and decoder to generate historical generated images with the same size and resolution as different sample images in the historical face image dataset; the encoder uses a convolutional neural network; the historical generated images are fused with the corresponding sample images through residual connections to obtain a historical fused image, and the historical fused image is input into an auxiliary classifier to train the auxiliary classifier and the preset generator to obtain the face liveness detection model containing the trained auxiliary classifier and the preset generator. In this embodiment, facial images containing real human faces are first acquired to obtain liveness sample images, and images containing fake faces generated through different deception methods are acquired to obtain attack sample images. Then, the acquired liveness sample images and attack sample images are labeled to construct a training dataset containing liveness sample images and attack sample images, namely, a historical face image dataset. The different deception methods include, but are not limited to, printed photo attacks, screen video replay attacks, and deepfake generation methods. Next, as shown in Figure 2, the acquired historical face image dataset is input into a preset generator built based on an encoder and decoder. The encoder and decoder adopt a U-Net structure with skip connections. The encoder can use a convolutional neural network (such as ResNet-18) pre-trained on a large-scale natural image dataset (such as the ImageNet dataset) to extract visual features in the image, and at the same time improve the face liveness detection model's ability to model basic visual features. A pre-defined generator can generate images with the same size and resolution as different sample images in a historical face image dataset, resulting in historical generated images. Further, these historical generated images are superimposed pixel-by-pixel with the corresponding sample images using residual connections (which directly add input to the output to solve the vanishing gradient problem and improve model training stability), resulting in a fused historical image. This fused historical image is then input into auxiliary classifiers (which can alleviate the vanishing gradient problem in deep networks and promote training convergence), thereby training both the auxiliary classifiers and the pre-defined generator to obtain a model for real-time face liveness detection / recognition, i.e., a face liveness detection model. It should be noted that the entire network of the face liveness detection model is differentiable and can be trained end-to-end.
[0060] In this embodiment, generating a historical image with the same size and resolution as different sample images in the historical face image dataset specifically includes: extracting visual features at different levels from different sample images in the historical face image dataset using an encoder in a preset generator to obtain historical visual feature maps corresponding to each level; inputting the historical visual feature maps corresponding to each level into the corresponding upsampling blocks in the decoder to perform upsampling operations on each historical visual feature map, thereby generating a historical image with the same size and resolution as different sample images. It should be noted that the goal of the preset generator is to learn a discriminative generated image that can generalize to unknown attacks, used to generate a deceptive image from the input face image with the same size and resolution as the original image. This image represents the location and intensity of potential attack traces in the input face image. In this embodiment, the encoder in the preset generator first extracts visual features at different levels (such as low-level, mid-level, and high-level visual features) from different sample images within the historical face image dataset, obtaining historical visual feature maps corresponding to each level. Low-level visual features include, but are not limited to, skin texture distribution, pixel-level noise patterns, and edge and contour information. Mid-level visual features include, but are not limited to, local region consistency, reflection distribution differences, and printing or screen imaging artifacts. High-level visual features include, but are not limited to, overall facial structure consistency and semantic statistical differences between real skin and non-biological materials. These features can be progressively extracted at different depth stages of the encoder. Referring to Figure 2, the encoder contains five downsampling stages (E1 to E5). As the depth increases, the receptive field gradually expands, thereby capturing the global semantic information of the input face image. Further, the historical visual feature maps corresponding to each level are input to the corresponding upsampling blocks in the decoder, thereby progressively restoring the multi-level visual features extracted by the encoder to the same spatial size and resolution as the input face image, generating a pixel-level generated image. Specifically, the historical visual feature maps corresponding to each level can be input into different upsampling blocks (D1 to D4) in the decoder. Nearest neighbor interpolation is used to upsample each historical visual feature map, doubling its resolution and restoring spatial resolution. Then, after passing through a convolutional layer, the generated image with deceptive cues is concatenated with the corresponding scale feature map in the encoder via skip connections. This fuses low-level detail information with high-level semantic information, ultimately outputting an image with the same size and resolution as the input sample image. The multi-scale skip connection method shown in Figure 2 allows detailed information (such as texture and edges) from the encoder to be passed to the decoder, which is crucial for generating pixel-level accurate images.Alternatively, the historical generated image output by the decoder can be passed through a Tanh activation function (i.e., hyperbolic tangent activation function) to normalize the pixel value of each pixel in the generated image to the same range as the input sample image.
[0061] It should be noted that the training process for the face liveness detection model specifically includes: calculating the loss value for the preset generator using the L1 loss function and the triplet loss function respectively, to obtain the regression loss value and the metric loss value; superimposing the regression loss value and the metric loss value according to preset weights to obtain the total loss value of the preset generator; superimposing the historical fused image and the corresponding sample image to obtain the superimposed image, and inputting the superimposed image into the auxiliary classifier to calculate the loss value of the auxiliary classifier using the cross-entropy loss function, to obtain the cross-entropy loss value; and optimizing and adjusting the parameters of the preset generator and the auxiliary classifier based on the total loss value and the cross-entropy loss value through backpropagation. In this embodiment, the training of the preset generator is supervised by two different loss functions (an explicit supervision based on regression and an implicit supervision based on metric learning), which can collaboratively optimize model parameters at different levels. The explicit supervision based on regression directly affects the output of the preset generator (i.e., the generated image), providing a clear zero-value target for live sample images. The implicit supervision based on metric learning, on the other hand, acts on the intermediate multi-layer features of the preset generator, structuring the feature space through comparisons of relationships between samples. Through this loss design, different structures of the encoder and decoder are affected; the former ensures the consistency of the live output, while the latter enhances the discriminative power of the features. Specifically, the loss values for the preset generator can be calculated using the L1 loss function (mean absolute error, MAE) and the triplet loss function (a loss function used in metric learning to optimize feature space distance) to obtain the regression loss value and the metric loss value. The L1 loss function is used to regress the historical generated images corresponding to each live sample image to the all-zero image. It can be understood that deception clues only exist in the attack sample images, so the live sample images should not contain any deception clues. To this end, this application applies asymmetric supervision to the live sample images and the attack sample images. Specifically, only a pixel-level regression loss (i.e., the L1 loss function) is applied to the live sample images. In order to further improve the discriminative power of the features, a multi-scale triplet loss is introduced on the multi-layer features of the generator (e.g., from the E5 layer of the encoder to the D4 layer of the decoder). The triplet loss function is used to increase the distance between the first set composed of all live sample images and the second set composed of all attack sample images.Furthermore, the historical fused image and the corresponding sample image are superimposed pixel by pixel using residual connections, and the superimposed image is input into the auxiliary classifier. The cross-entropy loss function is then used to calculate the binary classification loss value of the auxiliary classifier, thus obtaining the cross-entropy loss value. It should be noted that the auxiliary classifier, as a powerful supervisory signal, amplifies those deceptive cues that are crucial for classification while suppressing irrelevant noise, making the finally learned generated image cleaner. This is easier and more effective than directly learning the mapping from image to label. Finally, the two loss values (i.e., the total loss value and the cross-entropy loss value) are combined, and the classification error is backpropagated through gradient backpropagation. At the same time, the parameters of the preset generator and auxiliary classifier in the model are updated, thus obtaining a more accurate trained liveness detection model.
[0062] For live sample images, the final loss value (loss1) is: loss1 = cross-entropy loss + regression loss + metric loss; for attack sample images, the final loss value (loss2) is: loss2 = cross-entropy loss + metric loss. In summary, the L1 loss function compresses live sample images to zero at the output level, while the triplet loss function widens the distance between live sample image clusters and attack sample image clusters at the feature level, thus jointly shaping an optimized feature space that achieves cohesion between live samples and separation between live and attack samples.
[0063] This application, based on anomaly detection theory, introduces a pre-defined generator and an auxiliary classifier. By generating images of the same size and resolution as the input images, a strong regression constraint is applied to live sample images, causing the generated images to converge to zero. Attack sample images are unconstrained, thus guiding the network to learn deceptive features with generalizability. Simultaneously, a multi-scale loss metric is applied to the feature space, making the features of live sample images more compact and increasing the distance between them and attack sample images, thereby improving the model's ability to discriminate against unknown attacks. Finally, the generated images with deceptive cues are fused with the original sample images via skip connections and then input into the classifier for final judgment. This achieves liveness detection / recognition across devices and scenarios, significantly improving the accuracy of recognition / detection.
[0064] Specifically, the auxiliary classifier can be a lightweight convolutional neural network (containing multiple convolutional layers, followed by fully connected layers). Its parameter update process is integrated into the end-to-end training process. The specific steps are as follows: The auxiliary classifier adds the generated image with deceptive cues to the corresponding sample image to obtain the superimposed image, and adds deceptive "residuals" or "noise" to the basis of the sample image. This allows the gradient to not only update the parameters of the auxiliary classifier itself during backpropagation, but also backtrack along the residual path to the preset generator, thereby updating the parameters of the preset generator.
[0065] In one specific implementation, the auxiliary classifier may include: an input layer for receiving a superimposed image generated by pixel-by-pixel addition of the input sample image and the generated image (via residual connections); a feature extraction convolutional stack containing 2 to 4 convolutional modules for extracting discriminative features from the superimposed image; a global feature pooling layer for compressing the 3D feature map output by the last convolutional layer into a 1D feature vector using global average pooling after the convolutional stack; and an output layer (a fully connected layer of two neurons using the Softmax activation function) for outputting a liveness detection result with a binary probability distribution.
[0066] In this embodiment, only a pixel-level regression loss is applied to the live sample image. Specifically, the generated image with deceptive cues is compared with the all-zero image, and the bias is calculated using the L1 loss function. The mathematical expression for the corresponding L1 loss function is as follows:
[0067] ;
[0068] In the formula, The loss value of the L1 loss function. Live sample images from the historical face image dataset Quantity, Images of live samples The corresponding historical generated images; the objective of the L1 loss function is to make all live sample images The historical generated images are regressed to an all-zero map, where the all-zero map is the compact center of the live sample image in the feature space.
[0069] In this embodiment, the feature vector of the live sample image can be used as an anchor. In the feature space, the distance between the anchor and another live sample image (i.e., a positive sample) should be minimized, while the distance between the anchor and the attack sample image (i.e., a negative sample) should be increased. Specifically, multi-layer visual feature maps can be extracted from the encoder's E5 layer (i.e., the highest-scale layer) and the decoder's D1, D2, D3, and D4 layers, and spatial global average pooling can be performed to obtain feature vectors. Then, for each live sample image (anchor), another live sample image from the same batch is randomly selected as a positive sample, and an attack sample image is selected as a negative sample to construct a triplet. The sum of the triplet losses for the multi-layer features is then calculated. The mathematical expression for the corresponding triplet loss function is:
[0070] ;
[0071] In the formula, Let d be the loss value of the triplet loss function, d be the Euclidean distance between two feature vectors after two L2 normalizations (the core goal of which is to eliminate the dimensional differences between features by adjusting the scale of the vectors, while preserving the core distribution characteristics of the data), and T be the set of feature vectors of all the live sample images (i.e., the set of feature layers extracted from the network for calculating the loss metric), for example, {T1, T2, T3, T4}. Let represent the feature vector of the i-th live sample image (i.e., the positive sample). This represents the feature vector of another live sample image besides the i-th live sample image. Represents the feature vector of the i-th attack sample image (i.e., negative sample); m (Margin) is a preset constant greater than 0 used to control the distance between the live sample image and the attack sample image (e.g., to control the minimum distance between the positive sample and the negative sample to be greater than m).
[0072] Step S13: Generate a target generated image with the same size and resolution as the target face image using the preset generator, and fuse the target generated image with the target face image to obtain the current fused image.
[0073] In this embodiment, when the face liveness detection model receives the target face image to be detected, it first generates an image with the same size and resolution as the target face image through an internal preset generator to obtain a target generated image. Then, the generated target image is merged / overlaid with the target face image to obtain the current fused image.
[0074] In this embodiment, generating a target image with the same size and resolution as the target face image through the preset generator specifically includes: extracting visual features at different levels in the target face image using the encoder in the preset generator to obtain current visual feature maps corresponding to each level; inputting the current visual feature maps corresponding to each level into the corresponding upsampling blocks in the decoder to perform upsampling operations on each current visual feature map, thereby generating a target image with the same size and resolution as the target face image. In this embodiment, referring to Figure 3, the encoder in the preset generator first extracts visual features at different levels in the currently input face image I to be detected, obtaining current visual feature maps corresponding to each level. Then, the current visual feature maps corresponding to each level are input into the corresponding upsampling blocks in the decoder through skip connections, thereby performing upsampling operations on each current visual feature map, generating a generated image C with the same size and resolution as the currently input face image.
[0075] In one specific implementation, fusing the generated target image with the target face image to obtain the current fused image may specifically include: adding the generated target image and the target face image pixel by pixel using a residual connection method to obtain the current fused image. In this embodiment, referring to Figure 3, the generated image C and the face image I can be added pixel by pixel using a residual connection method to obtain the fused image S. Finally, the fused image S can be input to an auxiliary classifier for binary classification to obtain a detection result indicating whether the subject is alive.
[0076] Step S14: Process the current fused image using the auxiliary classifier to output a liveness detection result indicating whether the face in the target face image is a live body.
[0077] In this embodiment, the current fused image is input into the auxiliary classifier in the model so that the auxiliary classifier can perform binary classification prediction / determination of the face in the target face image and output the liveness detection result of whether it is a live body, thereby completing the real-time liveness detection of a single frame RGB image.
[0078] As can be seen, this application embodiment pre-creates a face liveness detection model that includes a preset generator and an auxiliary classifier. The preset generator contains an encoder and a decoder connected by skip connections. The preset generator can generate a generated image with deceptive cues that has the same size and resolution as the face image to be detected. Then, the generated image is fused with the face image to be detected, and the fused image is input into the auxiliary classifier to obtain the liveness detection result of the image to be detected. It can be seen that this application does not rely on additional information for liveness detection, thereby saving the cost of liveness detection. In addition, the skip connection method can improve the accuracy and efficiency of liveness detection. Furthermore, it solves the problem of insufficient generalization ability of traditional liveness detection methods under cross-device, cross-scene, and unknown attack conditions.
[0079] Accordingly, this application also discloses a face liveness detection device, as shown in Figure 4, which includes:
[0080] Image acquisition module 11 is used to acquire the target face image to be detected;
[0081] Input module 12 is used to input the target face image into the trained face liveness detection model; wherein, the face liveness detection model is a model obtained by training an initial model containing a preset generator and an auxiliary classifier using a historical face image dataset; the preset generator is a generator used to generate images containing deception clues, the preset generator contains an encoder and a decoder, and the encoder and the decoder are connected by a skip connection;
[0082] The generation module 13 is used to generate a target generated image that has the same size and resolution as the target face image through the preset generator;
[0083] The fusion module 14 is used to fuse the target generated image with the target face image to obtain the current fused image;
[0084] The liveness detection module 15 is used to process the current fused image through the auxiliary classifier to output a liveness detection result of whether the face in the target face image is a live body.
[0085] The specific workflow of each of the above modules can be found in the relevant content disclosed in the foregoing embodiments, and will not be repeated here.
[0086] Furthermore, this application also discloses an electronic device. FIG5 is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the figure should not be considered as any limitation on the scope of use of this application.
[0087] Figure 5 is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the face liveness detection method disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0088] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0089] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0090] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the face liveness detection method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include a computer program capable of performing other specific tasks.
[0091] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned disclosed face liveness detection method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0092] Furthermore, embodiments of this application also disclose a computer program product, including a computer program / instructions, which, when executed by a processor, implement the steps of the aforementioned face liveness detection method.
[0093] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0094] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0095] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0096] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0097] The foregoing has provided a detailed description of a face liveness detection method, apparatus, device, and storage medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and its core ideas. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for detecting human face liveness, characterized in that, include: The process involves: acquiring the target face image to be detected; inputting the target face image into a trained face liveness detection model; wherein the face liveness detection model is a model obtained by training an initial model containing a preset generator and an auxiliary classifier using a historical face image dataset; the preset generator is a generator used to generate images containing deception cues, the preset generator containing an encoder and a decoder, and the encoder and the decoder being connected via skip connections; generating a target image with the same size and resolution as the target face image using the preset generator, and fusing the target generated image with the target face image to obtain the current fused image; The auxiliary classifier processes the current fused image to output a liveness detection result, indicating whether the face in the target face image is a live person.
2. The face liveness detection method according to claim 1, characterized in that, Before acquiring the target face image to be detected, the method further includes: acquiring live sample images containing real face images and attack sample images containing fake face images to obtain a historical face image dataset; inputting the historical face image dataset into a preset generator constructed based on an encoder and a decoder to generate historical generated images with the same size and resolution as different sample images in the historical face image dataset; the encoder adopts a convolutional neural network; the historical generated images are fused with the corresponding sample images through residual connections to obtain a historical fused image, and the historical fused image is input into an auxiliary classifier to train the auxiliary classifier and the preset generator to obtain the face liveness detection model containing the trained auxiliary classifier and the preset generator.
3. The face liveness detection method according to claim 2, characterized in that, The step of generating historical images that are consistent with the size and resolution of different sample images in the historical face image dataset includes: extracting visual features at different levels from different sample images in the historical face image dataset using an encoder in a preset generator to obtain historical visual feature maps corresponding to each level; and inputting the historical visual feature maps corresponding to each level into the corresponding upsampling blocks in the decoder to perform upsampling operations on each historical visual feature map to generate historical images that are consistent with the size and resolution of different sample images.
4. The face liveness detection method according to claim 3, characterized in that, Also includes: The loss values for the preset generator are calculated using the L1 loss function and the triplet loss function, respectively, to obtain the regression loss value and the metric loss value. The regression loss value and the measurement loss value are superimposed according to preset weights to obtain the total loss value of the preset generator; The historical fused image and the corresponding sample image are superimposed to obtain the superimposed image. The superimposed image is then input into an auxiliary classifier to calculate the loss value of the auxiliary classifier using the cross-entropy loss function, thus obtaining the cross-entropy loss value. Based on the total loss value and the cross-entropy loss value, the parameters of the preset generator and the auxiliary classifier are optimized and adjusted through backpropagation. The L1 loss function is used to regress the historical generated images of each live sample image to an all-zero image. The triplet loss function is used to increase the distance between the first set composed of all live sample images and the second set composed of all attack sample images.
5. The face liveness detection method according to claim 4, characterized in that, The mathematical expression for the L1 loss function is: In the formula, The loss value of the L1 loss function. Live sample images from the historical face image dataset Quantity, Images of live samples The corresponding historical generated images; the objective of the L1 loss function is to make all live sample images The historical generated images regress to an all-zero graph.
6. The face liveness detection method according to claim 4, characterized in that, The mathematical expression for the triplet loss function is: In the formula, Let be the loss value of the triplet loss function, d be the Euclidean distance between the two L2-normalized feature vectors, and T be the set of feature vectors of all the live sample images. This represents the feature vector of the i-th live sample image. This represents the feature vector of another live sample image besides the i-th live sample image. represents the feature vector of the i-th attack sample image; m is a parameter used to control the distance between the live sample image and the attack sample image.
7. The face liveness detection method according to any one of claims 1 to 6, characterized in that, The step of generating a target image with the same size and resolution as the target face image through the preset generator includes: extracting visual features at different levels in the target face image through the encoder in the preset generator to obtain current visual feature maps corresponding to each level; inputting the current visual feature maps corresponding to each level into the corresponding upsampling blocks in the decoder to perform upsampling operations on each current visual feature map to generate a target image with the same size and resolution as the target face image; correspondingly, the step of fusing the target generated image with the target face image to obtain the current fused image includes: adding the target generated image and the target face image pixel by pixel through residual connection to obtain the current fused image.
8. A face liveness detection device, characterized in that, include: The system includes an image acquisition module for acquiring a target face image to be detected; an input module for inputting the target face image into a trained face liveness detection model; wherein the face liveness detection model is a model obtained by training an initial model containing a preset generator and an auxiliary classifier using a historical face image dataset; the preset generator is a generator for generating images containing deception cues, and the preset generator contains an encoder and a decoder, with the encoder and decoder connected via a skip connection; a generation module for generating a target image with the same size and resolution as the target face image using the preset generator; a fusion module for fusing the target generated image with the target face image to obtain a current fused image; and a liveness detection module for processing the current fused image using the auxiliary classifier to output a liveness detection result indicating whether the face in the target face image is live.
9. An electronic device, characterized in that, It includes a processor and a memory; wherein, when the processor executes a computer program stored in the memory, it implements the face liveness detection method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, Used to store a computer program; wherein, when the computer program is executed by a processor, it implements the face liveness detection method as described in any one of claims 1 to 7.