Training method, device, equipment and storage medium for face liveness detection model
Through two-stage training of the live face detection model, combined with fully convolutional neural network and loss function optimization, the problem of being unable to provide specific suspect areas for non-face live bodies in the existing technology has been solved, and the efficiency of manual verification and detection accuracy have been improved. .
Patent Information
- Application Number
- CN202110436488.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-22
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2041-04-22
AI Technical Summary
Existing facial liveness detection models cannot provide analysis of the reasons for specific suspect areas when identifying non-face living bodies, resulting in low manual verification efficiency.
By acquiring live sample images with and without faces, randomly intercepting local images from the non-face live sample images for the second stage of training, and combining the fully convolutional neural network and loss function optimization to achieve the labeling of suspected non-living areas. and positioning.
The efficiency of manual verification is improved, allowing staff to clearly locate specific suspect areas in non-living face images, thereby enhancing the accuracy and efficiency of detection.
Smart Images

Figure CN113158900B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a training method, device, equipment and storage medium for a face liveness detection model. Background Art
[0002] In the face liveness detection scenario, offline face liveness detection salespersons need to face complex, lengthy and tedious steps. They not only have to spend a lot of time to verify, but also fail to meet the time limit or miss high-risk cases during peak business hours. Such user experience not only wastes users' time but also increases the opportunity cost and service cost of business processes. At the same time, with the upgrading of mobile phones and the emergence of fraudulent means, how to detect face liveness in real time, accurately and efficiently through the digital risk control document re-shooting detection system is an urgent problem to be solved.
[0003] At present, face liveness detection is mainly divided into two categories: command-based liveness detection and silent liveness detection. The current defects of this type of face liveness detection are that the model used for liveness detection lacks enough real business data for model training and testing. Most of the public laboratory data are inconsistent with the data caliber of real business scenarios, which makes the model unusable in some real scenarios. In addition, the existing liveness detection model lacks robustness against new types of attacks. When detecting non-face liveness, the current liveness detection model is limited by the model structure and model training method. It can only output the final result of whether the face image to be tested is a live face, but cannot give the reason for judging it as a non-face liveness. When staff verify the identified non-face liveness, they need to spend a lot of time manually verifying it. Summary of the invention
[0004] The embodiments of the present invention provide a training method, device, equipment and storage medium for a face liveness detection model to solve the technical problem that the current face liveness detection model cannot further display the specific area where the face image is judged as non-live, resulting in low efficiency of manual verification.
[0005] A training method for a face liveness detection model, the method comprising:
[0006] Acquire original sample images including live sample images with human faces and live sample images with non-human faces;
[0007] Randomly intercepting a local image including a non-living body suspected area from the non-human face living body sample image according to a preset size, wherein the maximum side length of the preset size is smaller than the minimum side length of the size of the non-human face living body sample image;
[0008] The first stage of training of the face liveness detection model is performed using the original sample image;
[0009] When the loss function of the face liveness detection model converges in the first stage of training, the face liveness detection model is trained in the second stage using the local image;
[0010] When the loss function of the face liveness detection model converges in the second stage of training, a trained face liveness detection model is obtained.
[0011] A training device for a face liveness detection model, the device comprising:
[0012] A sample acquisition module, used to acquire original sample images including live face sample images and non-live face sample images;
[0013] An image capture module, used for randomly capturing a local image including a non-living body suspected area from the non-human face living body sample image according to a preset size, wherein the maximum side length of the preset size is smaller than the minimum side length of the size of the non-human face living body sample image;
[0014] A first training module, used for performing a first-stage training on a face liveness detection model using the original sample image;
[0015] A second training module is used to perform a second-stage training of the face liveness detection model using the local image when the loss function of the face liveness detection model converges in the first-stage training;
[0016] The convergence module is used to obtain a trained face liveness detection model when the loss function of the face liveness detection model converges in the second stage of training.
[0017] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the training method of the above-mentioned face liveness detection model when executing the computer program.
[0018] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the training method for the above-mentioned face liveness detection model.
[0019] The training method, device, equipment and storage medium of the face liveness detection model proposed in the present invention obtain original sample images including live face sample images and non-live face sample images, and randomly intercept local images including non-live suspected areas from the non-live face sample images according to a preset size, firstly perform the first stage training on the face liveness detection model through the complete original sample images, and after the first training stage, perform the second stage training on the face liveness detection model through the intercepted local images including non-live suspected areas, so that when the trained face liveness detection model detects the face image, it can not only detect whether the face image to be detected is a live face, but also can simultaneously display the specific suspected area of the non-live face when a non-live face is identified, so that when the staff verifies the identified non-live face, they can clearly locate the specific suspected area in the non-live face image, thereby improving the efficiency of manual verification. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0021] Figure 1 Schematic diagram of an application environment of a training method for a face liveness detection model in one embodiment of the present invention;
[0022] Figure 2 is a flow chart of a method for training a face liveness detection model in one embodiment of the present invention;
[0023] Figure 3 is a flow chart of performing the first stage training of the face liveness detection model through the original sample image in one embodiment of the present invention;
[0024] Figure 4 is a flow chart of performing the second stage training of the face liveness detection model through the partial image in one embodiment of the present invention;
[0025] Figure 5 is a schematic diagram of the structure of a training device for a face liveness detection model in one embodiment of the present invention;
[0026] Figure 6 is a schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0027] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0028] The training method of the face liveness detection model provided in this application can be applied to Figure 1 In an application environment, the computer device can communicate with the server through a network. The computer device can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices. The server can be implemented as an independent server or a server cluster consisting of multiple servers.
[0029] In one embodiment, if Figure 2 As shown, a training method for a face liveness detection model is provided, and the method is applied in Figure 1 The computer device in is taken as an example to illustrate, including the following steps S101 to S105.
[0030] S101, obtaining original sample images including living face sample images and non-living face sample images.
[0031] It is understandable that the original sample image carries the annotation of whether it is a live face, and the user can also annotate the local image of the non-live suspect area in the non-live sample image. The local image of the non-live suspect area can be, for example, the closed eye area, the mobile phone frame area surrounding the face image, the TV frame area, the projector frame area, etc.
[0032] S102. Randomly capture a local image including a non-living body suspected area from the non-human face living body sample image according to a preset size, wherein the maximum side length of the preset size is smaller than the minimum side length of the non-human face living body sample image.
[0033] In one embodiment, the preset size is preferably the size of a square, and the side length of the square is preferably one eighth of the maximum side length of the original sample image. For example, if the maximum side length of the original sample image is 256, the side length of the preset square can be 32. Furthermore, the side length of the square can also be 64, 96, 128, 160, 224, etc.
[0034] For the sample images of living objects, the same processing is performed as for the sample images of non-living objects, and the number distribution of each side length is obtained to perform random area sampling for each image.
[0035] S103: Performing the first stage training on the face liveness detection model using the original sample images.
[0036] In one of the embodiments, when the ratio of live face sample images and non-live face sample images in the original sample images is basically balanced, the face liveness detection model preferably uses binary cross entropy as the loss function of the face liveness detection model; when the ratio of live face sample images and non-live face sample images in the original sample images is extremely unbalanced, the face liveness detection model preferably uses focus loss or label distribution adaptive marginal loss as the loss function of the face liveness detection model.
[0037] Among them, the ratio of the live face sample image to the non-live face sample image is basically balanced, for example, the ratio of the live face sample image to the non-live face sample image is about 1:1, and the ratio of the live face sample image to the non-live face sample image is extremely unbalanced, for example, the ratio of the live face sample image to the non-live face sample image is less than 1:3 or greater than 3:1. Further, when the ratio of the live face sample image to the non-live face sample image is between 1 / 3 and 3, it is determined that the ratio of the live face sample image to the non-live face sample image is basically balanced.
[0038] This embodiment selects corresponding loss functions for original sample images of different types and proportions, so that the prediction accuracy of the trained face liveness detection model is more similar to the actual prediction scenario, thereby improving the prediction accuracy of the face liveness detection model.
[0039] Figure 3 is a flow chart of performing the first stage training of the face liveness detection model through the original sample image in one embodiment of the present invention. Further, as Figure 3 As shown, the step of performing the first stage training on the face liveness detection model includes the following steps S301 to S305:
[0040] S301, obtaining the total number of samples including the living face sample images and the non-living face sample images in the original sample images;
[0041] S302, obtaining a preset ratio of the total number of samples, where the preset ratio is less than 1 and greater than 0;
[0042] S303, the loss function of the face liveness detection model uses an adaptive learning rate mechanism to train the sample images of a preset proportion of the total sample quantity input previously;
[0043] S304, the loss function of the face liveness detection model uses a cosine decay learning rate to train the remaining sample images in the total number of samples input later;
[0044] S305. When the loss function of the face liveness detection model is trained with a cosine decay learning rate in the first stage until the loss function converges, it is determined that the face liveness detection model has completed training in the first stage.
[0045] In this embodiment, in the first stage, an adaptive learning rate mechanism is used to train a preset proportion of sample images in the total number of samples input earlier, and a cosine decay learning rate is used to train the remaining sample images in the total number of samples input later. Corresponding learning rates are used for training in different stages, thereby improving the convergence speed of the loss function of the face liveness detection model.
[0046] In one embodiment, the step of determining whether the loss function of the face liveness detection model converges in the first stage of training includes:
[0047] The gradient descent method is used to determine whether the loss function of the face liveness detection model converges in the first stage of training.
[0048] It can be understood that when the loss of N epochs input into the face liveness detection model obtained by the gradient descent method drops to a certain level and the output is stable, that is, the fluctuation is very small, it can be judged that the loss function of the face liveness detection model has converged in the first stage of training.
[0049] S104: When the loss function of the face liveness detection model converges in the first stage of training, the face liveness detection model is trained in the second stage using the local image.
[0050] Figure 4 is a flow chart of performing the second stage training of the face liveness detection model through the partial image in one embodiment of the present invention. Further, Figure 4 As shown, the step of performing the second stage training on the face liveness detection model includes the following steps S401 and S402:
[0051] S401, the loss function of the face liveness detection model uses a cosine attenuation learning rate to train the input local image in the second stage;
[0052] S402. When the loss function of the face liveness detection model is trained with a cosine decay learning rate in the second stage until the loss function converges, the face liveness detection model is optimized by a stochastic gradient descent optimizer SGD (stochastic gradient descent) until the loss function of the face liveness detection model converges again.
[0053] In this embodiment, the loss function of the face liveness detection model is trained using the cosine decay learning rate in the second stage of training, so that the loss function of the face liveness detection model is quickly fitted. When the loss function of the face liveness detection model is trained using the cosine decay learning rate in the second stage until the loss function converges, the face liveness detection model is optimized by the stochastic gradient descent optimizer SGD until the loss function of the face liveness detection model converges again. This can further improve the convergence speed of the loss function of the face liveness detection model while making the loss function of the face liveness detection model finally converge.
[0054] In one embodiment, the step of performing a second stage of training the face liveness detection model using the partial image comprises:
[0055] Inputting the local image into the fully convolutional neural network of the face liveness detection model;
[0056] Outputting a score map of the local image through the last convolution of the fully convolutional neural network;
[0057] Inputting the score map of the local image into the pooling layer of the fully convolutional neural network to obtain the detection score of the local image;
[0058] Performing maximum and minimum normalization processing on the detection scores of the local images to obtain standard scores;
[0059] The standard score is binarized to obtain a binary image corresponding to the local image and having a non-living body suspected area marked thereon.
[0060] It can be understood that after feeding the training data set into the fully convolutional neural network, the output of the last convolution is a H*W*1 score map denoted as S. After passing this detection score map through the global pooling layer, the detection score can be obtained. After the model reaches convergence, all the score maps of the training samples here are saved and denoted as {Sn}.
[0061] Furthermore, the score map is subjected to maximum and minimum normalization processing by the following formula:
[0062]
[0063] Wherein, S represents the detection score of the output local image, min(S) represents the minimum detection score in each local image, and max(S) represents the maximum detection score in each local image. It can be understood that S' calculated by this formula can also be represented by S'(i, j).
[0064] This embodiment can remove noise in the detection score by performing maximum and minimum normalization processing on the score map, so that the binary map finally obtained is more consistent with the local image marked with the non-living body suspected area.
[0065] Furthermore, the step of binarizing the standard score includes:
[0066] When the standard score is greater than or equal to a preset score, the binary image corresponding to the partial image is marked as 1; when the standard score is less than the preset score, the binary image corresponding to the partial image is marked as 0.
[0067] The process of binarizing the standard score can be described by the following formula:
[0068]
[0069] Among them, α represents the preset score, α is an adjustable parameter, which can generally be set to 0.5. When M(i, j)=1, it means that the corresponding area is marked as a non-living body suspected area, and when M(i, j)=0, it means that the corresponding area is marked as a living body area.
[0070] S105. When the loss function of the face liveness detection model converges in the second stage of training, a trained face liveness detection model is obtained.
[0071] In one embodiment, the step of determining whether the loss function of the face liveness detection model converges in the second stage of training includes:
[0072] Whether the loss function of the face liveness detection model converges in the second stage of training is determined by using an MCC (Matthew Correlation Coefficient) variant.
[0073] It can be understood that the Matthew correlation coefficient MCC is a balanced indicator for measuring the classification quality of a binary classifier for data sets of different sizes, and the MCC variant can be used to determine whether the loss function of the face liveness detection model converges in the second stage of training.
[0074] Furthermore, the step of judging whether the loss function of the face liveness detection model has converged in the second stage training by using the MCC variant includes the following steps (1) to (3).
[0075] (1) Record the true value and predicted value of whether each local image is a non-living object suspected area through a confusion matrix. The schematic diagram of the confusion matrix is shown in the following table (1):
[0076]
[0077] (1)
[0079] It can be understood that when the true value and the predicted value are both 0, it means that the true value and the predicted value of the local image are both living areas, and this situation is represented by "TN"; when the true value and the predicted value are both 1, it means that the true value and the predicted value of the local image are both non-living suspected areas, and this situation is represented by "TP"; when the predicted value is 0 but the true value is 1, it means that the true value of the local image is a non-living suspected area but the predicted value is a living area, and this situation is represented by "FN"; when the true value is 0 but the predicted value is 1, it means that the true value of the local image is a living area but the predicted value is a non-living suspected area, and this situation is represented by "FP".
[0080] (2) Combined with the confusion matrix, the value of the MCC variant is calculated by the following formula:
[0081]
[0082] Among them, β is a preset value and can be adjusted manually. When the importance of Informedness is greater, the value of β can be reduced, and when the importance of Markedness is greater, the value of β can be increased.
[0083] Further:
[0084] Informedness = r + invp - 1;
[0085] Markedness=p+invp-1.
[0086] Among them, r represents the recall rate, p represents the precision rate, and Recall It can be understood that TP, FP, FN, and FP in the formula all represent the number of corresponding symbols in the confusion matrix.
[0087] (3) When the change in the value of the MCC variant calculated in combination with the confusion matrix of each of the local images is less than a preset value, it is determined that the loss function of the face liveness detection model converges in the second stage training.
[0088] It is understandable that the confusion matrix is the starting point for explaining the MCC variant. By adjusting beta, the importance of informedness in model evaluation iteration can be adjusted. Currently, many algorithm iterations are based on loss or accuracy, but these evaluation criteria perform worse than the MCC variant mentioned in this case when the model lacks data and the labels are extremely unbalanced. By adjusting beta (i.e. parameter β), the MCC variant is also conducive to the exploration of the model in various optimization directions.
[0089] The face liveness detection model trained by this embodiment can not only detect whether the face image to be detected is a live face when detecting a face image, but also, when a non-live face is identified, the binarization processing applied in the model can obtain the specific suspected area marked with non-liveness, so that when the face image to be detected is detected as a non-live face image, the specific suspected area of the non-liveness can be displayed at the same time.
[0090] The training method of the face liveness detection model proposed in this embodiment first obtains original sample images including live face sample images and non-live face sample images, and randomly intercepts a local image including a non-live suspected area from the non-live face sample image according to a preset size, firstly performs a first-stage training on the face liveness detection model using the complete original sample images, and after the first training stage, performs a second-stage training on the face liveness detection model using the intercepted local image including the non-live suspected area, so that when the trained face liveness detection model detects a face image, it can not only detect whether the face image to be detected is a live face, but also can simultaneously display the specific suspected area of the non-live face when a non-live face is identified, so that when the staff verifies the identified non-live face, they can clearly locate the specific suspected area in the non-live face image, thereby improving the efficiency of manual verification.
[0091] Through experiments, it was found that the face liveness detection model proposed in this embodiment can judge and feedback the customer's liveness confidence probability and score map within an average of 50 milliseconds based on the front of the ID card uploaded by the user. The post-model detection misjudgment of online interception was tested after millions of data. The face liveness detection model trained by this embodiment can identify samples that are artificially judged as obviously non-live, such as suspected mobile phone frames and unnatural image distortions, with a probability of 99.3%. The face liveness detection model can cover more than 87% of business non-liveness feature scenarios and performs well against 40% of new attacks after testing.
[0092] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0093] In one embodiment, a training device for a face liveness detection model is provided, and the training device for the face liveness detection model corresponds one-to-one to the training method for the face liveness detection model in the above embodiment. Figure 5 As shown, the training device 100 of the face liveness detection model includes a sample acquisition module 11, an image capture module 12, a first training module 13, a second training module 14 and a convergence module 15. The functional modules are described in detail as follows:
[0094] The sample acquisition module 11 is used to acquire original sample images including living face sample images and non-living face sample images;
[0095] An image capture module 12, configured to randomly capture a local image including a non-living body suspected area from the non-human face living body sample image according to a preset size, wherein the maximum side length of the preset size is smaller than the minimum side length of the size of the non-human face living body sample image;
[0096] A first training module 13, used for performing a first-stage training on a face liveness detection model using the original sample image;
[0097] A second training module 14 is used to perform a second-stage training of the face liveness detection model using the local image when the loss function of the face liveness detection model converges in the first-stage training;
[0098] The convergence module 15 is used to obtain a trained face liveness detection model when the loss function of the face liveness detection model converges in the second stage of training.
[0099] In one of the embodiments, when the ratio of live face sample images and non-live face sample images in the original sample images is basically balanced, the face liveness detection model preferably uses binary cross entropy as the loss function of the face liveness detection model; when the ratio of live face sample images and non-live face sample images in the original sample images is extremely unbalanced, the face liveness detection model preferably uses focus loss or label distribution adaptive marginal loss as the loss function of the face liveness detection model.
[0100] This embodiment selects corresponding loss functions for original sample images of different types and proportions, so that the prediction accuracy of the trained face liveness detection model is more similar to the actual prediction scenario, thereby improving the prediction accuracy of the face liveness detection model.
[0101] In one embodiment, the first training module 13 includes:
[0102] A sample quantity acquisition unit, used for acquiring the total sample quantity including the living face sample image and the non-living face sample image in the original sample image;
[0103] A ratio acquisition unit, used to acquire a preset ratio of the total sample quantity, where the preset ratio is less than 1 and greater than 0;
[0104] A first training unit, a loss function for the face liveness detection model, uses an adaptive learning rate mechanism to train sample images of a preset proportion of the total sample quantity input previously;
[0105] The second training unit, a loss function for the face liveness detection model, uses a cosine decay learning rate to train the remaining sample images in the total number of samples input later;
[0106] The first judgment unit is used to judge that the training of the face liveness detection model in the first stage is completed when the loss function of the face liveness detection model is trained using the cosine decay learning rate in the first stage until the loss function converges.
[0107] In this embodiment, in the first stage, an adaptive learning rate mechanism is used to train a preset proportion of sample images in the total number of samples input earlier, and a cosine decay learning rate is used to train the remaining sample images in the total number of samples input later. Corresponding learning rates are used for training in different stages, thereby improving the convergence speed of the loss function of the face liveness detection model.
[0108] Furthermore, the second training module 14 is specifically used to determine whether the loss function of the face liveness detection model converges in the first stage of training through the gradient descent method.
[0109] In one embodiment, the second training module 14 specifically includes:
[0110] The third training unit, which is used for the loss function of the face liveness detection model, uses a cosine decay learning rate to train the input local image in the second stage;
[0111] The fourth training unit is used to optimize the face liveness detection model through the stochastic gradient descent optimizer SGD when the loss function of the face liveness detection model is trained with the cosine decay learning rate in the second stage until the loss function converges until the loss function converges again.
[0112] In this embodiment, the loss function of the face liveness detection model is trained using the cosine decay learning rate in the second stage of training, so that the loss function of the face liveness detection model is quickly fitted. When the loss function of the face liveness detection model is trained using the cosine decay learning rate in the second stage until the loss function converges, the face liveness detection model is optimized by the stochastic gradient descent optimizer SGD until the loss function of the face liveness detection model converges again. This can further improve the convergence speed of the loss function of the face liveness detection model while making the loss function of the face liveness detection model finally converge.
[0113] Furthermore, the second training module 14 also includes:
[0114] A score map output unit, used to input the local image into the fully convolutional neural network of the face liveness detection model, and output the score map of the local image through the last convolution of the fully convolutional neural network;
[0115] A pooling unit, used for inputting the score map of the local image into the pooling layer of the full convolutional neural network to obtain a detection score of the local image;
[0116] A standardization processing unit, used for performing maximum and minimum standardization processing on the detection score of the local image to obtain a standard score;
[0117] The binarization processing unit is used to perform binarization processing on the standard score to obtain a binary image corresponding to the local image with the non-living body suspected area marked.
[0118] Furthermore, the standardization processing unit performs maximum and minimum standardization processing on the detection score by the following formula:
[0119]
[0120] Among them, S represents the detection score of the local image, min(S) represents the minimum detection score among the local images, and max(S) represents the maximum detection score among the local images.
[0121] This embodiment can remove noise in the detection score by performing maximum and minimum normalization processing on the score map, so that the binary map finally obtained is more consistent with the local image marked with the non-living body suspected area.
[0122] Furthermore, the binarization processing unit is specifically used to: when the standard score is greater than or equal to a preset score, mark the binary image corresponding to the local image as 1; when the standard score is less than the preset score, mark the binary image corresponding to the local image as 0.
[0123] The process of binarizing the standard score can be described by the following formula:
[0124]
[0125] Among them, α represents the preset score, α is an adjustable parameter, which can generally be set to 0.5. When M(i, j)=1, it means that the corresponding area is marked as a non-living body suspected area, and when M(i, j)=0, it means that the corresponding area is marked as a living body area.
[0126] Furthermore, the convergence module 15 is specifically used to determine whether the loss function of the face liveness detection model converges in the second stage training through the MCC variant.
[0127] Furthermore, the convergence module 15 specifically includes a recording unit, a calculation unit and a second judgment unit.
[0128] The recording unit is used to record the true value and predicted value of whether each local image is a non-living object suspected area through a confusion matrix. The schematic diagram of the confusion matrix is shown in the following table (1):
[0129] (1)
[0131] It can be understood that when the true value and the predicted value are both 0, it means that the true value and the predicted value of the local image are both living areas, and this situation is represented by "TN"; when the true value and the predicted value are both 1, it means that the true value and the predicted value of the local image are both non-living suspected areas, and this situation is represented by "TP"; when the predicted value is 0 but the true value is 1, it means that the true value of the local image is a non-living suspected area but the predicted value is a living area, and this situation is represented by "FN"; when the true value is 0 but the predicted value is 1, it means that the true value of the local image is a living area but the predicted value is a non-living suspected area, and this situation is represented by "FP".
[0132] The calculation unit is used to calculate the value of the MCC variant by combining the confusion matrix through the following formula:
[0133]
[0134] Among them, β is a preset value and can be adjusted manually. When the importance of Informedness is greater, the value of β can be reduced, and when the importance of Markedness is greater, the value of β can be increased.
[0135] Further:
[0136] Informedness = r + invp - 1;
[0137] Markedness=p+invp-1.
[0138] Among them, r represents the recall rate, p represents the precision rate, and Recall It can be understood that TP, FP, FN, and FP in the formula all represent the number of corresponding symbols in the confusion matrix.
[0139] The second judgment unit is used to judge that the loss function of the face liveness detection model converges in the second stage training when the change amount of the value of the MCC variant calculated in combination with the confusion matrix of each of the local images is less than a preset value.
[0140] It is understandable that the confusion matrix is the starting point for explaining the MCC variant. By adjusting beta, the importance of informedness in model evaluation iteration can be adjusted. Currently, many algorithm iterations are based on loss or accuracy, but these evaluation criteria perform worse than the MCC variant mentioned in this case when the model lacks data and the labels are extremely unbalanced. By adjusting beta (i.e. parameter β), the MCC variant is also conducive to the exploration of the model in various optimization directions.
[0141] The face liveness detection model trained by this embodiment can not only detect whether the face image to be detected is a live face when detecting a face image, but also, when a non-live face is identified, the binarization processing applied in the model can obtain the specific suspected area marked with non-liveness, so that when the face image to be detected is detected as a non-live face image, the specific suspected area of the non-liveness can be displayed at the same time.
[0142] The training device of the face liveness detection model proposed in this embodiment first obtains original sample images including live face sample images and non-live face sample images, and randomly intercepts local images including non-live suspected areas from the non-live face sample images according to a preset size, firstly performs the first stage training on the face liveness detection model through the complete original sample images, and after the first training stage, performs the second stage training on the face liveness detection model through the intercepted local images including non-live suspected areas, so that when the trained face liveness detection model detects the face image, it can not only detect whether the face image to be detected is a live face, but also can simultaneously display the specific suspected area of the non-live face when a non-live face is identified, so that when the staff verifies the identified non-live face, they can clearly locate the specific suspected area in the non-live face image, thereby improving the efficiency of manual verification.
[0143] The meaning of "first" and "second" in the above modules / units is only to distinguish different modules / units, and is not used to define which module / unit has a higher priority or other limiting meanings. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or modules is not necessarily limited to those steps or modules clearly listed, but may include other steps or modules that are not clearly listed or inherent to these processes, methods, products or devices. The division of modules in this application is only a logical division, and there may be other division methods when implemented in actual applications.
[0144] For the specific definition of the training device of the face liveness detection model, please refer to the definition of the training method of the face liveness detection model in the above text, which will not be repeated here. Each module in the training device of the above face liveness detection model can be implemented in whole or in part by software, hardware and their combination. The above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0145] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server through a network connection. When the computer program is executed by the processor, a training method for a face liveness detection model is implemented.
[0146] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the training method of the face liveness detection model in the above embodiment are implemented, such as Figure 2 Alternatively, when the processor executes the computer program, the functions of each module / unit of the training device for the face liveness detection model in the above embodiment are realized, for example Figure 5 The functions of modules 11 to 15 are shown in Figure 1. To avoid repetition, they will not be described here.
[0147] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the computer device, and various interfaces and lines are used to connect various parts of the entire computer device.
[0148] The memory can be used to store the computer program and / or module, and the processor realizes various functions of the computer device by running or executing the computer program and / or module stored in the memory and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, video data, etc.), etc.
[0149] The memory may be integrated into the processor or may be arranged separately from the processor.
[0150] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the training method of the face liveness detection model in the above embodiment are implemented, such as Figure 2 Steps 101 to 105 and other extensions of the method and related steps are shown. Alternatively, when the computer program is executed by the processor, the functions of each module / unit of the training device for the face liveness detection model in the above embodiment are realized, for example Figure 5 The functions of modules 11 to 15 are shown in Figure 1. To avoid repetition, they will not be described here.
[0151] The training method, device, equipment and storage medium of the face liveness detection model proposed in this embodiment obtain original sample images including live face sample images and non-live face sample images, and randomly intercept local images including non-live suspected areas from the non-live face sample images according to a preset size, firstly perform the first stage training on the face liveness detection model through the complete original sample images, and after the first training stage, perform the second stage training on the face liveness detection model through the intercepted local images including non-live suspected areas, so that when the trained face liveness detection model detects the face image, it can not only detect whether the face image to be detected is a live face, but also can simultaneously display the specific suspected area of the non-live face when a non-live face is identified, so that when the staff verifies the identified non-live face, they can clearly locate the specific suspected area in the non-live face image, thereby improving the efficiency of manual verification.
[0152] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0153] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0154] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A training method for a face liveness detection model, characterized in that: The method comprises: Acquire original sample images including live sample images with human faces and live sample images with non-human faces; Randomly intercepting a local image including a non-living body suspected area from the non-human face living body sample image according to a preset size, wherein the maximum side length of the preset size is smaller than the minimum side length of the size of the non-human face living body sample image; The first stage training of the face liveness detection model is performed using the original sample images, and the step of performing the first stage training of the face liveness detection model using the original sample images comprises: Acquire the total number of samples including the living face sample images and the non-living face sample images in the original sample images; Obtaining a preset ratio of the total sample quantity, wherein the preset ratio is less than 1 and greater than 0; The loss function of the face liveness detection model uses an adaptive learning rate mechanism to train the sample images of a preset proportion of the total number of samples input previously; The loss function of the face liveness detection model uses a cosine decay learning rate to train the remaining sample images in the total number of samples input later; When the loss function of the face liveness detection model is trained with a cosine decay learning rate in the first stage until the loss function converges, it is determined that the face liveness detection model has completed training in the first stage; When the loss function of the face liveness detection model converges in the first stage training, the face liveness detection model is trained in the second stage through the partial image, and the step of training the face liveness detection model in the second stage through the partial image includes: The loss function of the face liveness detection model uses a cosine attenuation learning rate to train the input local image in the second stage; When the loss function of the face liveness detection model is trained with a cosine decay learning rate in the second stage until the loss function converges, the face liveness detection model is optimized by a stochastic gradient descent optimizer SGD until the loss function of the face liveness detection model converges again; When the loss function of the face liveness detection model converges in the second stage of training, a trained face liveness detection model is obtained.
2. The training method of the face liveness detection model according to claim 1, characterized in that: The step of judging whether the loss function of the face liveness detection model converges in the first stage of training comprises: The gradient descent method is used to determine whether the loss function of the face liveness detection model converges in the first stage of training.
3. The training method of the face liveness detection model according to claim 1, characterized in that: The step of performing the second stage training of the face liveness detection model through the partial image comprises: Inputting the local image into the fully convolutional neural network of the face liveness detection model, and outputting a score map of the local image through the last convolution of the fully convolutional neural network; Inputting the score map of the local image into the pooling layer of the fully convolutional neural network to obtain the detection score of the local image; Performing maximum and minimum normalization processing on the detection scores of the local images to obtain standard scores; The standard score is binarized to obtain a binary image corresponding to the local image and having a non-living body suspected area marked thereon.
4. The training method of the face liveness detection model according to claim 3, characterized in that: The detection score is normalized to the maximum and minimum values by the following formula: Wherein, S represents the detection score of the local image, min(S) represents the minimum detection score in each local image, and max(S) represents the maximum detection score in each local image.
5. The training method of the face liveness detection model according to claim 1, characterized in that: The step of judging whether the loss function of the face liveness detection model converges in the second stage of training comprises: The MCC variant is used to determine whether the loss function of the face liveness detection model converges in the second stage of training.
6. A training device for a face liveness detection model, the device being used to implement the steps of the training method for a face liveness detection model as claimed in any one of claims 1 to 5, characterized in that: The device comprises: A sample acquisition module, used to acquire original sample images including live face sample images and non-live face sample images; An image capture module, used for randomly capturing a local image including a non-living body suspected area from the non-human face living body sample image according to a preset size, wherein the maximum side length of the preset size is smaller than the minimum side length of the size of the non-human face living body sample image; A first training module, used for performing a first-stage training on a face liveness detection model using the original sample images; A second training module is used to perform a second-stage training on the face liveness detection model using the local image when the loss function of the face liveness detection model converges in the first-stage training; The convergence module is used to obtain a trained face liveness detection model when the loss function of the face liveness detection model converges in the second stage training.
7. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the training method of the face liveness detection model as described in any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the training method of the face liveness detection model as described in any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Living body detection method and apparatus and electronic device
CN110458024A
Human face living body detection method and device
CN110751069A
Rapid living body detection method and system capable of automatically filtering fuzzy faces
CN111126283A
Living body detection method and device
CN112215045A
Living body recognition method and device, access control equipment control method and device and electronic equipment
CN112270288A
