Living body recognition method and device, terminal equipment and medium

By using an attention-based liveness detection model that combines liveness classification probability and feature similarity, the problem of insufficient applicability of existing liveness detection models is solved, achieving efficient and accurate liveness detection, countering various spoofing attacks, and ensuring user security.

CN115995113BActive Publication Date: 2026-01-09CHINA MERCHANTS BANK
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310139281.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-10
Publication Date
2026-01-09
Estimated Expiration
2043-02-10

AI Technical Summary

Technical Problem

In existing technologies, liveness detection models can only be applied to a single attack scenario, resulting in decreased recognition accuracy and cumbersome processes. They cannot effectively deal with various face spoofing attacks, thus affecting user security.

Method used

An attention-based liveness detection model is adopted to perform liveness detection on target face images through a preset model, outputting liveness classification probability and face feature vector. The liveness detection result is judged by combining feature similarity, and a single model can be used to deal with multiple forgery scenarios.

Benefits of technology

It improves the accuracy and efficiency of liveness detection, reduces costs, and can effectively identify fake live faces such as photos, videos, 3D models, or masks and headgear, ensuring user safety.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115995113B_ABST
    Figure CN115995113B_ABST
Patent Text Reader

Abstract

The application discloses a living body recognition method and device, a terminal device and a computer readable storage medium. The method comprises the following steps: obtaining a target face picture; based on an attention mechanism, performing living body recognition on the target face picture through a preset living body recognition model to obtain an output result of the living body recognition model, wherein the output result comprises a living body classification probability and a face feature vector of the target face picture; and determining a living body recognition result of the target face picture based on the living body classification probability and the face feature vector. The application can realize accurate and efficient living body recognition.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image recognition, and particularly relates to a living body recognition method and device, a terminal device and a computer readable storage medium. BACKGROUND

[0002] With the continuous development of optical imaging technology and deep learning technology, face recognition technology is widely used in user authentication, mobile payment, access control and the like. Meanwhile, more and more face spoofing attack methods have appeared, such as using paper, video, 3D mask, silicone head cover and the like to disguise the face of others in order to pass the face recognition, thereby threatening the safety of the rights and interests of others.

[0003] In order to defend against the above face spoofing attacks, a corresponding living body detection model is usually trained for different attack methods and different face scenes, but since the trained living body detection model can only be applied to a single attack scene, the living body recognition accuracy is greatly reduced, and the face recognition process is relatively cumbersome, time-consuming and laborious. SUMMARY

[0004] The main purpose of the present application is to provide a living body recognition method, device, terminal device and computer readable storage medium, which aims to realize accurate and efficient living body recognition.

[0005] To achieve the above purpose, the present application provides a living body recognition method, which comprises the following steps:

[0006] obtaining a target face picture;

[0007] based on an attention mechanism, performing living body recognition on the target face picture through a preset living body recognition model to obtain an output result of the living body recognition model, wherein the output result comprises a living body classification probability and a face feature vector corresponding to the target face picture;

[0008] determining a living body recognition result of the target face picture based on the living body classification probability and the face feature vector.

[0009] Optionally, the step of performing living body recognition on the target face picture through the preset living body recognition model based on the attention mechanism to obtain the output result of the living body recognition model comprises:

[0010] inputting an original matrix corresponding to the target face picture into the living body recognition model to perform residual operation;

[0011] based on an attention mechanism, performing one-dimensional full pooling operation on input features in a horizontal direction and input features in a vertical direction of the original matrix after the residual operation to respectively aggregate the input features in the horizontal direction and the input features in the vertical direction to obtain corresponding direction perception feature maps.

[0012] aggregate the plurality of the direction perception feature maps, and sequentially perform convolution processing, batch normalization processing and non-linear activation function processing on the aggregated direction perception feature maps;

[0013] separate the direction perception feature maps subjected to the convolution processing, the batch normalization processing and the non-linear activation function processing into a first feature map and a second feature map;

[0014] perform convolution processing and activation function processing on the first feature map to obtain a first matrix weight, and perform convolution processing and activation function processing on the second feature map to obtain a second matrix weight;

[0015] weight the original matrix subjected to the residual operation according to the first matrix weight and the second matrix weight to obtain an output result of the living body recognition model.

[0016] Optionally, the living body recognition method further comprises:

[0017] obtaining a loss function corresponding to the output result, and determining a weight of the loss function to train the living body recognition model.

[0018] Optionally, when the output result comprises a living body classification probability, the step of obtaining the loss function corresponding to the output result comprises:

[0019] obtaining, by a preset first loss calculation rule, a loss function corresponding to the living body classification probability.

[0020] Optionally, when the output result is a feature similarity corresponding to a face feature vector of a target face picture, before the step of obtaining the loss function corresponding to the output result, the method further comprises:

[0021] obtaining a first feature vector in a same category as the face feature vector and a second feature vector in a different category;

[0022] determining a maximum distance feature between the face feature vector and the first feature vector, and determining a minimum distance feature between the face feature vector and the second feature vector, to obtain a loss function of the face feature vector based on the maximum distance feature and the minimum distance feature.

[0023] Optionally, the step of obtaining the loss function corresponding to the output result comprises:

[0024] when the face feature vector is a positive sample feature, obtaining, by a preset second loss calculation rule, a loss function corresponding to the positive sample feature according to the maximum distance feature and the minimum distance feature;

[0025] When the face feature vector is a negative sample feature, a loss function corresponding to the negative sample feature is obtained according to the minimum distance feature and through a preset third loss calculation rule.

[0026] Optionally, the step of obtaining the target face picture comprises:

[0027] An initial face image is obtained through a preset face detection model.

[0028] The initial face image is subjected to face quality evaluation to obtain a target face image.

[0029] To achieve the above object, the present application further provides a living body recognition device, which comprises:

[0030] An obtaining module is configured to obtain a target face picture.

[0031] A living body recognition module is configured to perform living body recognition on the target face picture based on an attention mechanism and through a preset living body recognition model to obtain an output result of the living body recognition model, wherein the output result comprises a living body classification probability and a feature similarity corresponding to a face feature vector of the target face picture.

[0032] A determining module is configured to determine a living body recognition result of the target face picture based on the living body classification probability and the feature similarity corresponding to the face feature vector.

[0033] To achieve the above object, the present application further provides a terminal device, which comprises a memory, a processor and a living body recognition program stored in the memory and executable on the processor, and the living body recognition program, when executed by the processor, implements the steps of the living body recognition method as described above.

[0034] In addition, to achieve the above object, the present application further provides a computer readable storage medium, which stores a living body recognition program, and the living body recognition program, when executed by a processor, implements the steps of the living body recognition method as described above.

[0035] To achieve the above object, the present application further provides a computer program product, which comprises a computer program, and the computer program, when executed by a processor, implements the steps of the living body recognition method as described above.

[0036] The application provides a living body recognition method, device, terminal equipment, computer readable storage medium and computer program product.

[0037] Compared with the living body recognition mode in the prior art which can only be applied to a single scene, in the application, based on the attention mechanism, the living body recognition model is used to recognize the target person picture to obtain the living body classification probability and the feature similarity corresponding to the face feature vector of the target person picture, and then the living body recognition result of the target person picture is obtained according to the living body classification probability and the feature similarity, so as to determine that the target person picture is obtained from a user with a biological living body, rather than obtained by imitation such as a photo, a video, a 3D model or a mask head cover, and finally the living body recognition is realized. Therefore, the application solves the problem of personal property safety caused by the face recognition of a fake living body face using a photo, a video, a 3D model or a mask head cover, and only a single living body recognition model can cope with various living body face imitation scenes, which improves the living body recognition precision and efficiency, and reduces the living body recognition cost. BRIEF DESCRIPTION OF DRAWINGS

[0038] Figure 1 The structural schematic diagram of a hardware running environment related to an embodiment of the application is shown in the figure.

[0039] Figure 2 The first flowchart of an embodiment of the living body recognition method of the application is shown in the figure.

[0040] Figure 3 The network structure schematic diagram of the living body recognition model of an embodiment of the living body recognition method of the application is shown in the figure.

[0041] Figure 4 The second flowchart of an embodiment of the living body recognition method of the application is shown in the figure.

[0042] Figure 5 The attention parameter gamma-loss function schematic diagram of an embodiment of the living body recognition method of the application is shown in the figure.

[0043] Figure 6 The functional module schematic diagram of an embodiment of the living body recognition device of the application is shown in the figure.

[0044] The implementation, functional features and advantages of the present application will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION

[0045] It should be understood that the specific embodiments described herein merely exemplify the present application and do not limit the present application.

[0046] As shown in Figure 1 , the device structure of the hardware running environment involved in the embodiment of the present application is shown in the figure. Figure 1

[0047] The terminal device of the embodiment of the present application can be a smart phone, a computer, a server and a network device, etc. The terminal device in the embodiment can be used to realize the living body recognition.

[0048] As shown in Figure 1 , the terminal device can include a processor 1001 such as a CPU, a network interface 1004, a user interface 1003, a memory 1005 and a communication bus 1002. The communication bus 1002 is used to realize the connection and communication among these components. The user interface 1003 can include a display screen (Display) and an input unit such as a keyboard (Keyboard). The optional user interface 1003 can further include a standard wired interface and a wireless interface. The network interface 1004 can optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 can be a high-speed RAM memory or a stable memory (non-volatile memory) such as a disk memory. The memory 1005 can optionally be a storage device independent of the aforementioned processor 1001.

[0049] Those skilled in the art can understand that Figure 1 the device structure shown in the figure does not constitute a limitation on the living body recognition device, and can include more or fewer components than the figure, or combine certain components, or different component arrangements.

[0050] As shown in Figure 1 , the memory 1005 as a computer storage medium can include operations, network communication modules, user interface modules and living body recognition programs. The operation is a program for managing and controlling the hardware and software resources of the device, supporting the running of the living body recognition program and other software or programs. In Figure 1 the device shown in the figure, the user interface 1003 is mainly used for data communication with the client; the network interface 1004 is mainly used for establishing a communication connection with the server; and the processor 1001 can be used to call the living body recognition program stored in the memory 1005 and perform the following operations:

[0051] obtaining a target face picture;​

[0052] performing liveness recognition on the target face picture based on the attention mechanism to obtain an output result of the liveness recognition model, wherein the output result comprises a liveness classification probability and a face feature vector of the target face picture;

[0053] determining a liveness recognition result of the target face picture based on the liveness classification probability and the face feature similarity.

[0054] Further, the processor 1001 can be configured to invoke a liveness recognition program stored in the memory 1005 and perform the following operations:

[0055] inputting the original matrix corresponding to the target face picture into the liveness recognition model for residual operation;

[0056] based on the attention mechanism, performing one-dimensional full pooling operation on the input features in the horizontal direction and the input features in the vertical direction corresponding to the original matrix after the residual operation to obtain corresponding directional perception feature maps;

[0057] aggregating a plurality of directional perception feature maps, and sequentially performing convolution processing, batch normalization processing and nonlinear activation function processing on the aggregated directional perception feature maps;

[0058] separating the directional perception feature maps after the convolution processing, the batch normalization processing and the nonlinear activation function processing into a first feature map and a second feature map;

[0059] performing convolution processing and activation function processing on the first feature map to obtain a first matrix weight, and performing convolution processing and activation function processing on the second feature map to obtain a second matrix weight;

[0060] weighting the original matrix after the residual operation according to the first matrix weight and the second matrix weight to obtain the output result of the liveness recognition model.

[0061] Further, the processor 1001 can be configured to invoke a liveness recognition program stored in the memory 1005 and perform the following operations:

[0062] obtaining a loss function corresponding to the output result and determining a weight of the loss function to train the liveness recognition model.

[0063] Further, the processor 1001 can be configured to invoke a liveness recognition program stored in the memory 1005 and perform the following operations:

[0064] obtaining a loss function corresponding to the liveness classification probability by a preset first loss calculation rule.

[0065] Further, when the output result is a feature similarity corresponding to a face feature vector of a target face picture, before the step of obtaining a loss function corresponding to the output result, the processor 1001 can be configured to call a living body recognition program stored in the memory 1005, and perform the following operations:

[0066] obtain a first feature vector in the same category as the face feature vector and a second feature vector in a different category;

[0067] determine a maximum distance feature between the face feature vector and the first feature vector, and determine a minimum distance feature between the face feature vector and the second feature vector, to obtain a loss function of the face feature vector based on the maximum distance feature and the minimum distance feature.

[0068] Further, the processor 1001 can be configured to call a living body recognition program stored in the memory 1005, and perform the following operations:

[0069] when the face feature vector is a positive sample feature, obtain a loss function corresponding to the positive sample feature according to the maximum distance feature and the minimum distance feature by a preset second loss calculation rule;

[0070] when the face feature vector is a negative sample feature, obtain a loss function corresponding to the negative sample feature according to the minimum distance feature by a preset third loss calculation rule.

[0071] Further, the processor 1001 can be configured to call a living body recognition program stored in the memory 1005, and perform the following operations:

[0072] obtain at least one initial face picture by a preset face detection model;

[0073] perform face quality evaluation on the initial face picture to obtain a target face picture.

[0074] Reference Figure 2 , Figure 2 The flowchart of the first embodiment of the living body recognition method of the present application.

[0075] The embodiments of the living body recognition method provided by the present application are described above, and it should be noted that although the logical order is shown in the flowchart, in some cases, the steps shown or described herein can be executed in a different order from that shown herein.

[0076] Compared with the biometric features such as fingerprints, irises, etc., the facial features are the most easily obtained. The face recognition system gradually starts commercial use and develops towards the trend of automation and non-supervision, however, the current face recognition technology can identify the identity of the face image but cannot accurately distinguish the authenticity of the input face, so how to accurately and efficiently distinguish the authenticity of the image, resist fraud attacks and ensure the safety of the system has become an urgent problem to be solved in the face recognition technology. Generally, the living body recognition refers to judging whether the biological information is taken from the legal user with biological activity or is obtained through photos, videos, 3D models or mask headsets, etc.

[0077] In view of the above problems, in the prior art, a corresponding living body recognition model is generally constructed for different attack scenes, which leads to that the living body recognition model cannot be applied to various attack scenes, the living body recognition accuracy is greatly reduced, and the recognition process is complicated and the computing power cost is high.

[0078] Considering the limitations of the prior art, in the present application, a general and highly versatile single living body recognition model is constructed to improve the living body recognition accuracy and efficiency and reduce the living body recognition cost.

[0079] Specifically, the living body recognition method in the present embodiment includes the following steps:

[0080] Step S10, obtaining a target face picture;

[0081] In the present embodiment, the picture containing the face can be obtained by a device containing a camera, including but not limited to mobile terminal, PC terminal, etc., or directly through a local camera to obtain a picture containing a face.

[0082] On this basis, after the terminal device obtains the collected picture containing the face, it will further screen out a target face picture with higher quality from the multiple pictures containing the face.

[0083] Further, the above step S10 can include:

[0084] Step S101, obtaining at least one initial face image through a preset face detection model;

[0085] Step S102, performing face quality evaluation on the initial face image to obtain a target face image.

[0086] After detecting that a user enters pictures containing a face through a device containing a camera, a terminal device will obtain an initial face image corresponding to a face position from each picture containing a face through a preset face detection model, and then judge the face quality in the initial face image through a quality discrimination method. The quality discrimination method specifically includes: extracting face image features in the initial face image, then calculating face sharpness and brightness parameters using the face image features, and performing linear regression on key points in the initial face image to calculate face pitch angle, yaw angle, roll angle, closed eyes, open mouth, and the like.

[0087] The above operation obtains a face picture meeting the quality requirement. For example, scoring each initial face image is realized through the above quality discrimination method, so that each initial face image has a corresponding score. Finally, the initial face image corresponding to a score greater than a preset score threshold is taken as a target face image, and the target face image is input into a pre-constructed living body recognition model for living body recognition.

[0088] Step S20, based on the attention mechanism, the target face picture is subjected to living body recognition through a preset living body recognition model to obtain an output result of the living body recognition model, wherein the output result includes: a living body classification probability and a face feature vector of the target face picture.

[0089] After the terminal device obtains the target face picture meeting the quality requirement and sends the target face picture to the pre-constructed living body recognition model, the target face picture input is subjected to living body recognition by the living body recognition model based on the attention mechanism, and an output result of the living body recognition model is obtained. The output result contains two branches, one is a living body classification probability corresponding to the target face picture, and the other is a face feature vector of the target face picture.

[0090] It should be noted that in the present embodiment, the living body classification probability represents the probability that the output of the living body recognition model is a face corresponding to the target face picture, and in addition, it also includes the probability that the target face picture obtained through printing paper cutting, 3D model, screen reproduction, and the like is a non-living body. In addition, for the face feature vector output by the living body recognition model, a feature similarity corresponding to the face feature vector will be further obtained. The feature similarity corresponding to the face feature vector is specifically a cos angle value between the face feature vector and a preset average positive sample feature. The preset average positive sample feature is an initial labeled feature from a test set containing multiple target face pictures. In the present embodiment, the positive sample represents a living body, and the negative sample represents a non-living body.

[0091] Step S30, based on the living body classification probability and the face feature vector, determining a living body recognition result of the target face picture.

[0092] After the terminal device obtains the living body classification probability corresponding to the target face picture output by the living body recognition model and the feature similarity corresponding to the face feature vector, the terminal device will further determine the living body recognition result corresponding to the target face picture according to the living body classification probability and the feature similarity corresponding to the face feature vector.

[0093] Specifically, for example, the terminal device can calibrate different thresholds according to different non-living body interception rate requirements, and then, in combination with the living body classification probability and the feature similarity corresponding to the face feature vector, the terminal device can determine that the target face picture corresponding to the living body classification probability or the feature similarity greater than the threshold is taken from a legal user with a biological living body, rather than obtained through a photo, a video, a 3D model or a mask headgear, and finally realizes living body recognition. In this embodiment, the calibrated threshold is not specifically limited and can be flexibly set in combination with the actual living body recognition scene.

[0094] In this embodiment, after the terminal device obtains the collected face-containing picture, the terminal device will further screen a target face picture with high quality from the multiple face-containing pictures. The terminal device performs living body recognition on the input target face picture through the living body recognition model to obtain the output result of the living body recognition model, which contains two branches, one is the living body classification probability corresponding to the target face picture, and the other is the feature similarity corresponding to the face feature vector of the target face picture. Then, the terminal device determines the living body recognition result corresponding to the target face picture according to the living body classification probability and the feature similarity corresponding to the face feature vector.

[0095] Compared with the living body recognition mode in the prior art which can only be applied to a single scene, in the present application, based on the attention mechanism, the living body classification probability and the feature similarity corresponding to the face feature vector of the target face picture are obtained by performing living body recognition on the target face picture through the pre-constructed living body recognition model, and then the living body recognition result of the target face picture is obtained according to the living body classification probability and the feature similarity, so as to determine that the target face picture is taken from a user with a biological living body, rather than obtained through a photo, a video, a 3D model or a mask headgear, and finally realizes living body recognition. Therefore, the present application solves the problem of personal property safety caused by using a photo, a video, a 3D model or a mask headgear to counterfeit a living body face for face recognition, and only a single living body recognition model can cope with various face counterfeiting scenes, which not only improves the living body recognition accuracy, but also improves the living body recognition efficiency, and also reduces the living body recognition cost.

[0096] Further, based on the first embodiment of the living body recognition of the present application, the second embodiment of the living body recognition of the present application is proposed.

[0097] In the embodiment, the step S20 can include the following steps.

[0098] In step S201, the original matrix corresponding to the target face picture is input into the liveness recognition model to perform residual operation.

[0099] In step S202, based on the attention mechanism, the input features in the horizontal direction and the input features in the vertical direction corresponding to the original matrix after the residual operation are aggregated respectively by one-dimensional full pooling operation to obtain corresponding direction perception feature maps.

[0100] In step S203, the plurality of direction perception feature maps are aggregated, and the aggregated direction perception feature maps are sequentially subjected to convolution processing, batch normalization processing and nonlinear activation function processing.

[0101] In step S204, the direction perception feature maps subjected to the convolution processing, the batch normalization processing and the nonlinear activation function processing are separated into a first feature map and a second feature map.

[0102] In step S205, the first feature map is subjected to convolution processing and nonlinear activation function processing to obtain a first matrix weight, and the second feature map is subjected to convolution processing and nonlinear activation function processing to obtain a second matrix weight.

[0103] In step S206, the original matrix is weighted according to the first matrix weight and the second matrix weight to obtain the output result of the liveness recognition model.

[0104] It should be noted that, in the embodiment, as shown in Figure 3 , a structure similar to denseNet (dense convolutional network) is used as the liveness recognition model, and the input of the later layer is the result after the output concat (merge) of the previous multiple layers, so as to enhance the extraction ability of the liveness recognition model from the shallow texture features to the deep features. In addition, the attention mechanism is added to the liveness recognition model, and by embedding the position information into the channel attention, the network can pay attention to a larger area, while avoiding a large amount of calculation overhead.

[0105] On this basis, as shown in Figure 4 , the liveness recognition process of the terminal device on the target face picture by the liveness recognition model includes the following steps: inputting the original matrix corresponding to the target face picture into the residual module in the liveness recognition model to perform residual operation; performing one-dimensional full pooling operation on the input features in the horizontal direction and the input features in the vertical direction corresponding to the original matrix after the residual operation to obtain corresponding direction perception feature maps; aggregating the plurality of direction perception feature maps, and sequentially performing convolution processing, batch normalization processing and nonlinear activation function processing on the aggregated direction perception feature maps; separating the direction perception feature maps subjected to the convolution processing, the batch normalization processing and the nonlinear activation function processing into a first feature map and a second feature map; performing convolution processing and nonlinear activation function processing on the first feature map to obtain a first matrix weight, and performing convolution processing and nonlinear activation function processing on the second feature map to obtain a second matrix weight; and weighting the original matrix according to the first matrix weight and the second matrix weight to obtain the output result of the liveness recognition model. Figure 4The input features in the horizontal direction and the input features in the vertical direction corresponding to the original matrix after the residual operation are respectively aggregated to obtain corresponding directional perception feature maps; the two directional perception feature maps are aggregated into one directional perception feature map, and the directional perception feature map is sequentially subjected to convolution processing, batch normalization processing and nonlinear activation function processing; then, the directional perception feature map after the convolution processing, the batch normalization processing and the nonlinear activation function processing is separated into two feature maps, i.e. a first feature map and a second feature map, and the first feature map is input into a convolution layer and an activation function to obtain a first matrix weight, and the second feature map is also input into a convolution layer and an activation function to obtain a second matrix weight; each row of the original matrix after the residual operation is weighted by using the first matrix weight (a column matrix), and each column of each row of the original matrix after the weighting is weighted by using the second matrix weight (a row matrix) to finally obtain a new weighted matrix, i.e. an output result of the living body recognition model.

[0106] It can be seen that in the embodiment, the two directional perception feature maps embedding specific direction information are respectively encoded into two attention maps (i.e. the first matrix weight and the second matrix weight), and each attention map captures the long-range dependence of the directional perception feature map along a spatial direction.

[0107] Further, the output result of the living body recognition model is obtained by the above method, and the output result is divided into two branches, one branch is an 8-dimensional softmax classification result (i.e. a living body classification probability), and the other branch is a 128-dimensional face feature vector.

[0108] Specifically, the Softmax formula is as follows:

[0109]

[0110] wherein S i is the classification probability of the i-th class in the softmax classification result, e i is the output of the living body recognition model in the i-th class, and j is the number of classes of the softmax classification. In the 8-dimensional softmax branch result, the 0th class in the 8 data can be a living body, and the other classes can be a real person picture, a printed paper, a printed paper cut, a screen reproduction and the like non-living body. Therefore, the value of the living body classification probability S i (i=0) is closer to 1, the greater the probability that the face corresponding to the target face picture is a living body.

[0111] For the output result of the 128-dimensional feature vector, an initial calibration average positive sample feature needs to be determined in a test set containing the target face picture. Then, through the living body recognition model, the cos angle value of the above-mentioned 128-dimensional feature vector and the average positive sample feature (i.e. the feature similarity corresponding to the face feature vector of the target face picture) is calculated. Obviously, the closer the two features are, the smaller the angle is, and the closer the cos value is to 1.

[0112] In general, the living body recognition model outputs the living body classification probability and the feature similarity corresponding to the face feature vector of the target face picture, so as to further make a living body judgment based on the living body classification probability and the feature similarity.

[0113] Further, the living body recognition method in the embodiment can further include:

[0114] In step S40, the loss function corresponding to the output result is obtained, and the weight of the loss function is determined to train the living body recognition model.

[0115] It should be noted that in the embodiment, in order to realize accurate living body recognition, after obtaining the output result of the living body recognition model, the output result can be further used to train the living body recognition model.

[0116] Specifically, for example, the terminal device obtains the loss function corresponding to each output result and determines the weight of the loss function corresponding to the living body recognition model. It should be noted that when the living body recognition model is trained, the loss function corresponding to each output result is dynamically allocated and is not fixed.

[0117] In the embodiment, a single living body recognition model is used for living body detection, the living body recognition model includes a densenet structure with multiple layers of connection and feature combination and an attention structure of horizontal and vertical coordinates, and the living body recognition model outputs a double output including a living body classification probability and a feature similarity. Therefore, the present application can accurately detect the problem of face recognition using a fake living body face such as a photo, a video, a 3D model or a mask head cover containing a face image, improve the living body recognition accuracy and pass rate, and is widely applicable to various types of living body recognition scenes, thereby protecting the personal and property safety of users and improving the user experience.

[0118] Further, based on the first and second embodiments of the living body recognition of the present application, a third embodiment of the living body recognition of the present application is proposed.

[0119] In the embodiment, in the above-mentioned step S40, "obtaining the loss function corresponding to the output result" can include:

[0120] Step S401: Obtain the loss function corresponding to the liveness classification probability by using a preset first loss calculation rule.

[0121] It should be noted that in this embodiment, the calculation method of the loss function is different for different output results, namely the liveness classification probability and the feature similarity corresponding to the facial feature vector of the target face image.

[0122] Based on this, when the output result is the liveness classification probability, the corresponding loss function focalloss will be used according to the preset first loss calculation rule:

[0123] FL(p t )=-α t (1-p t ) γ log(p t )

[0124] Calculate the loss function corresponding to the liveness classification probability. Where FL(p) t ) represents the probability p of class t. t The corresponding loss function, where α is the weight and γ is the attention parameter, is as follows: Figure 5 As shown, the larger the value of γ, the less attention the loss function will pay to easily distinguishable samples and the more attention it will pay to difficult-to-distinguish samples.

[0125] Furthermore, before step S40, "obtaining the loss function corresponding to the output result", the following may also be included:

[0126] Step S50: Obtain a first feature vector that is in the same category as the face feature vector and a second feature vector that is in a different category;

[0127] Step S60: Determine the maximum distance feature between the face feature vector and the first feature vector, and determine the minimum distance feature between the face feature vector and the second feature vector, so as to obtain the loss function of the face feature vector based on the maximum distance feature and the minimum distance feature.

[0128] When training the liveness detection model, for each face feature vector in a batch, the terminal device needs to acquire a first feature vector belonging to the same category and a second feature vector belonging to a different category. Then, it calculates the maximum distance feature d(a,p) between the face feature vector and the first feature vector, and the minimum distance feature d(a,n) between the face feature vector and the second feature vector.

[0129] In step S40 above, "obtaining the loss function corresponding to the output result" may include:

[0130] In step S402, when the face feature vector is a positive sample feature, a loss function corresponding to the positive sample feature is obtained according to the maximum distance feature and the minimum distance feature by a preset second loss calculation rule.

[0131] In step S403, when the face feature vector is a negative sample feature, a loss function corresponding to the negative sample feature is obtained according to the minimum distance feature by a preset third loss calculation rule.

[0132] After the terminal device obtains the maximum distance feature d(a, p) between the face feature vector and the first feature vector, and the minimum distance feature d(a, n) between the face feature vector and the second feature vector, when the face feature vector is a positive sample feature, a preset second loss calculation rule is used to calculate the loss function corresponding to the positive sample feature according to the existing tripletloss.

[0133] L = max(d(a, p) - d(a, n) + margin, 0)

[0134] The loss function corresponding to the positive sample feature is calculated. Wherein, a, p, n respectively represent the anchor sample feature, the positive sample feature and the negative sample feature, d(a, p) represents the Euclidean distance between the sample features a and p (i.e. the maximum distance feature), d(a, n) represents the Euclidean distance between the sample features a and n (i.e. the minimum distance feature), margin is an artificially set inter-class interval, and the margin in the embodiment can be 0.

[0135] When the face feature vector is a negative sample feature, a preset third loss calculation rule is used to calculate the loss function corresponding to the negative sample feature according to the improved tripletloss.

[0136] L = max(-d(a, n) + margin, 0)

[0137] The loss function corresponding to the negative sample feature is calculated.

[0138] Through the above operation, the embodiment can effectively reduce the inter-class distance of the positive sample feature, and at the same time, enlarge the inter-class distance of the positive and negative sample features.

[0139] In addition, the weights of the loss functions corresponding to the two output results in the embodiment are dynamically allocated. For example, in the early stage of training of the living body recognition model, the loss function corresponding to the living body classification probability occupies a larger weight, and the weight of the loss function corresponding to the face feature vector of the target face picture gradually increases in the later stage of training.

[0140] Therefore, in the embodiment, the focal loss and the improved triplet loss are adopted based on different output results, and the living body recognition model is trained by dynamically assigning weights according to training rounds, so that the living body recognition accuracy and pass rate are improved, the misrecognition rate of unknown attack types is reduced, the model generalization is improved, and the model is universally applicable to various living body recognition scenes.

[0141] In addition, the embodiment of the present application further provides a living body recognition device, which refers to Figure 6 , the living body recognition device comprises:

[0142] The acquisition module 10 is configured to acquire a target face picture.

[0143] The living body recognition module 20 is configured to perform living body recognition on the target face picture by a preset living body recognition model based on an attention mechanism to obtain an output result of the living body recognition model, wherein the output result comprises a living body classification probability and a face feature vector of the target face picture.

[0144] The determination module 30 is configured to determine a living body recognition result of the target face picture based on the living body classification probability and the face feature vector.

[0145] Further, the living body recognition module 20 comprises:

[0146] The residual operation unit is configured to input an original matrix corresponding to the target face picture into the living body recognition model to perform residual operation.

[0147] The first aggregation unit is configured to perform one-dimensional full pooling operation based on an attention mechanism to aggregate input features in a horizontal direction and input features in a vertical direction of the original matrix after residual operation to obtain corresponding direction perception feature maps.

[0148] The first processing unit is configured to aggregate a plurality of direction perception feature maps, and sequentially perform convolution processing, batch normalization processing and nonlinear activation function processing on the aggregated direction perception feature maps.

[0149] The separation unit is configured to separate the direction perception feature maps after the convolution processing, the batch normalization processing and the nonlinear activation function processing into a first feature map and a second feature map.

[0150] The second processing unit is configured to perform convolution processing and activation function processing on the first feature map to obtain a first matrix weight, and perform convolution processing and activation function processing on the second feature map to obtain a second matrix weight.

[0151] a weighting unit configured to weight the original matrix after the residual operation according to the first matrix weight and the second matrix weight to obtain an output result of the living body recognition model.

[0152] Further, the living body recognition device further comprises:

[0153] a training module configured to obtain a loss function corresponding to the output result, and determine a weight of the loss function to train the living body recognition model.

[0154] Further, when the output result is a living body classification probability, the training module comprises:

[0155] a first loss function obtaining unit configured to obtain a loss function corresponding to the living body classification probability through a preset first loss calculation rule.

[0156] Further, when the output result is a feature similarity corresponding to a face feature vector of a target face picture, the living body recognition device further comprises:

[0157] a feature vector obtaining module configured to obtain a first feature vector in a same category as the face feature vector and a second feature vector in a different category;

[0158] a distance feature determining module configured to determine a maximum distance feature between the face feature vector and the first feature vector, and determine a minimum distance feature between the face feature vector and the second feature vector, to obtain a loss function of the face feature vector based on the maximum distance feature and the minimum distance feature.

[0159] Further, the training module comprises:

[0160] a second loss function obtaining unit configured to, when the face feature vector is a positive sample feature, obtain a loss function corresponding to the positive sample feature according to the maximum distance feature and the minimum distance feature through a preset second loss calculation rule;

[0161] a third loss function obtaining unit configured to, when the face feature vector is a negative sample feature, obtain a loss function corresponding to the negative sample feature according to the minimum distance feature through a preset third loss calculation rule.

[0162] Further, the obtaining module 10 comprises:

[0163] a face image obtaining unit configured to obtain at least one initial face image through a preset face detection model;

[0164] a quality evaluation unit configured to perform face quality evaluation on the initial face image to obtain a target face image.

[0165] The specific implementation of the living body recognition device is basically the same as the above-mentioned living body recognition method, and will not be repeated here.

[0166] In addition, the embodiment of the application also provides a computer readable storage medium, and the storage medium stores a living body recognition program. When the living body recognition program is executed by a processor, the steps of the living body recognition method described above are realized.

[0167] The embodiments of the living body recognition device and the computer readable storage medium can refer to the embodiments of the living body recognition method, which will not be repeated here.

[0168] It should be noted that in this article, the term "include", "contain" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or system including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or includes elements inherent to such process, method, article or system. Without more limitations, the element defined by the sentence "including a" does not exclude the presence of other identical elements in the process, method, article or system including the element.

[0169] The above-mentioned embodiment number of the application is only for description, not representing the advantages and disadvantages of the embodiments.

[0170] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment method can be realized by software and necessary general hardware platform, of course, it can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the application can be embodied in the form of software product, which is stored in a storage medium (such as ROM / RAM, magnetic disc, optical disc), including a plurality of instructions for making a terminal device (which can be a smart phone, computer, server and network equipment, etc.) execute the method described in each embodiment of the application.

[0171] The above is only the preferred embodiment of the application, and does not limit the patent scope of the application. Any equivalent structure or equivalent flow transformation made by using the content of the specification and drawings, or directly or indirectly applied to other related technical fields, is also included in the patent protection scope of the application.

Claims

1. A living body identification method characterized by comprising: The live body recognition method comprises: obtaining a target face picture; based on an attention mechanism, performing live body recognition on the target face picture through a preset live body recognition model to obtain an output result of the live body recognition model, wherein the output result comprises a live body classification probability and a face feature vector corresponding to the target face picture; calculating a feature similarity corresponding to the face feature vector, and determining a live body recognition result of the target face picture based on the live body classification probability and the feature similarity; wherein the step of obtaining the output result of the live body recognition model based on the attention mechanism and the preset live body recognition model and performing live body recognition on the target face picture comprises: inputting an original matrix corresponding to the target face picture into the live body recognition model to perform residual operation; based on an attention mechanism, performing one-dimensional full pooling operation on input features in a horizontal direction and input features in a vertical direction of the original matrix after residual operation to obtain corresponding directional perception feature maps; aggregating a plurality of directional perception feature maps, and sequentially performing convolution processing, batch normalization processing and nonlinear activation function processing on the aggregated directional perception feature maps; separating the directional perception feature maps after convolution processing, batch normalization processing and nonlinear activation function processing into a first feature map and a second feature map; performing convolution processing and activation function processing on the first feature map to obtain a first matrix weight, and performing convolution processing and activation function processing on the second feature map to obtain a second matrix weight; weighting the original matrix after residual operation according to the first matrix weight and the second matrix weight to obtain the output result of the live body recognition model.

2. The living body identification method according to claim 1, wherein The live body recognition method further comprises: obtaining a loss function corresponding to the output result, and determining a weight of the loss function to train the live body recognition model.

3. The living body identification method according to claim 2, wherein When the output result comprises a live body classification probability, the step of obtaining the loss function corresponding to the output result comprises: obtaining a loss function corresponding to the live body classification probability through a preset first loss calculation rule.

4. The living body identification method according to claim 2, wherein When the output result comprises a face feature vector corresponding to a target face picture, before the step of obtaining the loss function corresponding to the output result, the method further comprises: obtaining a first feature vector in the same category as the face feature vector and a second feature vector in a different category; determining a maximum distance feature between the face feature vector and the first feature vector, and determining a minimum distance feature between the face feature vector and the second feature vector, to obtain a loss function of the face feature vector based on the maximum distance feature and the minimum distance feature.

5. The living body identification method according to claim 4, wherein The step of obtaining the loss function corresponding to the output result comprises: when the face feature vector is a positive sample feature, obtaining a loss function corresponding to the positive sample feature through a preset second loss calculation rule according to the maximum distance feature and the minimum distance feature. When the face feature vector is a negative sample feature, a loss function corresponding to the negative sample feature is obtained according to the minimum distance feature and through a preset third loss calculation rule.

6. The living body identification method according to claim 1, wherein The step of obtaining the target face picture comprises: An initial face image is obtained through a preset face detection model. A target face image is obtained through face quality assessment on the initial face image.

7. A living body identification device characterized by comprising: The live body recognition device comprises: An obtaining module, configured to obtain a target face picture; A live body recognition module, configured to perform live body recognition on the target face picture based on an attention mechanism and through a preset live body recognition model to obtain an output result of the live body recognition model, wherein the output result comprises a live body classification probability and a face feature vector corresponding to the target face picture; the live body recognition module is further configured to input an original matrix corresponding to the target face picture into the live body recognition model to perform residual operation; based on the attention mechanism, one-dimensional full pooling operation is performed on input features in a horizontal direction and input features in a vertical direction corresponding to the original matrix after the residual operation to obtain corresponding directional perception feature maps; the directional perception feature maps are aggregated, and the aggregated directional perception feature maps are sequentially subjected to convolution processing, batch normalization processing and nonlinear activation function processing; the directional perception feature maps subjected to the convolution processing, the batch normalization processing and the nonlinear activation function processing are separated into a first feature map and a second feature map; the first feature map is subjected to convolution processing and activation function processing to obtain a first matrix weight, and the second feature map is subjected to convolution processing and activation function processing to obtain a second matrix weight; the original matrix after the residual operation is weighted based on the first matrix weight and the second matrix weight to obtain the output result of the live body recognition model; A determining module, configured to calculate a feature similarity corresponding to the face feature vector, and determine a live body recognition result of the target face picture based on the live body classification probability and the feature similarity.

8. A terminal device, comprising: The terminal device comprises a memory, a processor and a live body recognition program stored on the memory and executable on the processor, and the live body recognition program, when executed by the processor, implements the steps of the live body recognition method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a live body recognition program, and the live body recognition program, when executed by the processor, implements the steps of the live body recognition method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Silent living body detection method and device, terminal equipment and storage medium

    CN112651333A

  • Shielded face recognition method, device and equipment and readable storage medium

    CN113947802A