Training methods, apparatus and computer-readable storage media for detection models

By iteratively training and adjusting the parameters of the detection model, and grouping according to attack type and evaluating distance value, the problem of inaccurate detection of spoofed face information in the face recognition system is solved, and the accuracy of liveness detection is improved.

CN115273246BActive Publication Date: 2026-04-03ZHEJIANG DAHUA TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-20
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

Existing facial recognition systems suffer from inaccurate detection of spoofed facial information, especially when facing attacks using unknown non-live data. This makes it difficult to effectively distinguish between live and non-live faces, resulting in insufficient security.

Method used

By iteratively training the detection model, grouping non-live images according to attack type, and determining the evaluation value based on the distance and metric value between sample features and live features, the model parameters are adjusted to increase the distance between non-live features and live features, thereby improving detection accuracy.

Benefits of technology

After training, even when faced with unknown non-living image attacks, the detection model can accurately identify non-living objects, significantly improving the accuracy of liveness detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115273246B_ABST
    Figure CN115273246B_ABST
Patent Text Reader

Abstract

This application discloses a training method, apparatus, and computer-readable storage medium for a detection model. The training method includes: acquiring multiple sample images corresponding to the current iteration processing, and dividing the non-live images in the multiple sample images into multiple first image groups according to the attack type; acquiring the current live features corresponding to the current iteration processing of the detection model; determining a first distance value between the sample features of each first image group and the current live features; determining a first evaluation value corresponding to each first image group based on the first distance value and the corresponding metric value; determining a first loss value based on the first evaluation value corresponding to each first image group; and adjusting the parameters of the detection model based on the first loss value. The training method provided by this application can improve the accuracy of liveness detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of image processing technology, and in particular relates to a training method, apparatus and computer-readable storage medium for a detection model. Background Technology

[0002] In recent years, facial recognition technology has been increasingly applied to intelligent devices, such as turnstiles, attendance machines, and mobile phone facial payment systems. However, facial recognition technology currently faces significant security risks. For instance, if a user's facial information is stolen, it can be projected onto a mobile phone screen, printed as a photograph, or used to create a mask to impersonate the user's face for authentication, thus attacking the identity verification system. If the facial authentication system fails to accurately detect spoofed facial information, it can cause incalculable losses to users. Therefore, liveness detection for faces to be authenticated is essential.

[0003] Currently, research on liveness detection is becoming an increasingly important research task in face recognition. However, liveness data is relatively concentrated, while the types of attacks on non-liveness data are becoming more and more diverse. For example, attacks using black and white printed photos, color images wrapped in bags, and 3D head models made of different materials are being used. Therefore, in addition to detecting common non-liveness data, liveness detection systems also need to detect unknown data that has never been seen before. Summary of the Invention

[0004] This application provides a method, apparatus, and computer-readable storage medium for training a detection model, which can improve the accuracy of liveness detection.

[0005] The first aspect of this application provides a training method for a detection model, the training method comprising: iteratively processing the detection model in the following manner until the detection model converges: acquiring multiple sample images corresponding to the current iteration, and dividing the non-live images in the multiple sample images into multiple first image groups according to the attack type; acquiring the current live feature corresponding to the current iteration of the detection model; determining a first distance value between the sample feature of each first image group and the current live feature; determining a first evaluation value corresponding to each first image group based on the first distance value and the corresponding metric value, wherein, in response to the first distance value corresponding to the first image group being greater than or equal to the corresponding metric value, the first evaluation value corresponding to the first image group is equal to zero, otherwise the corresponding first evaluation value is greater than zero; determining a first loss value based on the first evaluation value corresponding to each first image group, wherein the smaller the first evaluation value corresponding to the first image group, the smaller the first loss value; and adjusting the parameters of the detection model based on the first loss value.

[0006] A second aspect of this application provides a training device, which includes a processor, a memory, and a communication circuit. The processor is coupled to the memory and the communication circuit, respectively. The memory stores program data, and the processor executes the program data in the memory to implement the steps in the above method.

[0007] A third aspect of this application provides a computer-readable storage medium storing a computer program that can be executed by a processor to implement the steps in the above-described method.

[0008] The beneficial effects are as follows: This application sets the first evaluation value corresponding to the first image group to be equal to zero when the first distance value corresponding to the first image group is greater than or equal to the corresponding metric value, otherwise the corresponding first evaluation value is greater than zero, and the first loss value is positively correlated with the first evaluation value. Thus, during the training process, the first distance value between the sample features of the first image group and the current live feature is made to be greater than or equal to the metric value corresponding to the first image group as much as possible, ensuring that the distance between the sample features of the first image group and the current live feature is large enough, and widening the distance between the non-live features of the first image group and the current live feature. Thus, after training, even if the attack type of the non-live image is unknown, the detection model will accurately identify it as non-live, which can improve the detection accuracy of the detection model. Attached Figure Description

[0009] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort, wherein:

[0010] Figure 1 This is a flowchart illustrating one implementation method of the training method for the detection model of this application;

[0011] Figure 2 yes Figure 1 A flowchart illustrating step S130;

[0012] Figure 3 yes Figure 1 A flowchart of step S140 in an application scenario;

[0013] Figure 4 yes Figure 1 A flowchart illustrating step S140 in another application scenario;

[0014] Figure 5 yes Figure 4 A flowchart illustrating step S1412;

[0015] Figure 6 yes Figure 1 A flowchart illustrating step S140 in another application scenario;

[0016] Figure 7 yes Figure 6 A flowchart illustrating step S1421;

[0017] Figure 8 yes Figure 1 A flowchart illustrating step S150;

[0018] Figure 9 This is a schematic diagram of one embodiment of the training device of this application;

[0019] Figure 10 This is a schematic diagram of another embodiment of the training device of this application;

[0020] Figure 11 This is a schematic diagram of one embodiment of the computer-readable storage medium of this application. Detailed Implementation

[0021] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0022] See Figure 1 , Figure 1 This is a flowchart illustrating one implementation method of the training method for the detection model of this application. The method includes:

[0023] Repeat steps S110-S150 until the detection model converges:

[0024] S110: Obtain multiple sample images corresponding to this iteration, and divide the non-live images in the multiple sample images into multiple first image groups according to the attack type.

[0025] Specifically, non-living images are different from living images. Living images refer to images taken directly of a living person, in which case the object to be authenticated in the image is a living person. Conversely, non-living images refer to images in which the object to be authenticated is not a living person. For example, the object to be authenticated in a non-living image is a printed object on paper, or the object to be authenticated in a non-living image is a 2D mask, 3D mask, or 3D head model, etc.

[0026] The attack type refers to the type of the object to be authenticated in the non-liveness image. For example, if the object to be authenticated in the non-liveness image is a paper print, then the attack type of the non-liveness image is a paper print attack; if the object to be authenticated in the non-liveness image is a 2D mask, then the attack type of the non-liveness image is a 2D mask attack; and if the object to be authenticated in the non-liveness image is a 3D head model, then the attack type of the non-liveness image is a 3D head model attack.

[0027] After acquiring multiple sample images, the non-living images within these sample images are grouped: sample images with the same attack type are grouped into one group, and sample images with different attack types are grouped into different groups, thus obtaining multiple first image groups. For example, non-living images with the attack type of paper printing attack are grouped into one group, images with the attack type of 2D mask attack are grouped into another group, images with the attack type of 3D mask attack are grouped into yet another group, and images with the attack type of 3D head model attack are grouped into yet yet another group.

[0028] It is understandable that after grouping, each first image group corresponds to an attack type, and different first image groups correspond to different attack types.

[0029] It should be noted that in different application scenarios, non-live images in multiple sample images can be grouped according to different rules. For example, the object to be authenticated in non-live image A is a 2D mask, and the object to be authenticated in non-live image B is a 3D mask. In one application scenario, the attack type of non-live image A and non-live image B can be determined to be the same, both being mask attacks. However, in another application scenario, the attack type of non-live image A and non-live image B can be determined to be different: the attack type of non-live image A is a 2D mask attack, and the attack type of non-live image B is a 3D mask attack.

[0030] In summary, the criteria for determining whether two non-living images are of the same attack type can be set according to actual needs, and no restrictions are imposed here.

[0031] S120: Obtain the current liveness feature corresponding to the current iterative processing of the detection model, and determine the first distance value between the sample feature of each first image group and the current liveness feature.

[0032] Specifically, the current liveness features are updated each time the detection model is trained. The purpose of training the detection model can be understood as making the current liveness features closer to the features of a real live body. Step S120 obtains the latest current liveness features. When step S120 is executed next time, the current liveness features obtained will be different from the current liveness features obtained this time.

[0033] Each first image group has a corresponding sample feature, which is related to the sample images in the first image group. The sample feature of the first image group is obtained by extracting features from the sample images in the first image group using the current detection model to be trained. In other words, the latest detection model is used to extract features from the sample images in the first image group to obtain the sample feature of the first image group.

[0034] In one application scenario, the process of determining the sample features of the first image group can be as follows: Feature extraction is performed on each sample image in the first image group using the detection model currently being trained, obtaining the image features of each sample image. Then, the image features corresponding to all sample images in the first image group are fused to obtain the sample features corresponding to the first image group. Any existing fusion technique can be used to fuse the image features corresponding to all sample images in the first image group; the details of this fusion process will not be elaborated here.

[0035] In another application scenario, the process of determining the sample features of the first image group can also be: using the detection model to be trained to extract features from any sample image in the first image group, and then using the image features of that sample image as the sample features of the first image group.

[0036] In summary, this application does not restrict the specific process of determining the sample features of the first image group, as long as the feature extraction is performed using the detection model to be trained.

[0037] The detection model can extract high-dimensional image features from sample images during feature extraction. This application does not restrict the structure of the detection model; for example, it can be a basic network such as ResNet or VGG, or a related evolved network.

[0038] The smaller the first distance value between the sample features of the first image group and the current liveness feature, the higher the similarity between the sample features of the first image group and the current liveness feature.

[0039] For ease of explanation, we assume that multiple first image groups are numbered starting from 1, and the first image group numbered i is denoted as first image group i. The first distance value between the sample features of first image group i and the current liveness feature is denoted as DL. i Here, the value of i ranges from [1, N], where N is the number of the first image group.

[0040] In one application scenario, the Euclidean distance between the sample features of the first image group i and the current liveness feature is determined as the first distance value DL between the sample features of the first image group i and the current liveness feature. iThe first distance value DL between the sample image of the first image group i and the current liveness feature is determined using the following formula. i :

[0041] Among them, c live This is the current living characteristic, x i These are the sample features of the first image group i.

[0042] Of course, in other embodiments, other formulas can be used to determine the first distance value between the sample features of the first image group and the current live features. This application does not limit the specific determination of the first distance value.

[0043] S130: Determine the first evaluation value corresponding to each first image group based on the first distance value and the corresponding metric value corresponding to each first image group, wherein the first evaluation value corresponding to the first image group is equal to zero if the first distance value corresponding to the first image group is greater than or equal to the corresponding metric value, otherwise the corresponding first evaluation value is greater than zero.

[0044] Specifically, each first image group corresponds to a metric value, and all metric values ​​for each first image group are positive numbers, which can be preset by the designer. The metric value corresponding to the first image group i is denoted as m. i The metric values ​​corresponding to different first image groups can be the same or different.

[0045] For each first image group, a first evaluation value is determined based on its corresponding first distance value and metric value. In other words, each first image group will have a corresponding first evaluation value. The first evaluation value corresponding to first image group i is denoted as p. i .

[0046] Specifically, when determining the first evaluation value corresponding to the first image group, if the first distance value corresponding to the first image group is greater than or equal to the corresponding metric value, then the corresponding first evaluation value is determined to be zero; otherwise, the corresponding first evaluation value is determined to be greater than zero.

[0047] See Figure 2 In this embodiment, the following steps S131-S134 are performed for each first image group to determine the first evaluation value corresponding to each first image group:

[0048] S131: Determine the difference between the metric value corresponding to the first image group and the corresponding first distance value to obtain the first difference value corresponding to the first image group.

[0049] That is, the first difference corresponding to the first image group i is m. i -DL i .

[0050] S132: Combine the first difference with zero to form the first array.

[0051] That is, the first array corresponding to the first image group i is (0, m) i -DL i ).

[0052] S133: Perform the maximum value operation on the first array to obtain the maximum value corresponding to the first image group.

[0053] Specifically, after step S133, the maximum value corresponding to the first image group i is equal to max(0, m). i -DL i ).

[0054] S134: Determine the first evaluation value corresponding to the first image group based on the maximum value corresponding to the first image group.

[0055] Specifically, after obtaining the maximum value corresponding to the first image group i, this maximum value can be directly determined as the first evaluation value p corresponding to the first image group i. i That is, p i =max(0, m) i -DL i Alternatively, the maximum value can be squared or cubed to obtain the first evaluation value p corresponding to the first image group i. i .

[0056] In this embodiment, the maximum value corresponding to the first image group i is squared to obtain the first evaluation value p corresponding to the first image group i. i That is, p i =max(0, m) i -DL i ) 2 For ease of explanation, the first evaluation value corresponding to the first image group i will be max(0, m). i -DL i ) 2 Please provide an explanation.

[0057] The first evaluation value corresponding to the first image group i is max(0, m) i -DL i ) 2 It can be seen that when m i -DL i When ≤0, the first evaluation value corresponding to the first image group i is equal to zero; otherwise, it is equal to m. i -DL i That is, when the first distance value DL corresponding to the first image group i i Greater than or equal to the corresponding metric value m iWhen the first evaluation value is zero, the first evaluation value corresponding to the first image group i is equal to zero; otherwise, the corresponding first evaluation value is greater than zero.

[0058] It should be noted that in other embodiments, other methods can be used to determine the first evaluation value corresponding to the first image group. As long as the first distance value corresponding to the first image group is greater than or equal to the corresponding metric value, the first evaluation value corresponding to the first image group is equal to zero; otherwise, the corresponding first evaluation value is greater than zero.

[0059] As can be seen from the above, the minimum evaluation value corresponding to the first image group is equal to zero.

[0060] S140: Determine a first loss value based on the first evaluation value corresponding to each first image group, wherein the smaller the first evaluation value corresponding to the first image group, the smaller the first loss value.

[0061] Specifically, the first loss value is related to the first assessment value; the smaller the first assessment value, the smaller the first loss value. In other words, the first loss value is positively correlated with the first assessment value.

[0062] S150: Adjust the parameters of the detection model based on the first loss value.

[0063] Specifically, after step S150, multiple new sample images are acquired, and based on these multiple new sample images, steps S110-S150 are executed until the detection model converges.

[0064] In the above implementation, the first evaluation value corresponding to the first image group is set to be equal to zero when the first distance value corresponding to the first image group is greater than or equal to the corresponding metric value; otherwise, the first evaluation value is greater than zero, and the first loss value is positively correlated with the first evaluation value. This ensures that during training, the first distance value between the sample features of the first image group and the current liveness feature is greater than or equal to the metric value corresponding to the first image group, guaranteeing that the distance between the sample features of the first image group and the current liveness feature is large enough. This widens the distance between the non-liveness features of the first image group and the current liveness feature, so that after training, even if the attack type of the non-liveness image is unknown, the detection model will accurately identify it as non-liveness, thereby improving the detection accuracy of the detection model.

[0065] In one application scenario, step S140 uses the following formula to determine the first loss value L. multimargin :

[0066] The average of the first evaluation values ​​is determined as the first loss value. This satisfies the condition that the smaller the first evaluation value corresponding to the first image group i, the smaller the first loss value. It can be understood that when p... i =max(0, m)i -DL i ) 2 hour,

[0067] In another application scenario, see [reference] Figure 3 The process of determining the first loss value in step S140 includes:

[0068] S1401: Determine a second distance value between the sample features of the second image group and the current liveness features, wherein the second image group includes liveness images from multiple sample images.

[0069] Specifically, the live images from multiple sample images are grouped into a second image group. It can be understood that the second image group consists of one image group.

[0070] Furthermore, after obtaining the second image group, the sample features of the second image group are determined. The process of determining the sample features of the second image group is similar to the process of determining the sample features of the first image group, and will not be repeated here.

[0071] The process of determining the second distance value corresponding to the second image group is similar to the process of determining the first distance value corresponding to the first image group, as detailed above. It will not be repeated here.

[0072] Understandably, the smaller the second distance value between the sample features of the second image group and the current liveness feature, the higher the similarity between the sample features of the second image group and the current liveness feature.

[0073] S1402: Determine the second evaluation value based on the second distance value, wherein the smaller the second distance value, the smaller the second evaluation value.

[0074] For ease of explanation, the second distance value will be denoted as DL. x Let the second evaluation value be denoted as k. The second distance value can be directly determined as the second evaluation value, i.e., k = DL. x Alternatively, the second distance value can be squared or cubed to obtain the second evaluation value.

[0075] In this embodiment, the second distance value is squared to obtain the second evaluation value, i.e., k = DL. x 2 For ease of explanation, the second evaluation value will be assumed to be equal to DL in the following text. x 2 Please provide an explanation.

[0076] S1403: Determine a first loss value based on the second evaluation value and the first evaluation value corresponding to each first image group, wherein the smaller the second evaluation value, the smaller the first loss value.

[0077] Specifically, the first loss value is correlated with both the first and second assessment values. The smaller the first assessment value, the smaller the first loss value; the smaller the second assessment value, the smaller the first loss value. In other words, the first loss value is positively correlated with both the first and second assessment values.

[0078] The first loss value can be obtained by summing all the first and second evaluation values, or it can be determined using the following formula:

[0079] Wherein, N+1 is the first sum of the number of image groups in the first image group and the number of image groups in the second image group; The second sum is obtained by summing all the first and second evaluation values; It is the product of the reciprocal of the first sum and the first product of the second sum.

[0080] It is understandable that when p i =max(0, m) i -DL i ) 2 k = DL x 2 hour,

[0081] It should be noted that in the above application scenario, the first product is directly determined as the first loss value. However, in other application scenarios, after obtaining the first product, other operations such as squaring or cubed can be performed on the first product to obtain the first loss value.

[0082] In addition to setting the first loss value to be positively correlated with the first evaluation value, the above scheme also sets the first loss value to be positively correlated with the second evaluation value. This is to minimize the distance between the sample features of the second image group and the current live features during the training process, thereby reducing the distance between the live features of the second image group and the current live features and further improving the detection accuracy of the detection model.

[0083] In this embodiment, the higher the similarity between the attack type corresponding to the first image group and the live object, the smaller the metric value corresponding to the first image group.

[0084] Specifically, the closer the attack type corresponding to the first image group is to that of a live target, the smaller the metric value corresponding to the first image group.

[0085] For better understanding, an example is given below for illustration: The attack type of the first image group 1 is paper printing attack, the attack type of the first image group 2 is 2D mask attack, the attack type of the first image group 3 is 3D mask attack, and the attack type of the first image group 4 is 3D head model attack. According to common sense, sorting in descending order of similarity to a live body, the sorting result is: the first image group 4, the first image group 3, the first image group 2, the first image group 1. Then, the magnitude relationship of the metric values between each first image group is set as: m4 < m3 < m2 < m1.

[0086] Setting the metric value according to the similarity between the attack type of the first image group and a live body can ensure a reasonable constraint relationship of the sample features of the first image groups with different attack types in the feature space, and further improve the detection accuracy of the detection model.

[0087] In another application scenario, refer to Figure 4 , the process of determining the first loss value in step S140 includes:

[0088] S1411: Respectively determine the first distance value corresponding to at least one first target image group minus the first distance value corresponding to the respective second target image group corresponding to the first target image group, to obtain the second difference value corresponding to each first target image group, where the metric value corresponding to the first target image group is less than the metric value corresponding to the respective second target image group.

[0089] Specifically, the first target image group can be any one of the first image groups, and the second target image group corresponding to the first target image group can be any one of the first image groups whose corresponding metric value is greater than the metric value corresponding to the first target image group.

[0090] For example, assume that for the first image group 1, the first image group 2, the first image group 3, and the first image group 4, their metric value magnitude relationship is: m1 < m2 < m3 < m4. Then, if the first image group 1 is taken as the first target image group, the second target image group corresponding to this first target image group can be the first image group 2, the second image group 3, or the first image group 4.

[0091] Step S1411 may involve determining that the first distance value corresponding to different first target image groups is reduced by the first distance value corresponding to the second target image group corresponding to each of the first target image groups, or determining that the first distance value corresponding to the same first target image group is reduced by the first distance value corresponding to the multiple second target image groups corresponding to the first target image group, or may simultaneously include: determining that the first distance value corresponding to different first target image groups is reduced by the first distance value corresponding to the second target image group corresponding to each of the first target image groups, and determining that the first distance value corresponding to the same first target image group is reduced by the first distance value corresponding to the multiple second target image groups corresponding to the same first target image group.

[0092] In this application scenario, the first image group is sorted according to the corresponding metric value from smallest to largest, wherein the second target image group corresponding to the first target image group is adjacent to the first target image group.

[0093] Specifically, after sorting the multiple first image groups according to their corresponding metric values ​​from smallest to largest, for any first target image group, its corresponding second target image group refers to the first image group that is adjacent to the first target image group and whose metric value is greater than the metric value corresponding to the first target image group.

[0094] For ease of explanation, after sorting the multiple first image groups in ascending order according to their corresponding metric values, the multiple first image groups are then numbered starting from 1 in a front-to-back order. At this point, m1 <m2、m2<m3,…,m i <m i+1 …, m N-1 <m N .

[0095] If the first image group i is the first target image group, then the second target image group corresponding to the first target image group is the first image group i+1, and the second difference is equal to DL. i -DL i+1 Here, the value of i ranges from [0, N-1].

[0096] In this application scenario, the number of second differences can be set to N-1. Specifically, step S1411 includes: calculating the first distance value corresponding to all first target image groups minus the first distance value corresponding to the corresponding second target image group, i.e., determining the values ​​of DL1-DL2, DL2-DL3, and so on, until DL... N-1 -DL N The value is obtained, thus yielding N-1 second differences.

[0097] In other application scenarios, the number of second differences can be set to be less than N-1. That is, only the first distance value corresponding to a portion of the first target image group is determined, minus the first distance value corresponding to the second target image group corresponding to the first target image group. However, for ease of explanation, the following explanation will use N-1 as the number of second differences.

[0098] S1412: Determine the third evaluation value corresponding to each second difference, wherein the third evaluation value corresponding to the second difference is equal to zero in response to the second difference being less than or equal to zero, otherwise the corresponding third evaluation value is greater than zero.

[0099] Specifically, when determining the third evaluation value corresponding to the second difference, if the second difference is less than or equal to zero, the corresponding third evaluation value is determined to be equal to zero; otherwise, the corresponding third evaluation value is determined to be greater than zero.

[0100] Among them, the second difference DL i -DL i+1 The corresponding third evaluation value is denoted as q. i .

[0101] See Figure 5 In this application scenario, for each second difference, the following steps S14121-S14123 are performed to obtain the third evaluation value corresponding to each second difference:

[0102] S14121: Combine the second difference with zero to form the second array.

[0103] Specifically, the second difference DL i -DL i+1 The second array consisting of zero and 0 is denoted as (0, DL). i -DL i+1 ).

[0104] S14122: Perform the maximum value operation on the second array to obtain the maximum value corresponding to the second difference.

[0105] Specifically, the second difference DL i -DL i+1 The corresponding maximum value is equal to max(0, DL) i -DL i+1 ).

[0106] S14123: Determine the third evaluation value corresponding to the second difference based on the maximum value corresponding to the second difference.

[0107] Specifically, after obtaining the maximum value corresponding to the second difference, this maximum value can be directly determined as the third evaluation value corresponding to the second difference, i.e., q. i =max(0,DL) i -DL i+1Alternatively, operations such as squaring or cubicing the maximum value can be performed to obtain the third evaluation value corresponding to the second difference.

[0108] In this embodiment, the maximum value corresponding to the second difference is squared to obtain the third evaluation value corresponding to the second difference, i.e., q. i =max(0,DL) i -DL i+1 ) 2 For ease of explanation, the third evaluation value will be used as q in the following text. i =max(0,DL) i -DL i+1 ) 2 Please provide an explanation.

[0109] S1413: Determine a first loss value based on the first evaluation value corresponding to each first image group and the third evaluation value corresponding to each second difference, wherein the smaller the third evaluation value corresponding to the first difference, the smaller the first loss value.

[0110] Specifically, the first loss value is related to both the first and third assessment values. The smaller the first assessment value, the smaller the first loss value, and the smaller the third assessment value, the smaller the first loss value.

[0111] The first loss value can be obtained by summing all the first and third evaluation values, or it can be determined using the following formula:

[0112]

[0113] Specifically, if the number of first evaluation values ​​is N and the number of third evaluation values ​​is N-1, then the sum of the number of first evaluation values ​​and the number of third evaluation values ​​is defined as the third sum, which is (2N-1). The fourth sum is obtained by summing all first evaluation values ​​and all third evaluation values. The product of the reciprocal of the third sum and the second product of the fourth sum equals

[0114] The above formula directly determines the second product as the first loss value. However, in other application scenarios, after obtaining the second product, other operations such as squaring or cubed can be performed on the second product to obtain the first loss value.

[0115] It is understandable that when p i =max(0, m) i -DL i ) 2 q i =max(0,DL) i -DL i+1 )2 When, the above formula can be

[0116] In the above application scenarios, in addition to widening the distance between the sample features of the first image group and the current liveness features, constraints are also imposed on the first distance values ​​corresponding to different first image groups based on the similarity between the attack type and the liveness. This is more realistic and can further improve the detection accuracy of the detection model.

[0117] In yet another application scenario, see [reference] Figure 6 Step S140, determining the first loss value, includes:

[0118] S1421: Determine the first loss value based on the second evaluation value, the first evaluation value corresponding to each first image group, and the third evaluation value corresponding to each second difference.

[0119] Among them, the second evaluation value, all the first evaluation values, and all the third evaluation values ​​can be summed, and the value obtained by the summation process is determined as the first loss value.

[0120] Or, see Figure 7 Step S1421 may specifically include:

[0121] S14211: Determine the sum of the number of the first evaluation value, the number of the second evaluation value, and the number of the third evaluation value to obtain the fifth sum value.

[0122] It is understandable that the fifth sum equals

[0123] S14212: Summing all the first, second, and third evaluation values ​​yields the sixth sum.

[0124] Specifically, if the number of first evaluation values ​​is N, the number of second evaluation values ​​is one, the number of third evaluation values ​​is N-1, then the sixth sum is equal to N+1+N-1, and the final result is 2N.

[0125] S14213: Determine the reciprocal of the fifth sum and the third product of the sixth sum.

[0126] Specifically, the third product equals

[0127] S14214: Determine the first loss value based on the third product.

[0128] Specifically, the third product can be directly determined as the first loss value, or the third product can be squared or cubed to obtain the first loss value.

[0129] For example, when the third product is determined as the first loss value, the formula for calculating the first loss value is:

[0130]

[0131] Where, when k = DL x 2 p i =max(0, m) i -DL i ) 2 , and q i =max(0,DL) i -DL i+1 ) 2 When the above formula is:

[0132] In this application scenario, on the one hand, the distance between the sample features of the first image group and the current liveness feature is increased, and on the other hand, the distance between the sample features of the second image group and the current liveness feature is decreased. At the same time, constraints are imposed on the first distance values ​​corresponding to different first image groups based on the similarity between the corresponding attack type and the liveness, which is more in line with reality and can further improve the detection accuracy of the detection model.

[0133] The above describes the specific process of determining the first loss value. The following describes the process of training the detection model based on the first loss value:

[0134] In one application scenario, the detection model can be trained using only the first loss value.

[0135] In another application scenario, see [reference] Figure 8 Step S150 includes:

[0136] S151: Use the detection model to perform liveness detection on multiple sample images to obtain multiple detection results.

[0137] Specifically, the detection model is used to perform liveness detection on each sample image to obtain the detection result for each sample image.

[0138] The detection model can be a binary classification model, which determines whether the received image is a live image or a non-live image. Alternatively, the detection model can be a multi-class classification model, which determines whether the received image is a live image or a non-live image. If the image is determined to be a non-live image, the model will also determine the attack type corresponding to the non-live image, such as a paper printing attack, a 2D mask attack, or a 3D head model attack.

[0139] S152: Determine the second loss value based on multiple detection results.

[0140] Specifically, the second loss value is denoted as L. cls The second loss value can be determined using either the cross-entropy loss function or other loss functions.

[0141] The process of determining the second loss value based on multiple test results is existing technology and will not be described in detail here.

[0142] S153: Determine the total loss value based on the first loss value and the second loss value.

[0143] One approach is to sum the first loss value and the second loss value to obtain the total loss value, or to sum the first loss value and the second loss value and then divide the sum by two to obtain the total loss value.

[0144] Alternatively, the first loss value and the second loss value can be weighted and summed to obtain the total loss value, which can be determined according to the following formula: c :

[0145] L c =γ1×L cls +γ2×L multimargin , where L cls Let γ1 be the weight corresponding to the second loss value, and L be the weight of the second loss value. multimargin γ1 is the first loss value, and γ2 is the weight corresponding to the first loss value.

[0146] Among them, γ1 and γ2 can be preset by the designer and are not restricted here.

[0147] S154: Adjust the parameters of the detection model based on the total loss value.

[0148] The parameters of the detection model are adjusted based on the final total loss value.

[0149] In the above scheme, the first loss value and the second loss value are combined to obtain the total loss value. The process of determining the first loss value and the process of determining the second loss value are different. Therefore, training the detection model based on the total loss value can further improve the accuracy of the detection model.

[0150] See Figure 9 , Figure 9This is a schematic diagram of one embodiment of the training device of this application. The training device 200 includes a processor 210, a memory 220, and a communication circuit 230. The processor 210 is coupled to the memory 220 and the communication circuit 230 respectively. The memory 220 stores program data. The processor 210 executes the program data in the memory 220 to implement the steps in any of the above embodiments. The detailed steps can be found in the above embodiments and will not be repeated here.

[0151] The training device 200 can be any device with image processing capabilities, such as a computer or a mobile phone, and there are no restrictions on its use.

[0152] See Figure 10 , Figure 10 This is a schematic diagram of another embodiment of the training device of this application. The training device 300 includes an acquisition module 310, a first determination module 320, a second determination module 330, a third determination module 340, and a training module 350.

[0153] The acquisition module 310 is used to divide the non-live images in the multiple sample images into multiple first image groups according to the attack type after acquiring multiple sample images.

[0154] The first determining module 320 is connected to the acquiring module 310 and is used to determine the first distance value between the sample features of each first image group and the current live features, wherein the current live features are updated each time the detection model is trained.

[0155] The second determining module 330 is connected to the first determining module 320 and is used to determine the first evaluation value corresponding to each first image group based on the first distance value and the corresponding metric value corresponding to each first image group. The first evaluation value corresponding to the first image group is equal to zero if the first distance value corresponding to the first image group is greater than or equal to the corresponding metric value, otherwise the first evaluation value is greater than zero.

[0156] The third determining module 340 is connected to the second determining module 330 and is used to determine a first loss value based on the first evaluation value corresponding to each first image group, wherein the smaller the first evaluation value corresponding to the first image group, the smaller the first loss value.

[0157] The training module 350 is connected to the third determination module 340 and is used to train the detection model based on the first loss value.

[0158] When the training device 300 is in operation, it executes the method steps of any of the above embodiments. For detailed method steps, please refer to the above content, which will not be repeated here.

[0159] The training device 300 can be any device with image processing capabilities, such as a computer or a mobile phone, and there are no restrictions on its use.

[0160] See Figure 11 , Figure 11 This is a schematic diagram of one embodiment of the computer-readable storage medium of this application. The computer-readable storage medium 400 stores a computer program 410, which can be executed by a processor to implement the steps in any of the above methods.

[0161] Specifically, the computer-readable storage medium 400 can be a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, or a device that can store the computer program 410. Alternatively, it can be a server that stores the computer program 410, which can send the stored computer program 410 to other devices for execution, or it can run the stored computer program 410 itself.

[0162] The above description is merely an embodiment of this application and does not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.

Claims

1. A method for training a detection model, characterized in that, The method includes: The detection model is iteratively processed in the following manner until it converges: Obtain multiple sample images corresponding to this iteration, and divide the non-live images in the multiple sample images into multiple first image groups according to the attack type; Obtain the current liveness features corresponding to this iteration; Determine the first distance value between the sample features of each of the first image groups and the current liveness feature; A first evaluation value is determined for each first image group based on the first distance value and the corresponding metric value. The first evaluation value for the first image group is zero if the first distance value is greater than or equal to the corresponding metric value, otherwise the first evaluation value is greater than zero. The metric value for each first image group is preset. A first loss value is determined based on the first evaluation value corresponding to each first image group, wherein the smaller the first evaluation value corresponding to the first image group, the smaller the first loss value; Based on the first loss value, the parameters of the detection model are adjusted; The step of determining the first evaluation value corresponding to each first image group based on the first distance value and the corresponding metric value corresponding to each first image group includes: The difference between the metric value and the corresponding first distance value for each first image group is determined to obtain the first difference for each first image group. Each of the first differences is combined with zero to form an array, resulting in multiple first arrays; Perform the maximum value operation on each of the first arrays to obtain the maximum value corresponding to each of the first image groups; The first evaluation value corresponding to each first image group is determined based on the maximum value corresponding to each first image group.

2. The method according to claim 1, characterized in that, The step of determining the first evaluation value corresponding to each first image group based on the maximum value corresponding to each first image group includes: The maximum value corresponding to each of the first image groups is squared to obtain the first evaluation value corresponding to each of the first image groups.

3. The method according to claim 1, characterized in that, The step of determining the first loss value based on the first evaluation value corresponding to each of the first image groups includes: Determine a second distance value between the sample features of the second image group and the current liveness feature, wherein the second image group includes liveness images from a plurality of the sample images; A second evaluation value is determined based on the second distance value, wherein the smaller the second distance value, the smaller the second evaluation value; The first loss value is determined based on the second evaluation value and the first evaluation value corresponding to each of the first image groups, wherein the smaller the second evaluation value, the smaller the first loss value.

4. The method according to claim 3, characterized in that, The step of determining the first loss value based on the first evaluation value and the second distance value corresponding to each first image group includes: Determine a first sum value of the number of image groups in the first image group and the number of image groups in the second image group; Summing all the first and second evaluation values ​​yields a second sum. Determine the first product of the reciprocal of the first sum and the second sum; The first loss value is determined based on the first product.

5. The method according to claim 1, characterized in that, The higher the similarity between the attack type corresponding to the first image group and the live object, the smaller the metric value corresponding to the first image group.

6. The method according to claim 5, characterized in that, The step of determining the first loss value based on the first evaluation value corresponding to each of the first image groups includes: The first distance value corresponding to at least one first target image group is subtracted from the first distance value corresponding to the second target image group corresponding to each of the first target image groups to obtain a second difference value corresponding to each first target image group, wherein the metric value corresponding to the first target image group is less than the metric value corresponding to the corresponding second target image group. A third evaluation value is determined for each of the second differences, wherein the third evaluation value corresponding to the second difference is equal to zero in response to the second difference being less than or equal to zero, and the corresponding third evaluation value is greater than zero otherwise; The first loss value is determined based on the first evaluation value corresponding to each of the first image groups and the third evaluation value corresponding to each of the second differences, wherein the smaller the third evaluation value, the smaller the first loss value.

7. The method according to claim 6, characterized in that, The method further includes: Sort the multiple first image groups according to the corresponding metric values ​​from smallest to largest; The second target image group corresponding to the first target image group is adjacent to the first target image group.

8. The method according to claim 6, characterized in that, The step of determining the third evaluation value corresponding to each second difference includes: Each of the second differences is combined with zero to form an array, resulting in multiple second arrays; Perform the maximum value operation on each of the second arrays to obtain the maximum value corresponding to each of the second differences; The third evaluation value corresponding to each second difference is determined based on the maximum value corresponding to each second difference.

9. The method according to claim 8, characterized in that, The step of determining the third evaluation value corresponding to each of the second differences based on the maximum value corresponding to each of the second differences includes: The maximum value corresponding to each of the second differences is squared to obtain the third evaluation value corresponding to each of the second differences.

10. The method according to claim 6, characterized in that, The step of determining the first loss value based on the first evaluation value corresponding to each first image group and the third evaluation value corresponding to each second difference includes: The sum of the number of the first evaluation value and the number of the third evaluation value is determined to obtain the third sum value; Summing all the first evaluation values ​​and all the third evaluation values ​​yields a fourth sum. Determine the second product of the reciprocal of the third sum and the fourth sum; The first loss value is determined based on the second product.

11. The method according to claim 1, characterized in that, The step of adjusting the parameters of the detection model based on the first loss value includes: The detection model is used to perform liveness detection on multiple sample images to obtain multiple detection results; Based on the multiple detection results, a second loss value is determined; The total loss value is determined based on the first loss value and the second loss value; The parameters of the detection model are adjusted based on the total loss value.

12. The method according to claim 11, characterized in that, The step of determining the total loss value based on the first loss value and the second loss value includes: The first loss value and the second loss value are weighted and summed to obtain the total loss value.

13. A training device, characterized in that, The training device includes a processor, a memory, and a communication circuit. The processor is coupled to the memory and the communication circuit. The memory stores program data. The processor executes the program data in the memory to implement the steps of the method as described in any one of claims 1-12.

14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that can be executed by a processor to implement the steps of the method as described in any one of claims 1-12.

Citation Information

Patent Citations

  • Image recognition method and device and terminal equipment

    CN111079785A