Liveness detection model training method, liveness detection method, device and electronic equipment
By introducing a dynamic routing network and multiple candidate networks into the liveness detection model, multi-expert fusion face liveness detection is achieved, which solves the problem of poor generalization in the existing technology and improves the accuracy and defense effect of liveness detection.
Patent Information
- Application Number
- CN202211610370.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-14
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2042-12-14
Smart Images

Figure CN115937993B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, specifically to the field of deep learning, image processing, and computer vision technology, and specifically to a liveness detection model training method, liveness detection method, device, and electronic device. Background Art
[0002] With the rapid development of artificial intelligence (AI), AI has been widely used in computer vision technology, speech recognition technology, natural language processing technology, deep learning, big data processing technology and other fields.
[0003] Image detection technology based on artificial intelligence has also been widely used in different scenarios. Among them, face liveness detection technology based on artificial intelligence is used to distinguish whether an image is taken by a real person. It is a basic component module of the face recognition system and ensures the security of the face recognition system. Therefore, how to improve the liveness detection performance is very important. Summary of the invention
[0004] The present disclosure provides a living body detection model training method, a living body detection method, a device and an electronic device.
[0005] According to one aspect of the present disclosure, a method for training a liveness detection model is provided, comprising:
[0006] The feature extraction network in the liveness detection model extracts features of the sample face area in the sample image to obtain sample face features; the liveness detection model also includes a dynamic routing network and at least two candidate liveness detection networks;
[0007] Selecting a target liveness detection network from the at least two candidate liveness detection networks according to the sample face features through the dynamic routing network;
[0008] Determining predicted liveness information of a sample image according to the sample face features through the target liveness detection network;
[0009] The feature extraction network, the dynamic routing network and the candidate liveness detection network are trained according to the target liveness detection network, the predicted liveness information, the annotated attack type of the sample image and the annotated liveness information of the sample image.
[0010] According to another aspect of the present disclosure, a living body detection method is provided, comprising:
[0011] Acquire the target image to be detected;
[0012] The target face feature is obtained by extracting the feature of the target face area in the target image through the feature extraction network in the liveness detection model; the liveness detection model is trained by the liveness detection model training method disclosed in any embodiment of the present disclosure;
[0013] Selecting at least one target liveness detection network from at least two candidate liveness detection networks of the liveness detection model according to the target face features through a dynamic routing network in the liveness detection model;
[0014] The target living body detection network determines the predicted living body information of the target image according to the target facial features.
[0015] According to another aspect of the present disclosure, a living body detection model training device is provided, comprising:
[0016] A sample face feature module is used to extract features of a sample face region in a sample image through a feature extraction network in a liveness detection model to obtain sample face features; the liveness detection model also includes a dynamic routing network and at least two candidate liveness detection networks;
[0017] A target network selection module, configured to select a target liveness detection network from the at least two candidate liveness detection networks according to the sample face features through the dynamic routing network;
[0018] A sample liveness prediction module, used to determine predicted liveness information of a sample image according to the sample face features through the target liveness detection network;
[0019] A network training module is used to train the feature extraction network, the dynamic routing network and the candidate liveness detection network according to the target liveness detection network, the predicted liveness information, the annotated attack type of the sample image and the annotated liveness information of the sample image.
[0020] According to another aspect of the present disclosure, there is provided a living body detection device, comprising:
[0021] A target image module is used to obtain a target image to be detected;
[0022] A target face feature module is used to extract features of a target face region in a target image through a feature extraction network in a liveness detection model to obtain target face features; the liveness detection model is trained using the liveness detection model training method disclosed in any embodiment of the present disclosure;
[0023] A target network selection module, configured to select at least one target liveness detection network from at least two candidate liveness detection networks of the liveness detection model according to the target face features through a dynamic routing network in the liveness detection model;
[0024] The target liveness prediction module is used to determine the predicted liveness information of the target image according to the target facial features through the target liveness detection network.
[0025] According to another aspect of the present disclosure, there is provided an electronic device, the electronic device comprising:
[0026] at least one processor; and
[0027] a memory communicatively connected to the at least one processor; wherein,
[0028] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method provided by any embodiment of the present disclosure.
[0029] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable a computer to execute the method provided by any embodiment of the present disclosure.
[0030] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0032] Figure 1a is a flow chart of a method for training a liveness detection model according to an embodiment of the present disclosure;
[0033] Figure 1b is a structural schematic diagram of a living body detection model provided according to an embodiment of the present disclosure;
[0034] Figure 2 is a flow chart of another method for training a liveness detection model according to an embodiment of the present disclosure;
[0035] Figure 3a is a flowchart of another method for training a liveness detection model according to an embodiment of the present disclosure;
[0036] Figure 3b is a structural schematic diagram of a living body detection model provided according to an embodiment of the present disclosure;
[0037] Figure 4 is a flow chart of a living body detection method provided according to an embodiment of the present disclosure;
[0038] Figure 5 is a structural schematic diagram of a living body detection model training device provided according to an embodiment of the present disclosure;
[0039] Figure 6 is a structural schematic diagram of a living body detection device provided according to an embodiment of the present disclosure;
[0040] Figure 7 It is a block diagram of an electronic device used to implement the liveness detection model training method or the liveness detection method of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0041] Figure 1a 1 is a flow chart of a method for training a liveness detection model according to an embodiment of the present disclosure. The method is applicable to the case of training a liveness detection model. The method can be executed by a liveness detection model training device, which can be implemented in software and / or hardware and can be integrated into an electronic device. Figure 1a As shown, the living body detection model training method of this embodiment may include:
[0042] S101, extracting features of a sample face region in a sample image through a feature extraction network in a liveness detection model to obtain sample face features; the liveness detection model further includes a dynamic routing network and at least two candidate liveness detection networks;
[0043] S102, selecting a target liveness detection network from the at least two candidate liveness detection networks according to the sample face features through the dynamic routing network;
[0044] S103, determining predicted liveness information of the sample image according to the sample face features through the target liveness detection network;
[0045] S104, training the feature extraction network, the dynamic routing network and the candidate liveness detection network according to the target liveness detection network, the predicted liveness information, the annotated attack type of the sample image and the annotated liveness information of the sample image.
[0046] Figure 1b is a schematic diagram of a living body detection model provided according to an embodiment of the present disclosure, with reference to Figure 1bThe liveness detection model to be trained includes a feature extraction network, a dynamic routing network and at least two candidate liveness detection networks. The N candidate liveness detection networks are composed of 1 real person module and N-1 expert modules. Each expert module is used to defend against the corresponding candidate attack type, and each expert module corresponds to the candidate attack type one by one. The feature extraction network is used to extract facial features from the image, and the dynamic routing network is used to select the corresponding expert module according to the facial features, and the facial features are dynamically routed to the selected expert module, and the selected expert module performs liveness detection. Among them, N is a natural number greater than 1. By combining the dynamic routing network and the candidate liveness detection network, different attack types of data are identified by different expert modules, which greatly improves the accuracy and generalization of the liveness detection algorithm, and can solve the problem of poor generalization of deep learning face liveness algorithms caused by complex and diverse attack samples.
[0047] The sample data set includes not only real-life images, but also candidate attack images corresponding to each candidate attack type. The sample data not only has labeled live information, but also has labeled attack types, which are the attack types corresponding to the sample data.
[0048] In the disclosed embodiment, face detection can be performed on the sample image to extract the sample face area. Specifically, face detection can be performed on the sample image through a face detection model to obtain the approximate location area of the face, wherein the face detection model is used to detect the location of the face; based on the approximate location area of the face, face key point detection can be performed through a face key point detection model to obtain the coordinate values of the face key points, and 72 face key points can be preset; face alignment can be performed based on the coordinate values of the face key points to obtain the sample face area information. The face alignment process can be as follows: the maximum and minimum values of the horizontal and vertical coordinates are obtained according to the coordinates of the 72 facial key points, the face frame is determined by combining the maximum and minimum values, the face frame is expanded by three parts to capture the face image, and the face image is adjusted to a fixed size, such as 224×224; the face image is normalized, for example, the pixel value of each pixel in the face image is subtracted by 128 and then divided by 256, so that the pixel value of each pixel is between [-0.5, 0.5], and the sample face area image after normalization is subjected to random data enhancement processing, and the sample face area image is divided into 196 image blocks (patches) of size 16×16 as the input of the liveness detection model.
[0049] In the liveness detection model, the feature extraction network extracts features from the input sample face area to obtain the sample face features. The dynamic routing network can select a target liveness detection network from at least two candidate liveness detection networks based on the sample face features, and routes the sample face features only to the target liveness detection network. The target liveness detection network is used to perform liveness detection on the sample face features to obtain the predicted liveness information of the sample image. Other candidate liveness detection networks except the target liveness detection network do not need to process the sample image. A loss function is constructed based on the target liveness detection network, the predicted liveness information, the labeled attack type of the sample image, and the labeled liveness information of the sample image, and the loss function is used to train the feature extraction network, the dynamic routing network, and the candidate liveness detection network. By introducing a dynamic routing network and a candidate liveness detection network including multiple expert modules into the liveness detection model, using the expert modules to defend against the corresponding attack types, and using the dynamic routing network to select the corresponding expert modules, a face liveness detection method based on multi-expert fusion is implemented. Compared with the single liveness detection network method in related technologies, it has a good defense effect in the face of many attack methods and can greatly improve the accuracy and generalization of the liveness detection algorithm.
[0050] The technical solution provided by the embodiment of the present disclosure introduces a dynamic routing network and multiple expert modules into the liveness detection model, uses the expert modules to defend against corresponding attack types, and uses the dynamic routing network to select the corresponding expert modules, thereby realizing a face liveness detection method based on multi-expert fusion, which can greatly improve the accuracy and generalization of the liveness detection algorithm.
[0051] Figure 2 FIG. 1 is a flowchart of another method for training a liveness detection model according to an embodiment of the present disclosure. Figure 2 The liveness detection model training method of this embodiment may include:
[0052] S201, extracting features of a sample face region in a sample image through a feature extraction network in a liveness detection model to obtain sample face features; the liveness detection model further includes a dynamic routing network and at least two candidate liveness detection networks;
[0053] S202, determining the similarity between the sample face feature and at least two candidate class centers through the dynamic routing network; the candidate class centers correspond one to one with the candidate living body detection networks;
[0054] S203, selecting a target liveness detection network from the at least two candidate liveness detection networks according to the similarity;
[0055] S204, determining predicted liveness information of the sample image according to the sample face features through the target liveness detection network;
[0056] S205: training the feature extraction network, the dynamic routing network and the candidate liveness detection network according to the target liveness detection network, the predicted liveness information, the annotated attack type of the sample image and the annotated liveness information of the sample image.
[0057] In the disclosed embodiment, each attack type has its own attack class center, that is, each candidate liveness detection network has its own candidate class center, and the candidate class center is used to characterize the facial features of the corresponding attack type. The dynamic routing module can initialize the candidate class center for each candidate liveness detection network, and continuously learn the candidate class center during the training phase, so that the learned candidate class center matches the attack type corresponding to the candidate liveness detection network.
[0058] In the training phase, the feature extraction network extracts features from the input sample face area to obtain sample face features, and the dynamic routing network calculates the similarity between the sample face features and each candidate class center. The similarity with the candidate class center is used to characterize the probability that the sample image belongs to the candidate attack type corresponding to the candidate class center. The greater the similarity, the higher the risk of belonging to the corresponding candidate attack type. The dynamic routing network can select a candidate liveness detection network with relatively high similarity as the target liveness detection network for the sample image, and route the sample face features to the target liveness detection network, which performs liveness detection based on the sample face features to obtain the predicted liveness information of the sample image.
[0059] It should be noted that the disclosed embodiment does not specifically limit the number of target liveness detection networks. Only one candidate liveness detection network with the greatest similarity can be used as the target liveness detection network of the sample image, and the prediction result of the target liveness detection network can be used as the predicted liveness information of the sample image; the first i candidate liveness detection networks with relatively large similarity can also be used as the target liveness detection network of the sample image, and i target liveness detection networks are used to perform fusion prediction on the sample facial features to obtain the fusion prediction result as the predicted liveness information of the sample image, where i is a fixed natural number greater than 1. In the case of multiple target liveness detection networks, the disclosed embodiment does not specifically limit the fusion method of each target liveness detection network. By selecting the target liveness detection network from each candidate liveness detection network according to the similarity between the sample facial features and the centers of each candidate class through the dynamic routing module, the matching degree between the target liveness detection network and the sample image can be improved, thereby improving the accuracy of the predicted liveness information.
[0060] In an optional embodiment, the feature extraction network, the dynamic routing network and the candidate liveness detection network are trained according to the target liveness detection network, the labeled attack type of the sample image and the labeled liveness information of the sample image, including: determining the target attack type corresponding to the target liveness detection network as the predicted attack type based on the preset association relationship between the candidate liveness detection network and the candidate attack type; constructing a first loss function according to the predicted attack type and the labeled attack type of the sample image, and using the first loss function to train the dynamic routing network; constructing a second loss function according to the predicted liveness information and the labeled liveness information of the sample image, and using the second loss function to train the feature extraction network and the candidate liveness detection network.
[0061] In the disclosed embodiment, an association relationship between candidate liveness detection networks and candidate attack types is also preset. Still taking the example of N candidate liveness detection networks including 1 real person module and N-1 expert modules, that is, when one candidate liveness detection network is a real person module and the remaining N-1 candidate liveness detection networks are different expert modules, the expert modules are preset with their own candidate attack types.
[0062] Specifically, based on the association between the preset candidate liveness detection network and the candidate attack type, the target attack type corresponding to the target liveness detection network can be determined as the predicted attack type of the sample image; the predicted attack type and the labeled attack type of the sample image are compared to obtain a first comparison result, and a first loss function is constructed according to the first comparison result, and the first loss function is used to train the dynamic routing network so that the dynamic routing network continuously learns the centers of each candidate class; the predicted liveness information and the labeled liveness information of the sample image are compared to obtain a second comparison result, and a second loss function is constructed according to the second comparison result, and the second loss function is used to train the feature extraction network and the candidate liveness detection network so that the feature extraction parameters and the candidate liveness detection parameters are continuously learned. It should be noted that there are sample images of different attack types in the sample data set, and the sample images of each attack type are only used to train the candidate liveness detection network corresponding to the attack type, and are not used to train the candidate liveness detection networks corresponding to other attack types. That is to say, for a certain sample image, the second loss function of the sample image is only used to train the feature extraction network and the target liveness detection network, and is not used to train other candidate liveness detection networks except the target liveness detection network.
[0063] By training the dynamic routing network according to the predicted attack type and labeled attack type of the sample image, the attack class center can be accurately learned; and for each candidate liveness detection network, by using the predicted liveness information and labeled liveness information of the sample image belonging to the corresponding attack type to train the candidate liveness detection network, the accuracy of the candidate liveness detection network can be improved, thereby further improving the overall performance of liveness detection.
[0064] In an optional implementation, the candidate attack types include at least one of the following: electronic screen attack, paper attack, two-dimensional mask attack, three-dimensional head model attack, or ID photo attack. In the case of five expert modules, the candidate attack types of each expert module are electronic screen attack, paper attack, two-dimensional mask attack, three-dimensional head model attack, and ID photo attack. By deploying expert modules for multiple attack types and using the expert modules to defend against the corresponding attack types, the defense effect can be improved.
[0065] The technical solution provided by the embodiment of the present disclosure can improve the matching degree between the target liveness detection network and the sample image by selecting the target liveness detection network from the candidate liveness detection networks according to the similarity between the sample facial features and the centers of the candidate classes through the dynamic routing module, thereby improving the accuracy of predicting liveness information; and can improve the defense effect by deploying expert modules for various attack types respectively and using the expert modules to defend against the corresponding attack types.
[0066] Figure 3a is a flow chart of another method for training a liveness detection model according to an embodiment of the present disclosure. This embodiment is an optional solution proposed based on the above embodiment. Figure 3a The liveness detection model training method of this embodiment may include:
[0067] S301, using sample images to pre-train the multi-head self-attention module and the point-by-point forward network module in the visual transformer, and using the trained multi-head self-attention module as the initial feature extraction network in the living body detection model;
[0068] S302, duplicating the trained point-by-point forward network module to obtain at least two point-by-point forward network modules as initial candidate liveness detection networks in at least two liveness detection models;
[0069] S303, adding an initial dynamic routing network to an initial feature extraction network and at least two initial candidate living body detection networks;
[0070] S304, extracting features of the sample face region in the sample image through a feature extraction network in the liveness detection model to obtain sample face features;
[0071] S305, selecting a target liveness detection network from the at least two candidate liveness detection networks according to the sample face features through the dynamic routing network;
[0072] S306, determining predicted liveness information of the sample image according to the sample face features through the target liveness detection network;
[0073] S307: training the feature extraction network, the dynamic routing network and the candidate liveness detection network according to the target liveness detection network, the predicted liveness information, the annotated attack type of the sample image and the annotated liveness information of the sample image.
[0074] Among them, S301-S303 is the initialization stage of the liveness detection model, and S304-S307 is the training stage of the liveness detection model.
[0075] Figure 3b is a schematic diagram of a living body detection model provided according to an embodiment of the present disclosure; Figure 3b In the disclosed embodiment, the liveness detection model is initialized based on the network of the Vision Transformer (ViT). The liveness detection model includes a plurality of encoders connected in sequence, and an output layer connected to the tail encoder, each encoder including a multi-head self-attention module (MHSA) and a position-wise feed-forward network module (FFN). The MHSA module is used to perform self-attention calculation to obtain the self-attention score of the original image tag, and the FFN module is used to perform prediction.
[0076] In the initialization stage, various sample images in the sample data set are used to pre-train the MHSA module and FFN module in the visual transformer, and the pre-trained ViT liveness detection model is obtained by using binary cross entropy for supervision; the MHSA module in the ViT liveness detection model is used as the initial feature extraction network; the FFN module in the ViT liveness detection model is copied multiple times as at least two initial candidate liveness detection networks, and a dynamic routing network is added before each FFN module, the input end of the dynamic routing network is connected to the output end of the feature extraction network, and the output end of the dynamic routing network is connected to the input end of each candidate liveness detection network. By constructing a liveness detection model based on the network of the visual transformer, the pre-trained FFN module can be directly copied as the initial candidate liveness detection network, which can not only improve the construction efficiency of the candidate liveness detection network; but also facilitate the dynamic routing network to learn the center of each candidate class, further improving the liveness detection performance.
[0077] In an optional implementation, the dynamic routing network adopts a fully connected (FC) neural network structure. The reliability of the dynamic routing network can be improved by adopting a neural network structure in the dynamic routing network.
[0078] In an optional implementation, the method further includes: obtaining a labeled attack type of a newly added sample image, and using the labeled attack type as a newly added attack type; adding a corresponding candidate liveness detection network for the newly added attack type, and training the added candidate liveness detection network.
[0079] In the case of a new attack type, the annotated attack type of the new sample image is used as the new attack type, and a corresponding candidate liveness detection network is added to the liveness detection model for the new attack type. The input end of the new candidate liveness detection network is connected to the output end of the dynamic routing network, and the new sample image is used to train the added candidate liveness detection network. Still taking the liveness detection model including 1 real person module and N-1 expert modules as an example, in the case of a new attack type, a corresponding candidate liveness detection network is set for the new attack type in the liveness detection model as the Nth expert module. It should be noted that during the training process of the added candidate liveness detection network, the feature extraction network, the existing candidate class center in the dynamic routing network, and the existing candidate liveness detection network can be fixed and no further training is required.
[0080] Specifically, a new sample face area is extracted from the new sample image, the new sample face area is input into the feature extraction network to obtain the new sample face feature, a dynamic routing module is used to determine the similarity between the new sample face feature and each candidate liveness detection network, and the new candidate liveness detection network is selected as the target liveness detection network of the new sample image according to the similarity, and the target liveness detection network of the new sample image is used to determine the predicted liveness information of the new sample image; a first loss function is constructed according to the labeled attack type of the new sample image and the candidate attack type corresponding to the target liveness detection network, and the first loss function is used to train the dynamic routing network, so as to learn the candidate class center for the new attack type; a second loss function is constructed according to the labeled liveness information and the predicted liveness information of the new sample image, and the second loss function is used to train the target liveness detection network (i.e., the new candidate liveness detection network) and the feature extraction network.
[0081] In the case of new attack types, the liveness detection model is expanded by adding candidate liveness detection networks for the new attack types, using new sample image data to learn the candidate class centers of the new attack types in the dynamic routing network, and learning the added candidate liveness detection networks. That is, in the case of new attack types, only one expert module needs to be added for fine-tuning, which further improves the generalization of liveness detection.
[0082] The technical solution provided by the embodiment of the present disclosure builds a liveness detection model based on the network of the visual transformer, and directly copies the pre-trained FFN module as a candidate liveness detection network, which not only improves the construction efficiency of the candidate liveness detection network; but also facilitates the dynamic routing network to learn the centers of each candidate class, further improving the liveness detection performance; and, in the event of a new attack type, only one expert module needs to be added for fine-tuning, which further improves the generalization of liveness detection.
[0083] Figure 4 1 is a flow chart of a liveness detection method provided according to an embodiment of the present disclosure. The method is applicable to the case of performing liveness detection on an image. The method can be executed by a liveness detection device, which can be implemented in software and / or hardware and can be integrated into an electronic device. Figure 4 As shown, the living body detection method of this embodiment may include:
[0084] S401, obtaining a target image to be detected;
[0085] S402, extracting features of a target face region in a target image through a feature extraction network in a liveness detection model to obtain target face features;
[0086] S403, selecting at least one target liveness detection network from at least two candidate liveness detection networks of the liveness detection model according to the target face features through a dynamic routing network in the liveness detection model;
[0087] S404: Determine predicted liveness information of the target image according to the target facial features through the target liveness detection network.
[0088] Among them, the liveness detection model is trained using the liveness detection model training method disclosed in any embodiment of the present disclosure; the liveness detection model includes a feature extraction network, a dynamic routing network and at least two candidate liveness detection networks, the dynamic routing network learns the candidate class center for the candidate liveness detection network, and the candidate class center is used to characterize the facial features of the candidate liveness detection network corresponding to the attack type.
[0089] In the prediction stage, face detection is performed on the target image to obtain the target face area, the target face area is input into the feature extraction network, the feature extraction network is used to extract features of the target face area to obtain target face features, the target face features are input into the dynamic routing network, the dynamic routing network is used to select the target liveness detection network from the candidate liveness detection network according to the target face features and the centers of each candidate class obtained through learning, and the target liveness detection network is used to perform liveness detection on the target face features to obtain the predicted liveness information of the target image.
[0090] Since the liveness detection model includes candidate liveness detection networks corresponding to each attack type, that is, each expert module is used to defend against the corresponding attack type; and the dynamic routing network has learned the candidate class center corresponding to each candidate liveness detection network, the use of each candidate class center can quickly and accurately route the target facial features to the target liveness detection network, thereby improving the accuracy of liveness prediction.
[0091] The technical solution provided by the embodiment of the present disclosure can greatly improve the accuracy and generalization of the liveness detection algorithm by introducing a dynamic routing network and multiple expert modules into the liveness detection model, using the expert modules to defend against corresponding attack types, and using the dynamic routing network to select the corresponding expert modules.
[0092] In an optional implementation, the selecting at least one target liveness detection network from at least two candidate liveness detection networks of the liveness detection model according to the target facial features through the dynamic routing network in the liveness detection model includes: determining the similarity between the target facial features and at least two candidate class centers through the dynamic routing network in the liveness detection model; one-to-one correspondence between the candidate class centers and the candidate liveness detection networks; and selecting at least one target liveness detection network from the at least two candidate liveness detection networks according to the similarity.
[0093] In the disclosed embodiment, each attack type has its own attack class center. In the prediction stage, the feature extraction network extracts the input target face area to obtain the target face features, and the dynamic routing network calculates the similarity between the target face features and each candidate class center respectively; and the candidate liveness detection network with relatively high similarity can be selected as the target liveness detection network of the target image, and the target liveness detection network is used to perform liveness detection according to the target face features to obtain the predicted liveness information of the target image.
[0094] It should be noted that, when the target liveness detection network is unique, the candidate liveness detection network with the greatest similarity can be used as the target liveness detection network, and the prediction result of the target liveness detection network can be used as the predicted liveness information of the target image; when the target liveness detection network is not unique, the first i candidate liveness detection networks with relatively large similarity can be used as the target liveness detection network of the target image, and the i target liveness detection networks are used to perform fusion prediction on the face features of the target sample to obtain the fusion prediction result as the predicted liveness information of the target image, where i is a fixed natural number greater than 1. The target liveness detection network is selected from each candidate liveness detection network according to the similarity between the target face features and the centers of each candidate class obtained through learning through the dynamic routing module, which can improve the matching degree between the target liveness detection network and the target image, thereby improving the accuracy of liveness detection on the target image.
[0095] Figure 5 1 is a schematic diagram of the structure of a liveness detection model training device provided according to an embodiment of the present disclosure. This embodiment is applicable to the case of training a liveness detection model. The device can be implemented in software and / or hardware. Figure 5 As shown, the living body detection model training device 500 of this embodiment may include:
[0096] A sample face feature module 510 is used to extract features of a sample face region in a sample image through a feature extraction network in a liveness detection model to obtain sample face features; the liveness detection model also includes a dynamic routing network and at least two candidate liveness detection networks;
[0097] A target network selection module 520, configured to select a target liveness detection network from the at least two candidate liveness detection networks according to the sample face features through the dynamic routing network;
[0098] A sample liveness prediction module 530, configured to determine predicted liveness information of a sample image according to the sample face features through the target liveness detection network;
[0099] The network training module 540 is used to train the feature extraction network, the dynamic routing network and the candidate liveness detection network according to the target liveness detection network, the predicted liveness information, the annotated attack type of the sample image and the annotated liveness information of the sample image.
[0100] In an optional implementation, the target network selection module 520 includes:
[0101] A sample similarity unit, used to determine the similarity between the sample face feature and at least two candidate class centers through the dynamic routing network; the candidate class centers correspond one to one with the candidate living body detection networks;
[0102] A target network selection unit is used to select a target liveness detection network from the at least two candidate liveness detection networks according to the similarity.
[0103] In an optional implementation, the network training module 540 includes:
[0104] A predicted attack type unit, configured to determine, based on a preset association relationship between candidate liveness detection networks and candidate attack types, a target attack type corresponding to the target liveness detection network as a predicted attack type;
[0105] A first training unit, configured to construct a first loss function according to the predicted attack type and the annotated attack type of the sample image, and train the dynamic routing network using the first loss function;
[0106] The second training unit is used to construct a second loss function according to the predicted living body information and the labeled living body information of the sample image, and use the second loss function to train the feature extraction network and the candidate living body detection network.
[0107] In an optional implementation, the candidate attack types include at least one of the following: electronic screen attack, paper attack, two-dimensional mask attack, three-dimensional head model attack or ID photo attack.
[0108] In an optional implementation, the above-mentioned living body detection model training device 500 further includes an initialization module, and the initialization module includes:
[0109] A feature initialization unit, used to pre-train the multi-head self-attention module and the point-by-point forward network module in the visual transformer using a sample image, and use the trained multi-head self-attention module as an initial feature extraction network;
[0110] A live body initialization unit, used to copy the trained point-by-point forward network module to obtain at least two point-by-point forward network modules as at least two initial candidate live body detection networks;
[0111] The routing initialization unit is used to add an initial dynamic routing network to an initial feature extraction network and at least two initial candidate living body detection networks.
[0112] In an optional implementation, the dynamic routing network adopts a fully connected neural network structure.
[0113] In an optional implementation, the liveness detection model training device 500 further includes a new attack module, and the new attack includes:
[0114] A new acquisition unit is added, which is used to acquire the annotated attack type of the newly added sample image, and use the annotated attack type as the newly added attack type;
[0115] A new training unit is added, which is used to add a corresponding candidate liveness detection network for the new attack type and train the added candidate liveness detection network.
[0116] The technical solution of the disclosed embodiment is based on the ViT model structure, introduces dynamic routing and multiple expert modules, utilizes these expert modules to defend against corresponding attack types, utilizes dynamic routing to select corresponding expert modules, greatly improves the accuracy and generalization of the liveness detection algorithm, and is easy to expand. When a new attack type appears, it only needs to add the corresponding expert module for fine-tuning.
[0117] Figure 6 1 is a schematic diagram of a liveness detection device according to an embodiment of the present disclosure. This embodiment is applicable to liveness detection. The device can be implemented in software and / or hardware. Figure 6 As shown, the living body detection device 600 of this embodiment may include:
[0118] The target image module 610 is used to obtain the target image to be detected;
[0119] A target face feature module 620 is used to extract features of a target face region in a target image through a feature extraction network in a liveness detection model to obtain target face features; the liveness detection model is trained using the liveness detection model training method disclosed in any embodiment of the present disclosure;
[0120] A target network selection module 630 is used to select at least one target liveness detection network from at least two candidate liveness detection networks of the liveness detection model according to the target face features through a dynamic routing network in the liveness detection model;
[0121] The target living body prediction module 640 is used to determine the predicted living body information of the target image according to the target facial features through the target living body detection network.
[0122] In an optional implementation, the target network selection module 620 includes:
[0123] A target similarity unit, used to determine the similarity between the target face feature and at least two candidate class centers through a dynamic routing network in a liveness detection model; the candidate class centers correspond one to one with the candidate liveness detection networks;
[0124] A target network selection unit is used to select at least one target liveness detection network from the at least two candidate liveness detection networks according to the similarity.
[0125] The technical solution of the disclosed embodiment is based on the ViT model structure, introduces dynamic routing and multiple expert modules, utilizes these expert modules to defend against corresponding attack types, utilizes dynamic routing to select corresponding expert modules, greatly improves the accuracy and generalization of the liveness detection algorithm, and is easy to expand. When a new attack type appears, it only needs to add the corresponding expert module for fine-tuning.
[0126] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0127] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0128] Figure 7 It is a block diagram of an electronic device used to implement the liveness detection model training method or the liveness detection method of the embodiment of the present disclosure.
[0129] Figure 7 A schematic block diagram of an example electronic device 700 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0130] like Figure 7 As shown, the electronic device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0131] Multiple components in the electronic device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the electronic device 700 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0132] The computing unit 701 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 701 performs the various methods and processes described above, such as a liveness detection model training method or a liveness detection method. For example, in some embodiments, the liveness detection model training method or the liveness detection method may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the liveness detection model training method or the liveness detection method described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to execute the liveness detection model training method or the liveness detection method in any other appropriate manner (for example, by means of firmware).
[0133] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0134] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0135] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0136] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0137] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communications network). Examples of communications networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0138] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0139] Artificial intelligence is a discipline that studies how to use computers to simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, planning, etc.). It includes both hardware-level and software-level technologies. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, and big data processing; artificial intelligence software technologies mainly include computer vision technology, speech recognition technology, natural language processing technology, machine learning / deep learning technology, big data processing technology, knowledge graph technology, and other major directions.
[0140] Cloud computing refers to a technology system that uses network access to elastically scalable shared physical or virtual resource pools. Resources can include servers, operating systems, networks, software, applications, and storage devices, and can be deployed and managed on demand and in a self-service manner. Cloud computing technology can provide efficient and powerful data processing capabilities for technical applications such as artificial intelligence and blockchain, as well as model training.
[0141] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0142] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A method for training a liveness detection model, the method include: The feature extraction network in the liveness detection model extracts features of the sample face area in the sample image to obtain the sample face features; The liveness detection model also includes a dynamic routing network and at least two candidate liveness detection networks; Determine the similarity between the sample face feature and at least two candidate class centers through the dynamic routing network; the candidate class centers correspond one to one with the candidate living body detection networks; Selecting a target liveness detection network from the at least two candidate liveness detection networks according to the similarity; Determining predicted liveness information of a sample image according to the sample face features through the target liveness detection network; The feature extraction network, the dynamic routing network and the candidate liveness detection network are trained according to the target liveness detection network, the predicted liveness information, the annotated attack type of the sample image and the annotated liveness information of the sample image.
2. The method according to claim 1, in, The training of the feature extraction network, the dynamic routing network and the candidate liveness detection network according to the target liveness detection network, the annotated attack type of the sample image and the annotated liveness information of the sample image comprises: Based on the association relationship between the preset candidate liveness detection networks and the candidate attack types, determining the target attack type corresponding to the target liveness detection network as the predicted attack type; Constructing a first loss function according to the predicted attack type and the annotated attack type of the sample image, and using the first loss function to train the dynamic routing network; A second loss function is constructed according to the predicted living body information and the labeled living body information of the sample image, and the second loss function is used to train the feature extraction network and the candidate living body detection network.
3. The method according to claim 2, in, The candidate attack types include at least one of the following: electronic screen attack, paper attack, two-dimensional mask attack, three-dimensional head model attack or ID photo attack.
4. The method according to any one of claims 1 to 3, further comprising: include: The multi-head self-attention module and the point-by-point forward network module in the visual transformer are pre-trained using sample images, and the trained multi-head self-attention module is used as the initial feature extraction network; The trained point-by-point forward network module is copied to obtain at least two point-by-point forward network modules as at least two initial candidate living body detection networks; An initial dynamic routing network is added to an initial feature extraction network and at least two initial candidate living body detection networks.
5. The method according to claim 4, in, The dynamic routing network adopts a fully connected neural network structure.
6. The method according to claim 4, further comprising: include: Obtain the annotated attack type of the newly added sample image, and use the annotated attack type as the newly added attack type; A corresponding candidate liveness detection network is added for the newly added attack type, and the added candidate liveness detection network is trained.
7. A method for detecting a living body, the method comprising: include: Acquire the target image to be detected; The target face area in the target image is extracted by the feature extraction network in the liveness detection model to obtain the target face features; The liveness detection model is trained by the method described in any one of claims 1 to 6; Selecting at least one target liveness detection network from at least two candidate liveness detection networks of the liveness detection model according to the target face features through a dynamic routing network in the liveness detection model; The target living body detection network determines the predicted living body information of the target image according to the target facial features.
8. The method according to claim 7, in, The method of selecting at least one target liveness detection network from at least two candidate liveness detection networks of the liveness detection model according to the target face feature through the dynamic routing network in the liveness detection model comprises: Determine the similarity between the target face feature and at least two candidate class centers through a dynamic routing network in a liveness detection model; the candidate class centers correspond one to one with the candidate liveness detection networks; At least one target living body detection network is selected from the at least two candidate living body detection networks according to the similarity.
9. A living body detection model training device, the device include: A sample face feature module is used to extract features of a sample face region in a sample image through a feature extraction network in a liveness detection model to obtain sample face features; The liveness detection model also includes a dynamic routing network and at least two candidate liveness detection networks; A target network selection module, configured to select a target liveness detection network from the at least two candidate liveness detection networks according to the sample face features through the dynamic routing network; A sample liveness prediction module, used to determine predicted liveness information of a sample image according to the sample face features through the target liveness detection network; A network training module, used for training the feature extraction network, the dynamic routing network and the candidate liveness detection network according to the target liveness detection network, the predicted liveness information, the annotated attack type of the sample image and the annotated liveness information of the sample image; Wherein, the target network selection module includes: A sample similarity unit, used to determine the similarity between the sample face feature and at least two candidate class centers through the dynamic routing network; the candidate class centers correspond one to one with the candidate living body detection networks; A target network selection unit is used to select a target liveness detection network from the at least two candidate liveness detection networks according to the similarity.
10. The device according to claim 9, in, The network training module includes: A predicted attack type unit, configured to determine, based on a preset association relationship between candidate liveness detection networks and candidate attack types, a target attack type corresponding to the target liveness detection network as a predicted attack type; A first training unit, configured to construct a first loss function according to the predicted attack type and the annotated attack type of the sample image, and train the dynamic routing network using the first loss function; The second training unit is used to construct a second loss function according to the predicted living body information and the labeled living body information of the sample image, and use the second loss function to train the feature extraction network and the candidate living body detection network.
11. The device according to claim 10, in, The candidate attack types include at least one of the following: electronic screen attack, paper attack, two-dimensional mask attack, three-dimensional head model attack or ID photo attack.
12. The device according to any one of claims 9 to 11, further comprising an initialization module, wherein the initialization module include: A feature initialization unit, used to pre-train the multi-head self-attention module and the point-by-point forward network module in the visual transformer using a sample image, and use the trained multi-head self-attention module as an initial feature extraction network; A live body initialization unit, used to copy the trained point-by-point forward network module to obtain at least two point-by-point forward network modules as at least two initial candidate live body detection networks; The routing initialization unit is used to add an initial dynamic routing network to an initial feature extraction network and at least two initial candidate living body detection networks.
13. The device according to claim 12, in, The dynamic routing network adopts a fully connected neural network structure.
14. The device according to claim 12, further comprising a new attack module, wherein the new attack module include: A new acquisition unit is added, which is used to acquire the annotated attack type of the newly added sample image, and use the annotated attack type as the newly added attack type; A new training unit is added, which is used to add a corresponding candidate liveness detection network for the new attack type and train the added candidate liveness detection network.
15. A living body detection device, the device include: A target image module is used to obtain a target image to be detected; A target face feature module is used to extract features of a target face region in a target image through a feature extraction network in a liveness detection model to obtain target face features; The liveness detection model is trained by the method described in any one of claims 1 to 6; A target network selection module, configured to select at least one target liveness detection network from at least two candidate liveness detection networks of the liveness detection model according to the target face features through a dynamic routing network in the liveness detection model; The target liveness prediction module is used to determine the predicted liveness information of the target image according to the target facial features through the target liveness detection network.
16. The device according to claim 15, in, The target network selection module includes: A target similarity unit, used to determine the similarity between the target face feature and at least two candidate class centers through a dynamic routing network in a liveness detection model; the candidate class centers correspond one to one with the candidate liveness detection networks; A target network selection unit is used to select at least one target liveness detection network from the at least two candidate liveness detection networks according to the similarity.
17. An electronic device, include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 8.
18. A non-transitory computer-readable storage medium storing computer instructions, in, The computer instructions are used to make a computer execute the method according to any one of claims 1-8.
19. A computer program product storing computer instructions, in, The computer instructions are used to make a computer execute the method according to any one of claims 1-8.
