A method for training a live body detection model and a live body detection method
By training a lightweight liveness detection model using knowledge distillation technology, the problems of false positives and slow inference speed in existing models are solved, resulting in faster and more accurate liveness detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN ORBBEC CO LTD
- Filing Date
- 2022-10-24
- Publication Date
- 2026-07-10
AI Technical Summary
Existing liveness detection models cannot accurately capture the true and false dimensions of a face, are prone to misjudgment or are too strict, and have a large number of model parameters, slow inference speed, and are difficult to deploy on systems with low computing power.
A liveness detection model is trained using knowledge distillation. A lightweight liveness detection model is constructed by knowledge transfer from the initial lightweight model and the teacher model. The loss function is determined by knowledge distillation for training.
A lightweight liveness detection model has been implemented, which improves the accuracy of spurious body detection, and enhances detection speed and user experience.
Smart Images

Figure CN115601812B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of biometric technology, and in particular relates to a training method for a liveness detection model and a liveness detection method. Background Technology
[0002] Liveness detection is a method used in identity verification scenarios to determine the true physiological characteristics of an object, verifying whether the user is a real, living person. Current technologies employ neural network models for liveness detection; however, these models often fail to accurately capture the true and false dimensions of a face, frequently misidentifying fake faces as real ones, or exhibiting overly strict anti-spoofing measures that sometimes fail even for real people, resulting in a poor user experience. Furthermore, existing liveness detection models have a large number of parameters, slow inference speeds, and are difficult to deploy on systems with limited computing power. Summary of the Invention
[0003] This application provides a training method for a liveness detection model and a liveness detection method to solve the above-mentioned problems.
[0004] In a first aspect, embodiments of this application provide a method for training a liveness detection model, comprising: acquiring an initial lightweight model and a teacher model; acquiring a training sample set, the training sample set including face sample data and its corresponding feature map labels; the mean of the feature map labels indicating the liveness detection result of the face sample data; inputting the face sample data into the teacher model for processing to obtain first dimension information and a first feature map corresponding to the face sample data; inputting the face sample data into the initial lightweight model and training it based on the first dimension information to obtain a target liveness detection model.
[0005] Secondly, embodiments of this application provide a liveness detection method, comprising: acquiring a target face image to be detected; inputting the target face image to be detected into a trained liveness detection model obtained by the liveness detection model training method of the first aspect for detection processing, and obtaining a liveness detection result corresponding to the target face image to be detected.
[0006] Thirdly, embodiments of this application provide a training apparatus for a liveness detection model, comprising: a model acquisition unit for acquiring an initial lightweight model and a teacher model; a training sample set acquisition unit for acquiring a training sample set, the training sample set including face sample data; a teacher model processing unit for inputting the face sample data into the teacher model for processing to obtain first dimension information; and an initial lightweight model processing unit for inputting the face sample data into the initial lightweight model and training it based on the first dimension information to obtain a target liveness detection model.
[0007] Fourthly, embodiments of this application provide a door lock system, including: an imaging module for acquiring a face image to be identified; and a processor for inputting the face image to be identified into a liveness detection model for detection processing to obtain a liveness detection result corresponding to the face image to be identified in order to control the lock to open or close; wherein the liveness detection model is trained by the training method of the liveness detection model as described in the first aspect above.
[0008] Fifthly, embodiments of this application provide a training device for a liveness detection model, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the method described in the first aspect above.
[0009] In a sixth aspect, embodiments of this application provide a liveness detection device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method described in the second aspect above.
[0010] In a seventh aspect, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method as described in the first aspect or the second aspect above.
[0011] In this embodiment, on one hand, an initial lightweight model and a teacher model are obtained; a training sample set, including face sample data, is obtained; the face sample data is input into the teacher model for processing to obtain first-dimensional information; the face sample data is input into the initial lightweight model and trained based on the first-dimensional information to obtain the target liveness detection model. In the above scheme, the liveness detection model is trained based on knowledge distillation, transferring knowledge from the teacher model with a large number of parameters trained on a large dataset to the initial lightweight model with a small number of parameters. This results in better real / fake detection performance with less computation and faster speed, making the trained liveness detection model more lightweight, smaller, and faster inference. Furthermore, since knowledge distillation is used to determine the loss function based on the features of both models for training, the accuracy of the liveness detection model in judging fakes is greatly improved, resulting in a better user experience during liveness detection.
[0012] On the other hand, the target face image to be detected is acquired; the target face image to be detected is input into the trained liveness detection model obtained by the liveness detection model training method as described in the first aspect for detection processing, and the liveness detection result corresponding to the target face image to be detected is obtained. In the above scheme, the liveness detection model trained by the liveness detection model training method of the first aspect is used for liveness detection. Since this model is a lightweight model, it is smaller, inference is faster, and the liveness detection speed is faster. Furthermore, since this model uses knowledge distillation to determine the loss function based on the features of two models, thereby training the model, the accuracy of the liveness detection model in judging fakes is greatly improved when performing liveness recognition, and the user experience is also better. Attached Figure Description
[0013] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0014] Figure 1 A schematic diagram of a door lock system is provided in the first embodiment of this application;
[0015] Figure 2 This is a schematic flowchart of a liveness detection method provided in the second embodiment of this application;
[0016] Figure 3 This is a schematic diagram of a training device for a liveness detection model provided in the third embodiment of this application;
[0017] Figure 4 This is a schematic flowchart of a training method for a liveness detection model provided in the fourth embodiment of this application;
[0018] Figure 5 This is a schematic diagram of the structure of the initial lightweight model in the training method of a liveness detection model provided in the fourth embodiment of this application;
[0019] Figure 6 This is a detailed schematic flowchart of S104 in the training method of a liveness detection model provided in the fourth embodiment of this application;
[0020] Figure 7 This is a schematic diagram of a training device for a liveness detection model provided in the fifth embodiment of this application. Detailed Implementation
[0021] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0022] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0023] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0024] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."
[0025] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0026] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0027] Please see Figure 1 , Figure 1 A schematic diagram of a door lock system is provided in the first embodiment of this application. (See diagram below.) Figure 1As shown, the door lock device 10 in this embodiment includes an imaging module 101, a processor 102, and a lock body 103. The imaging module 101 is used to acquire an image of a face to be identified and transmit it to the processor 102. After receiving the image of the face to be identified, the processor 102 inputs the image of the face to be identified into a liveness detection model for detection processing, and obtains the liveness detection result corresponding to the image of the face to be identified in order to control the lock body 103 to open or close.
[0028] In one embodiment, the imaging module 101 may be a 2D imaging module, and the acquired face image may be a 2D image. The 2D imaging module includes an infrared (IR) camera, and the acquired 2D image may be an infrared (IR) image.
[0029] In one embodiment, the imaging module 101 may be a 3D imaging module, with an infrared floodlight installed on the 3D imaging module. When the infrared floodlight is lit, the infrared IR camera in the 3D imaging module acquires the floodlight IR image.
[0030] The processor 102 performs face matting and fusion processing on the aforementioned IR image to obtain a face image to be identified, and inputs the face image to be identified into a liveness detection model for detection processing to obtain a liveness detection result corresponding to the face image to be identified. The processor 102 controls the lock to open or close based on the liveness detection result. The door lock device 10 also includes a register 104, which stores a pre-trained liveness detection model for the processor 102 to call. The liveness detection method corresponding to this liveness detection model can be found in the relevant description of the second embodiment.
[0031] Please see Figure 2 , Figure 2 This is a schematic flowchart of a liveness detection method provided in the second embodiment of this application. In this embodiment, the execution entity of the liveness detection method is the processor in the aforementioned door lock system; this method can also be applied to other related electronic devices. For example... Figure 2 The liveness detection method shown may include:
[0032] S201: Obtain the target face image to be detected.
[0033] The processor acquires the target face image to be detected. The target face image to be detected can be an image of the target being detected captured by the imaging module in the first embodiment and then processed to obtain a face image. The target face image to be detected generally includes a face, and the face here is not limited to a live object or a prosthetic.
[0034] S202: Input the target face image to be detected into the liveness detection model for detection processing to obtain the liveness detection result corresponding to the target face image to be detected.
[0035] The liveness detection model in this embodiment is obtained through training. For a description of the corresponding training method, please refer to the embodiment of the training method for the liveness detection model in the fourth embodiment below, which will not be elaborated here.
[0036] The target face image to be detected is input into a liveness detection model for processing, yielding a liveness detection result. Specifically, the processor obtains the target face image and calls the pre-trained liveness detection model in its registers. The model processes the input of the target face image to be detected, obtaining a target feature map. This target feature map is a matrix, and its mean value indicates the liveness detection result. For example, the target feature map can be a 14×14 matrix, and its mean value is the sum of the 196 values in the matrix divided by 196. If the mean value of the target feature map is greater than a preset threshold, the liveness detection result is "live"; if the mean value is less than or equal to the preset threshold, the liveness detection result is "sham".
[0037] In one embodiment, in order to obtain high-precision liveness detection results, the liveness detection model in this embodiment can be equipped with a feature fusion module. The liveness detection model includes a fourth feature extraction module, a fifth feature extraction module, a sixth feature extraction module, and a second feature fusion module.
[0038] Specifically, during training, the liveness detection model first constructs an initial lightweight model, then trains this initial lightweight model to obtain the final liveness detection model. The initial lightweight model can be constructed according to predefined modules, which may include three convolutional modules, three pooling modules, three downsampling modules, and one feature fusion module. Each convolutional module and its corresponding pooling module, after training, constitutes a feature extraction module. The three convolutional modules and their corresponding three pooling modules, after training, yield the fourth, fifth, and sixth feature extraction modules in the liveness detection model.
[0039] Specifically, the processor controls the input of the face image to be recognized into the fourth feature extraction module for processing, obtaining the fourth low-dimensional information. This fourth low-dimensional information is automatically input into the fifth feature extraction module for processing, obtaining the fourth medium-dimensional information. The fourth medium-dimensional information is automatically input into the sixth feature extraction module for processing, obtaining the fourth high-dimensional information. Further, the fourth low-dimensional information, the fourth medium-dimensional information, and the fourth high-dimensional information are downsampled respectively, yielding the fifth low-dimensional information, the fifth medium-dimensional information, and the fifth high-dimensional information. The second feature fusion module concatenates the fifth low-dimensional information, the fifth medium-dimensional information, and the fifth high-dimensional information along the channel dimension to obtain target fusion information. Based on the fusion information, the target feature map corresponding to the face image to be recognized is determined. The mean of the target feature map can determine the liveness detection result corresponding to the face image to be recognized. The liveness detection result can be used to determine whether the lock is opened or closed.
[0040] In one embodiment, each feature extraction module includes multiple convolutional layers and at least one pooling layer. The more convolutional layers there are, the richer the features can be extracted, and the higher the completeness of the features extracted by the neural network.
[0041] Furthermore, the downsampling module reduces the fourth low-dimensional information, the fourth medium-dimensional information, and the fourth high-dimensional information to obtain the corresponding fifth low-dimensional information, the fifth medium-dimensional information, and the fifth high-dimensional information. The downsampling module includes multiple convolutional layers.
[0042] In this embodiment, a target face image to be detected is acquired. This target face image is then input into a trained liveness detection model obtained using the liveness detection model training method described in the fourth embodiment for detection processing, resulting in a liveness detection result corresponding to the target face image. Because this model is lightweight, it is smaller, inference is faster, and liveness detection is faster. Furthermore, since this model uses knowledge distillation to determine the loss function based on the features of two models for training, it significantly improves the accuracy of the liveness detection model in identifying fake faces, resulting in a better user experience.
[0043] Please see Figure 3 , Figure 3 This is a schematic diagram of a training device for a liveness detection model provided in the third embodiment of this application, which can be used to train the liveness detection model. Figure 3As shown, the training device 3 for the liveness detection model in this embodiment includes a processor 30, a memory 31, and a computer program 32 stored in the memory 31 and executable on the processor 30, such as a training program for the liveness detection model. When the processor 30 executes the computer program 32, it implements the steps in the liveness detection model training method embodiment. The training device 3 for the liveness detection model can be a server, a PC, etc., and is not particularly limited here.
[0044] The training device 3 for the liveness detection model may include, but is not limited to, a processor 30 and a memory 31. Those skilled in the art will understand that... Figure 3 This is merely an example of a training device 3 for a liveness detection model and does not constitute a limitation on the training device 3 for a liveness detection model. It may include more or fewer components than shown in the figure, or combine certain components, or different components. For example, the training device 3 for a liveness detection model may also include input / output devices, network access devices, buses, etc.
[0045] The processor 30 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.
[0046] The memory 31 can be an internal storage unit of the training device 3 for the liveness detection model, such as a hard disk or RAM. The memory 31 can also be an external storage device of the training device 3 for the liveness detection model, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc., equipped on the training device 3 for the liveness detection model. Furthermore, the training device 3 for the liveness detection model can include both internal and external storage units. The memory 31 is used to store the computer program and other programs and data required by the training device for the liveness detection model. The memory 31 can also be used to temporarily store data that has been output or will be output.
[0047] The training device 3 for the liveness detection model is used to train the liveness detection model. For a specific training method for the liveness detection model, please refer to the training method for the liveness detection model provided in the fourth embodiment below.
[0048] Please see Figure 4 , Figure 4 This is a schematic flowchart illustrating a training method for a liveness detection model provided in the fourth embodiment of this application. In this embodiment, the execution entity of the liveness detection model training method is a device with liveness detection model training capabilities. The trained liveness detection model can be ported to a door lock system. For example... Figure 4 The training methods for the liveness detection model shown may include:
[0049] S401: Obtain the initial lightweight model and the teacher model.
[0050] The device acquires an initial lightweight model. In this embodiment, the initial lightweight model is the student network model. The initial lightweight model is used to train the final required liveness detection model.
[0051] In building the initial lightweight model, it can be constructed based on predefined modules, such as... Figure 5 As shown, Figure 5 This is a schematic diagram of the initial lightweight model. The initial lightweight model is pre-defined to include three convolutional modules, three pooling modules, three downsampling modules, and one feature fusion module. According to... Figure 5 The structure in the model is used to construct an initial lightweight model.
[0052] The device acquires a teacher model, which is used to guide the training of the initial lightweight model. Compared to the initial lightweight model, the teacher model offers superior performance and higher accuracy, but it has a more complex structure with more channels and slower computation speed. For example, the initial lightweight model can be the Unet initial lightweight model (Unet is the most commonly used and simplest segmentation model; it is simple, efficient, easy to understand, and easy to build, and can be trained on small datasets), and the teacher model is the Unet teacher model. The number of basic residual modules in the Unet teacher model is greater than that in the Unet initial lightweight model; the number of convolutions in the basic residual modules of the Unet teacher model is also greater than that in the basic residual modules of the Unet initial lightweight model.
[0053] In one embodiment, the number of channels in the teacher model can be a multiple of the number of channels in the initial lightweight model. For example, the number of channels in the teacher model can be 128, while the number of channels in the initial lightweight model is 32, meaning the number of channels in the teacher model is four times that of the initial lightweight model.
[0054] The teacher model should perform the same function as the initial lightweight model. That is, both the teacher model and the initial lightweight model are used for liveness detection and output information identifying the liveness detection results.
[0055] S402: Obtain the training sample set, which includes face sample data.
[0056] The device acquires a training sample set, which includes face sample data. This face sample data can be images containing faces, and these faces are not limited to live or prosthetic faces. Prosthetic faces can include 2D-printed faces, plastic masks, resin masks, silicone head molds, etc. It is understood that acquiring liveness sample data can obtain faces from people of different races, ages, and genders to improve the accuracy of liveness detection.
[0057] Furthermore, the training sample set can also include feature map labels corresponding to face sample data; the mean of the feature map labels indicates the liveness detection result of the face sample data. Here, the feature map label is a feature map consisting entirely of 0s or 1s, which can also be understood as a matrix consisting entirely of 0s or 1s. The mean of the feature map labels indicates the liveness detection result of the face sample data; the mean of an all-0s matrix indicates that the liveness detection result of the face sample data is a fake, and the mean of an all-1s matrix indicates that the liveness detection result of the face sample data is a live person.
[0058] It is understandable that the more face sample data and their corresponding feature map labels there are in the training set, and the more diverse the types of face sample data and their corresponding feature map labels, the higher the accuracy of the detection results of the trained model.
[0059] It should be noted that in this embodiment, both the teacher model and the initial lightweight model are trained using the same face sample data and their corresponding feature map labels. This allows for the transfer of knowledge from the teacher model, which has a large number of parameters and is trained on a large dataset, to the initial lightweight model, which has a small number of parameters.
[0060] S403: Input the face sample data into the teacher model for processing to obtain the first dimension information.
[0061] The device inputs facial sample data into the teacher model for processing, obtaining the first dimension information. This first dimension information refers to the array extracted by the feature extraction module during the processing of the facial sample data into the teacher model; this array represents the features of that dimension. For example, if the teacher model uses multiple interconnected feature extraction modules, each module can sequentially obtain at least the first, second, and third features. The dimensions of the first, second, and third features are different, corresponding to low, medium, and high dimensions, respectively. Therefore, the first dimension information includes the first, second, and third features.
[0062] S404: Input the face sample data into the initial lightweight model and train it based on the first dimension information to obtain the target liveness detection model.
[0063] Face sample data is input into the initial lightweight model for processing. Based on the first dimension information, the model is trained. The knowledge from the teacher model with a large number of parameters trained on a large dataset is transferred to the initial lightweight model with a small number of parameters, and the target liveness detection model is obtained.
[0064] Specifically, the training sample set also includes feature map labels corresponding to face sample data; the mean of the feature map labels indicates the liveness detection result of the face sample data, such as... Figure 6 As shown, S404 can include S4041-S4045, and S4041-S4045 are as follows:
[0065] S4041: Input the face sample data into the initial lightweight model for processing to obtain the second dimension information and the target feature map corresponding to the face sample data.
[0066] In this embodiment, the device inputs the face sample data processed by the teacher model into the initial lightweight model for further processing, obtaining the second-dimensional information and the target feature map corresponding to the face sample data. Specifically, the device inputs the face sample data into the initial lightweight model for processing to obtain the target feature map corresponding to the face sample data output by the teacher model.
[0067] The second dimension information refers to the dimensional features extracted by the feature extraction module during the process of inputting face sample data into the initial lightweight model for processing.
[0068] For information on the second dimension and the target feature map, please refer to the relevant description of the first dimension and the first feature map in S103, which will not be repeated here.
[0069] Specifically, in one implementation, to better learn the features of real and fake objects during the training process and obtain a high-precision liveness detection model, the initial lightweight model in this embodiment can be equipped with a feature fusion module to perform multi-scale feature fusion on the learned features. The second information includes second low-dimensional information, second medium-dimensional information, and second high-dimensional information; the initial lightweight model includes a first feature extraction module, a second feature extraction module, a third feature extraction module, and a first feature fusion module.
[0070] It is understandable that shallow networks extract low-dimensional features, while deep networks extract high-dimensional features. Although the number of channels remains the same, the network becomes deeper and extracts high-dimensional features. Therefore, after three convolutions, low-dimensional, medium-dimensional, and high-dimensional features are obtained respectively.
[0071] Specifically, the face sample data is input into the first feature extraction module for processing to obtain the second low-dimensional information; the second low-dimensional information is input into the second feature extraction module for processing to obtain the second medium-dimensional information; the second medium-dimensional information is input into the third feature extraction module for processing to obtain the second high-dimensional information; the second low-dimensional information, the second medium-dimensional information, and the second high-dimensional information are downsampled respectively to obtain the third low-dimensional information, the third medium-dimensional information, and the third high-dimensional information; based on the first feature fusion module, the third low-dimensional information, the third medium-dimensional information, and the third high-dimensional information are concatenated along the channel dimension to obtain fused dimension information, and the target feature map corresponding to the face sample data is determined based on the fused dimension information.
[0072] In one embodiment, each feature extraction module includes at least multiple convolutional layers and at least one pooling layer. The more convolutional layers there are, the richer the features that can be extracted, and the higher the completeness of the features extracted by the neural network.
[0073] Furthermore, the second low-dimensional information, the second medium-dimensional information, and the second high-dimensional information need to be reduced in dimensionality by the downsampling module to obtain the corresponding third low-dimensional information, third medium-dimensional information, and third high-dimensional information. The downsampling module includes multiple convolutional layers to reduce the dimensionality of the second low-dimensional information, the second medium-dimensional information, and the second high-dimensional information.
[0074] To better learn the features of real and fake objects during training and obtain a high-precision liveness detection model, the teacher model can also be equipped with a feature fusion module to perform multi-scale feature fusion on the learned features. The process of setting up a feature fusion module in the teacher model to perform multi-scale feature fusion on the learned features can be found in the description above regarding setting up a feature fusion module in the initial lightweight model to perform multi-scale feature fusion on the learned features; it will not be repeated here.
[0075] S4042: Calculate the first target loss value based on the first dimension information, the second dimension information, the target feature map, the feature map label corresponding to the face sample data, and the first preset loss function.
[0076] The first target loss value is calculated using the device's first-dimensional information, second-dimensional information, target feature map, feature map labels corresponding to the face sample data, and a first preset loss function. In other words, in this embodiment, when calculating the first target loss value, the error is calculated using the target feature map and the feature map labels corresponding to the face sample data. The similarity between the first-dimensional information and the second-dimensional information is also calculated. The first target loss value is calculated using both the error and the similarity, ensuring that the initial lightweight model inherits as much of the teacher model's ability to distinguish between real and fake objects as possible.
[0077] Specifically, feature similarity is calculated on the first and second dimension information to obtain target similarity information. The target mean square error is calculated based on the feature map labels corresponding to the target feature map and the face sample data. The first target loss value is obtained based on the target similarity information and the target mean square error.
[0078] It should be noted that the first preset loss function can be the cross-entropy loss function, and there are no restrictions here.
[0079] Similarity information can be determined by calculating cosine similarity, and the degree of similarity between the first and second dimension information can be judged by calculating the cosine value of the first dimension information and the second dimension information.
[0080] In one implementation, both the initial lightweight model and the teacher model are equipped with a feature fusion module. The first-dimensional information and the second-dimensional information both contain features of different dimensions. The first-dimensional information includes first low-dimensional information, first mid-dimensional information, and first high-dimensional information; the second-dimensional information includes second low-dimensional information, second mid-dimensional information, and second high-dimensional information; the target similarity information includes first similarity information, second similarity information, and third similarity information.
[0081] When calculating the feature similarity between the first and second dimension information, the following method can be used: calculate the feature similarity between the first low-dimensional information and the second low-dimensional information to obtain the first similarity information; calculate the feature similarity between the first mid-dimensional information and the second mid-dimensional information to obtain the second similarity information; calculate the feature similarity between the first high-dimensional information and the second high-dimensional information to obtain the third similarity information. That is, by calculating the similarity of features in different dimensions, the target similarity information between the first and second dimension information is finally obtained.
[0082] S4043: Determine whether the loss value of the first target is less than the preset threshold.
[0083] The device has a preset threshold value, which is used to determine whether to stop training. This threshold value can be set according to the user's requirements for the model's accuracy. The device determines whether the first target loss value is less than the preset threshold value.
[0084] S4044: If the first target loss value is less than the preset threshold, stop training and use the current initial lightweight model as the liveness detection model.
[0085] If the first target loss value is less than a preset threshold, training stops, and the current initial lightweight model is used as the liveness detection model. The process of transferring knowledge from the teacher model with a large number of parameters trained on a large dataset to the initial lightweight model with a small number of parameters is called knowledge distillation. When deploying to the terminal, only the knowledge-distilled initial lightweight model is used, and the feature map output by the initial lightweight model is used to determine the liveness detection result.
[0086] S4045: If the first target loss value is greater than or equal to the preset threshold, the initial lightweight model is updated according to the first target loss value, and then S4041 is executed.
[0087] If the first target loss value is greater than or equal to the preset threshold, it means that the current training is not completed. Then, the initial lightweight model is updated according to the first target loss value, and S4041 is returned to be executed. At this time, the initial lightweight model in S4041 is the updated initial lightweight model, that is, a new round of training is started.
[0088] In this embodiment, an initial lightweight model, a teacher model, and a training sample set are first obtained. The training sample set includes face sample data. Then, the face sample data is input into the teacher model for processing to obtain the first dimension information. The face sample data is also input into the initial lightweight model, and training is performed based on the first dimension information to obtain the target liveness detection model. In the above scheme, the liveness detection model is trained based on knowledge distillation. This transfers knowledge from the teacher model, trained on a large dataset with a large number of parameters, to the initial lightweight model with a small number of parameters. This results in better real / fake detection performance with less computation and faster speed, making the trained liveness detection model more lightweight, smaller, and faster inference. Furthermore, because knowledge distillation is used to determine the loss function based on the features of both models for training, the accuracy of the liveness detection model in detecting fakes is greatly improved, resulting in a better user experience during liveness detection.
[0089] Please see Figure 7 , Figure 7This is a schematic diagram of a training apparatus for a liveness detection model provided in the fifth embodiment of this application. Each unit included is used to perform the steps in the liveness detection model training method embodiment. For ease of explanation, only the parts relevant to this embodiment are shown. See also... Figure 7 The training device 7 for the liveness detection model includes:
[0090] The model acquisition unit 710 is used to acquire the initial lightweight model and the teacher model;
[0091] The training sample set acquisition unit 720 is used to acquire the training sample set, which includes face sample data.
[0092] The teacher model processing unit 730 is used to input face sample data into the teacher model for processing to obtain the first dimension information;
[0093] The initial lightweight model processing unit 740 is used to input face sample data into the initial lightweight model and train it based on the first dimension information to obtain the target liveness detection model.
[0094] The training device 7 for the liveness detection model is used to complete the training method for the liveness detection model as described in Embodiment 4. The specific process is the same as in the method embodiment and will not be described in detail here. This application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the steps in the various method embodiments described above.
[0095] This application provides a computer program product that, when run on a mobile terminal, enables the mobile terminal to implement the steps described in the above-described method embodiments.
[0096] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or some intermediate form. The computer-readable medium can include at least: any entity or device capable of carrying the computer program code to a photographing device / terminal device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electrical carrier signals or telecommunication signals.
[0097] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0098] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0099] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0100] In the embodiments provided in this application, it should be understood that the disclosed apparatus / network devices and methods can be implemented in other ways. For example, the apparatus / network device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0101] The unit described as a separate component may or may not be physically separate. The component shown as a unit may or may not be a physical unit; that is, it may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0102] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A training method for a liveness detection model, characterized in that, include: Obtain an initial lightweight model and a teacher model; the initial lightweight model includes a first feature extraction module, a second feature extraction module, a third feature extraction module, and a first feature fusion module; Obtain a training sample set, which includes face sample data; the training sample set also includes feature map labels corresponding to the face sample data; The mean value of the feature map labels indicates the liveness detection result of the face sample data; The face sample data is input into the teacher model for processing to obtain the first dimension information; The face sample data is input into the initial lightweight model, and trained based on the first dimension information to obtain a target liveness detection model, including: The face sample data is input into the initial lightweight model for processing to obtain the second dimension information and the target feature map corresponding to the face sample data; The first target loss value is calculated based on the first dimension information, the second dimension information, the target feature map, the feature map label corresponding to the face sample data, and the first preset loss function; Determine whether the first target loss value is less than a preset threshold; If the first target loss value is less than a preset threshold, training is stopped, and the current initial lightweight model is used as the liveness detection model. If the first target loss value is greater than or equal to the preset threshold, the initial lightweight model is updated according to the first target loss value, and the process of inputting the face sample data into the initial lightweight model for processing is returned to obtain the second dimension information and the target feature map corresponding to the face sample data. The step of inputting the face sample data into the initial lightweight model for processing to obtain the second dimension information and the target feature map corresponding to the face sample data includes: The face sample data is input into the first feature extraction module for processing to obtain the second low-dimensional information; The second low-dimensional information is input into the second feature extraction module for processing to obtain the second medium-dimensional information. The second intermediate dimension information is input into the third feature extraction module for processing to obtain the second high-dimensional dimension information; The second low-dimensional information, the second medium-dimensional information, and the second high-dimensional information are downsampled respectively to obtain the third low-dimensional information, the third medium-dimensional information, and the third high-dimensional information respectively. Based on the first feature fusion module, the third low-dimensional information, the third medium-dimensional information, and the third high-dimensional information are concatenated in the channel dimension to obtain fused dimension information, and the target feature map corresponding to the face sample data is determined according to the fused dimension information; wherein, the target feature map is a matrix, and the mean of the target feature map is used to identify the result of liveness detection.
2. The training method for the liveness detection model as described in claim 1, characterized in that, The step of calculating the first target loss value based on the first dimension information, the second dimension information, the target feature map, the feature map label corresponding to the face sample data, and the first preset loss function includes: Feature similarity is calculated on the first dimension information and the second dimension information to obtain target similarity information; The target mean square error is calculated based on the target feature map and the feature map labels corresponding to the face sample data; The first target loss value is obtained based on the target similarity information and the target mean square error.
3. The training method for the liveness detection model as described in claim 2, characterized in that, The first dimension information includes a first low-dimensional dimension information, a first medium-dimensional dimension information, and a first high-dimensional dimension information; the second dimension information includes a second low-dimensional dimension information, a second medium-dimensional dimension information, and a second high-dimensional dimension information; the target similarity information includes first similarity information, second similarity information, and third similarity information. The step of calculating feature similarity between the first dimension information and the second dimension information to obtain target similarity information includes: The first similarity information is obtained by calculating the feature similarity between the first low-dimensional information and the second low-dimensional information. The feature similarity is calculated between the first and second mid-dimensional information to obtain the second similarity information; The third similarity information is obtained by calculating the feature similarity between the first high-dimensional information and the second high-dimensional information.
4. A method for detecting liveness, characterized in that, include: Acquire the target face image to be detected; The target face image to be detected is input into the trained liveness detection model obtained by the liveness detection model training method as described in any one of claims 1-3, and the liveness detection result corresponding to the target face image to be detected is obtained.
5. The live detection method as described in claim 4, characterized in that, The liveness detection model includes a fourth feature extraction module, a fifth feature extraction module, a sixth feature extraction module, and a second feature fusion module; The step of inputting the target face image to be detected and processing it using the liveness detection model to obtain the liveness detection result corresponding to the target face image to be detected includes: The target face image to be detected is input into the fourth feature extraction module for processing to obtain the fourth low-dimensional information. The fourth low-dimensional information is input into the fifth feature extraction module for processing to obtain the fourth medium-dimensional information. The fourth intermediate dimension information is input into the sixth feature extraction module for processing to obtain the fourth high-dimensional dimension information; The fourth low-dimensional information, the fourth medium-dimensional information, and the fourth high-dimensional information are downsampled respectively to obtain the fifth low-dimensional information, the fifth medium-dimensional information, and the fifth high-dimensional information respectively. Based on the second feature fusion module, the fifth low-dimensional information, the fifth medium-dimensional information and the fifth high-dimensional information are spliced together in the channel dimension to obtain target fusion information, and the target feature map corresponding to the target face image to be detected is determined according to the fusion information. The liveness detection result corresponding to the target face image to be detected is determined based on the mean of the target feature map.
6. A training device for a liveness detection model, characterized in that, include: The model acquisition unit is used to acquire an initial lightweight model and a teacher model; the initial lightweight model includes a first feature extraction module, a second feature extraction module, a third feature extraction module, and a first feature fusion module; A training sample set acquisition unit is used to acquire a training sample set, which includes face sample data; the training sample set also includes feature map labels corresponding to the face sample data. The mean value of the feature map labels indicates the liveness detection result of the face sample data; The teacher model processing unit is used to input the face sample data into the teacher model for processing to obtain the first dimension information; An initial lightweight model processing unit is used to input the face sample data into the initial lightweight model and train it based on the first dimension information to obtain a target liveness detection model, including: The face sample data is input into the initial lightweight model for processing to obtain the second dimension information and the target feature map corresponding to the face sample data; The first target loss value is calculated based on the first dimension information, the second dimension information, the target feature map, the feature map label corresponding to the face sample data, and the first preset loss function; Determine whether the first target loss value is less than a preset threshold; If the first target loss value is less than a preset threshold, training is stopped, and the current initial lightweight model is used as the liveness detection model. If the first target loss value is greater than or equal to the preset threshold, the initial lightweight model is updated according to the first target loss value, and the process of inputting the face sample data into the initial lightweight model for processing is returned to obtain the second dimension information and the target feature map corresponding to the face sample data. The step of inputting the face sample data into the initial lightweight model for processing to obtain the second dimension information and the target feature map corresponding to the face sample data includes: The face sample data is input into the first feature extraction module for processing to obtain the second low-dimensional information; The second low-dimensional information is input into the second feature extraction module for processing to obtain the second medium-dimensional information. The second intermediate dimension information is input into the third feature extraction module for processing to obtain the second high-dimensional dimension information; The second low-dimensional information, the second medium-dimensional information, and the second high-dimensional information are downsampled respectively to obtain the third low-dimensional information, the third medium-dimensional information, and the third high-dimensional information respectively. Based on the first feature fusion module, the third low-dimensional information, the third medium-dimensional information, and the third high-dimensional information are concatenated in the channel dimension to obtain fused dimension information, and the target feature map corresponding to the face sample data is determined according to the fused dimension information; wherein, the target feature map is a matrix, and the mean of the target feature map is used to identify the result of liveness detection.
7. A door lock system, characterized in that, include: Imaging module, used to acquire images of the face to be identified; The processor is configured to input the face image to be identified into a liveness detection model for detection processing, and obtain the liveness detection result corresponding to the face image to be identified in order to control the lock to open or close; wherein, the liveness detection model is trained by the training method of the liveness detection model according to any one of claims 1-3.
8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the method as described in any one of claims 1 to 3, or any one of claims 4 to 5.