A detection model acquisition method, an activity detection method, and related devices

By training a pre-trained model with unlabeled samples to obtain initial parameters, and combining it with a small number of labeled samples for model initialization and training, the problem of insufficient accuracy of detection models in liveness detection is solved, and efficient liveness detection results are achieved.

CN115171224BActive Publication Date: 2025-12-16ALIBABA (CHINA) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210646729.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-09
Publication Date
2025-12-16
Estimated Expiration
2042-06-09

AI Technical Summary

Technical Problem

Existing activity detection technologies struggle to obtain a large number of labeled training samples, resulting in insufficient accuracy of the detection models.

Method used

Initial parameters are obtained by training a pre-trained model using unlabeled samples, and then the model is initialized and trained using a small number of labeled samples to form a detection model.

Benefits of technology

It improves the training efficiency and accuracy of the detection model, and achieves efficient liveness detection with a small number of labeled samples.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115171224B_ABST
    Figure CN115171224B_ABST
Patent Text Reader

Abstract

The application discloses an acquisition method of a detection model, comprising the following steps: acquiring initial parameters, wherein the initial parameters are parameters obtained from a pre-training model, the pre-training model is a model obtained by training N unlabeled samples, N is a positive integer; performing initialization processing on an initial detection model by using the initial parameters to obtain an initialized model; and training the initialized model by using M labeled samples to obtain a detection model, M is a positive integer, a difference value obtained by subtracting M from N is greater than a preset threshold, and a label corresponding to any one of the M labeled samples comprises information about whether an object in the any one labeled sample is a living body. The method can improve the accuracy of the detection model.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a detection model obtaining method, a liveness detection method and related devices. BACKGROUND

[0002] The liveness detection technology mainly refers to a technical solution for judging whether a face in collected data (for example, video data) is a real face or a fake face attack (for example, a face image printed by color paper).

[0003] In the traditional technology, a neural network model is usually trained by using a large number of labeled training samples to obtain a detection model. Further, the object in the obtained video data can be detected by using the detection model that meets the training standard. However, in some liveness detection technologies (for example, light liveness detection technology), it is usually difficult to obtain a large number of labeled training samples, so that the detection model obtained by using a small number of labeled training samples is not accurate enough.

[0004] Therefore, there is an urgent need for a detection model obtaining method to improve the accuracy of the detection model. SUMMARY

[0005] The present application provides a detection model obtaining method, a liveness detection method and related devices to improve the accuracy of the detection model.

[0006] The present application provides a detection model obtaining method, a liveness detection method and related devices to improve the accuracy of the detection model.

[0007] Optionally, in some implementations, the method further includes: erasing part of a region in any one of the N unlabeled samples to obtain an unlabeled sample after erasing processing; and training an initial pre-training model by using the unlabeled sample after erasing processing to obtain the pre-training model.

[0008] Optionally, in some other implementations, the initial pre-training model comprises an encoder and a decoder, the training of the initial pre-training model comprises: encoding the label-free sample after the erasing processing using the encoder to obtain an encoding result; decoding the encoding result using the decoder to obtain a restoration result according to the label-free sample after the erasing processing; comparing the restoration result with the label-free sample to determine whether the restored image meets the restoration requirement and record the result; repeating the above steps for the collected label-free samples, and determining whether the pre-training model is successfully trained according to the recorded result of each round; if not, adjusting the parameters of the encoder and the decoder, and if yes, ending the training; and the obtaining of the initial parameters comprises: obtaining the parameters of the encoder included in the pre-training model after the successful training as the initial parameters.

[0009] Optionally, in some other implementations, the detection model comprises a first output result, and the first output result is used to indicate whether the object to be detected in the test sample input into the detection model is a living body.

[0010] Optionally, in some other implementations, the label corresponding to the any one labeled sample further comprises a first color sequence of surface light irradiation received by the object in the any one labeled sample, the detection model further comprises a second output result, and the second output result is used to indicate a second color sequence of surface light received by the object to be detected in the test sample input into the detection model.

[0011] Optionally, in some other implementations, the label corresponding to the any one labeled sample further comprises a light available confidence of an environment in which the object in the any one labeled sample is located, the detection model further comprises a third output result, and the third output result is used to indicate a light available confidence of an environment in which the object to be detected in the test sample input into the detection model is located.

[0012] Optionally, in some other implementations, the any one label-free sample is an image frame, and the any one labeled sample is an image sequence.

[0013] Optionally, in some other implementations, the detection model is applied to an activity detection scene.

[0014] The embodiment of the present application further provides an activity detection method, comprising: receiving an activity detection request, wherein the activity detection request is used to request to perform activity detection on a to-be-detected object in an image sequence, and the image sequence is obtained by projecting light corresponding to light configuration information as a light source to the to-be-detected object and performing image acquisition on the to-be-detected object; processing the image sequence by using a detection model to obtain a first detection result; and determining whether the to-be-detected object in the image sequence is a living body according to the first detection result, wherein the detection model is a detection model obtained according to the detection model obtaining method provided in the embodiment of the present application.

[0015] Optionally, in some implementations, the determining whether the to-be-detected object in the image sequence is a living body according to the first detection result comprises: if the first detection result is used to indicate that the to-be-detected object in the image sequence is a living body, determining that the to-be-detected object in the image sequence is a living body.

[0016] Optionally, in another implementation, the label corresponding to the any one labeled sample further comprises a first color sequence of surface light irradiation received by the object in the any one labeled sample, the detection model further comprises a second output result, the second output result is used to indicate a second color sequence of light of a surface suffered by a to-be-detected object in a test sample input to the detection model, and the method further comprises: processing the image sequence by using the detection model to obtain a second detection result, the second detection result is used to indicate a third color sequence, and the third color sequence is a color sequence of light of a surface suffered by the to-be-detected object in the image sequence; and if it is determined that a difference between the color sequence of the light corresponding to the light configuration information and the third color sequence is greater than a preset threshold, determining that the image sequence is tampered.

[0017] Optionally, in another implementation, the label corresponding to the any one labeled sample further comprises a light available confidence of an environment in which the object in the any one labeled sample is located, the detection model further comprises a third output result, the third output result is used to indicate a light available confidence of an environment in which a to-be-detected object in a test sample input to the detection model is located, and the method further comprises: processing the image sequence by using the detection model to obtain a third detection result, the third detection result is used to indicate a light available confidence of an environment in which the to-be-detected object in the image sequence is located; and if the light available confidence is lower than a predetermined threshold, determining that the detection result of the detection model cannot be adopted.

[0018] Optionally, in some other implementations, the method further includes: after receiving the activity detection request, obtaining video data of the object to be detected in a case that the light irradiated according to the light configuration information irradiates the object to be detected; and obtaining the image sequence from the video data according to a preset time interval.

[0019] Optionally, in some other implementations, the method is applied to any one of the following application scenarios: a payment scenario, an account login scenario, or an access control security scenario.

[0020] The embodiment of the present application further provides an acquisition device of a detection model, including: an acquisition unit, configured to acquire initial parameters, the initial parameters being parameters acquired from a pre-training model, the pre-training model being a model obtained by training N unlabeled samples, N being a positive integer; a processing unit, configured to perform initialization processing on an initial detection model by using the initial parameters, to obtain an initialized model; and a training unit, configured to train the initialized model by using M labeled samples, to obtain a detection model, M being a positive integer, and a difference value obtained by subtracting M from N being greater than a preset threshold, a label corresponding to any one of the M labeled samples including information about whether an object in the any one of the labeled samples is a living body.

[0021] Optionally, in some implementations, the training unit is further configured to: erase a part of an area in any one of the N unlabeled samples, to obtain an unlabeled sample after erasing processing; and train an initial pre-training model by using the unlabeled sample after erasing processing, to obtain the pre-training model.

[0022] Optionally, in some other implementations, the training unit is further configured to: encode the unlabeled sample after erasing processing by using the encoder, to obtain an encoding result; decode the encoding result by using the decoder, to obtain a restoration result according to the unlabeled sample after erasing processing; compare the restoration result with the unlabeled sample, to determine whether the restored image meets a restoration requirement, and record a result; repeat the above steps for the collected unlabeled samples, and determine whether the pre-training model is successfully trained according to the recorded result of each round; if not, adjust parameters of the encoder and the decoder, and if yes, end the training; and the acquisition unit is further configured to acquire the parameters of the encoder included in the pre-training model after successful training, and use the parameters as the initial parameters.

[0023] Optionally, in some other implementations, the detection model includes a first output result, the first output result being used to indicate whether a to-be-detected object in a test sample input to the detection model is a living body.

[0024] Optionally, in some implementations, the label corresponding to the any one labeled sample further includes a first color sequence of surface light irradiation received by the object in the any one labeled sample, and the detection model further includes a second output result, the second output result being used to indicate a second color sequence of surface light received by the to-be-detected object in the test sample input to the detection model.

[0025] Optionally, in some implementations, the label corresponding to the any one labeled sample further includes a light available confidence of an environment in which the object in the any one labeled sample is located, and the detection model further includes a third output result, the third output result being used to indicate the light available confidence of the environment in which the to-be-detected object in the test sample input to the detection model is located.

[0026] Optionally, in some implementations, the any one unlabeled sample is an image frame, and the any one labeled sample is an image sequence.

[0027] Optionally, in some implementations, the detection model is applied to an activity detection scenario.

[0028] The embodiments of the present application further provide an activity detection device, including: a receiving unit configured to receive an activity detection request, the activity detection request being used to request to perform activity detection on a to-be-detected object in an image sequence, the image sequence being obtained by projecting light configured according to light configuration information as a light source to the to-be-detected object and performing image acquisition on the to-be-detected object; a processing unit configured to perform processing on the image sequence by using a detection model to obtain a first detection result; and a determining unit configured to determine whether the to-be-detected object in the image sequence is a living body according to the first detection result, wherein the detection model is a detection model obtained according to the detection model obtaining method provided in the embodiments of the present application.

[0029] Optionally, in some implementations, the determining unit is further configured to: if the first detection result is used to indicate that the to-be-detected object in the image sequence is a living body, determine that the to-be-detected object in the image sequence is a living body.

[0030] Optionally, in some other implementations, the label corresponding to the any one labeled sample further includes a first color sequence of surface light irradiation received by the object in the any one labeled sample, and the detection model further includes a second output result for indicating a second color sequence of surface light received by the to-be-detected object in the test sample input to the detection model, and the method further includes: processing the image sequence by using the detection model to obtain a second detection result for indicating a third color sequence, which is a color sequence of surface light received by the to-be-detected object in the image sequence; and determining that the image sequence is tampered if it is determined that a difference between the color sequence of the light corresponding to the light configuration information and the third color sequence is greater than a preset threshold.

[0031] Optionally, in some other implementations, the label corresponding to the any one labeled sample further includes a light available confidence of an environment in which the object in the any one labeled sample is located, and the detection model further includes a third output result for indicating a light available confidence of an environment in which the to-be-detected object in the test sample input to the detection model is located, and the processing unit is further configured to: process the image sequence by using the detection model to obtain a third detection result for indicating a light available confidence of an environment in which the to-be-detected object in the image sequence is located; and the determining unit is further configured to: determine that the detection result of the detection model cannot be adopted if the light available confidence is lower than a predetermined threshold.

[0032] Optionally, in some other implementations, the processing unit is further configured to: after receiving the activity detection request, obtain video data for the to-be-detected object in a case where the light corresponding to the light configuration information irradiates the to-be-detected object; and obtain the image sequence from the video data according to a preset time interval.

[0033] Optionally, in some other implementations, the method is applied to any one of the following application scenarios: a payment scenario, an account login scenario, or an access control security scenario.

[0034] It should be understood that the content described in this section is not intended to identify key or important features of the embodiments of the present disclosure, nor is it used to limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description.

[0035] The method for obtaining a detection model provided in the application comprises: obtaining initial parameters, the initial parameters being parameters obtained from a pre-training model, the pre-training model being a model obtained by training N unlabeled samples, N being a positive integer; performing initialization processing on an initial detection model by using the initial parameters to obtain an initialized model; and training the initialized model by using M labeled samples to obtain a detection model, M being a positive integer, and a difference value obtained by subtracting M from N being greater than a preset threshold, and a label corresponding to any one of the M labeled samples comprising information about whether an object in the any one of the labeled samples is a living body. In the process of obtaining the detection model, the pre-training model is obtained by training a large number of unlabeled samples, so that the utilization rate of the unlabeled data can be improved and the problem of a shortage of labeled data can be avoided. The initial detection model is initialized by using the parameters of the pre-training model, so that the number of training iterations of the detection model can be reduced and the training efficiency of the detection model can be improved. The initialized detection model is trained by using a small amount of labeled samples, so that the accuracy of the detection model can be further improved. That is, the method balances the training efficiency and the detection accuracy of the detection model.

[0036] The activity detection method provided in the application comprises: receiving an activity detection request, the activity detection request being used to request to perform activity detection on a to-be-detected object in an image sequence, the image sequence being obtained by projecting light rays corresponding to light configuration information as light sources to the to-be-detected object and performing image acquisition on the to-be-detected object; processing the image sequence by using a detection model to obtain a first detection result; and determining whether the to-be-detected object in the image sequence is a living body according to the first detection result, wherein the detection model is a model obtained according to the method for obtaining a detection model provided in the application. In the activity detection method, after receiving the activity detection request, the image sequence associated with the activity detection request is processed by using the detection model to obtain a first detection result, and whether the to-be-detected object in the image sequence is a living body is determined according to the first detection result. The detection model is determined according to the method for obtaining a detection model provided in the application, so that the first detection result has high accuracy. BRIEF DESCRIPTION OF DRAWINGS

[0037] Figure 1 is a flowchart of a method for obtaining a detection model provided in an embodiment of the application.

[0038] Figure 2 is a flowchart of a method for obtaining a pre-training model by training an initial pre-training model by using unlabeled samples provided in an embodiment of the application.

[0039] Figure 3 is a process schematic diagram of a method for obtaining a pre-training model by training an initial pre-training model by using unlabeled samples provided in an embodiment of the application.

[0040] Figure 4 is a flow chart of an activity detection method provided by an embodiment of the present application.

[0041] Figure 5 is a flow chart of another activity detection method provided by an embodiment of the present application.

[0042] Figure 6 is a schematic diagram of an acquisition device of a detection model provided by an embodiment of the present application.

[0043] Figure 7 is a schematic diagram of an activity detection device provided by an embodiment of the present application.

[0044] Figure 8 is a schematic diagram of an acquisition device of a detection model provided by an embodiment of the present application.

[0045] Figure 9 is a schematic diagram of an activity detection device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0046] In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application. However, it will be apparent to one skilled in the art that the present application can be practiced without the specific details set forth in this description. In other instances, well-known methods have not been described in detail in order to avoid obscuring the present application.

[0047] The present application provides an acquisition method of a detection model, an activity detection method and related devices.

[0048] First, the professional technical terms involved in the embodiments of the present application are briefly introduced:

[0049] Light activity detection: different color light is emitted through the screen of the device, and the change of the imaging of the face as the detection object is captured, so as to distinguish whether the object in front of the screen is the real person of the verifier. In the embodiments of the present application, only whether it is a living body is judged, and whether the detection object is the face of a specific person is not involved. The so-called activity detection is to judge whether the detection object is a living body.

[0050] The acquisition method of a detection model, the activity detection method and the related devices provided by the present application are described in detail below. It can be understood that the embodiments and the features in the embodiments provided by the present application can be combined with each other without conflict. In addition, the time sequence of the steps in each method embodiment described below is only an example, not a strict limitation.

[0051] Figure 1is a flowchart of a method for obtaining a detection model provided by an embodiment of the present application. The method for obtaining a detection model provided by an embodiment of the present application can be executed by a training device. It can be understood that the training device can be implemented as software, or a combination of software and hardware. For example, the training device in the embodiment of the present application can be, but is not limited to, a server or a terminal device used by a user. As shown in FIG. 1, the method for obtaining a detection model provided by an embodiment of the present application includes steps S110 to S130. The steps S110 to S130 will be described in detail below. Figure 1 The method for obtaining a detection model provided by an embodiment of the present application includes steps S110 to S130. The steps S110 to S130 will be described in detail below.

[0052] In step S110, an initial parameter is obtained, which is a parameter obtained from a pre-trained model. The pre-trained model is a model obtained by training N unlabeled samples, where N is a positive integer.

[0053] In the embodiment of the present application, the initial parameter is obtained from an encoder included in the pre-trained model obtained by training. In a specific implementation mode provided in the embodiment, the initial parameter is a parameter of the encoder included in the pre-trained model provided by the embodiment. The specific implementation mode of the embodiment will be described below in combination with the specific implementation mode.

[0054] In the specific implementation mode provided by the embodiment, the pre-trained model is a model mainly including an encoder and a decoder; the pre-trained model is obtained by training an initial pre-trained model using unlabeled samples (or unlabeled samples); that is, the training process is a self-supervised training process.

[0055] In the process of training the above pre-trained model, the encoder is the main object to be trained, and the initial parameter in this step is a parameter obtained from the pre-trained model, where the parameter refers to the parameter of the encoder after training.

[0056] In the pre-training process, for the original image frame used for training as the unlabeled sample, the encoder first encodes the original image frame to obtain encoded data; the decoder in the pre-trained model is similar to an adversarial model, which is used to decode the encoded data encoded by the encoder into image data, and obtain the decoded image according to the converted image data; then, the decoded image is compared with the original image frame, and if the comparison shows that the difference between the decoded image and the original image frame is within a predetermined threshold, the encoder reaches a predetermined training effect. The parameters contained in the encoded frame reaching the predetermined training effect can better reflect the features of the image frame, and therefore can be used as the initial parameter.

[0057] For example, the original image frame provided to the encoder is a face image. Generally, the image is divided into several fixed-size regions, and each region is encoded according to the characteristics (such as RGB parameter characteristics) of the region. The encoder learns the face image and obtains the encoding of the face image. These encoded regions may correspond to the features of the face, such as some regions reflecting the shape of the eyes, some regions reflecting the shape of the nose or the shape of the mouth, etc. The decoder in the pre-trained model can decode the encoding results of each region output by the encoder in the pre-trained model to obtain the decoding results corresponding to the results output by the encoder. For example, the input of the decoder is the image region features of the corresponding eye, nose, or mouth output by the encoder. The decoder decodes these features and combines them to obtain the face image corresponding to these features. The subsequent steps of the embodiment continue to perform supervised training on these initial parameters, and better training results can be obtained. The encoder in the pre-trained model can learn the important features of the input data from the input data input to the encoder.

[0058] The following will be described in detail in combination with Figure 2 , Figure 3 The above describes a preferred way of training an initial pre-trained model using unlabeled samples. Figure 2 is a flowchart of the preferred way, Figure 3 is a schematic diagram of the processing procedure of the preferred way. The preferred way is characterized in that part of the blocks of the original image frame are randomly erased and provided to the encoder, so that the encoder can reflect the image features of the face at a deeper level.

[0059] In step S201, each sample in the N unlabeled samples is subjected to the following erasing process: part of the region is erased to obtain N unlabeled samples after erasing.

[0060] This step implements the preliminary processing of the image frames as samples, which is specifically erasing part of the content. Since these image frames are not labeled in any way, they are referred to as unlabeled samples. Since no labeling is required, these image frames as samples are easier to obtain.

[0061] As known to those skilled in the art, for model training, a sufficient number of samples are required to obtain better training results, such as tens of thousands, hundreds of thousands, or millions of samples available for training. Therefore, the number of the N unlabeled samples described in this step can be any of the above possibilities, or in other orders of magnitude according to specific training requirements. Obviously, N is a positive integer; of course, the specific value does not need to be particularly accurate. The erasing process in this step needs to be performed on each unlabeled sample respectively. Since the processing procedure of each sample is basically the same, the following will be described in detail with Figure 3The original image frame A in the image is used as an example of an unlabeled sample.

[0062] Machine learning model training includes supervised training and self-supervised training. Supervised training uses labeled samples provided to the machine learning model, which then judges the accuracy of its processing results based on the labels, thus adjusting its parameters. Obviously, this training mode requires labeling the samples according to training needs, obtaining labeled samples (or annotated samples). These labels are generally done manually, and the required number of samples is often very large, leading to high costs and the inability to avoid errors in manual labeling. In contrast, this preferred solution uses self-supervised training to train the initial pre-trained model. The training samples do not need to be labeled, i.e., unlabeled samples are used. This significantly reduces the cost of obtaining samples compared to labeled samples, and the samples are readily available, making the training of the initial pre-trained model easier in this preferred solution.

[0063] like Figure 3 As shown, the original image frame A, as an unlabeled sample, can be obtained from various facial image video frames. For example, videos collected during facial recognition from facial images gathered by various terminal devices. After desensitization processing, video frames can be extracted from these data as unlabeled samples. Specifically, for example, videos V collected and uploaded to the server... i (i = 1, 2, ..., n), these videos have no labels, but are generally related to facial recognition. Then, the videos are segmented to obtain frames. j (j = 1, 2, ... m); these video frames are the initial samples, or initial image frames.

[0064] Since initial image frames collected from different sources may have significantly different image parameters, some standardized preprocessing is required to ensure data consistency during machine training. Specifically, this includes scaling the initial image frames to a uniform size, for example, scaling them to 224*224*3 (where 224 represents pixels and 3 represents different channels, such as RGB which includes three channels, or depth). Then, the scaled image frames are spatially segmented into patches based on pixel coordinates. Each patch has a fixed size, for example, 16*16, thus forming a patch sequence (patch1, patch2, ..., patch) from an initial image frame. p This yields the initial processed original image frame; such as... Figure 3 The original image frame A is shown.

[0065] The partial region is preferably a region in units of blocks, and these regions are random. Of course, it cannot be ruled out that a block of a partial region at a fixed position is erased, but using the fixed position erasing method may result in poor generalization. Of course, it cannot be ruled out that it can be used in the case of low demand. Obviously, this implementation scheme is also within the scope of protection claimed in the present application.

[0066] As shown in Figure 3 , the original image frame A is divided into 16 image blocks, and 9 image blocks are randomly erased to obtain the erased no-label sample, i.e., a sample composed of unerased image blocks, which represents the original image frame A and participates in the subsequent encoding process of the encoder 210.

[0067] In step S202, the initial pre-training model is trained using the N erased no-label samples to obtain the pre-training model, wherein the initial pre-training model includes an encoder and a decoder.

[0068] In this step, the initial training model is trained using the no-label sample obtained in the foregoing step S201, and the pre-training model is obtained when the training meets the target requirements. The initial training model is a machine learning model with initial parameters and a predetermined model structure. Naturally, among various machine learning models, there are many machine models that can be selected, and for image recognition, there are also many choices. Generally, a self-supervised training machine learning model has an encoder and a decoder (or called decoder). The parameters of the trained encoder can reflect the characteristics of image recognition, and therefore can be used as the initial parameters for the initialization of the initial detection model in the subsequent step.

[0069] As shown in Figure 3 , the encoder 210 encodes the erased no-label sample. The so-called encoding is to convert the information of the original image block to a new low-dimensional mathematical space through a mapping function. In the case of different parameters of the encoder 210, different encoding results can be obtained, and the mapping function includes the related parameters for conversion. Of course, in the present preferred embodiment, the parameters in the encoder 210 are actually in a to-be-determined state before and during the training, and the whole self-supervised training process is mainly to obtain reasonable parameter selection of the encoder 210.

[0070] The process of training the initial pre-training model in this step can be referred toFigure 2 From step S202-1 to step S202-3.

[0071] Step S202-1: Use the encoder to encode the erased unlabeled sample to obtain the encoding result.

[0072] In this step, encoder 210 encodes the unlabeled samples after the erasure process to obtain the encoding result. For example... Figure 3 As shown in the figure, this diagram uses a single original image frame A from the N unlabeled samples as an example to illustrate the encoding process. Although only one unlabeled sample is used here as an example, in reality, the same processing needs to be performed on all N unlabeled samples.

[0073] like Figure 3 As shown, encoding the unlabeled samples after erasure is essentially encoding the remaining image patches after erasure. Figure 3 In a specific example, the encoder 210 encodes the image parameters of the remaining 7 image patches, that is, it transforms and maps these image parameters to another low-dimensional mathematical space for expression through a mapping function. This step only needs to encode the remaining 7 image patches, which represent the characteristics of the entire original image frame A. In this step, different selections of the mapping function parameters by the encoder 210 will result in different encoding results, and different results correspond to different ways of reflecting the features of the original image frame A. The purpose of training the pre-trained model is to select the parameters as reasonably as possible to make it reflect the deep features of the image as much as possible.

[0074] Step S202-2: Use the decoder to decode the encoding result to obtain the restoration result of the unlabeled sample after the erasure process.

[0075] The decoder 220 is used to perform the inverse operation on the encoding result of the encoder 210, that is, to restore the original image as much as possible based on the encoder's encoding result. This can be understood as using an inverse mapping function to convert the encoder 210's encoding result back into image parameters. Only in this way can it be compared with the original image frame in the next step to determine the encoding effect of the encoder 210. Therefore, the relationship between the decoder 220 and the encoder 210 can be compared to an adversarial training process. The decoding level of the decoder 220 obviously affects the training effect; therefore, the parameters of the inverse mapping function in the decoder also affect the training effect and need to be continuously adjusted during the training process.

[0076] like Figure 3As shown, during the decoding process of the decoder 220, on the one hand, the image blocks coded by the encoder 210 are decoded, and on the other hand, the image blocks erased in the erasing process and the decoded image blocks are combined with each other, so that the restoration result of the unlabeled sample can be obtained.

[0077] In step S202-3, the restoration result is compared with the unlabeled sample, and it is determined whether the restored image meets the restoration requirement, and the result is recorded.

[0078] This step is used to evaluate the coding and decoding effects of the original image frame A by the encoder 210 and the decoder 220. The specific evaluation method is to directly compare the restoration result with the unlabeled sample, i.e., the original image frame A, to determine whether the restored image meets the restoration requirement. The comparison method can have multiple ways, and the comparison standard can be selected according to the specific situation. Generally, the result can be divided into two categories: qualified and unqualified.

[0079] The above is the training process of a specific original image frame A. This process finally determines whether the current round of training meets the requirements of the specific original image frame A. The entire training process needs to accumulate enough coding and decoding processes of the unlabeled sample, and according to the statistical results of the comparison, the parameters of the encoder 210 and the decoder 220 are adjusted, which can be illustrated by the following step S202-4.

[0080] In step 202-4, the above steps are repeated for the collected unlabeled samples, and according to the recorded results of each round, it is determined whether the pre-training model is successfully trained. If not, the parameters of the encoder and the decoder are adjusted, and if so, the training is ended.

[0081] In the actual training process, according to the number N of the collected unlabeled samples and the specific training requirements, the appropriate timing for adjusting the parameters of the pre-training model can be selected. For example, after starting the training, the parameters can be adjusted when the comparison result of the first unlabeled sample is unqualified, and the adjustment is continued until it is qualified. After accumulating a certain amount of data, the pre-training model can be adjusted again when the statistical data of the comparison results of the pre-training model is lower than the predetermined qualified standard. Finally, a sufficient number of training results of the unlabeled samples can be accumulated, and the qualified rate of the comparison results of the restored pre-training model is adjusted to reach the predetermined threshold. In this way, the initial pre-training model is successfully trained, and becomes a pre-training model whose parameters can be used as initial parameters.

[0082] The initial parameters are the parameters of the encoder included in the pre-trained model after the training, which are used as the initial parameters in the preferred embodiment. Since the trained encoder can accurately reflect the features of the face image, these parameters are a good expression mode of the deep features of the face image.

[0083] In step S120, the initial detection model is initialized using the initial parameters to obtain an initialized model.

[0084] In some possible implementations, the initial detection model includes an encoder and a classifier used for classifying the results output by the encoder. In some possible implementations, the classifier is a single-task classifier. In other possible implementations, the classifier is a multi-task classifier. Based on this, the initial detection model is initialized using the initial parameters to obtain an initialized model, including initializing the encoder in the initial detection model using the initial parameters to obtain the initialized model.

[0085] The initialized model described above uses the parameters of the trained encoder as the initial parameters, and these initial parameters can better extract the face features. That is, the parameters of the pre-trained model obtained by training using the unlabeled samples can better extract the deep features of the face, and these features have better recognition effect for the liveness detection. Based on these parameters, only further fine adjustment is needed to quickly obtain a more accurate liveness detection model.

[0086] In step S130, the initialized detection model is trained using M labeled samples to obtain a detection model, where M is a positive integer, and the difference between N and M is greater than a preset threshold, and the label corresponding to any one of the M labeled samples includes information about whether the object in the labeled sample is a live body.

[0087] This step is a further fine adjustment based on the detection model using the parameters obtained by training using the unlabeled samples, to obtain a detection model for specific task requirements. The detection model obtained by the method is used for face liveness recognition. This step performs supervised training on the detection model based on the labeled samples.

[0088] In this step, first need to explain how to obtain the M labeled samples. Here, M is a positive integer, and the difference between N minus M is greater than a predetermined threshold; the meaning of the definition is that the two values of N and M can have an order of magnitude difference, so that by using a relatively small number of labeled samples, the detection model of the embodiment can be trained to obtain; and since the parameters of the pre-trained model trained using N unlabeled samples are used as initial parameters, these initial parameters can better reflect the deep sample features, so that the number of labeled samples M is small, and the detection model that meets the training requirements can be quickly trained to obtain.

[0089] The labeled sample is generally extracted from the obtained video image for face recognition to form a group of video frames, and then labeled to form a labeled sample.

[0090] A preferred obtaining method is to use a randomly generated method to obtain a light living body configuration file Conf = {(color1, color2, color3), (light1, light2, ligh3), duration1, duration2, duration3}, and according to the indication of the configuration file, the light living body of the identification object is collected, that is, the color sequence (color1, color2, color3) and the corresponding light intensity (light1, light2, ligh3) and the corresponding duration duration1, duration2, duration3 are used to light the identified object and simultaneously collect video images; according to the requirement of generating labeled samples, the above configuration file corresponding to the video image is returned when the video image is returned, and the time nodes (t1, t2, t3, t4) of the light color switching are recorded at the same time. Of course, whether the object photographed by the video image is a living body is also returned to label it; for the obtained video image, a number of video frames are extracted to form a group of labeled samples, specifically, four video frames can be extracted from the video image, and a typical extraction method is to extract the video frame sequence of each color of the video V according to the switching time node (t1, t2, t3, t4)

[0091] F = {I1, I2, I3, I4}

[0092] I1 = V t1

[0093] I2 = V t2-t0+(t3-t1) / 2

[0094] I3 = V t3-t0+(t3-t2) / 2

[0095] I4 = V t4-t0+duration3 / 2

[0096] wherein the subscript indicates the time point at which the video frame is obtained, and t0 is the starting time point of the video.

[0097] The extracted set of video frames, together with the labels thereof, form a (or a set of) labeled sample, which can be used for supervised training of the detection model.

[0098] Of course, the above is the preferred embodiment of the application required to obtain a labeled sample, if only the basic effect is needed, a number of video frames can be randomly obtained from the image video, and whether it is a living body is labeled.

[0099] The detection model can use various machine learning models under general technology, especially models suitable for image recognition; the detection model used in the embodiment includes an encoder for encoding images, and the encoder is used to encode the image to be recognized. Then, the encoding result of the encoder is provided to the subsequent classifier, and the classifier classifies according to the detection target of the detection model to obtain the required recognition result. The training process of the detection model will be further described below. The encoder of the detection model uses the parameters of the encoder obtained in the self-supervised learning, so that the achievements of the self-supervised learning can be borrowed, thereby obtaining better classification effect under fewer training samples.

[0100] In some possible implementations, the detection model includes a first output result, which is used to indicate whether the object to be detected in the test sample input to the detection model is a living body. In this implementation, the classifier included in the detection model can be understood as a classifier with a single classification task. At this time, the label corresponding to the labeled sample includes information about whether the object in any one labeled sample is a living body; the labeled sample can have several forms, and a typical form is a series of images obtained in a face recognition process, which are separated by several seconds.

[0101] Optionally, in some possible implementation manners, the label corresponding to any one of the labeled samples further includes a first color sequence of surface light irradiation received by the object in any one of the labeled samples, and the first color sequence is obtained by acquiring a color sequence in a randomly generated light living body configuration file Conf = {(color1, color2, color3), (light1, light2, light3), duration1, duration2, duration3} in the process of the labeled sample; correspondingly, the detection model further includes a second output result, and the second output result is used to indicate a second color sequence of surface light received by the object to be detected in the test sample input to the detection model, so that the detection model can identify color change in the image video to be recognized after being successfully trained.

[0102] In this implementation manner, the classifier included in the detection model can be understood as a classifier with two classification tasks.

[0103] Optionally, in some possible implementation manners, the label corresponding to any one of the labeled samples further includes a light available confidence of an environment in which the object in any one of the labeled samples is located, and the detection model further includes a third output result, and the third output result is used to indicate the light available confidence of the environment in which the object to be detected in the test sample input to the detection model is located. In this implementation manner, the classifier included in the detection model can be understood as a classifier with three classification tasks.

[0104] The detection models in the above several forms are respectively used to provide detection with different confidence levels.

[0105] Taking face activity detection as an example, if the detection model only outputs the first output result, that is, only outputs the face activity detection result, the output result is the recognition result of whether the tested sample is a living face. If there is only the first output result, the reliability of the detection model may be affected by some malicious attacks to output incorrect results. For example, a malicious attack mode of using a face image instead of a static image of a face, and an injection attack mode of hijacking a camera function.

[0106] If the detection model has not only the first output result, but also a second output result, and the provided detection sample is matched with the first color sequence of surface light irradiation, then according to the second output result, the recognition result of the second color sequence of light on the surface to which the object to be detected in the test sample input into the detection model is output, and the confidence level of whether the two are consistent after comparing the first color sequence of surface light irradiation used when obtaining the video frames is determined. According to the determination result, the above-mentioned static image malicious attack mode or the intermediate access malicious attack mode can be excluded. Because the malicious attack cannot provide light irradiation consistent with the detection sample. The second output result provided by the detection model is actually to enable the detection model to have the ability to identify the light irradiation condition according to the provided detection sample.

[0107] If the detection model has not only the first output result, but also a second output result, and a third output result, the third output result can further combine the confidence level of the available ambient light reflected in the third output result to determine whether the color sequence of light irradiation obtained in the second output result is in a reasonable brightness environment. Only in a reasonable brightness environment, the color sequence identified by the second output result is reliable and recognized.

[0108] In this way, if the above-mentioned scheme with three output results is adopted, the obtained detection model can make very accurate judgments on the images obtained in the activity detection process of the surface light irradiation mode.

[0109] The sample format of any one labeled sample is not specifically limited. For example, when any one unlabeled sample in the above-mentioned step S110 is an image sequence, the any one labeled sample can also be an image frame.

[0110] The above-mentioned detection model needs to be trained under a sufficient number of labeled samples to achieve sufficient training effect. Since the encoder in the detection model uses the parameters of the foregoing self-supervised training, the required training effect can be quickly obtained.

[0111] The scene to which the detection model provided by the embodiment of the present application is applied is not specifically limited. For example, the detection model can be applied to an activity detection scene.

[0112] It should be understood that the above-mentioned Figure 1The acquisition method of the detection model shown is merely illustrative, and does not constitute any limitation on the acquisition method of the detection model provided by the embodiments of the present application. For example, the initial detection model can also be directly trained using the labeled samples to obtain the detection model with single task or multi-task. For another example, in the step S130, the detection model includes an encoder and a classifier, and the classifier is a classifier with single task or multi-task, which is introduced as an example. Alternatively, the detection model in the step S130 can also include an encoder, a first classifier and a second classifier, and the first classifier and the second classifier are both single-task classifiers. The first classifier is used to output the first output result, and the second classifier is used to output the third output result.

[0113] The acquisition method of the detection model provided by the embodiments of the present application uses a large number of unlabeled samples to train a pre-trained model, initializes the parameters of the encoder included in the initial detection model using the parameters of the encoder included in the pre-trained model to obtain an initialized detection model, and trains the initialized detection model using a small number of labeled samples to obtain the detection model. In the process of obtaining the detection model, the pre-trained model is obtained by training the unlabeled samples, which can improve the utilization rate of the unlabeled data and avoid the problem of shortage of labeled data. Initializing the initial detection model using the parameters of the pre-trained model can reduce the number of training iterations of the detection model and improve the efficiency of training the detection model. Training the initialized detection model using a small number of labeled samples can further improve the accuracy of the detection model.

[0114] Figure 4 is a flowchart of an activity detection method provided by the embodiments of the present application. The activity detection method provided by the embodiments of the present application can be executed by an activity detection device. It can be understood that the activity detection device can be implemented as software or a combination of software and hardware. For example, the activity detection device in the embodiments of the present application can be, but is not limited to, a server or a terminal device used by a user. For example, Figure 4 The activity detection method provided by the embodiments of the present application includes steps S410 to S430. Next, steps S410 to S430 are described in detail.

[0115] In step S410, an activity detection request is received, the activity detection request being used to request to perform activity detection on a to-be-detected object in an image sequence, the image sequence being obtained by projecting light corresponding to light configuration information as a light source to the to-be-detected object and performing image acquisition on the to-be-detected object.

[0116] The activity detection request can be initiated according to the needs of a specific smart terminal application. The image sequence it collects is sent to the server for recognition. The detection model that executes the activity detection method of this application is deployed in the server in the form of a process.

[0117] The image sequences provided to the detection model are generally obtained through the camera equipment of a smart terminal. Typically, a number of video frames are extracted from the video data collected by the camera equipment at predetermined time intervals and provided to the detection model for liveness detection.

[0118] Optionally, before step S410, the following steps may be included: obtaining the video data when light corresponding to the pre-set light configuration information illuminates the object to be detected; and obtaining an image sequence from the video data according to a preset time interval. This preset time interval can be set according to the actual scenario and is not specifically limited thereto. The image sequence may include one or more images, which correspond to one or more video frames in the video data. By obtaining video data in conjunction with the above-mentioned light configuration information, the situation of secretly collecting video information for illegal activity detection can be largely avoided.

[0119] Step S420: Process the image sequence using the detection model to obtain the first detection result.

[0120] In this embodiment of the application, the detection model can be based on the above. Figure 1 The detection model shown is obtained using the method described above. For details on the method for obtaining the detection model, please refer to the above. Figure 1 The details described will not be elaborated further here. It is understood that this detection model is a pre-trained model, and it may include an encoder and a classifier.

[0121] Step S430: Based on the first detection result, determine whether the object to be detected in the image sequence is a living body.

[0122] In some possible implementations, determining whether the object to be detected in the image sequence is a live subject based on the first detection result includes: if the first detection result indicates that the object to be detected in the image sequence is a live subject, then the object to be detected in the image sequence is determined to be a live subject. It is understood that in this implementation, the classifier included in the detection model can be understood as a classifier with a single task: determining whether the subject is a live subject.

[0123] Optionally, in some other possible implementation manners, the label corresponding to any one of the labeled samples further includes a first color sequence of surface light radiation received by the object in any one of the labeled samples. In this implementation manner, the detection model further includes a second output result, the second output result being used to indicate a second color sequence of surface light received by the to-be-detected object in the test sample input to the detection model. Based on this, in the embodiments of the present application, the following steps can also be performed: processing the image training by using the detection model to obtain a second detection result, the second detection result being used to indicate a third color sequence, the third color sequence being a color sequence of surface light received by the to-be-detected object in the image sequence; and in a case where the light available confidence of the environment in which the to-be-detected object in the image sequence is located meets a preset requirement, if it is determined that the difference between the color sequence of the light corresponding to the light configuration information and the third color sequence is greater than a preset threshold, it is determined that the image sequence is tampered.

[0124] It can be understood that in this implementation manner, the classifier included in the detection model can be understood as a classifier with multiple tasks, the multiple tasks including a task of judging whether it is a live body and a task of obtaining the color sequence of the surface temperature light received by the to-be-detected object in the input data.

[0125] The embodiments of the present application also provide two implementation manners of obtaining the light available confidence of the environment in which the to-be-detected object in the image sequence is located. Hereinafter, the two implementation manners are specifically introduced.

[0126] Implementation manner one:

[0127] In this implementation manner, the label corresponding to any one of the labeled samples used to obtain the detection model further includes the light available confidence of the environment in which the object in any one of the labeled samples is located. Further, the detection model further includes a third output result, the third output result being used to indicate the light available confidence of the environment in which the to-be-detected object in the test sample input to the detection model is located. Based on this, the light available confidence of the environment in which the to-be-detected object in the image sequence is located can be obtained by: processing the image training by using the detection model to obtain a third detection result, the third detection result being used to indicate the light available confidence of the environment in which the to-be-detected object in the image sequence is located.

[0128] It should be noted that the step of "processing the image training by using the detection model to obtain the third detection result" in the above implementation manner one can be combined with the above step S420 as one step. That is, the first detection result and the third detection result are obtained by processing the image training by using the detection model.

[0129] It can be understood that, in the above implementation manner one, the output result of the detection model further includes the light availability confidence of the environment in which the to-be-detected object in the image sequence is located. In this implementation manner, the classifier included in the detection model can be understood as a classifier with multiple tasks, including a task of judging whether it is a living body, a task of obtaining the color sequence of the surface temperature light to which the to-be-detected object in the input data is subjected, and a task of obtaining the light availability confidence of the environment in which the to-be-detected object in the input data is located.

[0130] Implementation manner two:

[0131] In this implementation manner, the light availability confidence of the environment in which the to-be-detected object in the image sequence is located can be obtained in the following manner: obtaining the light availability confidence of the light in the environment in which the to-be-detected object is located in the video data in a case where the light configured by the light configuration information irradiates the to-be-detected object; and obtaining the light availability confidence of the light in the environment in which the to-be-detected object in the image sequence is located from the video data according to a preset time interval.

[0132] It should be noted that the step of “processing the image training by using the detection model to obtain the third detection result” in the above implementation manner two can be combined with the above step S420 as one step. In one possible implementation manner, the image training is processed by using the detection model to obtain the first detection result, the second detection result, and the third detection result.

[0133] It can be understood that, in the above implementation manner two, the light availability confidence of the environment in which the to-be-detected object in the image sequence is located can be obtained from the light sensor.

[0134] The detection result of the light availability confidence can be used as a basis for judging whether the collection environment of the image information meets the requirements. In this way, the light availability confidence detection result and the color sequence detection result are used as a basis for judging whether the video information collected is normal. If it is normal, the judgment result of the activity detection is reliable. If it is not normal, the intelligent terminal can send a prompt to the user.

[0135] The activity detection can be used as a pre-process of face recognition, or can be directly combined with the face feature information stored in the database to perform face recognition.

[0136] The activity detection method can be applied to, but is not limited to, any one of the following application scenarios: a payment scenario, an account login scenario, or an access control security scenario.

[0137] It should be understood that the above Figure 4 The activity detection method shown in the figure is only illustrative and does not constitute any limitation on the method for obtaining the detection model provided by the embodiments of the present application.

[0138] The activity detection method provided in the embodiments of the present application, after receiving an activity detection request, processes an image sequence associated with the activity detection request by using a detection model to obtain a first detection result, and determines whether a to-be-detected object in the image sequence is a living body according to the first detection result. The detection model is determined according to the method for obtaining the detection model provided in the present application, so that the first detection result has high accuracy. In addition, when the output of the detection model further includes a second detection result and a third detection result, it can be determined according to the second detection result and the third detection result whether the image sequence is tampered or attacked, which can improve the accuracy of detecting image-based attacks and injection-based attacks.

[0139] Figure 5 is a flowchart of another activity detection method provided in the embodiments of the present application. The activity detection method provided in the embodiments of the present application can be executed by an activity detection device. It can be understood that the activity detection device can be implemented as software, or a combination of software and hardware. For example, the activity detection device in the embodiments of the present application can be, but is not limited to, a server or a terminal device used by a user. As Figure 5 The activity detection method provided in the embodiments of the present application includes steps S510 to S580. In the following, steps S510 to S580 are described in detail.

[0140] Step S510, obtaining video data.

[0141] The video data is obtained by projecting light corresponding to the light configuration information as a light source to the to-be-detected object and video collecting the to-be-detected object. The light configuration information can include light availability confidence of the light and color sequence information of the light. The type and number of colors of the light included in the light configuration information are not specifically limited.

[0142] Step S520, extracting video frames from the video data according to a preset time interval to obtain an image sequence.

[0143] In the embodiments of the present application, the image sequence can include 4 video frames in the video data.

[0144] Optionally, in other implementations, the image sequence can further include a larger number (for example, 8) or a smaller number (for example, 1 or 2) of video frames in the video data.

[0145] Step S530, inputting the image sequence into a detection model to obtain a first detection result, a second detection result and a third detection result.

[0146] The first detection result is used to indicate whether the to-be-detected object in the image sequence is a living body. The second detection result is used to indicate the light available confidence of an environment in which the to-be-detected object in the image sequence is located. The third detection result is used to indicate a color sequence of light of a surface on which the to-be-detected object in the image sequence is located.

[0147] In step S540, a preliminary judgment result of whether the to-be-detected object in the image sequence is a living body is obtained according to the first detection result.

[0148] The preliminary judgment result of whether the to-be-detected object in the image sequence is a living body is obtained according to the first detection result, and includes: if the first detection result indicates that the to-be-detected object in the image sequence is a living body, step S550 is performed after step S540; and if the first detection result indicates that the to-be-detected object in the image sequence is a non-living body, step S570 is performed after step S540, and the detection is ended.

[0149] In step S550, it is determined whether the light available confidence of the environment in which the to-be-detected object in the image sequence is located meets a preset requirement according to the second detection result.

[0150] The determination of whether the light available confidence of the environment in which the to-be-detected object in the image sequence is located meets the preset requirement according to the second detection result includes: if it is determined that the preset requirement is met, step S560 is performed after step S550; and if it is determined that the preset requirement is not met, step S570 is performed after step S550. The preset requirement is used to indicate a preset environmental light available confidence, and the size of the preset environmental light available confidence can be set according to actual requirements.

[0151] In step S560, it is determined whether the image sequence is tampered with according to the third detection result.

[0152] The determination of whether the image sequence is tampered with according to the third detection result includes: by comparing the difference between the color sequence of the light corresponding to the light configuration information and the third detection result, it is determined whether the image sequence is tampered with. The specific method of judging the difference can be to judge whether the difference between the color sequence of the light corresponding to the light configuration information and the third color sequence is greater than a preset threshold value, if yes, it is determined that the image sequence is tampered with, and if no, it is determined that the image sequence is not tampered with.

[0153] It can be understood that if it is determined according to the third detection result that the image sequence is tampered with, step S570 is performed after step S560; and if it is determined according to the third detection result that the image sequence is not tampered with, step S580 is performed after step S560.

[0154] In step S570, the image sequence is intercepted, and the detection is ended.

[0155] Step S580, the image sequence is sent to a downstream task.

[0156] The downstream task can include a task associated with activity detection. For example, the task associated with activity detection can be face recognition, and further payment task, etc.

[0157] It should be understood that the above Figure 5 The activity detection method shown is only illustrative, and does not constitute any limitation on the acquisition method of the detection model provided by the embodiments of the present application. For example, the above step S530 can be replaced by the following steps: inputting the image sequence into the detection model to obtain the first detection result and the second detection result. In this implementation manner, the third detection result in the above step S530 also needs to be obtained by other devices (for example, a light sensor).

[0158] The activity detection method provided by the embodiments of the present application uses the detection model to process the image sequence to obtain the detection result corresponding to the image sequence. The detection model is a model with multi-task output results, and the detection model is a model obtained according to the acquisition method of the detection model provided by the embodiments of the present application. The detection model has high accuracy. Based on this, the detection result corresponding to the image sequence obtained has high accuracy. Specifically, in the case where the first detection result determines that the to-be-detected object in the image sequence is a live body, if the second detection result determines that the light available confidence of the environment where the to-be-detected object in the image sequence is located satisfies the preset requirement, whether the image sequence is tampered with is determined by comparing whether the color sequence of the light corresponding to the light configuration information is consistent with the third detection result, so that image-based attacks or injection attacks can be effectively intercepted.

[0159] The above combines Figures 1 to 5 The acquisition method of the detection model and the activity detection method provided by the present application are described in detail. Next, the acquisition device of the detection model, the activity detection device, the acquisition equipment of the detection model and the activity detection equipment provided by the present application are introduced. It should be understood that the acquisition method of the detection model introduced above corresponds to the acquisition device of the detection model and the acquisition equipment of the detection model involved below, and the activity detection method in the above corresponds to the activity detection device and the activity detection equipment involved below. Therefore, the content not described in detail in the following can be referred to the related description in the above method embodiment. Figures 6 to 9 The acquisition method of the detection model and the activity detection device provided by the present application are introduced. It should be understood that the acquisition method of the detection model introduced above corresponds to the acquisition device of the detection model and the acquisition equipment of the detection model involved below, and the activity detection method in the above corresponds to the activity detection device and the activity detection equipment involved below. Therefore, the content not described in detail in the following can be referred to the related description in the above method embodiment.

[0160] Corresponding to the acquisition method of the detection model provided by the embodiments of the present application, the embodiments of the present application provide an acquisition device of the detection model. As Figure 6 shown, the device includes an acquisition unit 610, a processing unit 620 and a training unit 630,

[0161] The acquisition unit 610 is configured to acquire an initial parameter, the initial parameter being a parameter acquired from a pre-trained model, the pre-trained model being a model obtained by training using N unlabeled samples, N being a positive integer; the processing unit 620 is configured to perform initialization processing on an initial detection model by using the initial parameter, to obtain an initialized model; and the training unit 630 is configured to train the initialized model by using M labeled samples, to obtain a detection model, M being a positive integer, and a difference value obtained by subtracting M from N being greater than a preset threshold, and a label corresponding to any one of the M labeled samples including information about whether an object in the any one of the labeled samples is a living body.

[0162] Optionally, in some implementations, the training unit 630 is further configured to: erase a part of an area in any one of the N unlabeled samples to obtain an unlabeled sample after erasing processing; and train an initial pre-trained model by using the unlabeled sample after erasing processing, to obtain the pre-trained model.

[0163] Optionally, in some other implementations, the training unit 630 is further configured to: encode the unlabeled sample after erasing processing by using the encoder, to obtain an encoding result; decode the encoding result by using the decoder, to obtain a restoration result according to the unlabeled sample after erasing processing; compare the restoration result with the unlabeled sample, to determine whether the restored image meets a restoration requirement, and record a result; repeat the above steps for the collected unlabeled samples, and determine whether the pre-trained model is successfully trained according to the recorded result of each round; if not, adjust parameters of the encoder and the decoder, and if yes, end the training; and the acquisition unit 610 is further configured to acquire the parameters of the encoder included in the pre-trained model after successful training, as the initial parameter.

[0164] Optionally, in some other implementations, the detection model includes a first output result, the first output result being used to indicate whether a to-be-detected object in a test sample input to the detection model is a living body.

[0165] Optionally, in some other implementations, the label corresponding to the any one of the labeled samples further includes a first color sequence of surface light radiation received by an object in the any one of the labeled samples, and the detection model further includes a second output result, the second output result being used to indicate a second color sequence of surface light received by a to-be-detected object in a test sample input to the detection model.

[0166] Optionally, in some implementations, the label corresponding to the any one labeled sample further includes a light availability confidence of an environment in which an object in the any one labeled sample is located, and the detection model further includes a third output result, the third output result being used to indicate a light availability confidence of an environment in which a to-be-detected object in a test sample input to the detection model is located.

[0167] Optionally, in some implementations, the any one unlabeled sample is an image frame, and the any one labeled sample is an image sequence.

[0168] Optionally, in some implementations, the detection model is applied to an activity detection scenario.

[0169] It should be noted that the detailed description of the obtaining apparatus of the detection model provided in the embodiments of the present application can refer to the related description in the above-mentioned obtaining method of the detection model provided in the embodiments of the present application, which will not be described here.

[0170] Corresponding to the activity detection method provided in the embodiments of the present application, the embodiments of the present application provide an activity detection apparatus. As shown in Figure 7 the apparatus includes a receiving unit 710, a processing unit 720 and a determining unit 730,

[0171] The receiving unit 710 is configured to receive an activity detection request, the activity detection request being used to request to perform activity detection on a to-be-detected object in an image sequence, the image sequence being obtained by projecting light configured information as a light source to the to-be-detected object and performing image acquisition on the to-be-detected object; the processing unit 720 is configured to process the image sequence by using a detection model to obtain a first detection result; and the determining unit 730 is configured to determine whether the to-be-detected object in the image sequence is a living body according to the first detection result, wherein the detection model is a detection model obtained according to the above-mentioned obtaining method of the detection model provided in the embodiments of the present application.

[0172] Optionally, in some implementations, the determining unit 730 is further configured to: if the first detection result is used to indicate that the to-be-detected object in the image sequence is a living body, determine that the to-be-detected object in the image sequence is a living body.

[0173] Optionally, in some other implementations, the label corresponding to the any one labeled sample further includes a first color sequence of surface light irradiation received by the object in the any one labeled sample, and the detection model further includes a second output result for indicating a second color sequence of surface light received by the to-be-detected object in the test sample input to the detection model. The processing unit 720 is further configured to: process the image sequence by using the detection model to obtain a second detection result for indicating a third color sequence, which is a color sequence of surface light received by the to-be-detected object in the image sequence; and the determination unit 730 is further configured to: if it is determined that the color sequence of the light corresponding to the light configuration information is different from the third color sequence by more than a preset threshold, determine that the image sequence is tampered.

[0174] Optionally, in some other implementations, the label corresponding to the any one labeled sample further includes a light available confidence of an environment in which the object in the any one labeled sample is located, and the detection model further includes a third output result for indicating a light available confidence of an environment in which the to-be-detected object in the test sample input to the detection model is located. The processing unit 720 is further configured to: process the image sequence by using the detection model to obtain a third detection result for indicating a light available confidence of an environment in which the to-be-detected object in the image sequence is located; and the determination unit 730 is further configured to: if the light available confidence is lower than a predetermined threshold, determine that the detection result of the detection model cannot be trusted.

[0175] Optionally, in some other implementations, the processing unit 720 is further configured to: after receiving the activity detection request, obtain video data for the to-be-detected object in a case where the light corresponding to the light configuration information irradiates the to-be-detected object; and obtain the image sequence from the video data according to a preset time interval.

[0176] Optionally, in some other implementations, the method is applied to any one of the following application scenarios: a payment scenario, an account login scenario, or an access control security scenario.

[0177] It should be noted that the detailed description of the activity detection device embodiment provided in this embodiment of the present application can refer to the related description in the activity detection method provided in the above embodiment of the present application, which will not be described here again.

[0178] Corresponding to the method for obtaining a detection model provided in this embodiment of the present application, this embodiment of the present application provides a device for obtaining a detection model. As shown in Figure 8As shown, the obtaining device of the detection model includes a processor 810 and a memory 820. The memory 820 is configured to store programs supporting the device to perform the above-mentioned Figure 1 As shown, the program of the obtaining method of the detection model, the processor 810 is configured to execute the program stored in the memory 820.

[0179] The program includes one or more computer instructions, wherein the one or more computer instructions can be implemented by the processor 810 to perform the following steps: obtaining initial parameters, the initial parameters are parameters obtained from a pre-trained model, the pre-trained model is a model obtained by training N unlabeled samples, N is a positive integer; the initial parameters are used to initialize the initial detection model, and an initialized model is obtained; the initialized model is trained by using M labeled samples, and a detection model is obtained, M is a positive integer, and a difference obtained by subtracting M from N is greater than a preset threshold, and a label corresponding to any one of the M labeled samples includes information whether an object in any one of the labeled samples is a living body.

[0180] Optionally, the processor 810 executes the above-mentioned Figure 1 All or part of the steps in the method embodiments are not described in detail here, and the related description can be referred to the above description, which will not be described in detail here.

[0181] The structure of the activity detection device can further include a communication interface 830, which is configured to communicate with other devices or communication networks. For example, the M labeled samples are obtained through the communication interface 830.

[0182] Corresponding to the activity detection method provided in the embodiments of the present application, the embodiments of the present application provide an activity detection device. As shown in Figure 9 As shown, the activity detection device includes a processor 910 and a memory 920. The memory 920 is configured to store programs supporting the device to perform the above-mentioned Figure 4 And / or Figure 5 As shown, the program of the activity detection method, the processor 910 is configured to execute the program stored in the memory 920.

[0183] The program includes one or more computer instructions, wherein the one or more computer instructions enable the processor 910 to perform the following steps: receiving an activity detection request, the activity detection request being used to request to perform activity detection on a to-be-detected object in an image sequence, the image sequence being obtained by projecting light corresponding to light configuration information as a light source to the to-be-detected object and performing image acquisition on the to-be-detected object; processing the image sequence by using a detection model to obtain a first detection result; and determining whether the to-be-detected object in the image sequence is a living body according to the first detection result; wherein the detection model is a model obtained according to the method for obtaining a detection model provided in the embodiments of the present application.

[0184] Alternatively, the processor 910 performs all or part of the steps in the foregoing Figure 4 and / or Figure 5 method embodiments, and details that are not described herein can be referred to in the foregoing relevant description, and will not be described in detail here.

[0185] The structure of the activity detection device can further include a communication interface 930, which is used for the device to communicate with other devices or communication networks. For example, the activity detection request is received through the communication interface 930.

[0186] The embodiments of the present application also provide a computer storage medium for storing computer software instructions for the electronic device, which includes a program for performing the method for obtaining a detection model in the foregoing Figures 1 to 3 method embodiments.

[0187] The embodiments of the present application also provide a computer storage medium for storing computer software instructions for the electronic device, which includes a program for performing the activity detection method in the foregoing Figure 4 and / or Figure 5 method embodiments.

[0188] Through the description of the foregoing embodiments, those skilled in the art can easily understand that the example embodiments described herein can be implemented by software, or by a combination of software and necessary hardware. Therefore, the technical solutions according to the embodiments of the present application can be embodied in the form of a software product. The software product can be stored in a computer readable medium, including a number of instructions to make a computer device (which can be a personal computer, a server, a terminal device, or a network device, etc.) execute the methods according to the embodiments of the present application.

[0189] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memories.

[0190] Memory can include, without being limited to, non-persistent memory, random access memory (RAM), and / or non-volatile memory, etc., such as read-only memory (ROM), or flash memory (flash RAM), in a computer-readable medium. Memory is an example of computer-readable media.

[0191] 1. Computer-readable media includes permanent and non-permanent, removable and non-removable media can be implemented by any method or technology to store information. Information can be computer-readable instructions, data structures, program modules 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, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, magnetic tape, magnetic disk storage or other magnetic storage media or any other non-transmission medium that can be used to store information that can be accessed by a computing device. According to the definition herein, computer-readable media does not include non-transitory computer-readable media, such as modulated data signals and carriers.

[0192] 2. Those skilled in the art should understand that the embodiments of the present application can be provided as a method, system or computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented 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.

[0193] Although the present application is disclosed as above with preferred embodiments, it is not intended to limit the present application, and any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of the present application, therefore the protection scope of the present application should be limited by the scope defined by the claims of the present application.

Claims

1. A method for obtaining a detection model, characterized in that, include: Obtain initial parameters, which are parameters obtained from a pre-trained model, where the pre-trained model is a model obtained by training with N unlabeled samples, where N is a positive integer; The initial detection model is initialized using the initial parameters to obtain the initialized model; The initialized model is trained using M labeled samples to obtain a detection model, where M is a positive integer and the difference between N and M is greater than a preset threshold. The label corresponding to any one of the M labeled samples includes information on whether the object in the labeled sample is a live object. The labeled sample is an image sequence. Specifically, a portion of a region in any one of the N unlabeled samples is erased to obtain an erased unlabeled sample; the erased unlabeled sample is then used to train an initial pre-trained model to obtain the pre-trained model. The initial pre-trained model includes an encoder and a decoder, wherein obtaining the initial parameters includes: obtaining the parameters of the encoder included in the pre-trained model after successful training, and using them as the initial parameters.

2. The method according to claim 1, characterized in that, The training of the initial pre-trained model includes: The encoder is used to encode the erased, unlabeled sample to obtain the encoding result; The decoder is used to decode the encoding result to obtain the restoration result of the unlabeled sample after the erasure process; The restoration result is compared with the unlabeled sample to determine whether the restored image meets the restoration requirements, and the result is recorded. Repeat the above steps for the collected unlabeled samples, and determine whether the pre-trained model has been successfully trained based on the results of each round. If it is unsuccessful, adjust the parameters of the encoder and decoder. If it is successful, end the training.

3. The method according to any one of claims 1 to 2, characterized in that, The detection model includes a first output result, which is used to indicate whether the object to be detected in the test sample input to the detection model is a living organism.

4. The method according to claim 1, characterized in that, The label corresponding to any tagged sample also includes the first color sequence of the surface light received by the object in the tagged sample. The detection model also includes a second output result, which is used to indicate a second color sequence of light received by the surface of the object to be detected in the test sample input to the detection model.

5. The method according to claim 1, characterized in that, The label corresponding to any tagged sample also includes the available confidence level of the light in the environment where the object in the tagged sample is located. The detection model also includes a third output result, which is used to indicate the confidence level of the available light in the environment of the object to be detected in the test sample input to the detection model.

6. The method according to claim 1, characterized in that, Each unlabeled sample is an image frame.

7. The method according to claim 1, characterized in that, The detection model is applied to activity detection scenarios.

8. A method for detecting activity, characterized in that, include: Receive an activity detection request, the activity detection request being used to request activity detection of an object to be detected in an image sequence, the image sequence being obtained by projecting light corresponding to the light configuration information as a light source onto the object to be detected and acquiring an image of the object to be detected; The image sequence is processed using a detection model to obtain a first detection result; Based on the first detection result, a preliminary judgment result is made as to whether the object to be detected in the image sequence is a living body; The detection model is the detection model obtained by the method according to any one of claims 1 to 7.

9. The method according to claim 8, characterized in that, The step of determining whether the object to be detected in the image sequence is a live object based on the first detection result includes: If the first detection result is a preliminary judgment that the object to be detected in the image sequence is a living body, then the object to be detected in the image sequence is determined to be a living body.

10. The method according to claim 8 or 9, characterized in that, The detection model includes at least the technical features further defined in claim 4; The method further includes: The image sequence is processed using the detection model to obtain a second detection result. The second detection result is used to indicate a third color sequence, which is the color sequence of the light received by the surface of the object to be detected in the image sequence. If it is determined that the difference between the color sequence of the light corresponding to the light configuration information and the third color sequence is greater than a preset threshold, then it is determined that the image sequence has been tampered with.

11. The method according to claim 8, characterized in that, The detection model includes at least the technical features further defined in claim 5. The method further includes: The image sequence is processed using the detection model to obtain a third detection result, which is used to indicate the confidence level of the availability of light in the environment of the object to be detected in the image sequence; if the confidence level of the availability of light is lower than a predetermined threshold, the detection result of the detection model is determined to be unreliable.

12. The method according to claim 11, characterized in that, The method further includes: Upon receiving the activity detection request, when the light corresponding to the light configuration information illuminates the object to be detected, video data for the object to be detected is obtained. The image sequence is obtained from the video data according to a preset time interval.

13. The method according to any one of claims 8 to 9 and 11 to 12, characterized in that, The method can be applied to any of the following application scenarios: Payment scenarios, account login scenarios, or access control and security scenarios.

14. A device for acquiring a detection model, characterized in that, include: processor; as well as The memory is used to store data processing programs. After the activity detection device is powered on and the processor runs the programs, it executes the method as described in any one of claims 1 to 7.

15. An activity detection device, characterized in that, include: processor; as well as A memory for storing a data processing program, wherein after the activity detection device is powered on and the program is run by the processor, the method as described in any one of claims 8 to 13 is executed.

Citation Information

Patent Citations

  • Biological recognition method, device and system, storage medium and electronic equipment

    CN114495287A