Biological detection model training method and apparatus
By training a biometric detection model on the terminal side using knowledge distillation technology, the capabilities of a large model are transferred to a small model, solving the problem of computational resource limitations of the biometric detection model on the terminal side and achieving efficient and secure biometric detection results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
- Filing Date
- 2023-08-10
- Publication Date
- 2026-07-10
AI Technical Summary
In information networks, the security of user resource transactions is difficult to guarantee, and existing biometric detection models cannot be effectively deployed on the terminal side, resulting in limitations in computing resources and poor detection results.
By employing knowledge distillation technology, the biological detection capabilities of a large model are transferred to a small model on the terminal side through multiple transfer training processes involving teacher models, intermediate models, and student models. Distributed training using genetic distillation improves the robustness and efficiency of the biological detection model.
It enables the deployment of lightweight biometric detection models on the terminal side, while maintaining or improving the accuracy and robustness of biometric detection, effectively resisting attacks and ensuring the security of user resources.
Smart Images

Figure CN117095206B_ABST
Abstract
Description
Technical Field
[0001] This document relates to the field of data processing technology, and in particular to a method and apparatus for training a biological detection model. Background Technology
[0002] With the development of network and communication technologies, information networks have become an important part of life. More and more users are participating in various services provided by service providers online. As users participate in different services, the data required by the service also varies depending on the service.
[0003] With the development of information networks, users conduct resource transactions and transfers online. Since users' resources are their private property, transactions based on users' resources without their actual confirmation can affect their resource security and consequently increase their distrust of the services. Therefore, improving the security of resource transactions is an increasingly important concern for both service providers and users. Summary of the Invention
[0004] This specification provides one or more embodiments of a biometric detection model training method. The biometric detection model training method includes: acquiring user image samples; inputting the user image samples into a pre-trained teacher model, an intermediate model to be trained, and a student model to be trained for biometric detection, obtaining a first detection result, an intermediate detection result, and a second detection result; calculating a distillation loss based on the first detection result, the intermediate detection result, and the second detection result; and calculating a detection loss based on the second detection result and the user image samples. Adjusting the parameters of the teacher model, the intermediate model, and the student model according to the distillation loss and the detection loss, so that the trained student model is used as the biometric detection model.
[0005] This specification provides one or more embodiments of a biometric detection method, comprising: acquiring an image to be detected; inputting the image to be detected into a biometric detection model for biometric detection; and obtaining a biometric detection result. The biometric detection model includes a student model obtained by knowledge distillation of a pre-trained teacher model, an intermediate model to be trained, and a student model to be trained based on user image samples.
[0006] This specification provides one or more embodiments of a biometric detection model training apparatus, comprising: a sample acquisition module configured to acquire user image samples; a biometric detection module configured to input the user image samples into a pre-trained teacher model, an intermediate model to be trained, and a student model to be trained for biometric detection, obtaining a first detection result, an intermediate detection result, and a second detection result; a loss calculation module configured to calculate a distillation loss based on the first detection result, the intermediate detection result, and the second detection result, and to calculate a detection loss based on the second detection result and the user image samples; and a parameter adjustment module configured to adjust the parameters of the teacher model, the intermediate model, and the student model according to the distillation loss and the detection loss, so as to use the trained student model as a biometric detection model.
[0007] This specification provides one or more embodiments of a biometric detection device, including: an image acquisition module configured to acquire an image to be detected; and a biometric detection module configured to input the image to be detected into a biometric detection model for biometric detection to obtain a biometric detection result. The biometric detection model includes a student model obtained by knowledge distillation of a pre-trained teacher model, an intermediate model to be trained, and a student model to be trained based on user image samples.
[0008] This specification provides one or more embodiments of a biometric detection model training device, comprising: a processor; and a memory configured to store computer-executable instructions, which, when executed, cause the processor to: acquire user image samples; input the user image samples into a pre-trained teacher model, an intermediate model to be trained, and a student model to be trained for biometric detection, obtaining a first detection result, an intermediate detection result, and a second detection result; calculate a distillation loss based on the first detection result, the intermediate detection result, and the second detection result; and calculate a detection loss based on the second detection result and the user image samples; and adjust the parameters of the teacher model, the intermediate model, and the student model according to the distillation loss and the detection loss, so as to use the trained student model as a biometric detection model.
[0009] This specification provides one or more embodiments of a biometric detection device, including: a processor; and a memory configured to store computer-executable instructions, which, when executed, cause the processor to: acquire an image to be detected; input the image to be detected into a biometric detection model for biometric detection, and obtain a biometric detection result. The biometric detection model includes: a student model obtained by knowledge distillation of a pre-trained teacher model, an intermediate model to be trained, and a student model to be trained based on user image samples.
[0010] This specification provides one or more embodiments of a storage medium for storing computer-executable instructions that, when executed by a processor, implement the following process: acquiring user image samples; inputting the user image samples into a pre-trained teacher model, an intermediate model to be trained, and a student model to be trained for biometric detection, obtaining a first detection result, an intermediate detection result, and a second detection result; calculating a distillation loss based on the first detection result, the intermediate detection result, and the second detection result, and calculating a detection loss based on the second detection result and the user image samples; and adjusting the parameters of the teacher model, the intermediate model, and the student model according to the distillation loss and the detection loss, so that the trained student model is used as the biometric detection model.
[0011] This specification provides one or more embodiments of another storage medium for storing computer-executable instructions that, when executed by a processor, implement the following process: acquiring an image to be detected; inputting the image to be detected into a biometric detection model for biometric detection, and obtaining a biometric detection result. The biometric detection model includes a student model obtained by knowledge distillation of a pre-trained teacher model, an intermediate model to be trained, and a student model to be trained based on user image samples. Attached Figure Description
[0012] To more clearly illustrate the technical solutions in one or more embodiments of this specification or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 A schematic diagram of the implementation environment for a biological detection model training method provided in one or more embodiments of this specification;
[0014] Figure 2 A flowchart illustrating a biological detection model training method provided in one or more embodiments of this specification;
[0015] Figure 3 A schematic diagram illustrating a biological detection model training method provided in one or more embodiments of this specification;
[0016] Figure 4 A flowchart illustrating a biological detection model training method applied to a biological detection model training scenario, provided for one or more embodiments of this specification;
[0017] Figure 5A flowchart of a biological detection method provided for one or more embodiments of this specification;
[0018] Figure 6 A flowchart illustrating a biometric detection method for facial recognition payment scenarios, provided in one or more embodiments of this specification.
[0019] Figure 7 A schematic diagram of an embodiment of a biological detection model training device provided in one or more embodiments of this specification;
[0020] Figure 8 A schematic diagram of an embodiment of a biological detection device provided in one or more embodiments of this specification;
[0021] Figure 9 A schematic diagram of a biological detection model training device provided in one or more embodiments of this specification;
[0022] Figure 10 This is a schematic diagram of the structure of a biological detection device provided in one or more embodiments of this specification. Detailed Implementation
[0023] To enable those skilled in the art to better understand the technical solutions in one or more embodiments of this specification, the technical solutions in one or more embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this specification, and not all of the embodiments. Based on one or more embodiments of this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the protection scope of this document.
[0024] The biological detection model training method provided in one or more embodiments of this specification is applicable to the implementation environment of training biological detection models, such as... Figure 1 As shown, the implementation environment includes at least a server 101 for training the biological detection model. The server 101 can be a single server, a server cluster consisting of several servers, or one or more cloud servers in a cloud computing platform, for training the biological detection model.
[0025] Furthermore, the implementation environment may also include a terminal 102, which can be configured as a client for an application. This client can take the form of an application, a subroutine within an application, a service module within an application, or a web application. The terminal 102 is equipped with a biometric detection model for performing biometric detection during biometric identification. The terminal 102 can be a mobile phone, personal computer, tablet computer, e-book reader, VR (Virtual Reality) based information interaction device, in-vehicle terminal, IoT device, wearable smart device, laptop computer, desktop computer, etc. The terminal 102 can also be used to acquire images to be detected.
[0026] In this implementation environment, server 101 trains the biometric detection model based on two knowledge distillation networks during the process. Specifically, user image samples are input into the pre-trained teacher model, the intermediate model to be trained, and the student model to be trained for biometric detection, obtaining a first detection result, an intermediate detection result, and a second detection result. Distillation loss and detection loss are calculated based on the first detection result, the intermediate detection result, the second detection result, and the user image samples. The parameters of the teacher model, the intermediate model, and the student model are adjusted based on the two losses. After training, the trained student model is used as the biometric detection model. In this way, the biometric detection capability of the large model teacher model is distributed and transferred to the small model student model through genetic distillation, so that the student model can be deployed on terminal 102. Moreover, the student model has a more powerful biometric detection capability, reducing the memory of the biometric detection model deployed on terminal 102, and ensuring the biometric detection effect.
[0027] This specification provides one or more embodiments of a biological detection model training method, as follows:
[0028] Reference Figure 2 The biological detection model training method provided in this embodiment specifically includes steps S202 to S208.
[0029] Step S202: Obtain user image samples.
[0030] The user image samples described in this embodiment include user images labeled to indicate whether they are real biological entities; wherein, the label data for real user images can be 1, and the label data for abnormal biological user images can be 0. Optionally, the user images include collected images of the user's real biometric features, such as a real user's face image; during model training, positive and negative samples are needed together to train the model to obtain a better-performing biological detection model, therefore, the user images also include images of the user that are not real; for example, images of user portraits on paper, collected images of mannequins, photos on mobile phones, and collected images of wax figures. Images of real users are positive samples, and images of non-real users are negative samples.
[0031] In specific implementation, during the training of the biological detection model, it is necessary to obtain user image samples for model training; optionally, the user image samples in this embodiment include at least one of the following: user image samples obtained by annotating user images read from the database of related services, and user image samples obtained by annotating user images collected and uploaded by the terminal.
[0032] In one optional implementation of this embodiment, obtaining user image samples includes: obtaining user images; and annotating the user images to obtain user image samples. Optionally, obtaining user images includes: obtaining historical user images from the database of the target service; if the number of historical user images is less than a preset threshold, issuing an image collection reminder; if the number of historical user images is greater than or equal to the preset threshold, identifying the historical user images as user images. Alternatively, obtaining user images can also be implemented as follows: obtaining historical user images from the database of the target service; if real biological user images and abnormal biological user images in the historical user images meet certain conditions, then the historical user images are used as user images; if the conditions are not met, issuing an image collection reminder to collect user images; optionally, the conditions include that the number of real biological user images and the number of abnormal biological user images in the historical user images are greater than a first threshold; optionally, the target service is, for example, a facial recognition service.
[0033] Step S204: Input the user image sample into the pre-trained teacher model, the intermediate model to be trained, and the student model to be trained for biometric detection to obtain the first detection result, the intermediate detection result, and the second detection result.
[0034] In the above steps, user image samples are obtained. In this embodiment, after obtaining user image samples, the biometric detection model is trained based on the user image samples. In order to transfer the biometric detection capabilities of the larger model to the small edge model, so that the small model has more powerful biometric detection capabilities when performing edge biometric detection, in this embodiment, during the training of the biometric detection model, the student model is trained based on the knowledge distillation method to obtain a biometric detection model with smaller memory footprint but stronger biometric detection capabilities.
[0035] The teacher model described in this embodiment includes a pre-trained model with biometric detection capabilities; optionally, the teacher model can be obtained through pre-training based on the user image samples. The intermediate model to be trained and the student model to be trained have the same model structure as the teacher model; optionally, the teacher model, the intermediate model, and the student model to be trained include a feature encoding module and a probability calculation module. The probability calculation module includes a softmax layer. It should be noted that the student model is a lightweight model compared to the teacher model. Through knowledge distillation, this lightweight student model network can achieve the performance of the teacher model. In other words, the size of the student network is smaller than that of the teacher network.
[0036] In practical applications, directly using models that meet the memory requirements of the edge device for biometric detection is difficult to meet service requirements in terms of pass rate and recall rate, and the model cannot be optimized by adding data. In addition, if the model capability is transferred through a single distillation learning, there are certain requirements for the differences between the teacher model and the student model, and it cannot be transferred to a sufficiently robust edge device model.
[0037] Based on this, this embodiment uses genetic distillation to distribute the biometric detection capabilities of a larger model to smaller edge models. That is, by deploying multiple knowledge distillation networks, the capabilities of the teacher model are distributed and progressively transferred to intermediate models, and then from intermediate models to student models. These two transfers are trained synchronously, achieving better biometric detection performance for the edge student models. Optionally, the intermediate model, acting as a student model, establishes distillation learning with the teacher model; the intermediate model, acting as a teacher model, also establishes distillation learning with the student models to be trained.
[0038] In practice, after obtaining user image samples, knowledge distillation is performed on the pre-trained teacher model, the intermediate model to be trained, and the student model to be trained based on the user image samples to obtain the trained student model as a biological detection model for deployment on the edge.
[0039] In the specific execution process, user image samples are input into the pre-trained teacher model, the intermediate model to be trained, and the student model to be trained for biometric detection to obtain the first detection result, the intermediate detection result, and the second detection result.
[0040] To improve the biometric detection capability of the pre-trained teacher model, in one optional implementation of this embodiment, the feature encoding module in the teacher model is determined in the following manner:
[0041] Calculate the number of samples in the user image sample;
[0042] The number of encoding layers in the feature encoding layer is determined based on the number of samples, and the feature encoding module in the teacher model is constructed based on the number of encoding layers in the feature encoding layer.
[0043] To enhance the biometric detection capabilities of the teacher model, the number of feature encoding layers in the teacher model is determined based on the number of user image samples. Feature encoding modules in the teacher model are constructed based on the number of feature encoding layers. In this way, when the number of samples is large enough, more feature encoding layers are deployed for feature encoding, making the obtained sample features more effective, thereby improving the accuracy of probability calculations performed by the probability calculation module based on sample features.
[0044] In specific implementation, during the biometric detection process of inputting user image samples into the pre-trained teacher model, the intermediate model to be trained, and the student model to be trained, the teacher model performs knowledge distillation with the student model using the intermediate model to be trained, and the intermediate model to be trained is used as the teacher model to perform knowledge distillation with the student model. Furthermore, in the knowledge distillation process using the intermediate model to be trained as the teacher model and the student model to be trained, to improve the effectiveness and accuracy of parameter adjustment for both the intermediate model to be trained and the student model to be trained, i.e., for loss calculation, this embodiment sets different distillation temperatures for the student model.
[0045] Based on this, in this embodiment, during the biometric detection process, the teacher model and the intermediate model to be trained respectively input the user image sample into the feature encoding modules of the teacher model and the intermediate model for feature encoding to obtain the sample features of the user image sample; the sample features are then input into the probability calculation modules of the teacher model and the intermediate model for probability calculation to obtain the first detection result output by the probability calculation module of the teacher model and the intermediate detection result output by the probability calculation module of the intermediate model.
[0046] Optionally, the distillation temperature of the probability calculation module of the intermediate model is a first temperature.
[0047] To enable the student model to learn the biometric detection capabilities of the teacher model while also performing more accurate biometric detection on user image samples, in one optional implementation of this embodiment, the student model to be trained performs biometric detection in the following manner:
[0048] The user image sample is input into the feature encoding module for feature encoding to obtain the sample features of the user image sample;
[0049] The sample features are input into a probability calculation module with a distillation temperature of the first temperature to perform probability calculations and obtain soft targets; the sample features are input into a probability calculation module with a distillation temperature of the second temperature to perform probability calculations and obtain hard targets.
[0050] The second detection result includes the soft target and the hard target.
[0051] Specifically, during the biometric detection process, the student model first inputs the user image sample into the feature encoding module for feature encoding to obtain the sample features of the user image sample; then, the sample features are input into the probability calculation module at a distillation temperature of the first temperature for probability calculation to obtain soft targets. In addition, the distillation temperature of the probability calculation module is adjusted to a second temperature, and the sample features are input into the probability calculation module at the second temperature for probability calculation to obtain hard targets. The soft targets and hard targets input from the probability calculation modules at different distillation temperatures are used as the second detection results of the student model.
[0052] For example, the student model includes a feature encoding module and a softmax. When a user image sample is input into the student model, the feature encoding module first encodes the user image sample to obtain the sample features of the user image sample. Then, the sample features are input into a softmax with T=1 for probability calculation to obtain the hard target. Alternatively, the sample features are input into a softmax with T=5 for probability calculation to obtain the soft target.
[0053] It should be noted that the first detection result, the intermediate detection result, and the second detection result are the probabilities of the teacher model, the intermediate model to be trained, and the student model to be trained, respectively, in determining whether the user image sample is a real organism after performing biological detection.
[0054] Step S206: Calculate distillation loss based on the first detection result, the intermediate detection result, and the second detection result; and calculate detection loss based on the second detection result and the user image sample.
[0055] In the above steps, user image samples are input into the pre-trained teacher model, the intermediate model to be trained, and the student model to be trained for biometric detection to obtain a first detection result, an intermediate detection result, and a second detection result. In this step, after obtaining the first detection result, the intermediate detection result, and the second detection result, the training loss is calculated based on the first detection result, the intermediate detection result, the second detection result, and the user image samples. Specifically, in the process of calculating the training loss, the distillation loss is calculated based on the first detection result, the intermediate detection result, and the second detection result, and the detection loss is calculated based on the second detection result and the user image samples.
[0056] To achieve knowledge distillation of the intermediate model by the teacher model, and knowledge distillation of the student model by the intermediate model, this embodiment calculates the distillation loss based on the first detection result, the intermediate detection result, and the second detection result. To improve the biometric detection capabilities of the teacher model, the intermediate model, and the student model to be trained, this embodiment calculates the detection loss based on the second detection result and user image samples. In one optional implementation of this embodiment, the process of calculating the distillation loss based on the first detection result, the intermediate detection result, and the second detection result is implemented in the following way:
[0057] Based on the first detection result and the intermediate detection result, the first distillation loss is calculated;
[0058] The second distillation loss is calculated based on the intermediate detection results and the soft targets in the second detection results;
[0059] The distillation loss is calculated based on the first distillation loss, the second distillation loss, and their respective weights.
[0060] Specifically, in the knowledge distillation process of the teacher model and the intermediate model, the first distillation loss is calculated based on the first detection result output by the teacher model and the intermediate detection result output by the intermediate model, which is to say, the distillation loss of the first knowledge distillation network is calculated based on the first detection result and the intermediate detection result; the second distillation loss is calculated based on the soft target output by the intermediate detection result and the student model to be trained, which is to say, the distillation loss of the second knowledge distillation network is calculated based on the soft target output by the biological detection of the student model to be trained; after obtaining the first distillation loss and the second distillation loss, the distillation loss is calculated according to the first distillation loss, the second distillation loss and their respective weights, which is to say, the distillation loss is calculated according to the distillation loss of the first knowledge distillation network and the distillation loss of the second knowledge distillation network and their respective weights.
[0061] For example, distillation loss It means, including and , and During the calculation process, it can be done through To calculate, where, , , In the calculation process, v is the first detection result. z represents the i-th result in the first detection result; z represents the intermediate detection result. This is the i-th intermediate detection result. In the calculation process, v represents the intermediate detection result, and z represents the soft target in the second detection result. After calculation... and back, ,in, .
[0062] In addition to calculating the distillation loss, to improve the biometric detection capability of the trained biometric detection model, this embodiment also calculates the detection loss based on the second detection result and user image samples; in one optional implementation of this embodiment, the detection loss is calculated in the following manner:
[0063] The detection loss is calculated based on the labeled data of the user image samples and the hard targets in the second detection result.
[0064] Specifically, the detection loss is calculated using the labeled data of user image samples as hard labels and the hard targets in the second detection result.
[0065] For example, detecting loss express, = ;in, = , c represents a hard label, z represents a hard target.
[0066] like Figure 3As shown, taking an intermediate model as an example, the training process of the biometric detection model includes a teacher model, an intermediate model, and a student model. The teacher model and the intermediate model form a first knowledge distillation network, with the intermediate model acting as the student model within the first knowledge distillation network. The intermediate model and the student model form a second knowledge distillation network, with the intermediate model acting as the teacher model within the second knowledge distillation network. After obtaining user image samples, these samples are input into the teacher model, intermediate model, and student model respectively for biometric detection, obtaining soft labels output by the teacher model, soft targets output by the intermediate model, and soft targets and hard targets output by the student model. The first distillation loss is calculated based on the soft labels output by the teacher model and the soft targets output by the intermediate model. The second distillation loss is calculated using the soft targets output by the intermediate model as soft labels and the soft targets output by the student model. Furthermore, the detection loss is calculated using the labeled data of the user image samples as hard labels and the hard targets output by the student model. After calculating the first and second distillation losses, the distillation loss is calculated according to the first distillation loss, its weight, and its weight. Optionally, the sum of the weights of the first and second distillation losses is equal to 1. It should also be noted that the first and second distillation loss weights can be manually set hyperparameters. Initially, the first and second distillation loss weights can be set to 0.5 respectively, and can be adjusted appropriately according to the training situation. Specific adjustment strategies could be to gradually increase the second distillation loss weight or gradually increase the first distillation loss weight; this embodiment does not impose any limitations on this. Optionally, the detection loss can be the entropy loss calculated from the labeled data of the user image samples and the hard targets in the second detection results. In the calculation of the distillation loss, in addition to the calculation based on the above process, more complex comparison learning loss functions (loss functions that calculate the similarity between two features) can be introduced to jointly calculate the distillation loss; this embodiment does not impose any limitations on this.
[0067] Step S208: Adjust the parameters of the teacher model, the intermediate model, and the student model according to the distillation loss and the detection loss, so as to use the trained student model as the biological detection model.
[0068] The biometric detection described in this embodiment includes determining whether the person performing the biometric identification is a real person, rather than relying on technologies such as photos, mobile phones, screens, or masks. Biometric detection is a method for determining the true physiological characteristics of an object in some identity verification scenarios. In facial recognition applications, biometric detection can verify whether the user is a real biological entity by using technologies such as facial landmark localization and facial tracking through combined actions such as blinking, opening the mouth, shaking the head, and nodding. It can effectively resist common attack methods such as photos, videos, face swapping, masks, occlusion, 3D animations, and screen re-capture, thereby helping users identify abnormal recognition behavior and protecting user interests.
[0069] In the above steps, the distillation loss is calculated based on the first detection result, the intermediate detection result, and the second detection result, and the detection loss is calculated based on the second detection result and the user image sample. In this step, the parameters of the teacher model, the intermediate model, and the student model are adjusted based on the calculated distillation loss and the detection loss, and the student model obtained after training is used as the biological detection model.
[0070] To improve the effectiveness of parameter adjustment, in one optional implementation of this embodiment, the following operations are performed during the parameter adjustment of the teacher model, intermediate model, and student model based on distillation loss and detection loss:
[0071] The training loss is calculated based on the distillation loss, the distillation loss weight, the detection loss, and the detection loss weight.
[0072] Based on the training loss, the parameters of the teacher model, the intermediate model, and the student model to be trained are adjusted.
[0073] Specifically, in the process of adjusting the parameters of the teacher model, intermediate model, and student model based on distillation loss and detection loss, the training loss is first calculated based on the distillation loss and detection loss, and then the parameters of the teacher model, intermediate model, and student model are adjusted based on the training loss. During the calculation of the training loss based on the distillation loss and detection loss, the training loss is calculated using the distillation loss, its weight, the detection loss, and its weight.
[0074] Continuing with the previous example, in the calculation... and Then, the training loss L is calculated. ;in It should be noted that, and Hyperparameters can be manually set. The initial weights for distillation loss and detection loss can be set to 0.5 respectively, and can be adjusted according to actual needs. For example, the weight for detection loss can be gradually increased.
[0075] In the specific implementation process, the above method is used to train the model until the model converges, and the trained student model is obtained. The student model is then deployed on the edge as a biometric detection model for biometric detection.
[0076] Furthermore, the above description of the training process of the biological detection model provided in this embodiment is based on the number of intermediate models as one. In this embodiment, in order to perform knowledge distillation more accurately, multiple intermediate models can be set up in parallel during the knowledge distillation process of using intermediate models as student models and teacher models. Each intermediate model learns the ability of different structures of the teacher model, and then multiple intermediate models are used as teacher models and student models to be trained for knowledge distillation.
[0077] In one optional implementation of this embodiment, the user image samples are input into a pre-trained teacher model, an intermediate model to be trained, and a student model to be trained for biometric detection to obtain a first detection result, an intermediate detection result, and a second detection result. This can also be achieved in the following ways:
[0078] The user image samples are input into a pre-trained teacher model, at least one intermediate model to be trained, and a student model to be trained for biometric detection to obtain a first detection result, at least one intermediate detection result, and a second detection result.
[0079] Furthermore, optionally, the process of calculating distillation loss based on the first detection result, the intermediate detection result, and the second detection result is implemented in the following manner:
[0080] Based on the first detection result and the at least one intermediate detection result, at least one first distillation loss is calculated, and based on the at least one first distillation loss, a first target distillation loss is calculated; and,
[0081] Based on the at least one intermediate detection result and the second detection result, at least one second distillation loss is calculated, and based on the at least one second distillation loss, a second target distillation loss is calculated;
[0082] Calculate the distillation loss based on the first target distillation loss and the second target distillation loss.
[0083] Specifically, when there are at least one intermediate model in parallel, user image samples are input into the teacher model, each intermediate model and the student model for biometric detection to obtain a first detection result, at least one intermediate detection result and a second detection result; in the process of calculating distillation loss, a first target distillation loss is calculated based on the first detection result and at least one intermediate detection result, and a second target distillation loss is calculated based on the at least one intermediate detection result and the second detection result, and the distillation loss is calculated based on the first target distillation loss and the second target distillation loss.
[0084] It should be noted that, in the process of calculating the first target distillation loss based on the first detection result and at least one intermediate detection result, at least one first distillation loss is calculated based on the first detection result and each intermediate detection result, and then the first target distillation loss is calculated based on at least one first distillation loss. In the process of calculating the first target distillation loss, it can be calculated based on at least one first distillation loss and its corresponding weight, wherein the sum of the weights corresponding to each first distillation loss is equal to 1.
[0085] Similarly, in the process of calculating the second target distillation loss based on at least one intermediate detection result and the second detection result, at least one second distillation loss is calculated based on at least one intermediate detection result and the second detection result, and then the second target distillation loss is calculated based on at least one second distillation loss. In the process of calculating the second target distillation loss, it can be calculated based on at least one second distillation loss and its corresponding weight, wherein the sum of the weights corresponding to each second distillation loss is equal to 1.
[0086] The aforementioned parallel arrangement of multiple intermediate models means that each intermediate model includes multiple intermediate sub-models. Specifically, in the first knowledge distillation network, the student model comprises multiple intermediate sub-models, and in the second knowledge distillation network, the teacher model comprises multiple intermediate sub-models. Furthermore, besides parallel arrangement of multiple intermediate models, multiple intermediate models can also be arranged sequentially. Taking two sequentially arranged intermediate models as an example, the model training process includes three knowledge distillation networks. The first knowledge distillation network includes the teacher network and the first intermediate model, which is the student model within the first knowledge distillation network. In the second knowledge distillation network, the first intermediate model is the teacher model, and the second intermediate model is the student model. The third knowledge distillation network includes the second intermediate model and the student model, where the second intermediate model is the teacher model within the third knowledge distillation network. Specifically, regardless of the number of knowledge distillation networks, the training loss is similar to that in the case of two knowledge distillation networks, only with an additional layer of distillation loss. The calculation process for the distillation loss of the two knowledge distillation networks described above can be referred to, and this embodiment does not impose further limitations.
[0087] It should also be noted that, in order to obtain a more lightweight student model, multiple knowledge distillation networks can be configured according to actual needs, but this embodiment does not limit this.
[0088] That is, in this embodiment, the number of intermediate models includes at least one model in parallel, as well as at least one model that undergoes knowledge distillation in sequence.
[0089] In the actual implementation process, after training and obtaining the student model as a biometric detection model, the biometric detection model is deployed on the terminal side for biometric detection.
[0090] In one optional implementation of this embodiment, after the biological detection model is trained and obtained, the following operations are performed:
[0091] Acquire the image to be detected;
[0092] The image to be detected is input into a biological detection model for biological detection to obtain biological detection results.
[0093] Optionally, the biometric detection model includes: a student model obtained by knowledge distillation of a pre-trained teacher model, an intermediate model to be trained, and a student model to be trained based on user image samples.
[0094] For example, in a facial recognition verification scenario, after the terminal collects the user's image to be detected, it inputs the image to be detected into a biometric detection model for biometric detection and obtains the biometric detection result. If the biometric detection result is a biometric category, the terminal sends the image to be detected carrying the biometric category to the verification server so that the verification server can match user information based on the image to be detected and determine that the verification is successful if the user information is matched. If the biometric detection result is an abnormal biometric category, the terminal issues an abnormal biometric alert.
[0095] For example, in a facial recognition payment scenario, after the terminal collects the user's image to be detected, it inputs the image into a biometric detection model for biometric detection, obtaining the biometric detection result. If the biometric detection result is a biometric category, the terminal sends the image carrying the biometric category to the payment server. If the image carries a biometric category, the payment server matches the user's account based on the image and processes the payment based on the matched target account. If the biometric detection result is an abnormal biometric category, the terminal issues an abnormal biometric alert. It should be noted that the process of matching the user's account and processing the payment based on the target account can be implemented according to the general logic of facial recognition payment, and will not be elaborated further in this embodiment.
[0096] With the continuous development of facial recognition, biometric detection has become an indispensable part of the facial recognition process. It can effectively intercept attack samples of abnormal biological types. Moreover, with the development of technology, more and more facial recognition systems are migrating to the terminal side for deployment. The limitation of computing resources has brought a negative impact on stable biometric detection.
[0097] Therefore, this embodiment uses a genetic algorithm combined with knowledge distillation to transfer capabilities of the biometric detection model. Without changing the complexity of the biometric detection model deployed on the terminal side, more robust biometric detection capabilities are extracted from a larger model. In order to transfer model capabilities from a larger model, model training is performed based on knowledge distillation. The capabilities of the teacher model are gradually transferred to the intermediate model and then to the student model in a distributed manner, and trained synchronously. Ultimately, the learning model on the terminal side has better biometric detection capabilities.
[0098] In summary, the biological detection model training method provided in this embodiment comprises three models: a teacher model, an intermediate model, and a student model. Distillation learning is established between the teacher model and the intermediate model, and between the intermediate model and the student model. The entire training is conducted through end-to-end multi-task learning, thereby gradually transferring the biological detection capabilities of the teacher model to the student model on the terminal side. This framework is universal and can repeatedly establish multiple sets of genetic relationships, that is, establish multiple knowledge distillations, meaning that the intermediate model includes multiple components. Through overall learning and training, it is possible to transfer the capabilities of a larger model to a smaller model that meets the deployment requirements on the terminal side.
[0099] It should also be noted that the framework provided in this embodiment for transferring the capabilities of the teacher model to the student model through multiple knowledge distillations can be applied not only to the transfer of biological detection capabilities, but also to the transfer of other capabilities, such as risk identification capabilities. This embodiment does not limit this application.
[0100] The following description uses the application of the biological detection model training method provided in this embodiment in a biological detection model training scenario as an example to further illustrate the biological detection model training method provided in this embodiment. (See also...) Figure 4 The biological detection model training method applied to the training scenario of biological detection models includes the following steps.
[0101] Step S402: Obtain user face image samples.
[0102] Step S404: Train the teacher model to be trained based on user face image samples to obtain the pre-trained teacher model.
[0103] Step S406: Input the user's face image sample into the pre-trained teacher model, the intermediate model to be trained, and the student model to be trained for biometric detection to obtain the first detection result, the intermediate detection result, and the second detection result.
[0104] Step S408: Calculate the first distillation loss using the first detection result as the soft label and the intermediate detection result as the soft target.
[0105] Step S410: Calculate the second distillation loss using the intermediate detection result as the soft label and the soft target in the second detection result.
[0106] Step S412: Calculate the detection loss using the labeled data of the user's face image sample as hard labels and the hard targets in the second detection result.
[0107] It should be noted that steps S408, S410 and S412 can be executed simultaneously.
[0108] Step S414: Calculate the distillation loss based on the first distillation loss, the second distillation loss, and their respective weights.
[0109] Step S416: Calculate the training loss based on the distillation loss, detection loss, and their respective weights.
[0110] Step S418: Adjust the parameters of the teacher model, intermediate model, and student model based on the training loss.
[0111] Step S420: Use the trained student model as a biometric detection model.
[0112] It should be noted that after adjusting the parameters of the teacher model, intermediate model and student model based on the training loss in step S418, the process returns to steps S406 to S418 until the model converges.
[0113] One or more embodiments of a biological detection method provided in this specification are as follows:
[0114] The relevant content of the biological detection method provided in this embodiment is similar to the relevant content of the biological detection model training method provided in the above embodiments. When reading this embodiment, please refer to the relevant content of the above embodiments or make adaptive modifications to the relevant content of the above embodiments. This embodiment will not be described in detail here.
[0115] Reference Figure 5 The biological detection method provided in this embodiment specifically includes steps S502 to S504.
[0116] Step S502: Obtain the image to be detected.
[0117] The image to be detected includes a captured image of the user's biometric features; for example, a user's facial image.
[0118] Step S504: Input the image to be detected into the biological detection model for biological detection and obtain the biological detection result.
[0119] In this embodiment, optionally, the biological detection model includes: a student model obtained by knowledge distillation of the pre-trained teacher model, the intermediate model to be trained, and the student model to be trained based on user image samples.
[0120] For example, in a facial recognition verification scenario, after the terminal collects the user's image to be detected, it inputs the image to be detected into a biometric detection model for biometric detection and obtains the biometric detection result. If the biometric detection result is a biometric category, the terminal sends the image to be detected carrying the biometric category to the verification server so that the verification server can match user information based on the image to be detected and determine that the verification is successful if the user information is matched. If the biometric detection result is an abnormal biometric category, the terminal issues an abnormal biometric alert.
[0121] For example, in a facial recognition payment scenario, after the terminal collects the user's image to be detected, it inputs the image into a biometric detection model for biometric detection, obtaining the biometric detection result. If the biometric detection result is a biometric category, the terminal sends the image carrying the biometric category to the payment server. If the image carries a biometric category, the payment server performs user account matching based on the image and processes the payment based on the matched target account. If the biometric detection result is an abnormal biometric category, the terminal issues an abnormal biometric alert. It should be noted that the process of matching user accounts and processing payments based on the target account can be implemented according to the general logic of facial recognition payment, and will not be elaborated further in this embodiment.
[0122] The training process of the biological detection model is explained in detail below.
[0123] Optionally, the biological detection model is trained using the following method:
[0124] User image samples are input into the pre-trained teacher model, the intermediate model to be trained, and the student model to be trained for biometric detection, to obtain the first detection result, the intermediate detection result, and the second detection result.
[0125] Distillation loss is calculated based on the first detection result, the intermediate detection result, and the second detection result; and detection loss is calculated based on the second detection result and the user image sample.
[0126] The parameters of the teacher model, the intermediate model, and the student model are adjusted based on the distillation loss and the detection loss, so that the trained student model can be used as a biological detection model.
[0127] The user image samples described in this embodiment include user images labeled to indicate whether they are real biological entities; wherein, the label data for real user images can be 1, and the label data for abnormal biological user images can be 0. Optionally, the user images include collected images of the user's real biometric features, such as a real user's face image; during model training, positive and negative samples are needed together to train the model to obtain a better-performing biological detection model, therefore, the user images also include images of the user that are not real; for example, images of user portraits on paper, collected images of mannequins, photos on mobile phones, and collected images of wax figures. Images of real users are positive samples, and images of non-real users are negative samples.
[0128] In specific implementation, during the training of the biological detection model, it is necessary to obtain user image samples for model training; optionally, the user image samples in this embodiment include at least one of the following: user image samples obtained by annotating user images read from the database of related services, and user image samples obtained by annotating user images collected and uploaded by the terminal.
[0129] In one optional implementation of this embodiment, obtaining user image samples includes: obtaining user images; and annotating the user images to obtain user image samples. Optionally, obtaining user images includes: obtaining historical user images from the database of the target service; if the number of historical user images is less than a preset threshold, issuing an image collection reminder; if the number of historical user images is greater than or equal to the preset threshold, identifying the historical user images as user images. Alternatively, obtaining user images can also be implemented as follows: obtaining historical user images from the database of the target service; if real biological user images and abnormal biological user images in the historical user images meet certain conditions, then the historical user images are used as user images; if the conditions are not met, issuing an image collection reminder to collect user images; optionally, the conditions include that the number of real biological user images and the number of abnormal biological user images in the historical user images are greater than a first threshold; optionally, the target service is, for example, a facial recognition service.
[0130] After obtaining user image samples, a biometric detection model is trained based on the user image samples. In order to transfer the biometric detection capabilities of the larger model to the small edge model, so that the small model has a more powerful biometric detection capability when performing edge biometric detection, in this embodiment, during the training of the biometric detection model, a student model is trained based on knowledge distillation to obtain a biometric detection model with a smaller memory footprint but stronger biometric detection capabilities.
[0131] The teacher model described in this embodiment includes a pre-trained model with biometric detection capabilities; optionally, the teacher model can be obtained through pre-training based on the user image samples. The intermediate model to be trained and the student model to be trained have the same model structure as the teacher model; optionally, the teacher model, the intermediate model, and the student model to be trained include a feature encoding module and a probability calculation module. The probability calculation module includes a softmax layer. It should be noted that the student model is a lightweight model compared to the teacher model. Through knowledge distillation, this lightweight student model network can achieve the performance of the teacher model. In other words, the size of the student network is smaller than that of the teacher network.
[0132] In practical applications, directly using models that meet the memory requirements of the edge device for biometric detection is difficult to meet service requirements in terms of pass rate and recall rate, and the model cannot be optimized by adding data. In addition, if the model capability is transferred through a single distillation learning, there are certain requirements for the differences between the teacher model and the student model, and it cannot be transferred to a sufficiently robust edge device model.
[0133] Based on this, this embodiment uses genetic distillation to distribute the biometric detection capabilities of a larger model to smaller edge models. That is, by deploying multiple knowledge distillation networks, the capabilities of the teacher model are distributed and progressively transferred to intermediate models, and then from intermediate models to student models. These two transfers are trained synchronously, achieving better biometric detection performance for the edge student models. Optionally, the intermediate model, acting as a student model, establishes distillation learning with the teacher model; the intermediate model, acting as a teacher model, also establishes distillation learning with the student models to be trained.
[0134] In practice, after obtaining user image samples, knowledge distillation is performed on the pre-trained teacher model, the intermediate model to be trained, and the student model to be trained based on the user image samples to obtain the trained student model as a biological detection model for deployment on the edge.
[0135] In the specific execution process, user image samples are input into the pre-trained teacher model, the intermediate model to be trained, and the student model to be trained for biometric detection to obtain the first detection result, the intermediate detection result, and the second detection result.
[0136] To improve the biometric detection capability of the pre-trained teacher model, in one optional implementation of this embodiment, the feature encoding module in the teacher model is determined in the following manner:
[0137] Calculate the number of samples in the user image sample;
[0138] The number of encoding layers in the feature encoding layer is determined based on the number of samples, and the feature encoding module in the teacher model is constructed based on the number of encoding layers in the feature encoding layer.
[0139] To enhance the biometric detection capabilities of the teacher model, the number of feature encoding layers in the teacher model is determined based on the number of user image samples. Feature encoding modules in the teacher model are constructed based on the number of feature encoding layers. In this way, when the number of samples is large enough, more feature encoding layers are deployed for feature encoding, making the obtained sample features more effective, thereby improving the accuracy of probability calculations performed by the probability calculation module based on sample features.
[0140] In specific implementation, during the biometric detection process of inputting user image samples into the pre-trained teacher model, the intermediate model to be trained, and the student model to be trained, the teacher model performs knowledge distillation with the student model using the intermediate model to be trained, and the intermediate model to be trained is used as the teacher model to perform knowledge distillation with the student model. Furthermore, in the knowledge distillation process using the intermediate model to be trained as the teacher model and the student model to be trained, to improve the effectiveness and accuracy of parameter adjustment for both the intermediate model to be trained and the student model to be trained, i.e., for loss calculation, this embodiment sets different distillation temperatures for the student model.
[0141] Based on this, in this embodiment, during the biometric detection process, the teacher model and the intermediate model to be trained respectively input the user image sample into the feature encoding modules of the teacher model and the intermediate model for feature encoding to obtain the sample features of the user image sample; the sample features are then input into the probability calculation modules of the teacher model and the intermediate model for probability calculation to obtain the first detection result output by the probability calculation module of the teacher model and the intermediate detection result output by the probability calculation module of the intermediate model.
[0142] Optionally, the distillation temperature of the probability calculation module of the intermediate model is a first temperature.
[0143] To enable the student model to learn the biometric detection capabilities of the teacher model while also performing more accurate biometric detection on user image samples, in one optional implementation of this embodiment, the student model to be trained performs biometric detection in the following manner:
[0144] The user image sample is input into the feature encoding module for feature encoding to obtain the sample features of the user image sample;
[0145] The sample features are input into a probability calculation module with a distillation temperature of the first temperature to perform probability calculations and obtain soft targets; the sample features are input into a probability calculation module with a distillation temperature of the second temperature to perform probability calculations and obtain hard targets.
[0146] The second detection result includes the soft target and the hard target.
[0147] Specifically, during the biometric detection process, the student model first inputs the user image sample into the feature encoding module for feature encoding to obtain the sample features of the user image sample; then, the sample features are input into the probability calculation module at a distillation temperature of the first temperature for probability calculation to obtain soft targets. In addition, the distillation temperature of the probability calculation module is adjusted to a second temperature, and the sample features are input into the probability calculation module at the second temperature for probability calculation to obtain hard targets. The soft targets and hard targets input from the probability calculation modules at different distillation temperatures are used as the second detection results of the student model.
[0148] For example, the student model includes a feature encoding module and a softmax. When a user image sample is input into the student model, the feature encoding module first encodes the user image sample to obtain the sample features of the user image sample. Then, the sample features are input into a softmax with T=1 for probability calculation to obtain the hard target. Alternatively, the sample features are input into a softmax with T=5 for probability calculation to obtain the soft target.
[0149] It should be noted that the first detection result, the intermediate detection result, and the second detection result are the probabilities of the teacher model, the intermediate model to be trained, and the student model to be trained, respectively, in determining whether the user image sample is a real organism after performing biological detection.
[0150] After obtaining the first detection result, intermediate detection result, and second detection result, the training loss is calculated based on the first detection result, intermediate detection result, second detection result, and user image samples. Specifically, in the process of calculating the training loss, the distillation loss is calculated based on the first detection result, intermediate detection result, and second detection result, and the detection loss is calculated based on the second detection result and user image samples.
[0151] To achieve knowledge distillation of the intermediate model by the teacher model, and knowledge distillation of the student model by the intermediate model, this embodiment calculates the distillation loss based on the first detection result, the intermediate detection result, and the second detection result. To improve the biometric detection capabilities of the teacher model, the intermediate model, and the student model to be trained, this embodiment calculates the detection loss based on the second detection result and user image samples. In one optional implementation of this embodiment, the process of calculating the distillation loss based on the first detection result, the intermediate detection result, and the second detection result is implemented in the following way:
[0152] Based on the first detection result and the intermediate detection result, the first distillation loss is calculated;
[0153] The second distillation loss is calculated based on the intermediate detection results and the soft targets in the second detection results;
[0154] The distillation loss is calculated based on the first distillation loss, the second distillation loss, and their respective weights.
[0155] Specifically, in the knowledge distillation process of the teacher model and the intermediate model, the first distillation loss is calculated based on the first detection result output by the teacher model and the intermediate detection result output by the intermediate model, which is to say, the distillation loss of the first knowledge distillation network is calculated based on the first detection result and the intermediate detection result; the second distillation loss is calculated based on the soft target output by the intermediate detection result and the student model to be trained, which is to say, the distillation loss of the second knowledge distillation network is calculated based on the soft target output by the biological detection of the student model to be trained; after obtaining the first distillation loss and the second distillation loss, the distillation loss is calculated according to the first distillation loss, the second distillation loss and their respective weights, which is to say, the distillation loss is calculated according to the distillation loss of the first knowledge distillation network and the distillation loss of the second knowledge distillation network and their respective weights.
[0156] For example, distillation loss It means, including and , and During the calculation process, it can be done through To calculate, where, , , In the calculation process, v is the first detection result. z represents the i-th result in the first detection result; z represents the intermediate detection result. This is the i-th intermediate detection result. In the calculation process, v represents the intermediate detection result, and z represents the soft target in the second detection result. After calculation... and back, ,in, .
[0157] In addition to calculating the distillation loss, to improve the biometric detection capability of the trained biometric detection model, this embodiment also calculates the detection loss based on the second detection result and user image samples; in one optional implementation of this embodiment, the detection loss is calculated in the following manner:
[0158] The detection loss is calculated based on the labeled data of the user image samples and the hard targets in the second detection result.
[0159] Specifically, the detection loss is calculated using the labeled data of user image samples as hard labels and the hard targets in the second detection result.
[0160] For example, detecting loss express, = ;in, = , c represents a hard label, z represents a hard target.
[0161] like Figure 3For example, taking an intermediate model as an example, the training process of the biometric detection model includes a teacher model, an intermediate model, and a student model. After obtaining user image samples, the user image samples are input into the teacher model, intermediate model, and student model respectively for biometric detection, obtaining the soft labels output by the teacher model, the soft targets output by the intermediate model, and the soft targets and hard targets output by the student model. A first distillation loss is calculated based on the soft labels output by the teacher model and the soft targets output by the intermediate model. A second distillation loss is calculated using the soft targets output by the intermediate model as soft labels and the soft targets output by the student model. Furthermore, a detection loss is calculated using the labeled data of the user image samples as hard labels and the hard targets output by the student model. After calculating the first and second distillation losses, a distillation loss is calculated according to the first distillation loss, its weight, and the weights of the second distillation loss. Optionally, the sum of the weights of the first and second distillation losses is equal to 1. It should also be noted that the first and second distillation loss weights can be manually set hyperparameters. Initially, the first and second distillation loss weights can be set to 0.5 respectively, and can be adjusted appropriately according to the training situation. Specific adjustment strategies could be to gradually increase the second distillation loss weight or gradually increase the first distillation loss weight; this embodiment does not impose any limitations on this. Optionally, the detection loss can be the entropy loss calculated from the labeled data of the user image samples and the hard targets in the second detection results. In the calculation of the distillation loss, in addition to the calculation based on the above process, more complex comparison learning loss functions (loss functions that calculate the similarity between two features) can be introduced to jointly calculate the distillation loss; this embodiment does not impose any limitations on this.
[0162] Based on the calculated distillation loss and detection loss, the parameters of the teacher model, intermediate model, and student model are adjusted, and the student model obtained after training is used as the biological detection model.
[0163] To improve the effectiveness of parameter adjustment, in one optional implementation of this embodiment, the following operations are performed during the parameter adjustment of the teacher model, intermediate model, and student model based on distillation loss and detection loss:
[0164] The training loss is calculated based on the distillation loss, the distillation loss weight, the detection loss, and the detection loss weight.
[0165] Based on the training loss, the parameters of the teacher model, the intermediate model, and the student model to be trained are adjusted.
[0166] Specifically, in the process of adjusting the parameters of the teacher model, intermediate model, and student model based on distillation loss and detection loss, the training loss is first calculated based on the distillation loss and detection loss, and then the parameters of the teacher model, intermediate model, and student model are adjusted based on the training loss. During the calculation of the training loss based on the distillation loss and detection loss, the training loss is calculated using the distillation loss, its weight, the detection loss, and its weight.
[0167] Continuing with the previous example, in the calculation... and Then, the training loss L is calculated. ;in It should be noted that, and Hyperparameters can be manually set. The initial distillation loss weight and detection loss weight can be set to 0.5 respectively, and can be adjusted according to actual needs. For example, the detection loss weight can be gradually increased.
[0168] In the specific implementation process, the above method is used to train the model until the model converges, and the trained student model is obtained. The student model is then deployed on the edge as a biometric detection model for biometric detection.
[0169] Furthermore, the above description of the training process of the biological detection model provided in this embodiment is based on the number of intermediate models as one. In this embodiment, in order to perform knowledge distillation more accurately, multiple intermediate models can be set up in parallel during the knowledge distillation process of using intermediate models as student models and teacher models. Each intermediate model learns the ability of different structures of the teacher model, and then multiple intermediate models are used as teacher models and student models to be trained for knowledge distillation.
[0170] In one optional implementation of this embodiment, the user image samples are input into a pre-trained teacher model, an intermediate model to be trained, and a student model to be trained for biometric detection to obtain a first detection result, an intermediate detection result, and a second detection result. This can also be achieved in the following ways:
[0171] The user image samples are input into a pre-trained teacher model, at least one intermediate model to be trained, and a student model to be trained for biometric detection to obtain a first detection result, at least one intermediate detection result, and a second detection result.
[0172] Furthermore, optionally, the process of calculating distillation loss based on the first detection result, the intermediate detection result, and the second detection result is implemented in the following manner:
[0173] Based on the first detection result and the at least one intermediate detection result, at least one first distillation loss is calculated, and based on the at least one first distillation loss, a first target distillation loss is calculated; and,
[0174] Based on the at least one intermediate detection result and the second detection result, at least one second distillation loss is calculated, and based on the at least one second distillation loss, a second target distillation loss is calculated;
[0175] Calculate the distillation loss based on the first target distillation loss and the second target distillation loss.
[0176] Specifically, when there are at least one intermediate model in parallel, user image samples are input into the teacher model, each intermediate model and the student model for biometric detection to obtain a first detection result, at least one intermediate detection result and a second detection result; in the process of calculating distillation loss, a first target distillation loss is calculated based on the first detection result and at least one intermediate detection result, and a second target distillation loss is calculated based on the at least one intermediate detection result and the second detection result, and the distillation loss is calculated based on the first target distillation loss and the second target distillation loss.
[0177] It should be noted that, in the process of calculating the first target distillation loss based on the first detection result and at least one intermediate detection result, at least one first distillation loss is calculated based on the first detection result and each intermediate detection result, and then the first target distillation loss is calculated based on at least one first distillation loss. In the process of calculating the first target distillation loss, it can be calculated based on at least one first distillation loss and its corresponding weight, wherein the sum of the weights corresponding to each first distillation loss is equal to 1.
[0178] Similarly, in the process of calculating the second target distillation loss based on at least one intermediate detection result and the second detection result, at least one second distillation loss is calculated based on at least one intermediate detection result and the second detection result, and then the second target distillation loss is calculated based on at least one second distillation loss. In the process of calculating the second target distillation loss, it can be calculated based on at least one second distillation loss and its corresponding weight, wherein the sum of the weights corresponding to each second distillation loss is equal to 1.
[0179] The aforementioned parallel arrangement of multiple intermediate models means that each intermediate model includes multiple intermediate sub-models. Specifically, in the first knowledge distillation network, the student model comprises multiple intermediate sub-models, and in the second knowledge distillation network, the teacher model comprises multiple intermediate sub-models. Furthermore, besides parallel arrangement of multiple intermediate models, multiple intermediate models can also be arranged sequentially. Taking two sequentially arranged intermediate models as an example, the model training process includes three knowledge distillation networks. The first knowledge distillation network includes the teacher network and the first intermediate model, which is the student model within the first knowledge distillation network. In the second knowledge distillation network, the first intermediate model is the teacher model, and the second intermediate model is the student model. The third knowledge distillation network includes the second intermediate model and the student model, where the second intermediate model is the teacher model within the third knowledge distillation network. Specifically, regardless of the number of knowledge distillation networks, the training loss is similar to that in the case of two knowledge distillation networks, only with an additional layer of distillation loss. The calculation process for the distillation loss of the two knowledge distillation networks described above can be referred to, and this embodiment does not impose further limitations.
[0180] It should also be noted that, in order to obtain a more lightweight student model, multiple knowledge distillation networks can be configured according to actual needs, but this embodiment does not limit this.
[0181] That is, in this embodiment, the number of intermediate models includes at least one model in parallel, as well as at least one model that undergoes knowledge distillation in sequence.
[0182] The following description uses the application of a biometric detection method provided in this embodiment in a facial recognition payment scenario as an example to further illustrate the biometric detection method provided in this embodiment. (See also...) Figure 6 The biometric detection method applied to facial recognition payment includes the following steps.
[0183] Step S602: Based on the pending payment order, call the configured collection component to collect the user's face image.
[0184] Step S604: Input the user's face image into the configured biometric detection model for biometric detection and obtain the biometric detection result;
[0185] If the biological detection result is a biological category, proceed to steps S606 to S608;
[0186] If the biological detection result is an abnormal biological category, proceed to step S610.
[0187] Step S606: If the biometric detection result is a biological category, send a payment request containing the user's face image and the order to be paid to the payment server.
[0188] After receiving a payment request, the payment server first verifies the user's identity based on their facial image. If the verification is successful, the server then processes the payment for the order based on the user's account that matches the facial image.
[0189] Step S608: Receive and display the payment result sent by the server.
[0190] Step S610: Display an alert for abnormal biological activity.
[0191] This specification provides one or more embodiments of a biological detection model training device as follows:
[0192] In the above embodiments, a biological detection model training method is provided, and correspondingly, a biological detection model training device is also provided, which will be described below with reference to the accompanying drawings.
[0193] Reference Figure 7 This illustration shows a schematic diagram of an embodiment of a biological detection model training device provided in this embodiment.
[0194] Since the apparatus embodiments correspond to the method embodiments, the descriptions are relatively simple. For relevant parts, please refer to the corresponding descriptions of the method embodiments provided above. The apparatus embodiments described below are merely illustrative.
[0195] This embodiment provides a biological detection model training device, including:
[0196] The sample acquisition module 702 is configured to acquire user image samples;
[0197] The biometric detection module 704 is configured to input the user image sample into a pre-trained teacher model, an intermediate model to be trained, and a student model to be trained for biometric detection, and obtain a first detection result, an intermediate detection result, and a second detection result.
[0198] The loss calculation module 706 is configured to calculate distillation loss based on the first detection result, the intermediate detection result and the second detection result, and to calculate detection loss based on the second detection result and the user image sample;
[0199] The parameter adjustment module 708 is configured to adjust the parameters of the teacher model, the intermediate model and the student model according to the distillation loss and the detection loss, so as to use the trained student model as a biological detection model.
[0200] This specification provides one or more embodiments of a biological detection device as follows:
[0201] In the above embodiments, a biological detection method is provided, and correspondingly, a biological detection device is also provided, which will be described below with reference to the accompanying drawings.
[0202] Reference Figure 8 The diagram illustrates a schematic representation of a biological detection device embodiment provided in this embodiment.
[0203] Since the apparatus embodiments correspond to the method embodiments, the descriptions are relatively simple. For relevant parts, please refer to the corresponding descriptions of the method embodiments provided above. The apparatus embodiments described below are merely illustrative.
[0204] This embodiment provides a biological detection device, including:
[0205] Image acquisition module 802 is configured to acquire an image to be detected;
[0206] The biological detection module 804 is configured to input the image to be detected into a biological detection model for biological detection and obtain biological detection results.
[0207] The biological detection model includes a student model obtained by knowledge distillation of a pre-trained teacher model, an intermediate model to be trained, and a student model to be trained based on user image samples.
[0208] This specification provides one or more embodiments of a biological detection model training device as follows:
[0209] Corresponding to the biological detection model training method described above, based on the same technical concept, one or more embodiments of this specification also provide a biological detection model training device, which is used to execute the biological detection model training method provided above. Figure 9 This is a schematic diagram of the structure of a biological detection model training device provided in one or more embodiments of this specification.
[0210] This embodiment provides a biological detection model training device, comprising:
[0211] like Figure 9As shown, biological detection model training devices can vary significantly due to differences in configuration or performance. They may include one or more processors 901 and memory 902, with memory 902 storing one or more application programs or data. Memory 902 can be temporary or persistent storage. The application programs stored in memory 902 may include one or more modules (not shown), each module including a series of computer-executable instructions from the biological detection model training device. Furthermore, processor 901 may be configured to communicate with memory 902, executing the series of computer-executable instructions stored in memory 902 on the biological detection model training device. The biological detection model training device may also include one or more power supplies 903, one or more wired or wireless network interfaces 904, one or more input / output interfaces 905, one or more keyboards 906, etc.
[0212] In one specific embodiment, the biological detection model training device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for the biological detection model training device, and is configured to be executed by one or more processors. The one or more programs include computer-executable instructions for performing the following:
[0213] Obtain user image samples;
[0214] The user image samples are input into the pre-trained teacher model, the intermediate model to be trained, and the student model to be trained for biometric detection to obtain the first detection result, the intermediate detection result, and the second detection result.
[0215] Distillation loss is calculated based on the first detection result, the intermediate detection result, and the second detection result; and detection loss is calculated based on the second detection result and the user image sample.
[0216] The parameters of the teacher model, the intermediate model, and the student model are adjusted based on the distillation loss and the detection loss, so that the trained student model can be used as a biological detection model.
[0217] This specification provides one or more embodiments of a biological detection device as follows:
[0218] Corresponding to the biological detection method described above, based on the same technical concept, one or more embodiments of this specification also provide a biological detection device for performing the biological detection method provided above. Figure 10This is a schematic diagram of the structure of a biological detection device provided in one or more embodiments of this specification.
[0219] This embodiment provides a biological detection device, including:
[0220] like Figure 10 As shown, biological detection devices can vary significantly due to differences in configuration or performance. They may include one or more processors 1001 and memory 1002, with memory 1002 storing one or more application programs or data. Memory 1002 can be temporary or persistent storage. The application programs stored in memory 1002 may include one or more modules (not shown), each module including a series of computer-executable instructions for the biological detection device. Furthermore, processor 1001 may be configured to communicate with memory 1002, executing the series of computer-executable instructions stored in memory 1002 on the biological detection device. The biological detection device may also include one or more power supplies 1003, one or more wired or wireless network interfaces 1004, one or more input / output interfaces 1005, one or more keyboards 1006, etc.
[0221] In one specific embodiment, the biological detection device includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for the biological detection device, and is configured to be executed by one or more processors. The one or more programs include computer-executable instructions for performing the following:
[0222] Acquire the image to be detected;
[0223] The image to be detected is input into a biological detection model for biological detection to obtain biological detection results;
[0224] The biological detection model includes a student model obtained by knowledge distillation of a pre-trained teacher model, an intermediate model to be trained, and a student model to be trained based on user image samples.
[0225] This specification provides one or more embodiments of a storage medium as follows:
[0226] Corresponding to the biological detection model training method described above, based on the same technical concept, one or more embodiments of this specification also provide a storage medium.
[0227] The storage medium provided in this embodiment is used to store computer-executable instructions, which, when executed by a processor, implement the following process:
[0228] Obtain user image samples;
[0229] The user image samples are input into the pre-trained teacher model, the intermediate model to be trained, and the student model to be trained for biometric detection to obtain the first detection result, the intermediate detection result, and the second detection result.
[0230] Distillation loss is calculated based on the first detection result, the intermediate detection result, and the second detection result; and detection loss is calculated based on the second detection result and the user image sample.
[0231] The parameters of the teacher model, the intermediate model, and the student model are adjusted based on the distillation loss and the detection loss, so that the trained student model can be used as a biological detection model.
[0232] It should be noted that the embodiments concerning storage media in this specification and the embodiments concerning biological detection model training methods in this specification are based on the same inventive concept. Therefore, the specific implementation of this embodiment can be referred to the implementation of the corresponding methods described above, and the repeated parts will not be described again.
[0233] One or more embodiments of another storage medium provided in this specification are as follows:
[0234] Corresponding to the biological detection method described above, based on the same technical concept, one or more embodiments of this specification also provide a storage medium.
[0235] The storage medium provided in this embodiment is used to store computer-executable instructions, which, when executed by a processor, implement the following process:
[0236] Acquire the image to be detected;
[0237] The image to be detected is input into a biological detection model for biological detection to obtain biological detection results;
[0238] The biological detection model includes a student model obtained by knowledge distillation of a pre-trained teacher model, an intermediate model to be trained, and a student model to be trained based on user image samples.
[0239] It should be noted that the embodiments of another storage medium in this specification and the embodiments of biological detection methods in this specification are based on the same inventive concept. Therefore, the specific implementation of this embodiment can be referred to the implementation of the corresponding method described above, and the repeated parts will not be described again.
[0240] The source and use of the facial data involved in this application comply with the provisions of the Personal Information Protection Law of the People's Republic of China and the Civil Code, and do not harm the public interest.
[0241] The various embodiments in this specification are described in a progressive manner. For the same or similar parts between the various embodiments, please refer to each other. Each embodiment focuses on describing the differences from other embodiments. For example, the device embodiment, equipment embodiment, and storage medium embodiment are all similar to the method embodiment, so the description is relatively simple. For reading the relevant content of the device embodiment, equipment embodiment, and storage medium embodiment, please refer to the description of the method embodiment.
[0242] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0243] In the 1930s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many improvements to the methodology today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that an improvement to the methodology cannot be implemented using hardware physical modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program and "integrate" a digital system onto a PLD themselves, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must also be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also understand that by simply performing some logic programming on the method flow using one of these hardware description languages and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.
[0244] The controller can be implemented in any suitable manner. For example, it can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code form, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included therein for implementing various functions can also be considered as structures within the hardware component. Alternatively, the means for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.
[0245] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.
[0246] For ease of description, the above apparatus is described by dividing it into various functional units. Of course, when implementing the embodiments of this specification, the functions of each unit can be implemented in one or more software and / or hardware.
[0247] Those skilled in the art will understand that one or more embodiments of this specification can be provided as a method, system, or computer program product. Therefore, one or more embodiments of this specification may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this specification may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0248] This specification is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this specification. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0249] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0250] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0251] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0252] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0253] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0254] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0255] One or more embodiments of this specification can be described in the general context of computer-executable instructions, such as program modules, that are executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a particular task or implement a particular abstract data type. One or more embodiments of this specification can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0256] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0257] The above description is merely an embodiment of this document and is not intended to limit the scope of this document. Various modifications and variations can be made to this document by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this document should be included within the scope of the claims of this document.
Claims
1. A method for training a biological detection model, comprising: Obtain user image samples; The user image samples are input into the pre-trained teacher model, the intermediate model to be trained, and the student model to be trained for biometric detection to obtain the first detection result, the intermediate detection result, and the second detection result. Distillation loss is calculated based on the first detection result, the intermediate detection result, and the second detection result; and detection loss is calculated based on the second detection result and the user image sample. The parameters of the teacher model, the intermediate model, and the student model are adjusted based on the distillation loss and the detection loss, so that the trained student model can be used as a biological detection model. The student model to be trained is subjected to biometric detection in the following manner: The user image sample is input into the feature encoding module for feature encoding to obtain the sample features of the user image sample; The sample features are input into a probability calculation module with a distillation temperature of the first temperature to perform probability calculations and obtain soft targets; the sample features are input into a probability calculation module with a distillation temperature of the second temperature to perform probability calculations and obtain hard targets. The second detection result includes the soft target and the hard target.
2. The method according to claim 1, wherein the intermediate model establishes distillation learning between the student model and the teacher model; and the intermediate model establishes distillation learning between the teacher model and the student model to be trained.
3. The method according to claim 1, wherein the teacher model, the intermediate model, and the student model to be trained include a feature encoding module and a probability calculation module.
4. The method according to claim 3, wherein the feature encoding module in the teacher model is determined in the following manner: Calculate the number of samples in the user image sample; The number of encoding layers in the feature encoding layer is determined based on the number of samples, and the feature encoding module in the teacher model is constructed based on the number of encoding layers in the feature encoding layer.
5. The method according to claim 1, wherein inputting the user image sample into a pre-trained teacher model, an intermediate model to be trained, and a student model to be trained for biometric detection to obtain a first detection result, an intermediate detection result, and a second detection result includes: The user image samples are input into a pre-trained teacher model, at least one intermediate model to be trained, and a student model to be trained for biometric detection to obtain a first detection result, at least one intermediate detection result, and a second detection result.
6. The method according to claim 5, wherein calculating the distillation loss based on the first detection result, the intermediate detection result, and the second detection result comprises: Based on the first detection result and the at least one intermediate detection result, at least one first distillation loss is calculated, and based on the at least one first distillation loss, a first target distillation loss is calculated; as well as, Based on the at least one intermediate detection result and the second detection result, at least one second distillation loss is calculated, and based on the at least one second distillation loss, a second target distillation loss is calculated; Calculate the distillation loss based on the first target distillation loss and the second target distillation loss.
7. The method according to claim 1, wherein calculating the distillation loss based on the first detection result, the intermediate detection result, and the second detection result comprises: Based on the first detection result and the intermediate detection result, the first distillation loss is calculated; The second distillation loss is calculated based on the intermediate detection results and the soft targets in the second detection results; The distillation loss is calculated based on the first distillation loss, the second distillation loss, and their respective weights.
8. The method according to claim 1, wherein calculating the detection loss based on the second detection result and the user image sample comprises: The detection loss is calculated based on the labeled data of the user image samples and the hard targets in the second detection result.
9. The method according to claim 1, wherein adjusting the parameters of the teacher model, the intermediate model, and the student model based on the distillation loss and the detection loss comprises: The training loss is calculated based on the distillation loss, the distillation loss weight, the detection loss, and the detection loss weight. Based on the training loss, the parameters of the teacher model, the intermediate model, and the student model to be trained are adjusted.
10. A biological detection method, comprising: Acquire the image to be detected; The image to be detected is input into a biological detection model for biological detection to obtain biological detection results; The biometric detection model includes a student model obtained by knowledge distillation of a pre-trained teacher model, an intermediate model to be trained, and a student model to be trained based on user image samples. The student model to be trained performs biometric detection in the following manner: the user image samples are input into a feature encoding module for feature encoding to obtain sample features of the user image samples; the sample features are input into a probability calculation module at a distillation temperature of a first temperature for probability calculation to obtain soft targets; and the sample features are input into a probability calculation module at a distillation temperature of a second temperature for probability calculation to obtain hard targets. The second detection result includes the soft targets and the hard targets, and the second detection result is obtained by inputting the user image samples into the student model to be trained for biometric detection.
11. A biological detection model training device, comprising: The sample acquisition module is configured to acquire user image samples; The biometric detection module is configured to input the user image sample into a pre-trained teacher model, an intermediate model to be trained, and a student model to be trained for biometric detection, and obtain a first detection result, an intermediate detection result, and a second detection result. The loss calculation module is configured to calculate distillation loss based on the first detection result, the intermediate detection result, and the second detection result, and to calculate detection loss based on the second detection result and the user image sample; The parameter adjustment module is configured to adjust the parameters of the teacher model, the intermediate model, and the student model based on the distillation loss and the detection loss, so as to use the trained student model as a biological detection model. The student model to be trained performs biological detection in the following manner: the user image sample is input into a feature encoding module for feature encoding to obtain the sample features of the user image sample; the sample features are input into a probability calculation module with a distillation temperature of a first temperature for probability calculation to obtain soft targets; and the sample features are input into a probability calculation module with a distillation temperature of a second temperature for probability calculation to obtain hard targets; wherein, the second detection result includes the soft targets and the hard targets.
12. A biological detection device, comprising: The image acquisition module is configured to acquire the image to be detected; The bio-detection module is configured to input the image to be detected into a bio-detection model for bio-detection and obtain bio-detection results; The biometric detection model includes a student model obtained by knowledge distillation of a pre-trained teacher model, an intermediate model to be trained, and a student model to be trained based on user image samples. The student model to be trained performs biometric detection in the following manner: the user image samples are input into a feature encoding module for feature encoding to obtain sample features of the user image samples; the sample features are input into a probability calculation module at a distillation temperature of a first temperature for probability calculation to obtain soft targets; and the sample features are input into a probability calculation module at a distillation temperature of a second temperature for probability calculation to obtain hard targets. The second detection result includes the soft targets and the hard targets, and the second detection result is obtained by inputting the user image samples into the student model to be trained for biometric detection.
13. A biological detection model training device, comprising: processor; And, a memory configured to store computer-executable instructions, which, when executed, cause the processor to: Obtain user image samples; The user image samples are input into the pre-trained teacher model, the intermediate model to be trained, and the student model to be trained for biometric detection to obtain the first detection result, the intermediate detection result, and the second detection result. Distillation loss is calculated based on the first detection result, the intermediate detection result, and the second detection result; and detection loss is calculated based on the second detection result and the user image sample. The parameters of the teacher model, the intermediate model, and the student model are adjusted based on the distillation loss and the detection loss, so that the trained student model can be used as a biological detection model. The student model to be trained is subjected to biometric detection in the following manner: The user image sample is input into the feature encoding module for feature encoding to obtain the sample features of the user image sample; The sample features are input into a probability calculation module with a distillation temperature of the first temperature to perform probability calculations and obtain soft targets; the sample features are input into a probability calculation module with a distillation temperature of the second temperature to perform probability calculations and obtain hard targets. The second detection result includes the soft target and the hard target.
14. A biological detection device, comprising: processor; And, a memory configured to store computer-executable instructions, which, when executed, cause the processor to: Acquire the image to be detected; The image to be detected is input into a biological detection model for biological detection to obtain biological detection results; The biometric detection model includes a student model obtained by knowledge distillation of a pre-trained teacher model, an intermediate model to be trained, and a student model to be trained based on user image samples. The student model to be trained performs biometric detection in the following manner: the user image samples are input into a feature encoding module for feature encoding to obtain sample features of the user image samples; the sample features are input into a probability calculation module at a distillation temperature of a first temperature for probability calculation to obtain soft targets; and the sample features are input into a probability calculation module at a distillation temperature of a second temperature for probability calculation to obtain hard targets. The second detection result includes the soft targets and the hard targets, and the second detection result is obtained by inputting the user image samples into the student model to be trained for biometric detection.