Cross-scene adaptation method and device for liveness detection model

By integrating the basic model with plugin modules, the problem of insufficient cross-scene adaptability of the liveness detection model is solved, enabling rapid adaptation and deployment in new scenarios and reducing computational resource consumption.

CN117115886BActive Publication Date: 2026-08-04ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
Filing Date
2023-08-18
Publication Date
2026-08-04

AI Technical Summary

Technical Problem

Existing liveness detection models experience performance degradation when applied across different scenarios, resulting in insufficient cross-scenario adaptability.

Method used

By training a base model and multiple plugin modules, and using adaptive plugin modules to select and fuse with the base model, cross-scene adaptation can be achieved.

Benefits of technology

It enables rapid adaptation and deployment of liveness detection models in new scenarios, reduces computational resource consumption, is suitable for lightweight devices, and does not require the re-collection and labeling of large amounts of data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117115886B_ABST
    Figure CN117115886B_ABST
Patent Text Reader

Abstract

The present specification relates to the technical field of face recognition, and provides a cross-scene adaptation method and device of a living body detection model, which comprises inputting face data in a target scene into a pre-trained base model to obtain living body detection features, inputting the living body detection features into a plurality of plug-in modules pre-trained to obtain plug-in features of each plug-in module, selecting a target plug-in module according to the plug-in features of each plug-in module, and performing fusion processing on the base model based on the target plug-in module to obtain a living body detection model. In the present specification, different scene plug-in modules and base models pre-trained are used, and the target plug-in module is adaptively selected based on a new scene and fused with the base model for processing, so that the living body detection model is quickly adapted and deployed across scenes, without the need to construct and train a plurality of living body detection models for different scenes, greatly reducing the consumption of computing resources, and enabling quick adaptation and deployment on lightweight devices.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to one or more embodiments in the field of face recognition technology, and in particular to a method and apparatus for cross-scene adaptation of a liveness detection model. Background Technology

[0002] Facial recognition technology has brought numerous conveniences to people's lives and work, and is widely used in payment systems, access control systems, attendance systems, and many other scenarios. Liveness detection is a crucial part of ensuring facial recognition security. With the development of machine learning technology, most liveness detection algorithms today are data-driven deep learning methods, which train liveness detection models to perform liveness detection on input facial images. However, existing liveness detection models lack cross-scenario adaptability, leading to significant performance degradation when applied across different scenarios. Summary of the Invention

[0003] To improve the cross-scene adaptation capability of the liveness detection model and enhance the liveness detection effect, this specification provides one or more embodiments of a liveness detection model cross-scene adaptation method and apparatus, a liveness detection method and apparatus, an electronic device, and a storage medium.

[0004] Firstly, one or more embodiments of this specification provide a method for cross-scene adaptation of a liveness detection model, including:

[0005] The face data of the target scene is input into the pre-trained base model to obtain the liveness detection features output by the base model;

[0006] The liveness detection features are input into multiple pre-trained plug-in modules to obtain the plug-in features output by each plug-in module; wherein, each plug-in module is trained based on sample data of a scene.

[0007] Based on the plugin features output by each plugin module, at least one target plugin module is selected from the plurality of plugin modules;

[0008] The target plugin module performs fusion processing on the base model to obtain the liveness detection model corresponding to the target scene.

[0009] In one or more embodiments of this specification, the step of fusing the base model based on the target plug-in module to obtain the liveness detection model corresponding to the target scene includes:

[0010] Based on the liveness detection features, the target fusion layer is determined from the multiple intermediate layers included in the base model;

[0011] The network parameters of the target fusion layer are fused based on the network parameters of the target plug-in module to obtain the liveness detection model.

[0012] In one or more embodiments of this specification, determining the target fusion layer from the multiple intermediate layers of the base model based on the liveness detection features includes:

[0013] The liveness detection features are input into a pre-trained layer selection module to obtain the target fusion layer output by the layer selection module.

[0014] In one or more embodiments of this specification, selecting at least one target plugin module from the plurality of plugin modules based on the plugin features output by each plugin module includes:

[0015] The plugin features output by each plugin module are input into a pre-trained adaptive plugin module to obtain the target plugin module output by the adaptive plugin module.

[0016] In one or more embodiments of this specification, the process of pre-training the base model includes:

[0017] Obtain a first training dataset, which includes sample data from multiple different scenarios;

[0018] The first training dataset is input into the initial model and the model to be pruned to obtain the first liveness detection feature and the first liveness detection result output by the initial model, and the second liveness detection feature and the second liveness detection result output by the model to be pruned.

[0019] Based on the first and second liveness detection features, and the difference between the first and second liveness detection results, the model to be pruned is pruned and trained until the model to be pruned meets the convergence condition, thus obtaining the base model.

[0020] In one or more embodiments of this specification, the process of pre-training the plug-in module includes:

[0021] Obtain a second training dataset, which includes sample data from one scene;

[0022] The second training dataset is input into the trained base model to obtain the liveness detection features output by the base model.

[0023] The liveness detection features output by the base model are input into the plug-in module to be trained to obtain the plug-in features output by the plug-in module.

[0024] The plug-in features are input into the trained base model to obtain the liveness detection results output by the base model.

[0025] Based on the loss corresponding to the liveness detection result, the parameters of the plug-in module are adjusted until the convergence condition is met, thus obtaining the trained plug-in module.

[0026] In one or more embodiments of this specification, the process of pre-training the adaptive plug-in module includes:

[0027] Obtain a third training dataset, which includes sample data of preset scenarios that are different from the scenarios corresponding to the plurality of plugin modules;

[0028] The third training dataset is input into the already trained base model to obtain the liveness detection features output by the base model.

[0029] The liveness detection features are input into multiple trained plug-in modules respectively to obtain the plug-in features output by each plug-in module;

[0030] The plugin features of each plugin module are input into the adaptive plugin module to be trained to obtain the first probability value corresponding to each plugin module;

[0031] The loss value is determined based on the preset constraints and the first probability value of each plug-in module, and the network parameters of the adaptive plug-in module are adjusted based on the loss value until the convergence condition is met, thus obtaining the trained adaptive plug-in module.

[0032] Secondly, one or more embodiments of this specification provide a method for detecting live organisms, including:

[0033] Acquire the face image to be detected captured in the target scene;

[0034] The face image to be detected is input into the liveness detection model to obtain the liveness detection result output by the liveness detection model, wherein the liveness detection model is obtained according to the method described in any embodiment of the first aspect.

[0035] Thirdly, one or more embodiments of this specification provide a cross-scene adaptation device for a liveness detection model, including:

[0036] The base model is configured to input face data from the target scene into a pre-trained base model to obtain liveness detection features output by the base model.

[0037] The multi-scene plugin module is configured to input the liveness detection features into multiple pre-trained plugin modules to obtain plugin features output by each plugin module; wherein each plugin module is trained based on sample data of a scene.

[0038] An adaptive plugin module is configured to select at least one target plugin module from the plurality of plugin modules based on the plugin features output by each plugin module.

[0039] The fusion processing module is configured to perform fusion processing on the base model based on the target plug-in module to obtain a liveness detection model corresponding to the target scene.

[0040] Fourthly, one or more embodiments of this specification provide a liveness detection device, comprising:

[0041] The image acquisition module is configured to acquire the face image to be detected in the target scene;

[0042] A liveness detection model is configured to input the face image to be detected into the liveness detection model and obtain the liveness detection result output by the liveness detection model, wherein the liveness detection model is obtained according to the method described in any embodiment of the first aspect.

[0043] Fifthly, one or more embodiments of this specification provide an electronic device, comprising:

[0044] processor; and

[0045] A memory storing computer instructions for causing the processor to perform the method described in any of the first or second aspects.

[0046] Sixthly, one or more embodiments of this specification provide a storage medium storing computer instructions for causing a computer to perform the method described in any embodiment of the first or second aspect.

[0047] The cross-scene adaptation method for the liveness detection model described in this specification includes inputting facial data from the target scene into a pre-trained base model to obtain liveness detection features; inputting the liveness detection features into multiple pre-trained plug-in modules to obtain plug-in features for each plug-in module; selecting a target plug-in module based on the plug-in features of each plug-in module; and fusing the base model based on the target plug-in module to obtain the liveness detection model. In this embodiment, by utilizing pre-trained plug-in modules and base models for different scenes, and adaptively selecting the target plug-in module to fuse with the base model based on a new scene, the liveness detection model can be rapidly adapted and deployed across scenes while maintaining model performance. This eliminates the need to build and train multiple liveness detection models for different scenes, significantly reducing the consumption of computing resources and enabling rapid adaptation and deployment on lightweight devices. Furthermore, it eliminates the need to re-collect large amounts of new scene data for manual annotation and network training, improving adaptation efficiency and enabling the model to handle various new scenes, making it suitable for large-scale deployment. Attached Figure Description

[0048] Figure 1 This is a structural block diagram of a cross-scene adaptation device for a liveness detection model provided in some embodiments of this specification.

[0049] Figure 2 This is a flowchart of a cross-scene adaptation method for a liveness detection model provided in some embodiments of this specification.

[0050] Figure 3 This is a flowchart of a cross-scene adaptation method for a liveness detection model provided in some embodiments of this specification.

[0051] Figure 4 This is a flowchart of a cross-scene adaptation method for a liveness detection model provided in some embodiments of this specification.

[0052] Figure 5 This is a schematic diagram of the cross-scene adaptation method of the liveness detection model provided in some embodiments of this specification.

[0053] Figure 6 This is a flowchart of a cross-scene adaptation method for a liveness detection model provided in some embodiments of this specification.

[0054] Figure 7 This is a schematic diagram of the cross-scene adaptation method of the liveness detection model provided in some embodiments of this specification.

[0055] Figure 8 This is a flowchart of a cross-scene adaptation method for a liveness detection model provided in some embodiments of this specification.

[0056] Figure 9 This is a flowchart of a live detection method provided in some embodiments of this specification.

[0057] Figure 10 This is a structural block diagram of a liveness detection device provided in some embodiments of this specification.

[0058] Figure 11 This is a structural block diagram of an electronic device provided in some embodiments of this specification. Detailed Implementation

[0059] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with one or more embodiments of this specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.

[0060] It should be noted that in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the method may include more or fewer steps than described in this specification. Furthermore, a single step described in this specification may be broken down into multiple steps in other embodiments; and multiple steps described in this specification may be combined into a single step in other embodiments.

[0061] Furthermore, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this manual are all information and data authorized by the user or fully authorized by all parties. The collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse.

[0062] Nowadays, facial recognition technology has provided many conveniences for people's production and life. It is widely used in many scenarios such as payment systems, access control systems, and attendance systems. However, at the same time, facial recognition technology also has its unique security risks, which limit its development. Among them, liveness attacks are the most common and also one of the most threatening security risks.

[0063] Liveness detection attacks refer to attacks where attackers use mobile phone photos, printed photos, or facial masks to replace real faces in attempts to bypass facial recognition systems. To detect liveness attacks, various liveness detection methods have been proposed. With the development of machine learning technology, most liveness detection algorithms are now data-driven deep learning methods. That is, by building and training a liveness detection model, the model outputs the image of the face to be recognized to determine whether it is an attack image or a genuine live image, thereby ensuring the security of the facial recognition system.

[0064] However, facial recognition systems have numerous application scenarios. When a liveness detection model trained on a dataset from a specific scenario is deployed to a new scenario, it often experiences a significant performance drop, resulting in insufficient cross-scenario adaptability of the liveness detection model.

[0065] In related technologies, to solve the problem of cross-scene adaptation of liveness detection models, the cross-scene adaptation methods mainly fall into the following two categories:

[0066] 1) Cross-scene adaptation method based on cloud-based multi-model fusion

[0067] This method allows for the training of numerous liveness detection models for different scenarios in the cloud. For example, N liveness detection models can be trained for N scenarios and then deployed on a cloud server. During application, the front end uploads the captured face images to the cloud, which are then input into the N different liveness detection models to obtain different liveness detection results. Finally, the final liveness detection result is obtained by fusing the N liveness detection results.

[0068] The advantage of this method is its good performance, but the disadvantages are that it requires training and deploying a large number of liveness detection models, which are difficult to maintain and consume huge amounts of computing resources. It can only be deployed on cloud servers and cannot be deployed on low-computing-power front-ends (such as mobile terminals), thus greatly limiting its application.

[0069] 2) Cross-scene adaptation method based on new scene data parameter tuning

[0070] This method allows for the collection of a large amount of data from new scenarios when deploying a liveness detection model across different scenarios, followed by retraining and re-deploying the original liveness detection model. However, this approach requires the collection and labeling of a large amount of new scenario data, resulting in a significant workload for data engineering, a long adaptation cycle, and the need for re-adaptation for each new scenario, making it unscalable.

[0071] As mentioned above, solving the performance and efficiency issues of cross-scene adaptation of liveness detection models is a key and challenging problem in the field of face recognition. Therefore, this specification provides one or more embodiments of a liveness detection model cross-scene adaptation method and apparatus, a liveness detection method and apparatus, an electronic device, and a storage medium, aiming to achieve rapid model adaptation and deployment while ensuring model performance when applying liveness detection models across different scenarios.

[0072] In some implementations, this specification provides a method for cross-scene adaptation of a liveness detection model, which can be applied to electronic devices.

[0073] Furthermore, the embodiments described in this specification do not require training and deploying multiple liveness detection models; only a lightweight base model and multiple plug-in modules need to be trained. Therefore, the consumption of computing resources is minimal, fully meeting the deployment requirements of lightweight devices such as mobile terminals and wearable devices. Thus, the electronic devices described in the embodiments of this specification can be any suitable type of device, such as mobile terminals, wearable devices, servers, or cloud platforms; this specification does not limit their application.

[0074] Figure 1 This document illustrates the architecture diagram of the cross-scene adaptation method for the liveness detection model in the embodiments described herein. (See also...) Figure 1 As shown, the cross-scene adaptation method of the liveness detection model in this specification mainly includes the following four parts:

[0075] 1) Basic Model

[0076] In the implementation of this specification, a base model needs to be trained first. The base model can be a liveness detection model with high generalization ability and lightweight. The base model will serve as the basic network architecture for cross-scene adaptation of the liveness detection model, and it can be trained using sample data from various scenarios.

[0077] 2) Multi-scene plugin module

[0078] In the embodiments described in this specification, it is also necessary to pre-build and train multiple plugin modules for different scenarios. Each scenario can correspond to one plugin module. For example, N plugin modules can be pre-built and trained for N scenarios.

[0079] Each plugin module can be a network structure consisting of one or more neural network layers. Plugin modules can be integrated into the intermediate layers of the base model, thereby achieving the integration of plugin modules and base model, enabling the base model to adapt to new scenarios.

[0080] 3) Adaptive Plug-in Module

[0081] In the embodiments described in this specification, the adaptive plugin module is used to automatically select one or more target plugin modules from N pre-trained plugin modules based on a small number of face images in new scenes. The target plugin module can be understood as a plugin module that is adapted to the new scene.

[0082] Adaptive plugin modules can be based on deep learning neural network modules, and can be obtained in advance through network training.

[0083] 4) Fusion Processing Module

[0084] In the embodiments described in this specification, the function of the fusion processing module is to fuse the target plugin module with the base model to obtain a new liveness detection model. It can be understood that since the target plugin module is suitable for the new scene, fusing the target plugin module with the base model results in a liveness detection model that is well-adapted to the new scene, ensuring the performance of the liveness detection model in the new scene.

[0085] As can be seen from the above, in the embodiments of this specification, when it is necessary to deploy a liveness detection model in a new scene, only a small amount of face data in the new scene needs to be collected. The adaptive plugin module is used to select one or more target plugin modules from the N pre-trained plugin modules, and the target plugin modules are fused with the pre-trained base model. This enables the rapid adaptation of the liveness detection model in the new scene without the need to collect a large amount of new scene data for manual annotation and network training. A liveness detection model that can be well adapted to the new scene can be obtained, thus completing the rapid adaptation and deployment of the liveness detection module across scenes.

[0086] Figure 2 The flowcharts of cross-scene adaptation methods for the liveness detection model in some embodiments of this specification are shown below. Figure 2 The methods described in this manual are explained.

[0087] like Figure 2 As shown, in some embodiments, the cross-scene adaptation method of the liveness detection model exemplified in this specification includes:

[0088] S210. Input the face data of the target scene into the pre-trained basic model to obtain the liveness detection features output by the basic model.

[0089] As can be seen from the foregoing, in the embodiments of this specification, a basic model needs to be pre-trained. The basic model refers to a liveness detection model with high generalization ability and lightweight. The basic model will serve as the basic network architecture for cross-scene adaptation of the liveness detection model.

[0090] In some implementations, a base model with high generalization ability can be obtained by training using sample data from multiple scenarios. Furthermore, to meet the requirement of lightweight deployment of the base model, a training process based on distillation and model pruning can be employed to obtain a lightweight base model. The training process of the base model will be described in the following implementation details and will not be elaborated upon here.

[0091] It's understandable that the trained base model is essentially a liveness detection model. The input is a face image, and the output is the liveness detection result corresponding to that face image. However, since this base model has high generalization ability for various scenarios, when it is deployed in a specific scenario, the accuracy of liveness detection for that scenario may not meet the requirements.

[0092] In the implementation method described in this specification, it is necessary to utilize the intermediate layer features of the base model to select a target plugin module that is adapted to the new scene from multiple pre-trained plugin modules, and then use the target plugin module to fuse the base model to obtain the final liveness detection model.

[0093] In the embodiments described in this specification, the target scenario is the new scenario in which the liveness detection model needs to be deployed. The target scenario can be any scenario suitable for implementation, such as payment scenario, access control scenario, attendance scenario, etc. This specification does not impose any restrictions on it.

[0094] In the embodiments described in this specification, when adapting the liveness detection model across scenarios, only a small amount of face data from the target scenario needs to be collected. For example, one or more face data from the target scenario can be collected. The face data is then input into a pre-trained base model. The base model extracts features from the face data through its internal convolutional layers to obtain intermediate features of the face data. These intermediate features are the liveness detection features described in this specification.

[0095] S220. Input the liveness detection features into multiple pre-trained plug-in modules to obtain the plug-in features output by each plug-in module.

[0096] As described above, in the embodiments of this specification, multiple plugin modules need to be pre-trained for different scenarios. For example, N plugin modules can be pre-trained for N scenarios. Each plugin module can consist of one or more convolutional layers. For example, in one example, each plugin module consists of two convolutional layers.

[0097] The process of training the plugin modules to obtain multiple plugin modules corresponding to different scenarios will be described in the following implementation method, and will not be detailed here.

[0098] The input to each plugin module is the liveness detection features output by the base model, and the output is the plugin features. Each plugin module is essentially a network layer that has learned the features of the corresponding scene. Therefore, after the liveness detection features pass through a plugin module, the resulting plugin features are those that incorporate the scene characteristics of that plugin module.

[0099] Based on this, the liveness detection features output by the base model can be input into each plugin module to obtain the plugin features output by each plugin module. The plugin features output by a plugin module are those that incorporate the characteristics of the corresponding scene.

[0100] S230. Based on the plugin characteristics output by each plugin module, select at least one target plugin module from multiple plugin modules.

[0101] As mentioned above, a target plugin module refers to a plugin module adapted to a target scene, and the plugin features of a plugin module refer to features that incorporate the characteristics of the corresponding scene. Therefore, in the embodiments of this specification, a target plugin module adapted to the target scene can be selected from multiple plugin modules based on the plugin features of each plugin module.

[0102] It should be noted that the target scenario is not necessarily a specific scenario corresponding to the multiple plug-in modules. It is understandable that the scenarios in which a face recognition system is deployed can vary greatly. Even for the same payment scenario, the accuracy of the liveness detection model may differ due to factors such as lighting conditions, camera angle, and indoor / outdoor location. Therefore, in the implementation method of this specification, the pre-trained N plug-in modules cannot cover all scenarios; only some representative scenarios can be selected.

[0103] For a new target scenario, which may be different from any of the N plugin modules, the key point of the implementation method of this specification is to select M target plugin modules from the N plugin modules, where N≥M≥1, and then use the fusion processing of these M target plugin modules with the basic model to obtain a liveness detection model adapted to the new scenario.

[0104] In other words, the implementation method in this specification is not limited to adapting to the N scenarios of the pre-trained plugin modules, but can utilize the selection and combination of the N pre-trained plugin modules to achieve adaptation to any new scenario.

[0105] Therefore, when training plugin modules for different scenarios, it is only necessary to select a small number of representative scenarios to train the plugin modules. The number of plugin modules does not need to be large. For example, in one example, the number of plugin modules pre-trained can be N=8. That is, when adapting to the target scenario, one or more of these 8 plugin modules can be selected as the target plugin modules, and the adaptation to the new scenario can be completed by using the combination of one or more target plugin modules.

[0106] In some embodiments of this specification, see Figure 1 As shown, adaptive plugin modules can be pre-trained and used to adaptively select target plugin modules. The implementation methods described below in this specification will illustrate this.

[0107] S240. Based on the target plugin module, the basic model is fused to obtain the liveness detection model corresponding to the target scene.

[0108] As mentioned above, the target plugin module refers to the plugin module that is adapted to the target scene. After determining the target plugin module, the target plugin module can be fused with the basic model. After the fusion process, a liveness detection model adapted to the target scene can be obtained.

[0109] It can be understood that each target plugin module is essentially one or more convolutional layers. When fusing the target plugin module with the base model, it is only necessary to superimpose the network parameters of the target plugin module with the network parameters of one or more intermediate layers of the base model to complete the fusion process. This is equivalent to fusing the scene features learned by the target plugin module into the base model, thereby obtaining a liveness detection model with target scene adaptation capabilities. The specific process of fusing the target plugin module with the base model is described in the implementation methods below, and will not be detailed here.

[0110] In the embodiments described in this specification, after obtaining the liveness detection model of the target scene, the liveness detection model can be deployed and applied in the target scene to achieve the liveness detection task of the target scene.

[0111] As described above, the embodiments in this specification utilize pre-trained plug-in modules and basic models for different scenarios. Based on new scenarios, the target plug-in module is adaptively selected and fused with the basic model. This ensures model performance while enabling rapid adaptation and deployment of the liveness detection model across scenarios. It eliminates the need to build and train multiple liveness detection models for different scenarios, significantly reducing computational resource consumption and enabling rapid adaptation and deployment on lightweight devices. Furthermore, it eliminates the need to re-collect large amounts of new scenario data for manual annotation and network training, improving adaptation efficiency and enabling it to handle various new scenarios, making it suitable for large-scale deployment.

[0112] In the implementation methods described below, the processes of basic model training, plugin module training, and adaptive plugin module training will be explained in stages.

[0113] 1. Construction and training of the basic model.

[0114] In some implementations, to achieve lightweight deployment of the base model, a training process based on distillation and model pruning can be used to obtain a lightweight base model.

[0115] The training process of a neural network model can be understood as the process of learning the weight matrix. The goal of model training is to make the model output as close as possible to the expected value. Therefore, by comparing the model's output value with the expected value, the weight vector of each layer of the neural network can be updated based on the difference between the two. Specifically, the difference between the output value and the expected value of the neural network model can be measured by a loss function or an objective function.

[0116] Distillation of neural network models is a method of model pruning and compression, analogous to the human learning process. In the distillation algorithm, the model that needs pruning is called the teacher model, and the pruned model is called the student model. Generally, the teacher model is much larger than the student model. During model training, the process of pruning the parameters of the teacher model through knowledge distillation is the pruning process. By continuously pruning, the model size can be continuously reduced to obtain the student model. Although the student model is much smaller than the teacher model, it can still learn the same knowledge, completing the knowledge transfer from the teacher model to the student model. Therefore, the student model still has good model accuracy.

[0117] In this embodiment, the base model is the pruned student model, and the teacher model before pruning is defined as the initial model. That is, in this embodiment, before training the base model, it is necessary to first construct and train the initial model. Since the initial model does not need to be deployed, a large-scale liveness detection model can be used. Those skilled in the art can understand this by referring to relevant technologies. The network structure and principle of the initial model will not be described in detail in this embodiment.

[0118] After obtaining the initial model, it can be understood that the base model is a lightweight model obtained by pruning the initial model. Therefore, at the beginning of training, the base model is consistent with the initial model. The following section will combine... Figure 3 The process of training to obtain the basic model is explained.

[0119] like Figure 3 As shown, in some embodiments, the process of pre-training the base model in the cross-scene adaptation method of the liveness detection model exemplified in this specification includes:

[0120] S310. Obtain the first training dataset.

[0121] In the embodiments described in this specification, considering the high generalization ability of the base model, the first training dataset for training the base model should preferably include sample data from multiple scenarios to expand the diversity of training samples, and both attack samples and live samples should be collected. The data for the first training dataset can be obtained through open-source data from the Internet.

[0122] S320. Input the first training dataset into the initial model and the model to be pruned to obtain the first liveness detection feature and the first liveness detection result output by the initial model, and the second liveness detection feature and the second liveness detection result output by the model to be pruned.

[0123] In the embodiments described in this specification, the model to be pruned is the model that needs to be pruned during the training process. At the beginning of training, the model to be pruned is consistent with the initial model.

[0124] During training, sample data from the first training dataset are input into both the initial model and the model to be pruned. The initial model can extract features from the input sample data to obtain the corresponding first liveness detection features, and predict the first liveness detection result based on these features. The first liveness detection features are the intermediate layer features obtained by the initial model, and the first liveness detection result is the liveness detection result predicted by the initial model.

[0125] Similarly, the model to be pruned can extract features from the input sample data to obtain the corresponding second liveness detection features, and predict and output the second liveness detection result based on the second liveness detection features. The second liveness detection features are the intermediate layer features obtained by the model to be pruned, and the second liveness detection result is the liveness detection result predicted by the model to be pruned.

[0126] S330. Based on the first liveness detection feature and the second liveness detection feature, as well as the difference between the first liveness detection result and the second liveness detection result, the model to be pruned is pruned and trained until the model to be pruned meets the convergence condition, and the basic model is obtained.

[0127] It is understandable that as the model to be pruned is continuously pruned and iterated, more and more parameters in the model to be pruned are removed, so the difference between the model to be pruned and the initial model becomes larger and larger. The goal of network training is to reduce the size of the model to be pruned while making the performance of the model to be pruned close to that of the initial model.

[0128] Therefore, the loss function for model training must at least include the liveness feature loss between the model to be pruned and the initial model, i.e., the difference between the first and second liveness detection features. This part of the loss ensures that the liveness features between the model to be pruned and the initial model remain as consistent as possible. It also needs to include the liveness detection loss between the model to be pruned and the initial model, i.e., the difference between the first and second liveness detection results. This part of the loss ensures that the liveness detection accuracy between the model to be pruned and the initial model remains as consistent as possible.

[0129] In some implementations, the loss function for model training may also include sparse loss, i.e., the L1 norm of the weights of the model to be pruned. This part of the loss ensures that as many network parameters as possible in the model to be pruned are set to zero. It may also include generalization loss, which ensures that the accuracy of the model to be pruned remains as consistent as possible across different scenarios.

[0130] Based on the above loss function, the pruning model is continuously pruned using backpropagation until it meets the convergence condition. The pruned model is the basic model described in this specification.

[0131] As can be seen from the above, in the embodiments of this specification, a training dataset is constructed using multi-scenario sample data, and a basic model is trained using distillation and pruning training methods. This results in a basic model with high generalization ability and lightweight design, providing a higher-performance basic model for cross-scenario adaptation and facilitating deployment on lightweight devices.

[0132] 2. Training of multi-scenario plugin modules.

[0133] In the embodiments described in this specification, multiple plug-in modules need to be trained for different scenarios. As mentioned above, a plug-in module can be a simple one-layer or multi-layer neural network layer. For example, a plug-in module can be composed of two convolutional layers.

[0134] In some implementations, the layer selection module is also trained simultaneously when training each plugin module. The role of the layer selection module is to select the intermediate layers from the base model that need to be fused with the plugin modules; these intermediate layers are also the target fusion layers described in this specification.

[0135] It is understandable that the network structure of the base model often includes multiple intermediate layers. Therefore, when fusing the target plugin module into the base model, it is necessary to fuse the target plugin module with a certain intermediate layer in the base model. The role of the layer selection module is to determine the target fusion layer in the base model that will be fused with the target plugin module. Therefore, the layer selection module can be trained simultaneously with the plugin module. The following section will combine... Figure 4 and Figure 5 The implementation method describes the training process of the plug-in module.

[0136] like Figure 4 As shown, in some embodiments, the cross-scene adaptation method of the liveness detection model exemplified in this specification, the process of training the plug-in module, includes:

[0137] S410. Obtain the second training dataset.

[0138] In the implementation of this specification, it is necessary to train plugin modules for multiple scenarios. For example, N scenarios correspond to N plugin modules. The training process for each plugin module is exactly the same. Therefore, the following description will only take the training process of one plugin module as an example.

[0139] When training a plugin module for a specific scenario, it is first necessary to obtain the training data for that scenario, i.e., the second training dataset. The second training dataset includes a large amount of face sample data for that scenario. In some implementations, the second training dataset can be obtained from open-source data on the Internet.

[0140] S420. Input the second training dataset into the trained base model to obtain the liveness detection features output by the base model.

[0141] As mentioned above, the input to the plug-in module is the intermediate layer features extracted by the base model, which is the liveness detection feature described in this specification, and the output is the plug-in feature. Therefore, the training of the plug-in module needs to be performed after the training of the base model; that is, the plug-in module is trained after the base model is trained first.

[0142] like Figure 5 As shown, during the training process, sample data from the second training dataset is input into the already trained base model. The base model performs feature extraction to obtain the liveness detection features corresponding to the sample data. Then, the liveness detection features are input into the plugin module to be trained to obtain the plugin features output by the plugin module. The plugin features are the liveness features after fusing the new scene features.

[0143] In some implementations, as described above, while training the plug-in module, it is also necessary to train the layer selection module. The input of the layer selection module is also the liveness detection features output by the base model, and its output is the probability that each network layer in the base model is selected as the target fusion layer, which is the layer selection probability described in this specification.

[0144] S430. Input the plugin features into the trained base model to obtain the liveness detection results output by the base model.

[0145] Combination Figure 5As shown, the plug-in features output by the plug-in module refer to the features after fusing new scene characteristics with the liveness detection features. These plug-in features need to be input into the base model again to obtain the final liveness detection results output by the base model.

[0146] S440. Based on the loss corresponding to the liveness detection results, adjust the parameters of the plug-in module until the convergence condition is met, and obtain the trained plug-in module.

[0147] In the implementation method described in this specification, the liveness detection result output by the basic model can be understood as the liveness detection result after the perturbation of the plug-in module is added. Based on the difference in the liveness detection result, the network parameters of the plug-in module itself can be optimized by backpropagation. This process is repeated until the convergence condition is met, the plug-in module is trained, and a plug-in module corresponding to a scene is obtained.

[0148] See Figure 5 As shown, in some implementations, the layer selection module needs to be trained simultaneously with the plugin module. That is, the loss function includes two parts: the loss corresponding to the liveness detection result and the loss corresponding to the layer selection probability. The constraint on the layer selection probability is that the number of target fusion layers selected by the base model should be as small as possible. Therefore, backpropagation is performed based on the above losses to adjust the parameters of both the plugin module and the layer selection module until the convergence condition is met, completing the training process for both modules.

[0149] The above example in this manual only describes the training process of the plugin module for one scenario. For plugin modules for other scenarios, you only need to repeat the above training process based on the sample data of that scenario to obtain plugin modules corresponding to multiple scenarios. This manual will not elaborate further.

[0150] 3. Adaptive Plugin Module

[0151] As mentioned above, the adaptive plugin module selects one or more target plugin modules from multiple plugin modules to adapt to the new scene. Therefore, when training the adaptive plugin module, only a small amount of sample data of the new scene is needed. The following section will combine... Figure 6 and Figure 7 Please provide an explanation.

[0152] like Figure 6 As shown, in some embodiments, the cross-scene adaptation method of the liveness detection model exemplified in this specification, the process of pre-training the adaptive plug-in module, includes:

[0153] S610. Obtain the third training dataset.

[0154] In the embodiments described in this specification, the third training dataset includes sample data of new scenes. A new scene refers to a preset scene that differs from the scenes corresponding to the aforementioned multiple plugin modules; that is, a scene outside the N scenes corresponding to the N plugin modules. In some embodiments, a small amount of sample data from new scenes can be collected as the third training dataset, such as a dozen or so sample images.

[0155] S620. Input the third training dataset into the trained base model to obtain the liveness detection features output by the base model.

[0156] S630. Input the liveness detection features into the trained multiple plugin modules respectively to obtain the plugin features output by each plugin module.

[0157] In the embodiments described in this specification, the input to the adaptive plug-in module is the plug-in features output by each plug-in module, while the input to the plug-in module is the liveness detection features output by the base model. Therefore, it can be understood that the training of the adaptive plug-in module should be performed after the training of the base model and the plug-in modules is completed. That is, the base model is trained first, then multiple plug-in modules for different scenarios are trained, and finally the adaptive plug-in module is trained.

[0158] like Figure 7 As shown, when training the adaptive plugin module, the sample data from the third training dataset is first input into the already trained base model. The base model then extracts features to obtain the liveness detection features corresponding to the sample data. Next, the liveness detection features are input into each plugin module to obtain the plugin features output by each module. The plugin features output by each module are features that incorporate the characteristics of the corresponding scene.

[0159] S640. Input the plugin features of each plugin module into the adaptive plugin module to be trained to obtain the first probability value corresponding to each plugin module.

[0160] In the embodiments described in this specification, the input of the adaptive plug-in module is the plug-in feature output by each plug-in module, and its output is the first probability value corresponding to each plug-in module. The first probability value represents the probability that each plug-in module is selected as the target plug-in module. The higher the first probability value, the higher the adaptability of the corresponding plug-in module to the target scene, and thus the higher the probability of it being selected as the target plug-in module.

[0161] S650. Determine the loss value based on the preset constraints and the first probability value of each plug-in module, and adjust the network parameters of the adaptive plug-in module based on the loss value until the convergence condition is met, thus obtaining the trained adaptive plug-in module.

[0162] In the embodiments described in this specification, the preset constraint condition can refer to minimizing the sum of the first probability values ​​of each plug-in module output by the adaptive plug-in module, thereby ensuring that the number of selected target plug-in modules is as small as possible, generally constrained to no more than 3 target plug-in modules.

[0163] Therefore, in some embodiments of this specification, the loss value can be obtained based on preset constraints and the first probability value of each plug-in module. Then, backpropagation is used to adjust the network parameters of the adaptive plug-in module. The above process is repeated to iteratively train the adaptive plug-in module until the convergence condition is met, thus completing the training of the adaptive plug-in module and obtaining the trained adaptive plug-in module.

[0164] See Figure 7 As shown, in some implementations, the loss function for training the adaptive plugin module may include not only the loss value mentioned above, but also the loss of the liveness detection result output by the base model. Thus, the adaptive plugin module is iteratively trained by combining the two losses to obtain the trained adaptive plugin module. This specification will not elaborate further on this.

[0165] 4. Liveness detection model adapts to different scenarios

[0166] After completing the network training process for each of the above modules, the liveness detection model described in this manual can be adapted to cross-scene scenarios based on the trained modules. The following section will combine... Figure 8 The implementation method is described below.

[0167] like Figure 8 As shown, in some embodiments, the cross-scene adaptation method of the liveness detection model exemplified in this specification includes:

[0168] S801. Input the face data of the target scene into the pre-trained basic model to obtain the liveness detection features output by the basic model.

[0169] In the example in this manual, the target scene is the new scene that the liveness detection model needs to adapt to across scenes. By collecting facial data from the target scene and inputting it into the already trained base model, the base model extracts features from the facial data through its internal convolutional layers, which can obtain the intermediate layer features of the facial data. These intermediate layer features are the liveness detection features described in this manual.

[0170] S802. Input the liveness detection features into multiple pre-trained plug-in modules to obtain the plug-in features output by each plug-in module.

[0171] In the examples provided in this manual, the liveness detection features output by the base model are input into each pre-trained plugin module to obtain the plugin features output by each plugin module. For instance, in one example, if eight plugin modules are pre-trained, the liveness detection features output by the base model can be input into each of these eight plugin modules to obtain the plugin features output by each of the eight plugin modules. The plugin features output by each plugin module represent features that incorporate the characteristics of its corresponding scene.

[0172] S803. Input the plugin features output by each plugin module into the pre-trained adaptive plugin module to obtain the target plugin module output by the adaptive plugin module.

[0173] Combination Figure 7 As shown, after obtaining the plugin features output by each plugin module, the plugin features of all plugin modules can be input into the pre-trained adaptive plugin module. The role of the adaptive plugin module is to select one or more target plugin modules that are compatible with the target scene from multiple plugin modules.

[0174] Thus, the adaptive plugin module obtains the first probability value corresponding to each plugin module based on the input plugin features, and then sorts the first probability values ​​from high to low, selecting one or more plugin modules with the highest first probability values ​​as the target plugin modules.

[0175] S804. Based on the liveness detection characteristics, determine the target fusion layer from the multiple intermediate layers included in the basic model.

[0176] Combination Figure 5 As shown in the example in this specification, the liveness detection features obtained through the base model are simultaneously input into the pre-trained layer selection module. The function of the layer selection module is to select the target fusion layer from the multiple intermediate layers included in the base model. The target fusion layer is used to perform fusion processing with the target plug-in module.

[0177] In one example, the liveness detection features output by the base model are input into a pre-trained layer selection module to obtain the layer selection probability output by the layer selection module. The layer selection probability represents the probability that each intermediate layer in the base model is selected as the target fusion layer. Thus, the neural network layer with the same data as the target plug-in module is selected from the network structure of the base model according to the layer selection probability from high to low.

[0178] S805. Based on the network parameters of the target plug-in module, perform fusion processing on the network parameters of the target fusion layer to obtain the liveness detection model.

[0179] As mentioned above, a plugin module is essentially a simple one or more convolutional layers. Therefore, for a selected target plugin module, the convolutional layer parameters of the target plugin module are superimposed with the convolutional layer parameters of the target fusion module of the base model to achieve the fusion processing of the target plugin module and the base model, resulting in a liveness detection model that is finally adapted to the target scene.

[0180] As described above, the embodiments in this specification utilize pre-trained plug-in modules and basic models for different scenarios. Based on new scenarios, the target plug-in module is adaptively selected and fused with the basic model. This ensures model performance while enabling rapid adaptation and deployment of the liveness detection model across scenarios. It eliminates the need to build and train multiple liveness detection models for different scenarios, significantly reducing computational resource consumption and enabling rapid adaptation and deployment on lightweight devices. Furthermore, it eliminates the need to re-collect large amounts of new scenario data for manual annotation and network training, improving adaptation efficiency and enabling it to handle various new scenarios, making it suitable for large-scale deployment.

[0181] After adapting the liveness detection model to the target scenario, the liveness detection module can be deployed and applied. In some implementations, this specification provides a liveness detection method, which can be implemented based on the aforementioned liveness detection model. The following describes the method in conjunction with... Figure 9 The implementation method is described below.

[0182] like Figure 9 As shown, in some embodiments, the liveness detection method exemplified in this specification includes:

[0183] S910. Acquire the face image to be detected collected in the target scene.

[0184] S920. Input the face image to be detected into the liveness detection model to obtain the liveness detection result output by the liveness detection module.

[0185] In the embodiments described in this specification, the liveness detection model of the target scene is the liveness detection model obtained by using the target plug-in module to fuse the basic model through the adaptation method of any of the aforementioned embodiments. This specification will not elaborate further on this.

[0186] Once the liveness detection model is obtained, it can be deployed and applied in the target scenario. In a real-world liveness detection scenario, the face recognition system can acquire the image of the face to be detected in the target scenario, and then input the image of the face to be detected into the liveness detection model to obtain the liveness detection result output by the liveness detection model.

[0187] In some implementations, the liveness detection model outputs a liveness attack probability, and a corresponding threshold can be pre-set for this probability. If the liveness attack probability output by the liveness detection model is less than this threshold, it indicates that the face image to be detected is a real live subject, thus determining the liveness detection result as "live". Conversely, if the liveness attack probability output by the liveness detection model is greater than or equal to this threshold, it indicates that the face image to be detected is an attacker, not a real live subject, thus determining the liveness detection result as "attack subject".

[0188] As described above, the embodiments in this specification utilize pre-trained plug-in modules and basic models for different scenarios. Based on new scenarios, the target plug-in module is adaptively selected and fused with the basic model. This ensures model performance while enabling rapid adaptation and deployment of the liveness detection model across scenarios. It eliminates the need to build and train multiple liveness detection models for different scenarios, significantly reducing computational resource consumption and enabling rapid adaptation and deployment on lightweight devices. Furthermore, it eliminates the need to re-collect large amounts of new scenario data for manual annotation and network training, improving adaptation efficiency and enabling it to handle various new scenarios, making it suitable for large-scale deployment.

[0189] Combination Figure 1 As shown, one or more embodiments of this specification provide a cross-scene adaptation device for a liveness detection model, including:

[0190] The base model is configured to input facial data from the target scene into a pre-trained base model to obtain liveness detection features output by the base model.

[0191] The multi-scene plugin module is configured to input liveness detection features into multiple pre-trained plugin modules to obtain plugin features output by each plugin module; wherein, each plugin module is trained based on sample data of a scene.

[0192] An adaptive plugin module is configured to select at least one target plugin module from multiple plugin modules based on the plugin features output by each plugin module.

[0193] The fusion processing module is configured to perform fusion processing on the base model based on the target plugin module to obtain the liveness detection model corresponding to the target scene.

[0194] As can be seen from the above, in the embodiments of this specification, when it is necessary to deploy a liveness detection model in a new scene, only a small amount of face data in the new scene needs to be collected. The adaptive plugin module is used to select one or more target plugin modules from the N pre-trained plugin modules, and the target plugin modules are fused with the pre-trained base model. This enables the rapid adaptation of the liveness detection model in the new scene without the need to collect a large amount of new scene data for manual annotation and network training. A liveness detection model that can be well adapted to the new scene can be obtained, thus completing the rapid adaptation and deployment of the liveness detection module across scenes.

[0195] like Figure 10 As shown, one or more embodiments of this specification provide a liveness detection device, comprising:

[0196] The image acquisition module is configured to acquire the face image to be detected in the target scene;

[0197] The liveness detection model is configured to input a face image to be detected into the liveness detection model and obtain the liveness detection result output by the liveness detection model. The liveness detection model is obtained according to the method of any of the aforementioned implementation methods.

[0198] This specification provides one or more embodiments of an electronic device, including:

[0199] processor; and

[0200] The memory stores computer instructions for causing the processor to execute the methods of any of the foregoing embodiments.

[0201] This specification provides a storage medium storing computer instructions for causing a computer to perform the methods of any of the foregoing embodiments.

[0202] Figure 11 This is a schematic structural diagram of an electronic device provided as an exemplary embodiment. Please refer to... Figure 11 At the hardware level, the device includes a processor 702, an internal bus 704, a network interface 706, memory 708, and non-volatile memory 710, and may also include other hardware required for different scenarios. One or more embodiments of this specification can be implemented in software, such as the processor 702 reading the corresponding computer program from the non-volatile memory 710 into memory 708 and then running it. Of course, in addition to software implementation, one or more embodiments of this specification do not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0203] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which can take the form of a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email sending and receiving device, game console, tablet computer, wearable device, or any combination of these devices.

[0204] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0205] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0206] Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0207] It should also be noted that 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 limitation, 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.

[0208] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims may be performed in a different order than those shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

[0209] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of one or more embodiments of this specification. The singular forms “a,” “described,” and “the” used in one or more embodiments of this specification and in the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0210] It should be understood that although the terms first, second, third, etc., may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of one or more embodiments of this specification, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "in response to a determination," or "when," or "in the event of a determination."

[0211] The above description is merely a preferred embodiment of one or more embodiments of this specification and is not intended to limit the scope of one or more embodiments of this specification. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of one or more embodiments of this specification shall be included within the scope of protection of one or more embodiments of this specification.

Claims

1. A method for cross-scene adaptation of a liveness detection model, comprising: The face data of the target scene is input into the pre-trained base model to obtain the liveness detection features output by the base model; The process of pre-training the base model includes: training using sample data from various scenarios; The liveness detection features are input into multiple pre-trained plug-in modules to obtain plug-in features output by each plug-in module. Each plug-in module is trained based on sample data from a specific scene. The pre-training process for the plug-in modules includes: acquiring a second training dataset containing sample data from a scene; inputting the second training dataset into the already trained base model to obtain liveness detection features output by the base model; inputting the liveness detection features output by the base model into the plug-in module to be trained to obtain plug-in features output by the plug-in module; inputting the plug-in features into the already trained base model to obtain the liveness detection result output by the base model; and adjusting the parameters of the plug-in module based on the loss corresponding to the liveness detection result until convergence is met, thus obtaining the trained plug-in module. Selecting at least one target plugin module from the plurality of plugin modules based on the plugin features output by each plugin module includes: inputting the plugin features output by each plugin module into a pre-trained adaptive plugin module to obtain the target plugin module output by the adaptive plugin module; The target plugin module is used to fuse the base model to obtain a liveness detection model corresponding to the target scene. The fusion process includes superimposing the network parameters of the target plugin module with one or more layers of network parameters of the base model.

2. The method according to claim 1, wherein the step of fusing the basic model based on the target plug-in module to obtain the liveness detection model corresponding to the target scene includes: Based on the liveness detection features, the target fusion layer is determined from the multiple intermediate layers of the base model, including: inputting the liveness detection features into a pre-trained layer selection module to obtain the target fusion layer output by the layer selection module; the process of pre-training the layer selection module includes: using the liveness detection features as input to obtain the layer selection probability, and adjusting the parameters of the layer selection module based on the loss of the layer selection probability until convergence; The network parameters of the target fusion layer are fused based on the network parameters of the target plug-in module to obtain the liveness detection model.

3. The method according to claim 1, wherein the process of pre-training the base model comprises: Obtain a first training dataset, which includes sample data from multiple different scenarios; The first training dataset is input into the initial model and the model to be pruned to obtain the first liveness detection feature and the first liveness detection result output by the initial model, and the second liveness detection feature and the second liveness detection result output by the model to be pruned. Based on the first and second liveness detection features, and the difference between the first and second liveness detection results, the model to be pruned is pruned and trained until the model to be pruned meets the convergence condition, thus obtaining the base model.

4. The method according to claim 1, wherein the process of pre-training the adaptive plugin module comprises: Obtain a third training dataset, which includes sample data of preset scenarios that are different from the scenarios corresponding to the plurality of plugin modules; The third training dataset is input into the already trained base model to obtain the liveness detection features output by the base model. The liveness detection features are input into multiple trained plug-in modules respectively to obtain the plug-in features output by each plug-in module; The plugin features of each plugin module are input into the adaptive plugin module to be trained to obtain the first probability value corresponding to each plugin module; The loss value is determined based on the preset constraints and the first probability value of each plug-in module, and the network parameters of the adaptive plug-in module are adjusted based on the loss value until the convergence condition is met, thus obtaining the trained adaptive plug-in module. The preset constraints ensure that the number of target plug-in modules corresponding to the first probability value output by the adaptive plug-in module is less than or equal to 3.

5. A method for detecting liveness, comprising: Acquire the face image to be detected captured in the target scene; The face image to be detected is input into the liveness detection model to obtain the liveness detection result output by the liveness detection model, wherein the liveness detection model is obtained by the method according to any one of claims 1 to 4.

6. A cross-scene adaptation device for a liveness detection model, comprising: The base model is configured to input face data from the target scene into a pre-trained base model to obtain liveness detection features output by the base model. The basic model is trained using sample data from various scenarios; A multi-scene plugin module is configured to input the liveness detection features into multiple pre-trained plugin modules to obtain plugin features output by each plugin module. Each plugin module is trained based on sample data from a single scene. The pre-training process for the plugin modules includes: acquiring a second training dataset, which includes sample data from a single scene; inputting the second training dataset into a trained base model to obtain liveness detection features output by the base model; inputting the liveness detection features output by the base model into a plugin module to be trained to obtain plugin features output by that plugin module; inputting the plugin features into the trained base model to obtain a liveness detection result output by the base model; and adjusting the parameters of the plugin module based on the loss corresponding to the liveness detection result until a convergence condition is met to obtain the trained plugin module. An adaptive plugin module, which is pre-trained and configured to take the plugin features output by each plugin module as input and select at least one target plugin module as output from the plurality of plugin modules; The fusion processing module is configured to perform fusion processing on the base model based on the target plug-in module to obtain a liveness detection model corresponding to the target scene. The fusion processing includes: superimposing the network parameters of the target plug-in module with one or more layers of network parameters of the base model.

7. A liveness detection device, comprising: The image acquisition module is configured to acquire the face image to be detected in the target scene; A liveness detection model is configured to input the face image to be detected into the liveness detection model and obtain the liveness detection result output by the liveness detection model, wherein the liveness detection model is obtained by the method according to any one of claims 1 to 4.

8. An electronic device, comprising: processor; and The memory stores computer instructions that cause the processor to perform the method of any one of claims 1 to 4, or the method of claim 5.

9. A storage medium storing computer instructions, said computer instructions being configured to cause a computer to perform the method of any one of claims 1 to 4, or to perform the method of claim 5.