A method, device and equipment for detecting living body

By combining information about face area and background area in vivo detection technology, features are extracted and similarity is calculated to generate vivo detection results, the problem of failure to fully utilize background information in the prior art is solved, and the accuracy of the detection results is improved and effectiveness.

CN114550244BActive Publication Date: 2024-12-24ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 15 Cites 0 Cited by

Patent Information

Application Number
CN202210128806.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-11
Publication Date
2024-12-24
Estimated Expiration
2042-02-11

AI Technical Summary

Technical Problem

Existing live detection technologies usually only focus on the face area and fail to make full use of image background information, which affects the accuracy and effectiveness of live detection results in high-difficulty attacks.

Method used

By obtaining the face area and background area in the image to be detected, the non-living probability values ​​are determined, and feature extraction is performed on the background area, the maximum similarity between the target feature vector and the pre-stored feature vector is calculated, and the vivo detection results are generated by combining the two. .

Benefits of technology

It improves the accuracy and effectiveness of live detection results, enhances the defense ability against high-difficulty attacks, and ensures the accuracy and effectiveness of generated results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114550244B_ABST
    Figure CN114550244B_ABST
Patent Text Reader

Abstract

The embodiments of this specification disclose a method, device and apparatus for liveness detection. The scheme may include: obtaining a first non-liveness probability value and a second non-liveness probability value corresponding to a face area and a background area in an image to be detected, respectively, and determining the maximum similarity between a target feature vector of the background area and a pre-stored feature vector corresponding to the background area in each non-liveness image sample, so that a liveness detection result can be generated according to the first non-liveness probability value, the second non-liveness probability value and the maximum similarity.
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 vision and image processing, and in particular to a method, device and equipment for detecting living things. Background Art

[0002] With the development of computer technology and optical imaging technology, user identification methods based on face recognition technology are becoming increasingly popular. In the process of face recognition applications, it is usually necessary to verify whether the user is actually alive in order to identify fraud during face recognition and protect the interests of users. At present, when performing liveness detection, the face area in the image captured by the device is usually analyzed and detected to generate liveness recognition results, but the background area in the image captured by the device is often not combined for liveness recognition, thus not comprehensively considering the impact of the user's environment on the liveness detection results.

[0003] Therefore, how to combine image background information to improve the accuracy and effectiveness of liveness detection results has become a technical problem that needs to be solved urgently. Summary of the invention

[0004] The embodiments of this specification provide a method, device and equipment for liveness detection, which can combine image background information to improve the accuracy and effectiveness of liveness detection results.

[0005] To solve the above technical problems, the embodiments of this specification are implemented as follows:

[0006] The embodiment of this specification provides a method for detecting a living body, including:

[0007] Obtaining a first non-living body probability value determined according to a face region in the image to be detected;

[0008] Acquire a second non-living body probability value determined according to a background area in the image to be detected;

[0009] Extracting features from the background area of ​​the image to be detected to obtain a target feature vector;

[0010] Determining the maximum similarity between the target feature vector and a pre-stored feature vector in a pre-stored feature vector set; the pre-stored feature vector is a feature vector of a background region in a non-living body image sample;

[0011] A liveness detection result is generated according to the first non-liveness probability value, the second non-liveness probability value and the maximum similarity.

[0012] The embodiment of this specification provides a living body detection device, including:

[0013] A first acquisition module, used to acquire a first non-living body probability value determined according to a face region in an image to be detected;

[0014] A second acquisition module, used to acquire a second non-living body probability value determined according to the background area in the image to be detected;

[0015] A feature extraction module is used to extract features from the background area in the image to be detected to obtain a target feature vector;

[0016] A maximum similarity determination module, used to determine the maximum similarity between the target feature vector and a pre-stored feature vector in a pre-stored feature vector set; the pre-stored feature vector is a feature vector of a background area in a non-living body image sample;

[0017] A liveness detection result generating module is used to generate a liveness detection result according to the first non-liveness probability value, the second non-liveness probability value and the maximum similarity.

[0018] The embodiment of this specification provides a living body detection device, including:

[0019] at least one processor; and,

[0020] a memory communicatively connected to the at least one processor; wherein,

[0021] The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:

[0022] Obtaining a first non-living body probability value determined according to a face region in the image to be detected;

[0023] Acquire a second non-living body probability value determined according to a background area in the image to be detected;

[0024] Extracting features from the background area of ​​the image to be detected to obtain a target feature vector;

[0025] Determining the maximum similarity between the target feature vector and a pre-stored feature vector in a pre-stored feature vector set; the pre-stored feature vector is a feature vector of a background region in a non-living body image sample;

[0026] A liveness detection result is generated according to the first non-liveness probability value, the second non-liveness probability value and the maximum similarity.

[0027] At least one embodiment provided in this specification can achieve the following beneficial effects:

[0028] The first non-liveness probability value and the second non-liveness probability value are determined respectively according to the face area and the background area in the image to be detected, and the maximum similarity between the target feature vector of the background area and the pre-stored feature vector corresponding to the background area in each non-liveness image sample (i.e., the attack sample) is determined, so as to generate a liveness detection result according to the first non-liveness probability value, the second non-liveness probability value and the maximum similarity. Since the second non-liveness probability value can reflect the probability that the image to be detected does not contain a live body predicted based on the background area of ​​the image to be detected, and the maximum similarity can represent the degree of similarity between the background area of ​​the image to be detected and a large number of identified attack samples, so as to reflect the probability that the image to be detected does not contain a live body, the scheme can fully combine the background area information in the image to be detected to generate a liveness detection result, which is conducive to improving the accuracy and effectiveness of the generated liveness detection result. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0030] Figure 1 A schematic diagram of the overall solution flow of a liveness detection method provided in an embodiment of this specification;

[0031] Figure 2 A schematic diagram of a flow chart of a liveness detection method provided in an embodiment of this specification;

[0032] Figure 3 A schematic diagram of a face area and a background area of ​​an image to be detected provided in an embodiment of this specification;

[0033] Figure 4 The embodiments of this specification provide corresponding to Figure 2 Schematic diagram of the lane flow of the liveness detection method in FIG.

[0034] Figure 5 The embodiments of this specification provide corresponding to Figure 2 A schematic diagram of the structure of a living body detection device;

[0035] Figure 6 The embodiments of this specification provide corresponding to Figure 2 A structural schematic diagram of a living body detection device. DETAILED DESCRIPTION

[0036] In order to make the purpose, technical solutions and advantages of one or more embodiments of this specification clearer, the technical solutions of one or more embodiments of this specification will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this description, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of one or more embodiments of this specification.

[0037] The technical solutions provided by the embodiments of this specification are described in detail below in conjunction with the accompanying drawings.

[0038] In the existing technology, with the widespread application of face recognition technology, risks also come with it. For example, criminals use printed photos, played videos, etc. to cheat and attack during the face recognition process. In order to solve such problems, liveness detection technology came into being. Liveness detection technology can identify whether the person performing the face recognition operation is a real living person, or a criminal who attacks by using printed photos, silicone masks, played videos, etc.

[0039] At present, commonly used liveness detection technologies usually only focus on the face area. By analyzing and processing the information contained in the face area, most of the risks brought by relatively simple attacks can be avoided. However, criminals often use more complex technologies to cheat and attack. Therefore, it may be difficult to capture traces of attacks in the face area, thus affecting the accuracy and effectiveness of the generated liveness detection results.

[0040] In practical applications, since the background area outside the face area in the image to be detected may also contain many clues of attacks, for example, since criminals may continue to cheat and attack in the same environment, the risk of attack during face scanning can be determined by the environmental information contained in the background area of ​​the image to be detected. In addition, for fixed users, the scene of face scanning is often fixed. Therefore, if the scene of face scanning of the user has changed significantly, there is a high possibility of attack risk during face scanning. Based on this, how to make full use of image background information and improve the performance of liveness detection algorithm in high-difficulty attacks has become a problem of concern.

[0041] In order to solve the defects in the prior art, this solution provides the following embodiments:

[0042] Figure 1 The present invention is a schematic diagram of the overall solution flow of a living body detection method provided in an embodiment of this specification.

[0043] like Figure 1As shown, when user 101 needs to perform face recognition at device 102, device 102 can collect images of user 101 to obtain images to be detected. In practical applications, device 102 can be directly used to perform the liveness detection method provided in the embodiments of this specification on the images to be processed, or device 102 can also send the images to be processed to server 103, so that server 103 can perform the liveness detection method provided in the embodiments of this specification on the images to be processed, and there is no specific limitation on this. Among them, device 102 and server 103 can be the client and server of the application for face recognition or for liveness detection, respectively.

[0044] For ease of understanding, the liveness detection method provided in the embodiment of this specification is explained by using the server 103 to execute the liveness detection method for the image to be processed. Assuming that the server 103 receives the image to be processed, the server 103 can perform foreground and background segmentation on the image to be processed to determine the face area (i.e., foreground area) and background area in the image to be detected. Subsequently, a first non-liveness probability value determined according to the face area in the image to be detected can be obtained, and a second non-liveness probability value determined according to the background area in the image to be detected can be obtained. Feature extraction is performed on the background area in the image to be detected to obtain a target feature vector; the maximum similarity between the target feature vector and the pre-stored feature vector in the pre-stored feature vector set is determined, wherein the pre-stored feature vector can be a feature vector of the background area in the non-liveness image sample (i.e., the attack sample). A liveness detection result is generated based on the first non-liveness probability value, the second non-liveness probability value, and the maximum similarity.

[0045] Figure 1 The scheme in the embodiment of the present invention separates the foreground and background of the image to be detected, generates a first non-liveness probability value and a second non-liveness probability value based on the foreground and the background respectively, and determines the liveness detection result by combining the similarity between the background area of ​​the image to be detected and a large number of identified attack samples, so as to fully combine the background area information in the image to be detected to generate the liveness detection result, which is beneficial to improving the defense capability of the liveness detection method against high-difficulty attacks, so as to ensure the accuracy and effectiveness of the generated liveness detection result.

[0046] Next, a liveness detection method provided in an embodiment of the specification will be specifically described with reference to the accompanying drawings:

[0047] Figure 2 The following is a flow chart of a method for detecting a living body provided in an embodiment of the present specification. From a program perspective, the execution subject of the process may be a device for performing live body detection, for example, Figure 1The device 102 or server 103 in the embodiment, or the application program installed in the above device, such as Figure 2 As shown, the process may include the following steps:

[0048] Step 202: Obtain a first non-living body probability value determined according to the face region in the image to be detected.

[0049] In the embodiments of this specification, the image to be detected can be an image collected by a device for the user to be detected when the user to be detected performs face recognition or liveness detection operations. In practical applications, the device can be a machine in a store that supports face payment or a user terminal device, and there is no specific limitation on this.

[0050] In the embodiments of this specification, the face area in the image to be detected may be the foreground area in the image to be detected, and the face area in the image to be detected should generally include the subject in the face recognition process (i.e., the user to be detected). Specifically, the face area in the image to be detected may include the face, torso and other body parts of the user to be detected, and in addition, may also include objects held by the user to be detected. However, in order to ensure the effectiveness of face recognition and liveness detection, the face area in the image to be detected should at least include the face image of the user to be detected.

[0051] For ease of understanding, the present specification provides a schematic diagram of a face area and a background area of ​​an image to be detected, such as Figure 3 As shown, the image to be detected may include an irregular face region 301 and an irregular background region 302. The face region 301 may include images of the user's face, chest, upper limbs, etc., while the background region 302 may be an area other than the face region 301 in the image to be detected. The background region 302 may include environmental information of the user, for example, a five-pointed star-shaped sign beside the user.

[0052] In the embodiments of the present specification, liveness detection can be performed based on the face area in the image to be detected to determine the first non-liveness probability value. The first non-liveness probability value can be used to reflect the probability that the image to be detected does not contain a live user, which is determined based on the face area in the image to be detected, that is, to reflect the possibility of fraud, cheating, and attack in the face recognition process.

[0053] Step 204: Obtain a second non-living body probability value determined according to the background area in the image to be detected.

[0054] In the embodiments of the present specification, the background area in the image to be detected may be other areas in the image to be detected except for the foreground area. The background area of ​​the image to be detected may generally include environmental information of the user to be detected, such as windows, doors, shelves, signs, etc. around the user.

[0055] In the embodiment of the present specification, liveness detection can be performed based on the background area in the image to be detected to determine the second non-liveness probability value. The second non-liveness probability value can be used to reflect the probability that the image to be detected does not contain a live user determined based on the background area in the image to be detected, that is, to reflect the possibility of fraud, cheating, or attacking behavior.

[0056] Step 206: extracting features from the background area in the image to be detected to obtain a target feature vector.

[0057] In the embodiments of the present specification, an image in the background area can be extracted from the image to be detected, and the vector data obtained after the extracted image in the background area is characterized can be used as a target feature vector, which contains a large amount of feature information in the image in the background area, so that it can be used to measure the similarity between the image in the background area and other attack background images, thereby facilitating the determination of the probability that the image to be detected does not contain a living body. Generally, the higher the similarity between the image in the background area and other attack background images, the greater the probability that the image to be detected does not contain a living body.

[0058] Step 208: Determine the maximum similarity between the target feature vector and a pre-stored feature vector in a pre-stored feature vector set; the pre-stored feature vector is a feature vector of a background region in a non-living body image sample.

[0059] In the embodiments of this specification, non-living image samples (i.e., attack image samples) may be images collected during the process of face recognition by criminals using fraud, cheating, or attacking means, for example, images collected when criminals perform aggressive face recognition in a rented house, etc. The background area in these non-living image samples usually contains attack information. Therefore, feature extraction may be performed on the background area of ​​the non-living image sample to obtain a pre-stored feature vector containing attack information, so that the similarity between the attack image sample and the image in the background area of ​​the image to be detected may be measured based on the similarity between the pre-stored feature vector and the target feature vector, thereby facilitating the determination of the probability that the image to be detected does not contain a living body.

[0060] In practical applications, the similarity between the target feature vector and each pre-stored feature vector may be calculated, and the maximum value among the calculated multiple similarities may be taken as the maximum similarity. The similarity between the target feature vector and each pre-stored feature vector may be cosine similarity.

[0061] Step 210: Generate a liveness detection result according to the first non-liveness probability value, the second non-liveness probability value and the maximum similarity.

[0062] In an embodiment of the present specification, the first non-living body probability value can reflect the possibility that the image to be detected does not contain a living body, determined based on the foreground area of ​​the image to be detected; the second non-living body probability value can reflect the possibility that the image to be detected does not contain a living body, determined based on the background area of ​​the image to be detected; the maximum similarity can reflect the similarity between the background area of ​​the image to be detected and the background area of ​​the attack image, and can be used to determine the possibility that the image to be detected does not contain a living body.

[0063] Based on this, the possibility that the image to be detected does not contain a living body can be determined according to the first non-living body probability value, the second non-living body probability value and the maximum similarity, so as to obtain a living body detection result for the image to be detected. Wherein, the first non-living body probability value, the second non-living body probability value and the maximum similarity are respectively proportional to the possibility that the image to be detected does not contain a living body.

[0064] Figure 2 In the scheme, a liveness detection result is generated according to the first non-liveness probability value, the second non-liveness probability value and the maximum similarity. Since the second non-liveness probability value can reflect the probability that the image to be detected does not contain a live body as predicted based on the background area of ​​the image to be detected, and the maximum similarity can represent the degree of similarity between the background area of ​​the image to be detected and a large number of identified attack samples, so as to reflect the probability that the image to be detected does not contain a live body, the scheme can fully combine the background area information in the image to be detected to generate a liveness detection result, which is conducive to improving the accuracy and effectiveness of the generated liveness detection result.

[0065] based on Figure 2 The method in this specification also provides some specific implementation plans of the method, which are described below.

[0066] In the embodiment of the present specification, since it is necessary to perform living body detection based on the foreground area and the background area of ​​the image to be detected respectively, it is necessary to segment the foreground area and the background area of ​​the image to be detected.

[0067] Based on this, before step 202: obtaining the first non-living body probability value determined according to the face region in the image to be detected, the following may also be included:

[0068] The image to be detected is segmented using an image segmentation model to obtain a face area in the image to be detected and a background area in the image to be detected; the background area in the image to be detected is the area outside the face area in the image to be detected; the image segmentation model is obtained by training a deep learning model based on a first preset loss function using image samples carrying preset image segmentation results.

[0069] Among them, the first preset loss function is used to characterize the degree of deviation between the predicted image segmentation result output by the image segmentation model and the preset image segmentation result, and to characterize the degree of deviation between the feature vectors of two feature image sub-regions of the same classification type determined according to the predicted image segmentation result, wherein the feature image sub-region is a partial area in the feature image generated during the process of the image segmentation model performing segmentation processing on the image sample.

[0070] In the embodiments of this specification, image segmentation can be a computer vision task of marking a designated area (e.g., foreground area, background area, designated object, etc.) according to the image content. In practical applications, an image segmentation model can be used to group objects belonging to the same category or the same entity in an image together and distinguish each sub-part, thereby achieving pixel-level image segmentation.

[0071] Specifically, since the present application needs to segment the face area (i.e., foreground) and background area in the image, the image segmentation model can be trained in advance using image samples carrying preset image segmentation results. The preset image segmentation results may refer to the annotation information of the face area or background area of ​​the image sample. It is worth noting that the face area of ​​the image sample may include the neck, chest, limbs, and objects held by the sample user in addition to the facial image of the sample user. The background area of ​​the image sample may refer to the area outside the foreground area of ​​the image sample.

[0072] In the embodiments of this specification, the existing image segmentation model can be used to segment the image to be detected to obtain the face area and background area in the image to be detected. However, in the prior art, when training the image segmentation model, the loss function used is usually only used to characterize the degree of deviation between the predicted image segmentation result output by the image segmentation model and the preset image segmentation result of the image sample, so that the accuracy of the foreground area and background area segmented by the existing image segmentation model is insufficient. Based on this, in order to overcome the above-mentioned defects of the existing image segmentation model, in the embodiments of this specification, the loss function used for training the image segmentation model is optimized.

[0073] Specifically, on the basis of the loss function of the existing image segmentation model, the loss function of the image segmentation model can also be used to characterize the degree of deviation between the feature vectors of two feature image sub-regions of the same classification type determined according to the predicted image segmentation result, and the feature image sub-region is a partial area in the feature image generated in the process of the image segmentation model performing segmentation processing on the image sample.

[0074] In practical applications, when an image segmentation model is trained using image samples, the fully connected layer of the image segmentation model generates a feature map of the image sample, and the feature map can distinguish the foreground area and the background area of ​​the image sample, so the feature map can be used as a feature image. The classification types of the sub-areas in the foreground area of ​​the feature map (i.e., the feature image sub-areas) are the same, and the classification types of the sub-areas in the background area of ​​the feature map (i.e., the feature image sub-areas) are also the same, but the classification types of the sub-areas in the foreground area and the background area of ​​the feature map are different.

[0075] In practical applications, the feature image sub-region may be a region of a preset size randomly selected from the feature image, and the preset size may be set according to actual needs, without specific limitation. For example, the preset size may be a region with a length and a width of 4 (pixels), etc. The deep learning model used to build the image segmentation model may be implemented using a UNET network structure. Of course, the deep learning model may also be other types of convolutional neural networks, without specific limitation.

[0076] In the embodiments of the present specification, since the features of feature image sub-regions of the same classification type are usually consistent, the loss function of the image segmentation model can be used to characterize the degree of deviation between the feature vectors of two feature image sub-regions of the same classification type determined according to the predicted image segmentation results, and by minimizing the loss function of the image segmentation model during the training process, the regional features with the same classification label (i.e., foreground type label or background type label) output by the image segmentation model are continuous, which is beneficial to improving the accuracy of the image segmentation model.

[0077] For ease of understanding, the embodiments of this specification also provide a formula for the loss function of the image segmentation model.

[0078] Specifically, the first preset loss function may include a first loss function and a second loss function; the first loss function may be used to characterize the degree of deviation between the predicted image segmentation result output by the image segmentation model and the preset image segmentation result. In practical applications, the first loss function may be implemented using a Euclidean distance loss function. The second loss function may be used to characterize the degree of deviation between feature vectors of two feature image sub-regions of the same classification type determined according to the predicted image segmentation result.

[0079] The formula of the first preset loss function may be: + .

[0080] The formula of the first loss function can be: .

[0081] The formula of the second loss function can be: .

[0082] in, It can represent a first preset loss function constructed by the first loss function and the second loss function, and N and M can be positive numbers. It can represent the predicted image segmentation result output by the image segmentation model, and GT can represent the preset image segmentation result of the image sample; Can be expressed The degree of deviation from GT, specifically, Can be expressed The square root of the sum of the squares of the differences from the components of GT. A feature vector of a feature image sub-region may be represented, can represent a feature vector of another feature image sub-region, and and The classification types of the two feature image sub-regions represented are the same; Can be expressed and The degree of deviation between Can be expressed and The square root of the sum of the squares of the differences between the components of .

[0083] In an embodiment of the present specification, the first preset loss function may be a weighted sum of a first loss function and a second loss function. By minimizing the first preset loss function during the training process of the image segmentation model, the image segmentation model can be optimized at one time using two first loss functions and second loss functions with different functions, thereby not only helping to improve the accuracy of the trained image segmentation model, but also helping to improve the training efficiency of the image segmentation model.

[0084] In the embodiments of this specification, the existing technology can also be used to determine the first non-living body probability value according to the face area in the image to be detected.

[0085] Specifically, step 202: obtaining a first non-living body probability value determined according to the face region in the image to be detected may include:

[0086] The first liveness detection model is used to perform liveness detection on the image within the face area of ​​the image to be detected to obtain a first non-liveness probability value; the first liveness detection model is obtained by training the first classification model using the image within the face area in the image sample collected by the device.

[0087] In the embodiments of this specification, the first liveness detection model can be implemented by a first classification model of binary classification. In practical applications, the first classification model can be implemented by using a ResNet18 network structure or other classification models based on convolutional neural networks, without specific limitation.

[0088] In the embodiments of this specification, before training the first classification model to obtain the first liveness detection model, it is necessary to prepare training samples in advance. Specifically, the device may first acquire image samples collected by the device, which may be image samples containing live faces and image samples not containing live faces (i.e., attack image samples) acquired from a legitimate image database, or image samples collected during the user's face recognition process based on user authorization, without specific limitation.

[0089] The face area (i.e., foreground area) and background area of ​​the image samples collected by the device are segmented, and the image in the face area of ​​the image samples collected by the device is extracted as a training sample, and label data indicating that a living body is included or a living body is not included is set for the training sample. Based on the binary classification loss function, the first classification model is trained using the training samples carrying the label data, and the first classification model can output the predicted probability value that the training sample does not contain a living body (i.e., a non-living body probability value). If the prediction accuracy of the trained first classification model meets the requirements, it can be used as the first living body detection model. In step 202, the image in the face area of ​​the image to be detected can be input into the first living body detection model, and the probability value of not containing a living body output by the first living body detection model is the first non-living body probability value.

[0090] In the embodiments of this specification, when the second non-living body probability value is determined according to the background area in the image to be detected, it can also be implemented based on a living body detection model.

[0091] Specifically, step 204: obtaining a second non-living body probability value determined according to the background area in the image to be detected may include:

[0092] A second liveness detection model is used to perform liveness detection on the image in the background area of ​​the image to be detected to obtain a second non-liveness probability value; the second liveness detection model is obtained by training the second classification model based on a second preset loss function using background image samples carrying preset liveness classification results; the background image samples are images in the background area of ​​the image samples collected by the device.

[0093] In the embodiments of this specification, the second liveness detection model can be implemented by a second classification model of binary classification. In practical applications, the second classification model can be implemented by using a ResNet18 network structure or other classification models based on convolutional neural networks, without specific limitation.

[0094] In an embodiment of the present specification, when obtaining training samples required for training the second classification model, the foreground area (i.e., the face area) and the background area of ​​the image samples collected by the device can be segmented first, and the images in the background area of ​​the image samples collected by the device can be extracted as training samples, and label data indicating whether a living body is included or not is set for the training sample. The label data can be used as a preset living body classification result for the training sample.

[0095] In the prior art, the second preset loss function used when training the second classification model to obtain the second liveness detection model can generally be used to characterize the degree of deviation between the predicted liveness classification result output by the second liveness detection model and the preset liveness classification result. Based on this loss function, the accuracy of the second non-liveness probability value output by the second liveness detection model can be guaranteed.

[0096] However, since in the embodiment of this specification, it is also necessary to extract features from the background area in the image to be detected to obtain the target feature vector, and the second liveness detection model usually generates the target feature vector in the process of classifying the image of the background area in the image to be detected, the second liveness detection model can be used to extract the target feature vector. In order to improve the accuracy of the target feature vector extracted by the second liveness detection model, the second preset loss function is also optimized in the embodiment of this specification.

[0097] Specifically, based on the binary classification loss function of the existing classification model, the second preset loss function can also be used to characterize the degree of deviation between the image feature vector of the preset category of the background image sample and the image feature cluster center of the preset category.

[0098] In practical applications, the last layer of the second classification model is the output layer, which can be used to output the probability that the background image sample does not contain a living body, and the network layer directly connected to the output layer is usually a fully connected layer. The fully connected layer can not only integrate the feature data of the background image samples extracted by the previous network layer of the second classification model, but also cluster the feature data of the background image samples to obtain image feature vectors of each preset category of the background image samples; the fully connected layer can also send the image feature vectors of each preset category of the background image samples to the output layer as input features of the output layer.

[0099] The model parameters of the second classification model usually also include image feature clustering centers of each preset category, and the image feature clustering centers of each preset category can be generated during the training process of the second classification model, wherein the image feature clustering center of any preset category can be the clustering center of the feature data of the background image sample of the preset category.

[0100] In the embodiments of the present specification, since the second preset loss function can be used to characterize the degree of deviation between the image feature vector of a preset category of background image samples and the image feature clustering center of the preset category, after training the second classification model with the goal of minimizing the second preset loss function, it can be ensured that the same background images are as close as possible in the feature space. If the second classification model is subsequently used to generate target feature vectors and pre-stored feature vectors, the accuracy of the maximum similarity between the determined target feature vector and the pre-stored feature vector can be improved to ensure the accuracy of the liveness detection results generated based on the maximum similarity.

[0101] Specifically, the second preset loss function may include a third loss function and a fourth loss function. The third loss function may be used to characterize the degree of deviation between the predicted liveness classification result output by the second liveness detection model and the preset liveness classification result; the third loss function may be an existing binary classification loss function, such as a cross entropy loss function. The fourth loss function may be used to characterize the degree of deviation between the image feature vector of the preset category of the background image sample and the image feature cluster center of the preset category.

[0102] The formula of the second preset loss function may be: + .

[0103] The formula of the third loss function can be: .

[0104] The formula of the fourth loss function can be: .

[0105] in, It can represent the second preset loss function constructed by the third loss function and the fourth loss function, and X and Z can be positive numbers. It can represent the predicted living body classification result output by the second living body detection model. It can represent the preset living body classification results of background image samples. represents the cross entropy loss function, express and The degree of deviation between them. The image feature vector of the i-th category of the background image sample can be represented, It can represent the cluster center of image features of the i-th category, Can be expressed and The degree of deviation between It can represent the square root of the sum of the squares of the differences between the image feature vector of the background image sample and the components of the image feature cluster center, where i is a positive integer greater than 1.

[0106] In the embodiment of the present specification, the second preset loss function can be a weighted sum of the third loss function and the fourth loss function. By minimizing the second preset loss function during the training process of the second liveness detection model, the second liveness detection model can be optimized by using two third loss functions and fourth loss functions with different functions at one time, which is beneficial to improving the training efficiency of the second liveness detection model.

[0107] In the embodiments of this specification, a method for extracting a target feature vector and an implementation method of the target feature vector using a second living body detection model are also provided.

[0108] Specifically, step 206: extracting features from the background area in the image to be detected to obtain a target feature vector may include:

[0109] Extract the first input feature vector of the fully connected layer of the second liveness detection model to obtain a target feature vector; the target feature vector is generated in the process of performing liveness detection on an image in a background area of ​​the image to be detected using the second liveness detection model.

[0110] In the embodiment of this specification, in the process of performing liveness detection on the image in the background area of ​​the image to be detected using the second liveness detection model, since the fully connected layer of the second liveness detection model can integrate the image feature data extracted by the previous network layer, the input feature vector (i.e., the first input feature vector) of the fully connected layer of the second liveness detection model can be extracted as the feature vector of the image in the background area of ​​the image to be detected, thereby obtaining a target feature vector. The target feature vector contains a large amount of feature information of the image in the background area of ​​the image to be detected.

[0111] In practical applications, the second liveness detection model may include one or more fully connected layers. Therefore, the target feature vector may be extracted by using any fully connected layer in the second liveness detection model or by using the fully connected layer connected to the output layer. There is no specific limitation on this.

[0112] Similarly, before step 206: determining the maximum similarity between the target feature vector and the pre-stored feature vectors in the pre-stored feature vector set, the following may also be included:

[0113] The second living body detection model is used to perform living body detection on the image in the background area of ​​the non-living body image sample, and the second input feature vector of the fully connected layer of the second living body detection model is extracted to obtain the pre-stored feature vector.

[0114] In the embodiments of the present specification, the principles adopted when extracting the target feature vector and the pre-stored feature vector using the second liveness detection model can be the same, that is, the fully connected layer used to extract the second input feature vector and the first input feature vector is usually the same fully connected layer, which is beneficial to improving the accuracy of the maximum similarity between the subsequently determined target feature vector and the pre-stored feature vector, and further helps to improve the accuracy of the generated liveness detection results.

[0115] In practical applications, non-living image samples can be images collected by pre-identified criminals during the aggressive liveness recognition process. The images in the background area of ​​these non-living image samples usually contain attack information. Therefore, the foreground and background of the non-living image samples can be segmented using a pre-trained graph segmentation model to extract the images in the background area of ​​the non-living image samples, and then the feature data of the images in the background area of ​​the non-living image samples can be extracted and stored to obtain a pre-stored feature vector containing attack information. If the maximum similarity between the target feature vector corresponding to the background area of ​​the image to be detected and the pre-stored feature vector is large, it can be indicated that the background area of ​​the image to be detected contains more attack information, thereby indicating that the image to be detected does not contain a living body and there is a high possibility of attack or cheating.

[0116] In practical applications, after identifying a new attack scenario, non-live image samples collected in the attack scenario can be added regularly, and the pre-stored feature vectors of the newly added non-live image samples can be extracted and stored to update the pre-stored feature vector set. Subsequently, when liveness detection is performed based on the updated pre-stored feature vector set, the newly added attack scenario can be included in the recognition scope, which is convenient, fast and low-cost.

[0117] Of course, other models or methods other than the second liveness detection model may be used to extract the target feature vector and the pre-stored feature vector, but it should generally be ensured that the target feature vector and the method for extracting the target feature vector are the same to ensure the accuracy of the generated liveness detection result.

[0118] In the embodiment of the present specification, step 210: generating a liveness detection result according to the first non-liveness probability value, the second non-liveness probability value and the maximum similarity may specifically include:

[0119] The product of the first non-living body probability value and a first preset weight is calculated to obtain a first weighted probability value.

[0120] The product of the second non-living body probability value and a second preset weight is calculated to obtain a second weighted probability value.

[0121] The product of the sum of the first weighted probability value and the second weighted probability value and the maximum similarity is calculated to obtain a target non-living body probability value.

[0122] It is determined whether the target non-living body probability value is greater than a preset threshold value to obtain a determination result.

[0123] If the judgment result indicates that the probability value of the target being a non-living object is greater than a preset threshold, a detection result indicating that the image to be detected does not contain a living object is generated.

[0124] If the judgment result indicates that the probability value of the target being a non-living object is less than or equal to a preset threshold, a detection result indicating that a living object is contained in the image to be detected is generated.

[0125] Among them, the first preset weight and the second preset weight are usually both positive numbers to ensure that the first non-live probability value, the second non-live probability value and the maximum similarity are proportional to the target non-live probability value. In the embodiment of this specification, the first preset weight and the second preset weight can be set according to actual needs, for example, set to 0.6 and 0.4 or 0.7 and 0.3 respectively, without specific limitation.

[0126] In the embodiment of the present specification, since the second non-living body probability value can reflect the probability that the image to be detected does not contain a living body predicted based on the background area of ​​the image to be detected, and the maximum similarity can represent the degree of similarity between the background area of ​​the image to be detected and a large number of identified attack samples, so as to reflect the probability that the image to be detected does not contain a living body, the scheme can fully combine the background area information in the image to be detected to generate a living body detection result, which is beneficial to improving the accuracy and effectiveness of the generated living body detection result.

[0127] Figure 4 The embodiments of this specification provide corresponding to Figure 2 Schematic diagram of the lane flow of the liveness detection method in FIG. Figure 2 As shown, the liveness detection process may involve execution entities such as image acquisition equipment and liveness detection equipment.

[0128] During the image acquisition stage, the image acquisition device can acquire the image to be detected during the user's face recognition process and send the image to be detected to the living body detection device.

[0129] In the liveness detection stage, the liveness detection device can use the image segmentation model to segment the received image to be detected to obtain the face area and the background area in the image to be detected. And, use the first liveness detection model to perform liveness detection on the image in the face area of ​​the image to be detected to obtain a first non-liveness probability value. Use the second liveness detection model to perform liveness detection on the image in the background area of ​​the image to be detected to obtain a second non-liveness probability value, and extract the first input feature vector of the fully connected layer of the second liveness detection model to obtain the target feature vector.

[0130] Determine the maximum similarity between the target feature vector and a pre-stored feature vector in a set of pre-stored feature vectors, wherein the pre-stored feature vector is a second input feature vector of a fully connected layer of the second liveness detection model extracted by performing liveness detection on an image in a background area of ​​the non-liveness image sample using the second liveness detection model.

[0131] The target non-live object probability value is determined according to the first non-live object probability value, the second non-live object probability value and the maximum similarity, wherein the first non-live object probability value, the second non-live object probability value and the maximum similarity are all proportional to the target non-live object probability value. It is judged whether the target non-live object probability value is greater than a preset threshold value. If so, a detection result indicating that the image to be detected does not contain a living object can be generated. Otherwise, a detection result indicating that the image to be detected contains a living object can be generated.

[0132] Based on the same idea, the embodiments of this specification also provide a device corresponding to the above method. Figure 5 The embodiments of this specification provide corresponding to Figure 2 A schematic diagram of the structure of a living body detection device. Figure 5 As shown, the device may include:

[0133] The first acquisition module 502 is used to acquire a first non-living body probability value determined according to the face region in the image to be detected.

[0134] The second acquisition module 504 is used to acquire a second non-living body probability value determined according to the background area in the image to be detected.

[0135] The feature extraction module 506 is used to extract features from the background area in the image to be detected to obtain a target feature vector.

[0136] The maximum similarity determination module 508 is used to determine the maximum similarity between the target feature vector and a pre-stored feature vector in a pre-stored feature vector set; the pre-stored feature vector is a feature vector of a background area in a non-living body image sample.

[0137] The liveness detection result generating module 510 is configured to generate a liveness detection result according to the first non-liveness probability value, the second non-liveness probability value and the maximum similarity.

[0138] based on Figure 5 The present specification also provides some specific implementation schemes of the device, which are described below.

[0139] Optional, Figure 5 The device may further include:

[0140] An image segmentation module is used to use an image segmentation model to perform segmentation processing on the image to be detected to obtain a face area in the image to be detected and a background area in the image to be detected; the background area in the image to be detected is the area outside the face area in the image to be detected; the image segmentation model is obtained by training a deep learning model based on a first preset loss function using image samples carrying preset image segmentation results.

[0141] Among them, the first preset loss function is used to characterize the degree of deviation between the predicted image segmentation result output by the image segmentation model and the preset image segmentation result, and to characterize the degree of deviation between the feature vectors of two feature image sub-regions of the same classification type determined according to the predicted image segmentation result, wherein the feature image sub-region is a partial area in the feature image generated during the process of the image segmentation model performing segmentation processing on the image sample.

[0142] Optionally, the first preset loss function may include a first loss function and a second loss function; the first loss function is used to characterize the degree of deviation between the predicted image segmentation result output by the image segmentation model and the preset image segmentation result; the second loss function is used to characterize the degree of deviation between the feature vectors of two feature image sub-regions of the same classification type determined according to the predicted image segmentation result.

[0143] The formula of the second loss function is: .

[0144] in, represents a feature vector of the feature image sub-region, represents a feature vector of another feature image sub-region, express and The degree of deviation between them.

[0145] Optionally, the first acquisition module 202 may be specifically configured to:

[0146] The first liveness detection model is used to perform liveness detection on the image within the face area of ​​the image to be detected to obtain a first non-liveness probability value; the first liveness detection model is obtained by training the first classification model using the image within the face area in the image sample collected by the device.

[0147] Optionally, the second acquisition module 204 may be specifically used to:

[0148] A second liveness detection model is used to perform liveness detection on the image in the background area of ​​the image to be detected to obtain a second non-liveness probability value; the second liveness detection model is obtained by training the second classification model based on a second preset loss function using background image samples carrying preset liveness classification results; the background image samples are images in the background area of ​​the image samples collected by the device.

[0149] Among them, the second preset loss function is used to characterize the degree of deviation between the predicted living body classification result output by the second living body detection model and the preset living body classification result, and to characterize the degree of deviation between the image feature vector of the preset category of the background image sample and the image feature clustering center of the preset category.

[0150] Optionally, the second preset loss function includes a third loss function and a fourth loss function; the third loss function is used to characterize the degree of deviation between the predicted liveness classification result output by the second liveness detection model and the preset liveness classification result; the fourth loss function is used to characterize the degree of deviation between the image feature vector of a preset category of the background image sample and the image feature clustering center of the preset category.

[0151] The formula of the fourth loss function is: .

[0152] in, represents the image feature vector of the i-th category of the background image sample, represents the cluster center of the image feature of the i-th category, express and The degree of deviation between them.

[0153] Optionally, the feature extraction module 506 may be specifically used for:

[0154] Extract the first input feature vector of the fully connected layer of the second liveness detection model to obtain a target feature vector; the target feature vector is generated in the process of performing liveness detection on an image in a background area of ​​the image to be detected using the second liveness detection model.

[0155] Optional, Figure 5The device may further include:

[0156] A pre-stored feature vector extraction module is used to use the second liveness detection model to perform liveness detection on the image in the background area of ​​the non-liveness image sample, extract the second input feature vector of the fully connected layer of the second liveness detection model, and obtain the pre-stored feature vector.

[0157] Optionally, the living body detection result generating module 510 may be specifically used for:

[0158] The product of the first non-living body probability value and a first preset weight is calculated to obtain a first weighted probability value.

[0159] The product of the second non-living body probability value and a second preset weight is calculated to obtain a second weighted probability value.

[0160] The product of the sum of the first weighted probability value and the second weighted probability value and the maximum similarity is calculated to obtain a target non-living body probability value.

[0161] It is determined whether the target non-living body probability value is greater than a preset threshold value to obtain a determination result.

[0162] If the judgment result indicates that the probability value of the target being a non-living object is greater than a preset threshold, a detection result indicating that the image to be detected does not contain a living object is generated.

[0163] If the judgment result indicates that the probability value of the target being a non-living object is less than or equal to a preset threshold, a detection result indicating that a living object is contained in the image to be detected is generated.

[0164] Based on the same idea, the embodiments of this specification also provide a device corresponding to the above method.

[0165] Figure 6 The embodiments of this specification provide corresponding to Figure 2 A schematic diagram of the structure of a liveness detection device. Figure 6 As shown, the device 600 may include:

[0166] at least one processor 610; and,

[0167] A memory 630 is communicatively connected to the at least one processor; wherein,

[0168] The memory 630 stores instructions 620 executable by the at least one processor 610. The instructions are executed by the at least one processor 610 to enable the at least one processor 610 to:

[0169] A first non-living body probability value determined according to a face region in the image to be detected is obtained.

[0170] A second non-living body probability value determined according to a background area in the image to be detected is obtained.

[0171] Feature extraction is performed on the background area in the image to be detected to obtain a target feature vector.

[0172] The maximum similarity between the target feature vector and a pre-stored feature vector in a pre-stored feature vector set is determined; the pre-stored feature vector is a feature vector of a background area in a non-living body image sample.

[0173] A liveness detection result is generated according to the first non-liveness probability value, the second non-liveness probability value and the maximum similarity.

[0174] Each embodiment in this specification is described in a progressive manner. The same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. Figure 6 As for the device shown, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0175] In the 1990s, it was very clear whether the improvement of a technology was hardware improvement (for example, improvement of the circuit structure of diodes, transistors, switches, etc.) or software improvement (improvement of the method flow). However, with the development of technology, many improvements of the method flow today can be regarded as direct improvements of the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be implemented with a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming themselves, without having to ask chip manufacturers to design and make dedicated integrated circuit chips. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one kind of HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages ​​and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.

[0176] The controller may be implemented in any suitable manner, for example, the controller may take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (e.g., software or firmware) executable by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, and the memory controller may also be implemented as part of the control logic of the memory. It is also known to those skilled in the art that, in addition to implementing the controller in a purely computer-readable program code manner, the controller may be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, such a controller may be considered as a hardware component, and the devices for implementing various functions included therein may also be considered as structures within the hardware component. Or even, the devices for implementing various functions may be considered as both software modules for implementing the method and structures within the hardware component.

[0177] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0178] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0179] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may 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.

[0180] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0181] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0182] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0183] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0184] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0185] Computer readable media include permanent and non-permanent, removable and non-removable media that 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 technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0186] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0187] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present application may 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 codes.

[0188] The present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0189] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims

1. A method for detecting a living body, comprising: Obtaining a first non-living body probability value determined according to a face region in the image to be detected; Obtaining a second non-living body probability value determined according to a background area in the image to be detected; the background area is obtained by segmenting the image to be detected based on an image segmentation model; the image segmentation model is obtained by training a deep learning model based on a first preset loss function using an image sample carrying a preset image segmentation result; The first preset loss function is used to characterize the degree of deviation between the predicted image segmentation result output by the image segmentation model and the preset image segmentation result, and to characterize the degree of deviation between the feature vectors of two feature image sub-regions of the same classification type determined according to the predicted image segmentation result, wherein the feature image sub-region is a partial region in the feature image generated in the process of the image segmentation model performing segmentation processing on the image sample; Extracting features from the background area of ​​the image to be detected to obtain a target feature vector; Determining the maximum similarity between the target feature vector and a pre-stored feature vector in a pre-stored feature vector set; the pre-stored feature vector is a feature vector of a background region in a non-living body image sample; A liveness detection result is generated according to the first non-liveness probability value, the second non-liveness probability value and the maximum similarity.

2. The method according to claim 1, before obtaining the first non-living body probability value determined according to the face area in the image to be detected, further comprising: The image to be detected is segmented using an image segmentation model to obtain a face region in the image to be detected and a background region in the image to be detected; The background area in the image to be detected is an area outside the face area in the image to be detected.

3. The method according to claim 2, wherein the first preset loss function comprises a first loss function and a second loss function; the first loss function is used to characterize the degree of deviation between the predicted image segmentation result output by the image segmentation model and the preset image segmentation result; the second loss function is used to characterize the degree of deviation between the feature vectors of two feature image sub-regions of the same classification type determined according to the predicted image segmentation result; The formula of the second loss function is: , in, represents a feature vector of the feature image sub-region, represents a feature vector of another feature image sub-region, express and The degree of deviation between them.

4. The method according to claim 1, wherein obtaining a first non-living body probability value determined according to a face region in the image to be detected comprises: Performing liveness detection on an image in a face region of the image to be detected using a first liveness detection model to obtain a first non-liveness probability value; The first living body detection model is obtained by using the device to collect images in the face area of ​​the image samples and training the first classification model.

5. The method according to claim 1, wherein obtaining a second non-living body probability value determined according to a background area in the image to be detected comprises: Using a second liveness detection model to perform liveness detection on an image in a background area of ​​the image to be detected, to obtain a second non-liveness probability value; The second living body detection model is obtained by training the second classification model based on a second preset loss function using background image samples carrying preset living body classification results; the background image samples are images in the background area of ​​the image samples collected by the device; Among them, the second preset loss function is used to characterize the degree of deviation between the predicted living body classification result output by the second living body detection model and the preset living body classification result, and to characterize the degree of deviation between the image feature vector of the preset category of the background image sample and the image feature clustering center of the preset category.

6. The method as claimed in claim 5, wherein the second preset loss function includes a third loss function and a fourth loss function; the third loss function is used to characterize the degree of deviation between the predicted living body classification result output by the second living body detection model and the preset living body classification result; the fourth loss function is used to characterize the degree of deviation between the image feature vector of the preset category of the background image sample and the image feature cluster center of the preset category; The formula of the fourth loss function is: , in, represents the image feature vector of the i-th category of the background image sample, represents the cluster center of the image feature of the i-th category, express and The degree of deviation between them.

7. The method according to claim 5 or 6, wherein extracting features from the background area in the image to be detected to obtain a target feature vector specifically comprises: Extracting a first input feature vector of a fully connected layer of the second living body detection model to obtain a target feature vector; The target feature vector is generated in the process of performing liveness detection on an image in a background area of ​​the image to be detected by using the second liveness detection model.

8. The method according to claim 7, before determining the maximum similarity between the target feature vector and the pre-stored feature vectors in the pre-stored feature vector set, further comprising: The second living body detection model is used to perform living body detection on the image in the background area of ​​the non-living body image sample, and the second input feature vector of the fully connected layer of the second living body detection model is extracted to obtain the pre-stored feature vector.

9. The method according to claim 1, wherein generating a liveness detection result according to the first non-liveness probability value, the second non-liveness probability value and the maximum similarity comprises: Calculating the product of the first non-living body probability value and a first preset weight to obtain a first weighted probability value; Calculating the product of the second non-living body probability value and a second preset weight to obtain a second weighted probability value; Calculating the product of the sum of the first weighted probability value and the second weighted probability value and the maximum similarity to obtain a target non-living body probability value; Determine whether the target non-living body probability value is greater than a preset threshold value, and obtain a determination result; If the judgment result indicates that the probability value of the target being a non-living object is greater than a preset threshold, a detection result indicating that the image to be detected does not contain a living object is generated; If the judgment result indicates that the probability value of the target being a non-living object is less than or equal to a preset threshold, a detection result indicating that a living object is contained in the image to be detected is generated.

10. A living body detection device, comprising: A first acquisition module, used to acquire a first non-living body probability value determined according to a face region in an image to be detected; A second acquisition module is used to obtain a second non-living body probability value determined according to a background area in the image to be detected; the background area is obtained by segmenting the image to be detected based on an image segmentation model; the image segmentation model is obtained by training a deep learning model based on a first preset loss function using an image sample carrying a preset image segmentation result; The first preset loss function is used to characterize the degree of deviation between the predicted image segmentation result output by the image segmentation model and the preset image segmentation result, and to characterize the degree of deviation between the feature vectors of two feature image sub-regions of the same classification type determined according to the predicted image segmentation result, wherein the feature image sub-region is a partial region in the feature image generated in the process of the image segmentation model performing segmentation processing on the image sample; A feature extraction module is used to extract features from the background area in the image to be detected to obtain a target feature vector; A maximum similarity determination module, used to determine the maximum similarity between the target feature vector and a pre-stored feature vector in a pre-stored feature vector set; the pre-stored feature vector is a feature vector of a background area in a non-living body image sample; A liveness detection result generating module is used to generate a liveness detection result according to the first non-liveness probability value, the second non-liveness probability value and the maximum similarity.

11. The apparatus of claim 10, further comprising: The image segmentation module is used to segment the image to be detected using an image segmentation model to obtain a face area in the image to be detected and a background area in the image to be detected; the background area in the image to be detected is the area outside the face area in the image to be detected.

12. The device according to claim 11, wherein the first preset loss function comprises a first loss function and a second loss function; the first loss function is used to characterize the degree of deviation between the predicted image segmentation result output by the image segmentation model and the preset image segmentation result; the second loss function is used to characterize the degree of deviation between the feature vectors of two feature image sub-regions of the same classification type determined according to the predicted image segmentation result; The formula of the second loss function is: , in, represents a feature vector of the feature image sub-region, represents a feature vector of another feature image sub-region, express and The degree of deviation between them.

13. The device according to claim 10, wherein the first acquisition module is specifically configured to: The first liveness detection model is used to perform liveness detection on the image within the face area of ​​the image to be detected to obtain a first non-liveness probability value; the first liveness detection model is obtained by training the first classification model using the image within the face area in the image sample collected by the device.

14. The device according to claim 10, wherein the second acquisition module is specifically configured to: Performing liveness detection on an image in a background area of ​​the image to be detected using a second liveness detection model to obtain a second non-liveness probability value; the second liveness detection model is obtained by training a second classification model based on a second preset loss function using background image samples carrying preset liveness classification results; the background image samples are images in the background area of ​​image samples collected by the device; in, The second preset loss function is used to characterize the degree of deviation between the predicted living body classification result output by the second living body detection model and the preset living body classification result, and to characterize the degree of deviation between the image feature vector of the preset category of the background image sample and the image feature clustering center of the preset category.

15. The device of claim 14, wherein the second preset loss function comprises a third loss function and a fourth loss function; the third loss function is used to characterize the degree of deviation between the predicted living body classification result output by the second living body detection model and the preset living body classification result; the fourth loss function is used to characterize the degree of deviation between the image feature vector of the preset category of the background image sample and the image feature cluster center of the preset category; The formula of the fourth loss function is: , in, represents the image feature vector of the i-th category of the background image sample, represents the cluster center of the image feature of the i-th category, express and The degree of deviation between them.

16. The device according to claim 14 or 15, wherein the feature extraction module is specifically used for: Extract the first input feature vector of the fully connected layer of the second liveness detection model to obtain a target feature vector; the target feature vector is generated in the process of performing liveness detection on an image in a background area of ​​the image to be detected using the second liveness detection model.

17. The apparatus of claim 16, further comprising: The pre-stored feature vector extraction module is used to use the second liveness detection model to perform liveness detection on the image in the background area of ​​the non-liveness image sample, extract the second input feature vector of the fully connected layer of the second liveness detection model, and obtain the pre-stored feature vector.

18. The device according to claim 10, wherein the living body detection result generating module is specifically used for: Calculating the product of the first non-living body probability value and a first preset weight to obtain a first weighted probability value; Calculating the product of the second non-living body probability value and a second preset weight to obtain a second weighted probability value; Calculating the product of the sum of the first weighted probability value and the second weighted probability value and the maximum similarity to obtain a target non-living body probability value; Determine whether the target non-living body probability value is greater than a preset threshold value, and obtain a determination result; If the judgment result indicates that the probability value of the target being a non-living object is greater than a preset threshold, a detection result indicating that the image to be detected does not contain a living object is generated; If the judgment result indicates that the probability value of the target being a non-living object is less than or equal to a preset threshold, a detection result indicating that a living object is contained in the image to be detected is generated.

19. A living body detection device, comprising: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to: Obtaining a first non-living body probability value determined according to a face region in the image to be detected; Obtain a second non-living body probability value determined according to a background area in the image to be detected; the background area is obtained by performing segmentation processing on the image to be detected based on an image segmentation model; the image segmentation model is obtained by training a deep learning model based on a first preset loss function using an image sample carrying a preset image segmentation result; the first preset loss function is used to characterize the degree of deviation between the predicted image segmentation result output by the image segmentation model and the preset image segmentation result, and to characterize the degree of deviation between feature vectors of two feature image sub-areas of the same classification type determined according to the predicted image segmentation result, wherein the feature image sub-area is a partial area in the feature image generated in the process of performing segmentation processing on the image sample by the image segmentation model; Extracting features from the background area of ​​the image to be detected to obtain a target feature vector; Determining the maximum similarity between the target feature vector and a pre-stored feature vector in a pre-stored feature vector set; the pre-stored feature vector is a feature vector of a background region in a non-living body image sample; A liveness detection result is generated according to the first non-liveness probability value, the second non-liveness probability value and the maximum similarity.

Citation Information

Patent Citations

  • Living body recognition method and device, storage medium, and computer equipment

    CN107818313A

  • Image recognition method, device and computing equipment and storage medium

    CN108764325A

  • Living body detection method, apparatus and system

    CN108875676A

  • Face recognition method, device, computer device and storage medium

    CN109241868A

  • Model training method and device, image processing method and device, terminal and storage medium

    CN110363138A