Live detection method, live detection model training method and device

By performing image segmentation and liveness detection on training sample images, and combining feature transformation units and classification units, the liveness detection model is optimized, solving the accuracy problem of spoofed face recognition in silent liveness detection, and achieving higher detection accuracy and model robustness.

CN115424293BActive Publication Date: 2026-04-24ZHEJIANG DAHUA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHEJIANG DAHUA TECH CO LTD
Filing Date
2022-08-02
Publication Date
2026-04-24

AI Technical Summary

Technical Problem

In silent liveness detection, the accuracy of detection using image data acquired by a camera is low, making it difficult to effectively identify fake faces.

Method used

By segmenting training sample images, calculating image segmentation loss and classification loss, optimizing the parameters of the liveness detection model, and combining feature transformation units and classification units, the sensitivity to fake faces is improved.

Benefits of technology

It improves the accuracy of silent liveness detection, enhances the ability to identify fake faces, and improves the model's generalization and robustness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115424293B_ABST
    Figure CN115424293B_ABST
Patent Text Reader

Abstract

The application discloses a living body detection method and a training method and device of a living body detection model. The living body detection model comprises a first module and a second module. The training method of the living body detection model comprises the following steps: obtaining a segmentation feature map by performing image segmentation on a training sample image through the first module, and calculating an image segmentation loss based on the segmentation feature map; obtaining a living body detection result by performing living body detection on the segmentation feature map through the second module, and calculating a classification loss based on the living body detection result; calculating a total loss based on the image segmentation loss and the classification loss; and optimizing parameters of the living body detection model based on the total loss to obtain a trained living body detection model. The application can improve the accuracy of silent living body detection based on picture data obtained by a camera.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to a liveness detection method, a training method for a liveness detection model, and an apparatus. Background Technology

[0002] Liveness detection technology is widely used in scenarios such as target recognition to detect fraudulent activities and protect user rights. Liveness detection technology can be divided into silent liveness detection and cooperative liveness detection in terms of implementation methods. However, performing silent liveness detection on image data acquired by a camera is a challenge. Summary of the Invention

[0003] This application provides a liveness detection method, a training method and apparatus for a liveness detection model, which can improve the accuracy of silent liveness detection based on image data acquired by a camera.

[0004] To achieve the above objectives, this application provides a training method for a liveness detection model, which includes a first module and a second module. The method includes:

[0005] The first module performs image segmentation on the training sample images to obtain segmentation feature maps, and then calculates the image segmentation loss based on the segmentation feature maps.

[0006] The second module performs liveness detection on the segmented feature map to obtain the liveness detection result, and the classification loss is calculated based on the liveness detection result;

[0007] The total loss is calculated based on image segmentation loss and classification loss;

[0008] The parameters of the liveness detection model are optimized using the total loss to obtain the trained liveness detection model.

[0009] The process involves segmenting the training sample images using the first module to obtain segmentation feature maps, and then calculating the image segmentation loss based on these feature maps, including:

[0010] Pre-classify the pixels in the training sample image to segment the training sample image into at least one region;

[0011] The first module is used to process the training sample images to obtain segmentation feature maps;

[0012] The label of each region is determined based on the features corresponding to each region in the segmentation feature map, so as to determine the label of all pixels in the training sample image.

[0013] The image segmentation loss is calculated based on the label of each pixel in the training sample image and the feature value corresponding to the label in the segmentation feature map.

[0014] The process of determining the label for each region based on the features corresponding to each region in the segmentation feature map includes:

[0015] The category of each pixel is determined by the category of the largest feature value among all feature values ​​corresponding to each pixel in the segmentation feature map.

[0016] The category that appears most frequently in each region is used as the label for all pixels in that region.

[0017] The second module performs liveness detection on the segmented feature map to obtain the liveness detection result, and calculates the classification loss based on the liveness detection result. This process includes:

[0018] Positive and negative sample pairs are constructed based on training sample images. In positive sample pairs, the liveness attributes of the training sample images are the same, while in negative sample pairs, the liveness attributes of the training sample images are different.

[0019] The second module performs liveness detection on the segmented feature map to obtain the liveness detection result. Based on the liveness detection result, the classification loss is calculated, including:

[0020] Determine the similarity of positive sample pairs under the liveness detection model, and determine the similarity of negative sample pairs under the liveness detection model;

[0021] The contrast loss is calculated based on the similarity of positive sample pairs and the similarity of negative sample pairs.

[0022] The total loss is calculated based on image segmentation loss and classification loss, including:

[0023] The total loss is calculated based on image segmentation loss, contrast loss, and classification loss.

[0024] in,

[0025] In at least some positive sample pairs, the objects corresponding to the training sample images have different identities, while in negative sample pairs, the objects corresponding to the training sample images have the same identity; and / or,

[0026] At least some positive sample pairs have different preset environment information corresponding to the training sample images, while negative sample pairs have the same preset environment information corresponding to the training sample images.

[0027] The second module includes a feature transformation unit, which comprises two symmetrical branches with shared parameters; it determines the similarity of positive sample pairs under the liveness detection model, and determines the similarity of negative sample pairs under the liveness detection model; including:

[0028] The similarity of the positive sample pair under the liveness detection model is obtained by inputting the two samples in the positive sample pair into the corresponding branches and calculating the similarity of the outputs of the two branches.

[0029] The two samples in the negative sample pair are input into the corresponding branches, and the similarity of the outputs of the two branches is calculated to obtain the similarity of the negative sample pair under the liveness detection model.

[0030] The liveness detection model includes a classification unit. A second module performs liveness detection on the segmented feature map to obtain the liveness detection result. Based on the liveness detection result, a classification loss is calculated, including:

[0031] The output of each branch of the feature transformation unit is processed by the classification unit to obtain the liveness attribute of the training sample image corresponding to the output of each branch.

[0032] The classification loss is calculated based on the liveness attributes of the training sample images.

[0033] The training sample images are the region images obtained by expanding the object region outward.

[0034] To achieve the above objectives, this application also provides a method for liveness detection using a liveness detection model, the liveness detection model comprising a first module and a second module, and the method comprising:

[0035] Acquire the image of the object to be detected;

[0036] The first module segments the image of the object to be detected, and obtains the segmentation feature map.

[0037] The second module performs liveness detection on the segmented feature map to obtain the liveness detection result of the image of the object to be detected.

[0038] The liveness detection model is optimized based on image segmentation loss and classification loss. The image segmentation loss is calculated based on the segmentation feature maps of the training sample images, and the classification loss is calculated based on the liveness detection results of the training sample images.

[0039] To achieve the above objectives, this application also provides an electronic device including a processor; the processor is configured to execute instructions to implement the above methods.

[0040] To achieve the above objectives, this application also provides a computer-readable storage medium for storing instruction / program data that can be executed to implement the above methods.

[0041] This application utilizes a first module to perform image segmentation on training sample images to obtain segmentation feature maps, and then calculates the image segmentation loss. Next, a second module is used to perform liveness detection on the segmentation feature maps to obtain liveness detection results, and then a classification loss is calculated based on the liveness detection results. Finally, a total loss is calculated based on the image segmentation loss and the classification loss. The parameters of the liveness detection model, including the first and second modules, are then optimized using the total loss. This allows the trained liveness detection model to detect whether an object in an image is alive through the classification loss, and the image segmentation loss makes the liveness detection model more sensitive to samples with obvious edges, such as paper and pictures containing objects. This makes the liveness detection model more attentive to salience flaws in forged faces, thereby improving the accuracy of silent liveness detection based on image data acquired from a camera. In other words, this application trains liveness detection and image segmentation in a multi-task manner to improve the sensitivity of the liveness detection framework to forged face flaws. Attached Figure Description

[0042] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0043] Figure 1 This is a flowchart illustrating one implementation method of the liveness detection model of this application;

[0044] Figure 2 This is a schematic diagram of one embodiment of the liveness detection model of this application;

[0045] Figure 3 This is a schematic diagram of one embodiment of the feature conversion unit in the liveness detection model of this application;

[0046] Figure 4 This is a schematic diagram of one embodiment of the liveness detection method of this application;

[0047] Figure 5 This is a schematic diagram of the structure of one embodiment of the electronic device of this application;

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

[0049] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application. In addition, unless otherwise specified (e.g., "or additionally" or "or in alternatives"), the term "or" as used herein refers to a non-exclusive "or" (i.e., "and / or"). Furthermore, the various embodiments described herein are not necessarily mutually exclusive, as some embodiments can be combined with one or more other embodiments to form new embodiments.

[0050] Specifically, such as Figure 1 As shown, the training method for the liveness detection model in this embodiment includes the following steps. Figure 2 As shown, the liveness detection module may include a first module and a second module. It should be noted that the step numbers are for simplification only and are not intended to limit the execution order of the steps. The execution order of the steps in this embodiment can be arbitrarily changed without departing from the technical concept of this application.

[0051] S101: The first module performs image segmentation on the training sample images to obtain segmentation feature maps, and the image segmentation loss is calculated based on the segmentation feature maps.

[0052] The first module can segment the training sample images to obtain segmentation feature maps. Subsequently, the liveness detection model can be trained based on the image segmentation loss calculated from the segmentation feature maps, resulting in a trained liveness detection model. Through training, the first module can distinguish different regions based on the edge features of each region and present the segmentation attributes of each pixel in the segmentation feature map. In this way, the first module can make the liveness detection model more sensitive to samples with obvious edges, such as paper and pictures with target face images, thereby guiding the liveness detection model to focus on non-liveness salience flaws, thus improving the accuracy of silent liveness detection based on image data acquired by the camera.

[0053] The training sample images can be semantically segmented using the first module, which allows the classification label of each pixel in the training sample images to be determined based on the first module.

[0054] The structure of the first module is unrestricted; for example, it can be a snake model or a SegNet structure.

[0055] To reduce the difficulty of annotation, an unsupervised image segmentation training method can be used for training, thereby avoiding the large amount of manpower and time cost of annotation in image segmentation tasks, and making the training method of this application applicable to a variety of scenarios and application devices.

[0056] Specifically, the pixels in the training sample images can be pre-classified to segment each training sample image into at least one region. Then, the first module is used to process the training sample images to obtain a segmentation feature map. Based on the features corresponding to each region in the segmentation feature map, the label of each region is determined to determine the label of all pixels in the training sample image. Then, based on the label of each pixel in the training sample image and the feature value corresponding to the label in the segmentation feature map, the image segmentation loss can be calculated. After training the liveness detection model including the first and second modules using the image segmentation loss, the semantic segmentation result determined based on the segmentation feature map can be close to the pre-classification result, so that the segmentation feature map output by the first module can better reflect the actual segmentation attributes of each pixel.

[0057] The pre-classification algorithm used is unrestricted; it can be a classic machine learning algorithm such as the Felzenszwalb segmentation algorithm, or other algorithms. Specifically, the Felzenszwalb segmentation algorithm can be used to perform preliminary clustering of pixels in the training sample image, yielding the clustering result S. k ,in:

[0058]

[0059] In optimizing the liveness detection model using the training method described in this application, the parameters of the pre-classification method can also be adjusted to group pixels with the same semantic meaning into one region, i.e., assigning the same semantic label to pixels of the same type. Specifically, when optimizing the parameters of the liveness detection model using the total loss calculated from the image segmentation loss, the parameters of the algorithm used in pre-classification can also be optimized using the total loss. In other implementations, the pre-classification algorithm used in pre-classification can be a pre-trained pre-classification algorithm.

[0060] The structure of the first module is unrestricted; for example, it can be a three-layer convolutional network structure or a deep learning model combined with an autoencoder.

[0061] After obtaining the segmentation feature map of the training sample image based on the first module, the label of each region can be determined based on the features corresponding to each region in the segmentation feature map.

[0062] And based on segmentation feature map f n The steps for determining the label for each region based on the features of each region may include:

[0063] Each pixel is in the segmentation feature map f n The category to which the maximum value of all feature values ​​belongs is taken as the category c of each pixel. n ,in:

[0064] f n =Net(x);

[0065] c n =argmax f n ;

[0066] The category that appears most frequently in each region t is the label for all pixels in each region. n The specific process is as follows:

[0067]

[0068]

[0069] Thus, the labels of all pixels in the training sample image can be determined through the above steps.

[0070] After determining the labels of all pixels in the training sample image, the image segmentation loss can be calculated based on the label of each pixel in the training sample image and the feature value corresponding to the label in the segmentation feature map.

[0071] Among them, the image segmentation loss L s The calculation formula can be:

[0072]

[0073] To maximize the accuracy of the liveness detection model, the training sample images in this application can be expanded versions of object images, such as expanded versions of face images. These training sample images can contain information beyond the object itself (e.g., edge defects on paper / mobile devices), facilitating liveness attribute determination. For example, the image segmentation module can segment the mobile device screen / paper and objects on the screen / paper in non-liveness images into the same region based on edge defects in the paper / mobile device. This allows the second module to classify the non-liveness image as non-liveness based on the characteristics of the paper / mobile device, thereby improving the liveness detection accuracy of the liveness detection model based on the expanded training sample images, and ultimately enhancing the generalization and robustness of the liveness detection algorithm.

[0074] In addition, before step S101, training sample images need to be acquired. The method for acquiring training sample images may include: after obtaining the object coordinates of a single frame of the video using an object detection operator, expanding the object region outwards by m object widths in both the positive and negative directions of the X and Y dimensions (where m is the expansion ratio), thus obtaining the expanded object data. The object can be a human face or a pet face, etc., and is not limited here.

[0075] S102: Liveness detection results are obtained by performing liveness detection on the segmentation feature map through the second module, and the classification loss is calculated based on the liveness detection results.

[0076] After obtaining the segmentation feature map of the training sample image based on step S101, the second module can perform liveness detection on the segmentation feature map to obtain the liveness detection result of the training sample image. That is, based on the training sample image, it is determined whether the object in the training sample image is alive or not. Then, the classification loss can be calculated based on the liveness detection result so that the liveness detection model can be optimized based on the classification loss, thereby enabling the trained liveness detection model to have the ability to detect whether the object in the image is alive.

[0077] The loss function used in calculating the classification loss is unrestricted; for example, it can be the cross-entropy loss function or the absolute value loss function.

[0078] For example, the classification loss L can be calculated using the following loss function formula and based on the liveness detection results of the training sample images. ce :

[0079]

[0080] Among them, y i p represents the category of the training sample images. i This represents the probability of being predicted as positive, where N is the total number of training sample images.

[0081] Alternatively, the following implementation method can be used to perform liveness detection on the segmented feature map through the second module to obtain the liveness detection result.

[0082] In one feasible approach, the second module can be a classification unit, which can process the segmentation feature map to obtain the liveness detection result.

[0083] In another possible implementation, the second module may include a feature transformation unit and a classification unit. Specifically, the feature transformation unit can transform the segmentation feature map to obtain the transformed features of the training sample image, and then the classification unit can classify the transformed features to obtain the liveness detection result.

[0084] Among them, such as Figure 3As shown, the feature transformation unit may include a feature encoder and a nonlinear mapper. The feature encoder processes the segmentation feature map to obtain the feature representation h of the training sample image. Then, the nonlinear mapper performs a nonlinear transformation on the feature representation h, mapping the feature representation h to the transformed feature z. In this way, the segmentation feature map can be projected onto the representation space through the feature encoder and the nonlinear mapper. Furthermore, the nonlinear mapper can filter out many low-level detail features that are general but irrelevant to the task in the feature representation output by the feature encoder, while retaining and processing high-order information relevant to the liveness detection task. Thus, the two-layer mapping of the feature encoder and the nonlinear mapper can, to a certain extent, ensure the filtering of irrelevant information and obtain discriminative and effective information, thereby improving the performance of the liveness detection model.

[0085] Prior to step S102, positive and negative sample pairs can be constructed based on the training sample images. The training sample images in a positive sample pair have the same liveness attribute; that is, the objects in the samples in the positive sample pair are either all live or all non-live. The training sample images in a negative sample pair have different liveness attributes; that is, one training sample image in the negative sample pair contains a live object, while the other contains a non-live object. For example, in a negative sample pair, one training sample image is a live face, and the other is a screen face.

[0086] In step S102, the feature similarity of positive sample pairs under the second module can be determined, as can the feature similarity of negative sample pairs under the second module. Then, the contrast loss is calculated based on the similarity of positive and negative sample pairs. In this way, by constructing similar instances (i.e., positive sample pairs) and dissimilar instances (i.e., negative sample pairs), a model can be learned that allows similar instances to be close in the representation space and dissimilar instances to be far apart in the representation space. This is so that the contrast loss can be used to train the liveness detection model, resulting in higher similarity of positive sample pairs output by the feature conversion unit and lower similarity of positive sample pairs output by the feature conversion unit. This further enhances the extraction of key features for identifying fake faces. That is, the conversion features of the image output by the feature conversion unit can more clearly present the liveness attributes of the image, thereby improving the accuracy of the liveness detection results of the image determined by the classification unit based on the conversion features and improving the generalization and robustness of the model.

[0087] The formula for calculating the contrast loss can be Softmax Loss or InfoNCELoss, as shown below:

[0088]

[0089] Where τ is the adjustable temperature parameter, S(z) i ,z jLet S(z) represent the feature similarity of the sample pairs. From the design structure of the contrastive loss function, the numerator encourages higher similarity for positive sample pairs, while the denominator encourages lower similarity for negative sample pairs. The feature similarity S(z) of the sample pairs is... i ,z j The formula for calculating ) is as follows:

[0090]

[0091] Among them, z i z is the transformation feature of one sample in a sample pair. j The transformation feature of another sample in a sample pair.

[0092] In other embodiments, the feature similarity of sample pairs can also be calculated using other methods, such as Euclidean distance.

[0093] Furthermore, in at least some positive sample pairs, the objects corresponding to the training sample images have different identities, while in negative sample pairs, the objects corresponding to the training sample images have the same identity. Thus, the contrast loss is calculated by using the similarity between positive sample pairs with different object identities and the similarity between negative sample pairs with the same object identity. This allows the feature transformation unit to be trained using the contrast loss, so that the feature transformation unit ignores the object identity factor and focuses on the significant discriminative features that distinguish between live and non-live objects, thereby improving the liveness detection accuracy of the liveness detection model trained by the training method of this application.

[0094] In addition, at least some positive sample pairs have different training sample images corresponding to at least one preset environmental information, while negative sample pairs have the same training sample images corresponding to at least one preset environmental information. Thus, the contrast loss is calculated by the similarity between positive sample pairs with different preset environmental information and negative sample pairs with the same preset environmental information. This allows the feature conversion unit to be trained using the contrast loss, so that the feature conversion unit ignores preset environmental factors and focuses on the significant discriminative features that distinguish between live and non-live objects, thereby improving the liveness detection accuracy of the liveness detection model trained by the training method of this application.

[0095] The preset environmental factors can be at least one of several environmental factors obtained by finely dividing broad environmental information. This fine-grained division can improve the effectiveness of the liveness detection model in ignoring environmental factors, thereby increasing the model's ability to distinguish between live and non-live entities. The various environmental factors obtained after finely dividing the broad environmental information can include scene information, lighting information, device information, etc.

[0096] To facilitate the calculation of feature similarity between positive and negative sample pairs under the liveness detection model, the feature transformation unit can be configured as a contrastive learning structure. This structure includes two symmetrical branches that share parameters. In this way, each of the two samples in a positive sample pair can be input into one branch of the feature transformation unit, and the similarity of the features output by the two branches can be calculated to obtain the similarity of the positive sample pair under the liveness detection model. Similarly, each of the two samples in a negative sample pair can be input into one branch of the feature transformation unit, and the similarity of the features output by the two branches can be calculated to obtain the similarity of the negative sample pair under the liveness detection model.

[0097] When the feature transformation module is a contrastive learning structure, the output of each branch of the feature transformation module can be processed by the classification unit to obtain the liveness attribute of the training sample image corresponding to the output of each branch; thus, the classification loss can be calculated based on the liveness attribute of the training sample image.

[0098] S103: Calculate the total loss based on image segmentation loss and classification loss.

[0099] After calculating the image segmentation loss and classification loss based on the above steps, the total loss can be calculated based on the image segmentation loss and classification loss. This total loss can then be used to optimize the parameters of the liveness detection model. In this way, the classification loss can enable the trained liveness detection model to detect whether an object in an image is alive, and the image segmentation loss can make the liveness detection model more sensitive to samples with obvious edges, such as paper and pictures with target face images. This can improve the accuracy of silent liveness detection based on image data acquired by a camera.

[0100] In one implementation, the image segmentation loss and classification loss can be directly added together to obtain the total loss.

[0101] In another implementation, the image segmentation loss and classification loss can be weighted to obtain the total loss. The weighting coefficients for the image segmentation loss and classification loss can be set according to the actual situation and are not limited here.

[0102] In another implementation, after calculating the contrast loss based on step S102, the total loss can be calculated based on the image segmentation loss, contrast loss, and classification loss. This allows the liveness detection model to ignore object identity factors and environmental factors and focus on the significant discriminative features that distinguish between live and non-live objects, thereby improving the accuracy of silent liveness detection based on image data acquired by the camera.

[0103] Specifically, as shown below, the image segmentation loss L can be... s , contrast loss L c And classification loss L ce We perform weighted averaging to obtain the total loss L. total ;

[0104] L total =γ·L ce +α·L c +β·L s ;

[0105] Where γ is the weighting coefficient of the classification loss, α is the weighting coefficient of the contrast loss, and β is the weighting coefficient of the image segmentation loss. The specific weighting coefficients for the image segmentation loss, contrast loss, and classification loss can be set according to the actual situation and are not limited here. For example, γ can be 1, α can be 0.7, and β can be 0.8.

[0106] S104: Optimize the parameters of the image segmentation module and the liveness detection model using the total loss to obtain the trained liveness detection model.

[0107] After obtaining the total loss based on step S103, the parameters of the liveness detection model can be optimized using the total loss to obtain the trained liveness detection model.

[0108] The parameters of the liveness detection model can be optimized using optimization methods such as gradient descent and Newton's method, with the total loss.

[0109] In this embodiment, the first module performs image segmentation on the training sample images to obtain a segmentation feature map, and then calculates the image segmentation loss. Next, the second module performs liveness detection on the segmentation feature map to obtain a liveness detection result, and then calculates the classification loss based on the liveness detection result. Then, the total loss is calculated based on the image segmentation loss and the classification loss. Finally, the parameters of the liveness detection model, including the first and second modules, are optimized using the total loss. This allows the trained liveness detection model to detect whether an object in an image is alive through the classification loss, and the image segmentation loss makes the liveness detection model more sensitive to samples with obvious edges, such as paper and pictures with objects. This makes the liveness detection model more attentive to salience flaws in forged faces, thereby improving the accuracy of silent liveness detection based on image data acquired from a camera. In other words, this application trains liveness detection and image segmentation in a multi-task manner to improve the sensitivity of the liveness detection framework to forged face flaws.

[0110] After training a liveness detection model using the above methods, the trained liveness detection model can be used for liveness detection. For example... Figure 4As shown, the liveness detection method may include the following steps. It should be noted that the step numbers are for simplification only and are not intended to limit the execution order of the steps. The execution order of the steps in this embodiment can be arbitrarily changed without departing from the technical concept of this application.

[0111] S201: Obtain the image of the object to be detected.

[0112] An image containing an object can be captured by the camera and used as the image of the object to be detected.

[0113] Alternatively, after acquiring the image captured by the camera, the object coordinates in the image are obtained using the object detection operator. Then, the object region is expanded outward by m object widths in both the positive and negative directions of the X and Y dimensions (m is the expansion ratio). This will give you the region image after the object region is expanded outward, which is the image of the object to be detected.

[0114] The objects described above are not limited; for example, they can be people, pets, or a part of a person or pet. For example, an object can be a human face.

[0115] The camera's structure is not limited; for example, it can be a bullet camera, a PTZ camera, a panoramic camera, etc.

[0116] S202: The first module segments the image of the object to be detected to obtain a segmentation feature map.

[0117] S203: Liveness detection is performed on the segmented feature map by the second module to obtain the liveness detection result of the image of the object to be detected.

[0118] The liveness detection model is optimized based on image segmentation loss and classification loss. The image segmentation loss is calculated based on the segmentation feature maps of the training sample images, while the classification loss is calculated based on the liveness detection results of the training sample images.

[0119] The second module may include a feature transformation unit and a classification unit.

[0120] When the feature transformation unit is a contrastive learning structure, the segmentation feature map of the image to be detected can be input into a branch of the feature transformation unit, and then the output of the branch can be input into the classification unit to obtain the liveness detection result of the face module to be detected output by the classification unit.

[0121] Please see Figure 5 , Figure 5 This is a schematic diagram of one embodiment of the electronic device 20 of this application. The electronic device 20 of this application includes a processor 22, which is used to execute instructions to implement the methods provided by any of the above embodiments of this application and any non-conflicting combinations thereof.

[0122] Processor 22 can also be referred to as CPU (Central Processing Unit). Processor 22 may be an integrated circuit chip with signal processing capabilities. Processor 22 can also be a general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component. A general-purpose processor can be a microprocessor, or processor 22 can be any conventional processor, etc.

[0123] The electronic device 20 may further include a memory 21 for storing instructions and data required for the processor 22 to run.

[0124] Please see Figure 6 , Figure 6 This is a schematic diagram of the structure of a computer-readable storage medium in an embodiment of this application. The computer-readable storage medium 30 in this embodiment stores instruction / program data 31. When executed, this instruction / program data 31 implements the methods provided in any embodiment of the above-described method of this application, as well as any non-conflicting combination thereof. The instruction / program data 31 can be formed into a program file and stored in the storage medium 30 in the form of a software product, so that a computer device (which may be a personal computer, server, or network device, etc.) or processor can execute all or part of the steps of the methods in various embodiments of this application. The aforementioned storage medium 30 includes various media capable of storing program code, such as a USB flash drive, portable hard drive, read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk, or devices such as computers, servers, mobile phones, and tablets.

[0125] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, or indirect coupling or communication connection between apparatuses or units, and may be electrical, mechanical, or other forms.

[0126] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0127] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0128] The above are merely embodiments of this application and do not limit the scope of this patent application. Any equivalent structural or procedural changes made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of this application.

Claims

1. A training method for a liveness detection model, characterized in that, The liveness detection model includes a first module and a second module connected in series, and the method includes: The first module performs unsupervised image segmentation on the training sample image to obtain a segmentation feature map, and calculates the image segmentation loss based on the segmentation feature map. The training sample image is a region image obtained by expanding the object region outward, which is used to enable the first module to learn the edge flaw information between the object region and the expanded region in the training sample image. The second module performs liveness detection on the segmented feature map to obtain a liveness detection result, and calculates a classification loss based on the liveness detection result; The total loss is calculated based on the image segmentation loss and the classification loss; The parameters of the liveness detection model are optimized using the total loss to obtain the trained liveness detection model; The step of obtaining a segmentation feature map by performing image segmentation on the training sample image through the first module, and calculating the image segmentation loss based on the segmentation feature map, includes: The pixels in the training sample image are pre-classified to segment the training sample image into at least one region; The first module is used to process the training sample images to obtain a segmentation feature map; The label of each region is determined based on the features corresponding to each region in the segmentation feature map, so as to determine the label of all pixels in the training sample image; The image segmentation loss is calculated based on the label of each pixel in the training sample image and the feature value corresponding to the label in the segmentation feature map; The step of determining the label of each region based on the features corresponding to each region in the segmentation feature map includes: The category of each pixel is determined by the category of the largest feature value among all feature values ​​corresponding to each pixel in the segmentation feature map. The category that appears most frequently in each region is used as the label for all pixels in each region.

2. The method according to claim 1, characterized in that, The step of performing liveness detection on the segmented feature map through the second module to obtain a liveness detection result, and calculating a classification loss based on the liveness detection result, includes the following steps: Positive sample pairs and negative sample pairs are constructed based on the training sample images. The positive sample pairs have the same liveness attribute of the training sample images, while the negative sample pairs have different liveness attributes of the training sample images. The step of performing liveness detection on the segmented feature map through the second module to obtain a liveness detection result, and calculating a classification loss based on the liveness detection result, includes: Determine the similarity of the positive sample pairs under the liveness detection model, and determine the similarity of the negative sample pairs under the liveness detection model; The contrast loss is calculated based on the similarity between the positive sample pairs and the negative sample pairs. The calculation of the total loss based on the image segmentation loss and the classification loss includes: The total loss is calculated based on the image segmentation loss, the contrast loss, and the classification loss.

3. The method according to claim 2, characterized in that, At least some of the positive sample pairs have different object identities corresponding to the training sample images, while the negative sample pairs have the same object identity corresponding to the training sample images; and / or, At least some of the positive sample pairs have different preset environment information corresponding to the training sample images, while the negative sample pairs have the same preset environment information corresponding to the training sample images.

4. The method according to claim 3, characterized in that, The second module includes a feature transformation unit, which comprises two symmetrical branches that share parameters; Determining the similarity of the positive sample pairs under the liveness detection model, and determining the similarity of the negative sample pairs under the liveness detection model, includes: The two samples in the positive sample pair are respectively input into the corresponding branches, and the similarity of the outputs of the two branches is calculated to obtain the similarity of the positive sample pair under the liveness detection model. The two samples in the negative sample pair are input into the corresponding branches respectively, and the similarity of the outputs of the two branches is calculated to obtain the similarity of the negative sample pair under the liveness detection model.

5. The method according to claim 4, characterized in that, The liveness detection model includes a classification unit. The liveness detection result is obtained by performing liveness detection on the segmented feature map using the second module, and a classification loss is calculated based on the liveness detection result, including: The classification unit processes the output of each branch of the feature transformation unit to obtain the liveness attribute of the training sample image corresponding to the output of each branch. The classification loss is calculated based on the liveness attribute of the training sample images.

6. A method for liveness detection using a liveness detection model, characterized in that, The liveness detection model includes a first module and a second module connected in series. The liveness detection model is trained using the training method described in any one of claims 1 to 5, wherein the method includes: Acquire the image of the object to be detected; The first module segments the image of the object to be detected to obtain a segmentation feature map; The second module performs liveness detection on the segmented feature map to obtain the liveness detection result of the image of the object to be detected. The liveness detection model is optimized based on image segmentation loss and classification loss. The image segmentation loss is calculated based on the segmentation feature maps of the training sample images, and the classification loss is calculated based on the liveness detection results of the training sample images.

7. An electronic device, characterized in that, The electronic device includes a processor for executing instructions to implement the method of any one of claims 1-6.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instruction / program data for execution to implement the method of any one of claims 1-6.

Citation Information

Patent Citations

  • Living body detection model training method and device

    CN112926508A

  • Training method and device for automatic driving semantic segmentation model

    CN113313716A