Model training method, living body detection method, device and electronic device

By generating new training data and combining it with original data to train the face liveness detection model, the problem of overfitting of the face liveness detection model in the existing technology is solved, and the detection effect and the robustness of the model are improved.

CN114463801BActive Publication Date: 2024-09-24MASHANG CONSUMER FINANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111245890.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-26
Publication Date
2024-09-24
Estimated Expiration
2041-10-26

AI Technical Summary

Technical Problem

Existing face liveness detection models are prone to overfitting problems during the training process, resulting in poor prediction results for data outside the training set and a high misjudgment rate.

Method used

By generating new training data, increasing data diversity, using existing face images for data enhancement, generating new face images and original images as training data, enriching the distribution of training data, thereby alleviating the over-fitting problem.

Benefits of technology

It improves the detection effect of the live face detection model, enhances the robustness of the model, obtains rich training data at low cost, expands the data distribution range, and improves the generalization ability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114463801B
    Figure CN114463801B
Patent Text Reader

Abstract

The present application provides a model training method, a liveness detection method, a device and an electronic device, the model training method comprising: obtaining an initial training data set, the initial training data set comprising first training data and second training data, the first training data comprising a first image and a first label, the second training data comprising a second image and a second label; performing data processing on the initial training data set to obtain a target training data set, the target training data set comprising all training data in the initial training data set and third training data outside the initial training data set, the third training data comprising a third image and a third label, the third image being an image generated based on the first image and the second image; inputting the target training data set into a pre-built liveness detection model for training to obtain a trained target model. The technical solution of the present application can at least improve the detection effect of the face liveness detection model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of face recognition technology, and in particular to a model training method, a living body detection method, a device and an electronic device. Background Art

[0002] As face recognition technology becomes more and more mature, face verification has been applied in many fields. In the face verification process, in addition to face recognition, it is usually necessary to detect whether the face image is alive, so as to prevent illegal users from using fake face images to carry out illegal acts. The existing liveness detection method mainly trains a large number of live face images and fake face images into the model, so that the trained model can identify whether the image is a live face image. However, in the face liveness detection training scenario, the overfitting problem is more serious. The trained model generally has a good fitting effect on the data distribution in the training set, but when predicting data outside the training set, the prediction result is prone to misjudgment. It can be seen that the existing face liveness detection model has the problem of poor detection effect. Summary of the invention

[0003] The present application provides a model training method, a liveness detection method, a device and an electronic device, which can improve the detection effect of a face liveness detection model.

[0004] In a first aspect, an embodiment of the present application provides a model training method, comprising:

[0005] Acquire an initial training data set, the initial training data set comprising first training data and second training data, the first training data comprising a first image and a first label, and the second training data comprising a second image and a second label;

[0006] Processing the initial training data set to obtain a target training data set, wherein the target training data set includes all the training data in the initial training data set and third training data outside the initial training data set, wherein the third training data includes a third image and a third label, and the third image is an image generated based on the first image and the second image;

[0007] Inputting the target training data set into a pre-built liveness detection model for training to obtain a trained target model;

[0008] The first image, the second image and the third image include faces, and the first label, the second label and the third label are used to indicate whether the corresponding images are living body images.

[0009] In a second aspect, the present application also provides a method for detecting a living body, including:

[0010] The image to be detected is input into the target model to obtain a detection result output by the target model, wherein the detection result is used to characterize whether the image to be detected is a living body image. The target model is a model trained based on the model training method described in the first aspect above.

[0011] In a third aspect, the embodiment of the present application further provides a model training device, including:

[0012] An acquisition module, configured to acquire an initial training data set, wherein the initial training data set includes first training data and second training data, wherein the first training data includes a first image and a first label, and the second training data includes a second image and a second label;

[0013] a data processing module, configured to perform data processing on the initial training data set to obtain a target training data set, wherein the target training data set includes all the training data in the initial training data set and third training data outside the initial training data set, wherein the third training data includes a third image and a third label, and the third image is an image generated based on the first image and the second image;

[0014] A training module, used for inputting the target training data set into a pre-built liveness detection model for training to obtain a trained target model;

[0015] The first image, the second image and the third image include faces, and the first label, the second label and the third label are used to indicate whether the corresponding images are living body images.

[0016] In a fourth aspect, the present application also provides a living body detection device, including:

[0017] The detection module is used to input the image to be detected into the target model to obtain the detection result output by the target model, and the detection result is used to characterize whether the image to be detected is a living image. The target model is a model trained based on the model training method described in the first aspect above.

[0018] In a fifth aspect, an embodiment of the present application further provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the method steps described in the first and second aspects above are implemented.

[0019] In a sixth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method steps described in the first and second aspects above are implemented.

[0020] In an embodiment of the present application, by using existing face images to generate new face images, and using the existing face images and the newly generated face images together as training data, the diversity of the training data can be increased, making the distribution of the training data richer, thereby alleviating the overfitting problem in the face liveness detection training scenario, and further improving the detection effect of the trained face liveness detection model. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0022] Figure 1 is a flow chart of the model training method provided in an embodiment of the present application;

[0023] Figure 2 is the true value image of the living body image in the embodiment of the present application;

[0024] Figure 3 is a flow chart of generating a third truth value map according to the first truth value map and the second truth value map in an embodiment of the present application;

[0025] Figure 4 is a flow chart of a liveness detection method provided in an embodiment of the present application;

[0026] Figure 5 is a flow chart of a process of detecting an image to be detected by a target model in an embodiment of the present application;

[0027] Figure 6 It is a distribution diagram of the classification results obtained after a certain image group is classified by a face liveness detection model trained by an existing method;

[0028] Figure 7 It is a distribution diagram of classification results obtained after a certain image group is classified by a target model trained according to the method provided in this application;

[0029] Figure 8 is a flow chart of a face recognition method provided by an embodiment of the present application;

[0030] Fig. 9 It is one of the structural schematic diagrams of the model training device provided in the embodiment of the present application;

[0031] Fig.10 This is one of the structural schematic diagrams of the living body detection device provided in the embodiment of the present application;

[0032] Fig.11 This is the second structural diagram of the model training device provided in the embodiment of the present application;

[0033] Fig.12 This is the second structural schematic diagram of the living body detection device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0034] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0035] In the related art, when training a face liveness detection model, due to the high cost of collecting prosthesis samples, the distribution and number of prosthesis samples available in the training data are limited. However, the existing prostheses are of various types and unknown, such as electronic screens of various materials, various paper photos, and masks of various materials. They belong to open sets, and the data distribution is very wide and cannot be exhaustively enumerated, which brings great difficulty to model learning. As a result, the problem of overfitting of the trained model is more serious, that is, the trained model generally has a good fitting effect on the data distribution in the training set, and when predicting the data outside the training set, the prediction result is prone to misjudgment. Based on this, in the embodiment of the present application, data enhancement processing is performed based on the existing training data to generate new training data, so that the diversity of the training data can be increased, making the distribution of the training data richer, and the data enhancement process only requires a low cost to obtain rich training data.

[0036] The overfitting problem mentioned above refers to the problem that during the model training process, the model cannot recognize the data well because the model learns the characteristics of the noise data in the training data, that is, the model cannot classify correctly and the model generalization ability is poor.

[0037] See also Figure 1 , Figure 1 A model training method provided in an embodiment of the present application comprises the following steps:

[0038] Step 101: Acquire an initial training data set, where the initial training data set includes first training data and second training data, where the first training data includes a first image and a first label, and the second training data includes a second image and a second label;

[0039] Step 102: performing data processing on the initial training data set to obtain a target training data set, wherein the target training data set includes all the training data in the initial training data set and third training data outside the initial training data set, wherein the third training data includes a third image and a third label, and the third image is an image generated based on the first image and the second image, wherein the data processing may be data enhancement processing;

[0040] Step 103: input the target training data set into a pre-built liveness detection model for training to obtain a trained target model;

[0041] The first image, the second image and the third image include faces, and the first label, the second label and the third label are used to indicate whether the corresponding images are living body images.

[0042] The above-mentioned initial training data set may be a training data set artificially constructed by relevant personnel, wherein the initial training data set may include training data corresponding to living body images and training data corresponding to non-living body images, wherein the non-living body images are the above-mentioned prosthesis samples. The living body may refer to a real human face with life, and the prosthesis may refer to a face impersonation that pretends to be a real person. Specifically, the difference between the living body image and the non-living body image lies in the different sources of the images. The living body image is an image obtained by image acquisition of a living face, and the non-living image may be artificially synthesized, or an image obtained by impersonating a living body, for example, it may be an image taken by a living body wearing a hood or mask to impersonate other living bodies, or it may be an image obtained by painting a human face, or it may be a paper face photo, a face photo displayed on a screen, etc.

[0043] Accordingly, the above-mentioned target model is specifically used to distinguish whether the currently acquired facial image or video is from a living face or a prosthetic face.

[0044] The first image, the second image and the third image include human faces, that is, the first image, the second image and the third image all include human face images.

[0045] Specifically, the training data corresponding to the living image may include: an image captured for a living face and a corresponding label, wherein the label is used to characterize the corresponding image as a living image, so that the living detection model can learn the corresponding features of the living face. Correspondingly, the non-living image may include: a non-living image and a corresponding label, wherein the label is used to mark the corresponding image as a non-living image, so that the living detection model can learn the corresponding features of the non-living face.

[0046] It is understandable that the first training data, the second training data, and the third training data may be training data corresponding to a living face image or training data corresponding to a non-living face image. The third image may be an image obtained by splicing the first image and the second image. For example, some facial features in the first image may be replaced with corresponding features in the second image to obtain the third image.

[0047] It is understandable that the above-mentioned initial training data set may include at least one training data group, wherein each training data group includes the first training data and the second training data. When the initial training data set is processed, data enhancement processing may be performed on each training data group in the initial training data set to obtain the target training data set.

[0048] In this implementation, existing face images are used to generate new face images, and the existing face images and the newly generated face images are used together as training data. In this way, the diversity of training data can be increased, making the distribution of training data richer, thereby alleviating the overfitting problem in the face liveness detection training scenario, and further improving the detection effect of the trained face liveness detection model.

[0049] In addition, the method provided by the embodiment of the present application has the following beneficial effects: (1) rich training data can be obtained at a relatively low cost, and the obtained training data has a wide distribution range; (2) by transferring the image content in the area, the image of any part of the face can be replaced, which is conducive to enriching the training data; (3) by using the training data after data enhancement processing to train the model, it is conducive to improving the robustness of the target model obtained by training.

[0050] Optionally, the performing data processing on the initial training data set to obtain a target training data set includes:

[0051] Transferring the content in the first area of ​​the first image to the second area of ​​the second image to obtain the third image, wherein the first area corresponds to the second area, the first area is located in the face area of ​​the first image, and the third image is the second image after the content in the first area is transferred to the second area;

[0052] The third label is set for the third image to obtain the third training data.

[0053] The first area may be an area randomly obtained from the face area of ​​the first image, and the first area and the second area may be the same area in the face, for example, both may be eye areas or both may be mouth areas.

[0054] In addition, the first image can be either a living face image or a non-living face image; accordingly, the second image can be either a living face image or a non-living face image. When at least one of the first image and the second image is a non-living image, after transferring the content in the first area to the second area. Since the third image includes the features in both the first image and the second image, that is, the third image includes the features of the non-living image, the label corresponding to the third image can be set as a non-living image, thereby increasing the diversity of non-living samples. Accordingly, when both the first image and the second image are living images, after transferring the content in the first area to the second area, since the third image does not include the features of the non-living image, the label of the third image can be set as a living image, thereby increasing the diversity of living samples. It can be seen that the above data processing process can be used for data enhancement of non-living images and can also be used for data enhancement of living images, which is conducive to enriching training data.

[0055] The above-mentioned transferring the content in the first area of ​​the first image to the second area of ​​the second image may refer to: overlaying the screen content in the first area of ​​the first image on the second area of ​​the second image. In addition, the above-mentioned transferring the content in the first area of ​​the first image to the second area of ​​the second image may refer to: replacing the screen content in the first area of ​​the first image with the second area of ​​the second image.

[0056] In this implementation, by transferring a partial area in the first image to a corresponding position in the second image, the diversity of the training data can be increased.

[0057] Optionally, transferring the content in the first area in the first image to the second area in the second image to obtain the third image includes:

[0058] Identify the location of a face in the first image, and identify the location of a face in the second image;

[0059] adjusting the position of the face in the first image based on a preset means so that the position of the face in the first image is aligned with the position of the face in the second image;

[0060] Acquire content within the first area in the first image;

[0061] Determining position information of the second area in the second image based on position information of the first area in the first image;

[0062] The content in the first area is transferred to the second area in the second image to obtain the third image.

[0063] Specifically, the faces in the first image and the second image can be respectively identified based on the existing face recognition algorithm to determine the position of the faces in the first image and the second image. Since the positions of the faces in different images may be different. Therefore, the position of the face in the first image can be adjusted based on a preset means so that the faces in the first image and the second image are located at the same position in the image. For example, the faces in the two images can be located in the center. In addition, since the display sizes of the faces in different images may be different, the size of the face in the first image can be adjusted based on the preset means so that the display sizes of the face images in the first image and the second image are consistent.

[0064] It is understandable that, in addition to adjusting the face in the first image based on the preset means, the face in the second image can also be adjusted based on the preset means so that the position of the face in the first image is aligned with the position of the face in the second image. In addition, the faces in the first image and the second image can also be adjusted simultaneously based on the preset means so that the position of the face in the first image is aligned with the position of the face in the second image.

[0065] The specific process of adjusting the position of the face in the first image based on the preset means may be: after recognizing the face in the first image based on the face recognition algorithm, the coordinates of each key point in the face in the first image may be determined, and then the coordinates of each key point may be transformed to the standard position of the corresponding key point, so that the position and display size of the face can be adjusted. For example, the coordinates of the key points in the first image obtained may be transformed to the standard coordinate position by using a similarity transformation method. The key points may be pre-set face key points.

[0066] It can be understood that the position adjustment process for other face images other than the first image is the same as the adjustment process for the first image, and will not be described again here to avoid repetition.

[0067] After realizing face alignment in the first image and the second image based on the above method, a first area can be randomly determined in the face area of ​​the first image, and then the content in the first area can be obtained and the coordinate position of the first area in the first image can be determined. Then, a position identical to the position of the first area can be determined in the second image, for example, both are eye positions, etc., and the first area in the first image can be transferred to the second area.

[0068] In this embodiment, the human faces in the first image and the second image are first identified, and then the position and size of the human faces in the first image are adjusted to align the positions and sizes of the human faces in the first image and the second image. Then, the regions in the first image and the second image are exchanged. In this way, the coordination of the human faces in the third image obtained after the region exchange can be improved, thereby improving the quality of the generated sample data.

[0069] Optionally, the target training data set further includes fourth training data other than the initial training data set, and the processing the initial training data set to obtain the target training data set further includes:

[0070] Transferring the content in the second area of ​​the second image to the first area of ​​the first image to obtain the fourth image, where the fourth image is the first image after the content in the second area is transferred to the first area;

[0071] A fourth label is set for the fourth image to obtain the fourth training data.

[0072] In this implementation, by exchanging the contents of the first area and the second area, two different sample images can be obtained through one exchange, which is beneficial to further increase the diversity of training data and make the distribution of training data richer.

[0073] Optionally, the first label is a first truth map corresponding to the first image, the second label is a second truth map corresponding to the second image, the third label is a third truth map corresponding to the third image, and setting the third label for the third image includes:

[0074] The content in the third area in the first truth map is transferred to the fourth area in the second truth map to obtain the third truth map, wherein the position of the third area corresponds to the position of the first area, and the position of the fourth area corresponds to the position of the second area. The third truth map is the second truth map after the content in the third area is transferred to the fourth area.

[0075] The truth map is a simple and intuitive image expressed in logical algebra (Boolean algebra). In the embodiment of the present application, the truth map may refer to an image obtained by marking the living area and the non-living area in the same image with different labels. For example, the truth map may be as follows: Figure 2 The black and white image shown in FIG. 1 , in which the living face area can be represented by the white area, and the non-living face area can be represented by the black area. Figure 2 With a complete face image, Figure 2 is the true value image corresponding to the living face image. Accordingly, when a true value image is completely black or has a white area with an incomplete face outline, for example Figure 3 The first image and the third image in the image can be used to determine the true value map as the true value map corresponding to the non-living image.

[0076] It can be understood that the size of the above-mentioned first truth map can be the same as that of the first image, and the color of each pixel in the first truth map can indicate whether the corresponding position in the first image is a living face image. Therefore, the size and coordinate position of the above-mentioned third area in the first truth map can be the same as the size and coordinate position of the first area in the first image, that is, the third area can characterize whether the content in the first area is a living face image. Correspondingly, the size and coordinate position of the above-mentioned fourth area in the second truth map can be the same as the size and coordinate position of the second area in the second image, that is, the fourth area can characterize whether the content in the second area is a living face image.

[0077] Thus, if the first region is a non-living image, the image of the third region will be a black image. After the content of the third region is transferred to the fourth region in the second truth map, no matter whether the second truth map includes a complete face contour image or not, the generated third truth map will definitely not include a complete face contour image. For example, see Figure 3 , the first image is a non-living image, the second image is a living image, and after the eye area in the first image is transferred to the eye area in the second image, the third image obtained is a non-living image.

[0078] Correspondingly, the fourth label is a fourth truth map corresponding to the fourth image, and setting the fourth label for the fourth image to obtain the fourth training data includes: transferring the content in the fourth area in the second truth map to the third area in the first truth map to obtain the fourth truth map, and the fourth truth map is the first truth map obtained after transferring the content in the fourth area to the third area.

[0079] It can be understood that the target model can also include a post-processing layer, which can be used to determine whether the face image in the truth map is complete and output the corresponding determination result, wherein the determination result includes: living face image and non-living face image.

[0080] It should be noted that if the first image is a non-living image, but the first image includes a part of a living image, for example, the mouth area of ​​the first image is a living image, and the second image is a living image, and the first area is the mouth area of ​​the first image, then after the content of the first area is transferred to the second area of ​​the second image, the third image obtained can also be regarded as a living image. Correspondingly, since the first area of ​​the first image is a living image, the third area of ​​the first truth map is a white area, so that after the content in the third area is transferred to the second truth map, the third truth map obtained can still include a complete face contour, that is, the third truth map can characterize the third image as a living image.

[0081] Accordingly, if the text labels in the prior art are used, the problem of mismatch between the labels and the generated image types may occur. For example, for the above case, when the first image is a non-living image, and the mouth area of ​​the first image is a living image, the first area is the mouth area of ​​the first image, and the second image is a living image, if the label setting method in the prior art is used, since the first image is a non-living image, the label of the first image may be 0, and the second image is a living image, so the label of the second image may be 1. At this time, after the third image is obtained by region exchange, since the third image is an image synthesized by a prosthetic image and a living image, the label of the third image may be identified as a prosthetic image, that is, the label of the third image may be identified as 0. Alternatively, the label of the third image may also be identified as the average of the label of the first image and the label of the second image, that is, the label of the third image may be identified as 0.5. However, based on the above-mentioned truth map judgment method, it can be seen that the third image obtained after region transfer is still a living image, that is, the label of the third image should actually be 1. It can be seen that the use of label setting methods in the prior art may lead to the problem that the set labels do not match the generated image types. In the embodiment of the present application, by adopting the method of exchanging the true value map regions, the classification of the generated new image can be determined more accurately, thereby further improving the accuracy of the training data generated by data processing.

[0082] Optionally, the target training data set includes at least one training data group, each of the training data groups includes the first training data and the second training data, and in any one of the training data groups, the faces in all the training data are the same face.

[0083] Specifically, since the facial features of different faces are usually different, if the same set of training data includes images of different faces, that is, the same training data group includes different facial images, then the differences between different images include not only the feature of whether the image is alive, but also features such as facial features that are irrelevant to model training. In order to avoid the model learning irrelevant features other than the feature of whether the image is alive during model training, in the embodiment of the present application, the faces in all training data in the same training data group are set to be the same face, so that the facial features in different training data in the same training data group are basically the same, and the main difference is the feature of whether the image is alive. This can further improve the effect of model training.

[0084] Wherein, each training data in the target training data set may include a living image of the same human face and a non-living image of the same human face.

[0085] When the target training data set includes at least two training data groups, the at least two training data groups correspond to at least two human faces, wherein one training data group corresponds to one human face, and the at least two human faces are different human faces, thereby facilitating the model to learn the features of different human faces.

[0086] In one embodiment of the present application, in the above training data set, the number of training data corresponding to the living body image is the same as the number of training data corresponding to the non-living body image. In this way, by setting the number of living body training data and non-living body training data in the training data set to 1:1, the model can further strengthen the learning of detailed features of human faces, that is, further strengthen the model to learn the distinguishable features between living bodies and non-living bodies.

[0087] In this implementation, by setting the faces in all training data in the same training data group to be the same face, it is helpful for the model to learn the essential features of the living body and prevent the model from excessively focusing on other irrelevant features such as ID or background. This can prevent the identity ID and background information in the image and other features irrelevant to the living body from interfering with the model training process, so as to further improve the effect of model training.

[0088] Optionally, in the training data group, the number of training data corresponding to the living body images is the same as the number of training data corresponding to the non-living body images.

[0089] In this implementation, by setting the number of living body training data and non-living body training data in the training data group to 1:1, the model can be further strengthened to learn the detailed features of the human face, that is, the model can be further strengthened to learn the distinguishable features between living bodies and non-living bodies.

[0090] See also Figure 4 , a living body detection method provided in an embodiment of the present application, comprising:

[0091] Step 401: Input the image to be detected into the target model to obtain the detection result output by the target model, wherein the detection result is used to characterize whether the image to be detected is a living body image. The target model is a model trained based on the model training method described in the above embodiment. For example, see Figure 5 When the image to be detected is a living body image, the target model can output a true value map corresponding to the living body image.

[0092] Specifically, see Figure 6 and Figure 7 , Figure 6 This is a schematic diagram of the distribution of classification results obtained after classifying a certain image group using a face liveness detection model trained according to existing methods. Figure 7 A distribution diagram of the classification results obtained after the image group is classified based on the target model trained by the method provided by the present application. The image group includes multiple face images, and region 0 may represent the region formed by the classification results of living images, and region 1 may represent the region formed by the classification results of non-living images. Figure 6-7 It can be seen that relative to Figure 6 In terms of Figure 7 The decision boundary is clearer and the distance between classes is larger. That is, the target model trained by the method provided in the embodiment of the present application is more accurate in prediction and has better classification effect than the face liveness detection model trained by the existing method.

[0093] In this implementation, since the target model is a model trained based on the model training method in the above embodiment, the target model can achieve all the beneficial effects of the target model in the above embodiment, and will not be described again here to avoid repetition.

[0094] See also Figure 8, the embodiment of the present application also provides a face recognition method, the method comprising: step 801, obtaining an image to be recognized input by a target user, and inputting the image to be recognized into a target model; step 802, when the result output by the target model indicates that the image to be recognized is a living image, performing face detection on the image to be recognized based on a face recognition algorithm; then, step 803, adjusting the face position in the image to be recognized based on a preset means, so that the face position in the image to be recognized is aligned with the face position in the target image, wherein the target image is a face image of the target user pre-stored in a database. Then, step 804, extracting face features in the image to be recognized and the target image respectively, and comparing the extracted features to determine whether the image to be recognized and the target image are images of the same face; step 805, outputting the result of face recognition.

[0095] See also Fig. 9 , a model training device 900 provided in an embodiment of the present application, comprising:

[0096] An acquisition module 901 is used to acquire an initial training data set, where the initial training data set includes first training data and second training data, where the first training data includes a first image and a first label, and the second training data includes a second image and a second label;

[0097] A data processing module 902 is used to perform data processing on the initial training data set to obtain a target training data set, where the target training data set includes all the training data in the initial training data set and third training data outside the initial training data set, where the third training data includes a third image and a third label, and the third image is an image generated based on the first image and the second image;

[0098] A training module 903 is used to input the target training data set into a pre-built liveness detection model for training to obtain a trained target model;

[0099] The first image, the second image and the third image include faces, and the first label, the second label and the third label are used to indicate whether the corresponding images are living body images.

[0100] Optionally, the data processing module 902 includes:

[0101] an image transfer submodule, configured to transfer the picture content in a first area in the first image to a second area in the second image to obtain the third image, wherein the first area corresponds to the position of the second area, the first area is located in the face area in the first image, and the third image is the second image after the content in the first area is transferred to the second area;

[0102] The label setting submodule is used to set the third label for the third image to obtain the third training data.

[0103] Optionally, the image transfer submodule includes:

[0104] an identification unit, configured to identify the position of a human face in the first image, and to identify the position of a human face in the second image;

[0105] an adjusting unit, configured to adjust the position of the face in the first image based on a preset means, so that the position of the face in the first image is aligned with the position of the face in the second image;

[0106] An acquisition unit, configured to acquire picture content within the first area in the first image;

[0107] a determining unit, configured to determine position information of the second area in the second image based on the position information of the first area in the first image;

[0108] A transfer unit is used to transfer the content in the first area to the second area in the second image to obtain the third image.

[0109] Optionally, the target training data set further includes fourth training data outside the initial training data set, and the image transfer submodule is further used to transfer the picture content in the second area in the second image to the first area in the first image to obtain the fourth image, where the fourth image is the first image after the content in the second area is transferred to the first area;

[0110] The label setting submodule is further used to set a fourth label for the fourth image to obtain the fourth training data.

[0111] Optionally, the first label is a first truth map corresponding to the first image, the second label is a second truth map corresponding to the second image, the third label is a third truth map corresponding to the third image, and the label setting submodule is specifically used to transfer the picture content in the third area in the first truth map to the fourth area in the second truth map to obtain the third truth map, the position of the third area corresponds to the position of the first area, the position of the fourth area corresponds to the position of the second area, and the third truth map is the second truth map after the content in the third area is transferred to the fourth area.

[0112] Optionally, the target training data set includes at least one training data group, each of the training data groups includes the first training data and the second training data, and in any one of the training data groups, the faces in all the training data are the same face.

[0113] Optionally, in the training data group, the number of training data corresponding to the living body images is the same as the number of training data corresponding to the non-living body images.

[0114] The model training device 900 provided in the embodiment of the present application can implement each process in the above-mentioned model training method embodiment. To avoid repetition, it will not be described here.

[0115] See also Fig.10 , a living body detection device 1000 provided in an embodiment of the present application, comprising:

[0116] The detection module 1001 is used to input the image to be detected into the target model to obtain the detection result output by the target model, and the detection result is used to characterize whether the image to be detected is a living image. The target model is a model trained based on the model training method described in the above embodiment.

[0117] The liveness detection device 1000 provided in the embodiment of the present application can implement each process in the above liveness detection method embodiment, and will not be described again here to avoid repetition.

[0118] See also Fig.11 , Fig.11 1 is a structural diagram of a model training device 1100 provided in another embodiment of the present application, such as Fig.11 As shown, the model training device 1100 includes: a processor 1101, a memory 1102, and a computer program stored in the memory 1102 and executable on the processor. The various components in the data sending device 1100 are coupled together via a bus interface 1103. When the computer program is executed by the processor 1101, the following steps are implemented:

[0119] Acquire an initial training data set, the initial training data set comprising first training data and second training data, the first training data comprising a first image and a first label, and the second training data comprising a second image and a second label;

[0120] Processing the initial training data set to obtain a target training data set, wherein the target training data set includes all the training data in the initial training data set and third training data outside the initial training data set, wherein the third training data includes a third image and a third label, and the third image is an image generated based on the first image and the second image;

[0121] Inputting the target training data set into a pre-built liveness detection model for training to obtain a trained target model;

[0122] The first image, the second image and the third image include faces, and the first label, the second label and the third label are used to indicate whether the corresponding images are living body images.

[0123] Optionally, the performing data processing on the initial training data set to obtain a target training data set includes:

[0124] Transferring the content in the first area of ​​the first image to the second area of ​​the second image to obtain the third image, wherein the first area corresponds to the second area, the first area is located in the face area of ​​the first image, and the third image is the second image after the content in the first area is transferred to the second area;

[0125] The third label is set for the third image to obtain the third training data.

[0126] Optionally, transferring the content in the first area in the first image to the second area in the second image to obtain the third image includes:

[0127] Identify the location of a face in the first image, and identify the location of a face in the second image;

[0128] adjusting the position of the face in the first image based on a preset means so that the position of the face in the first image is aligned with the position of the face in the second image;

[0129] Acquire content within the first area in the first image;

[0130] Determining position information of the second area in the second image based on position information of the first area in the first image;

[0131] The content in the first area is transferred to the second area in the second image to obtain the third image.

[0132] Optionally, the target training data set further includes fourth training data other than the initial training data set, and the processing the initial training data set to obtain the target training data set further includes:

[0133] Transferring the content in the second area of ​​the second image to the first area of ​​the first image to obtain the fourth image, where the fourth image is the first image after the content in the second area is transferred to the first area;

[0134] A fourth label is set for the fourth image to obtain the fourth training data.

[0135] Optionally, the first label is a first truth map corresponding to the first image, the second label is a second truth map corresponding to the second image, the third label is a third truth map corresponding to the third image, and setting the third label for the third image includes:

[0136] The content in the third area in the first truth map is transferred to the fourth area in the second truth map to obtain the third truth map, wherein the position of the third area corresponds to the position of the first area, and the position of the fourth area corresponds to the position of the second area. The third truth map is the second truth map after the content in the third area is transferred to the fourth area.

[0137] Optionally, the target training data set includes at least one training data group, each of the training data groups includes the first training data and the second training data, and in any one of the training data groups, the faces in all the training data are the same face.

[0138] Optionally, in the training data group, the number of training data corresponding to the living body images is the same as the number of training data corresponding to the non-living body images.

[0139] See also Fig.12 , Fig.12 1 is a structural diagram of a living body detection device 1200 provided in another embodiment of the present application. Fig.12 As shown, the liveness detection device 1200 includes: a processor 1201, a memory 1202, and a computer program stored in the memory 1202 and executable on the processor. The various components in the data sending device 1200 are coupled together via a bus interface 1203. When the computer program is executed by the processor 1201, the following steps are implemented:

[0140] The image to be detected is input into the target model to obtain a detection result output by the target model, wherein the detection result is used to characterize whether the image to be detected is a living body image. The target model is a model trained based on the model training method described in the first aspect above.

[0141] An embodiment of the present application also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0142] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

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

[0144] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling an electronic device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0145] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A model training method, characterized in that: include: Acquire an initial training data set, the initial training data set comprising first training data and second training data, the first training data comprising a first image and a first label, and the second training data comprising a second image and a second label; Performing data processing on the initial training data set to obtain a target training data set, wherein the target training data set includes all the training data in the initial training data set and third training data outside the initial training data set, wherein the third training data includes a third image and a third label, wherein the third image is an image obtained by transferring content in a first region in the first image to a corresponding region in the second image, wherein the first label is a first truth map, wherein the second label is a second truth map, and wherein the third label is a truth map obtained by transferring content in a region corresponding to the first region in the first truth map to a corresponding region in the second truth map; Inputting the target training data set into a pre-built liveness detection model for training to obtain a trained target model; The first image, the second image and the third image include faces, and the first label, the second label and the third label are used to indicate whether the corresponding images are living body images.

2. The method according to claim 1, characterized in that The processing of the initial training data set to obtain a target training data set includes: Transferring the content in the first area of ​​the first image to the second area of ​​the second image to obtain the third image, wherein the first area corresponds to the second area, the first area is located in the face area of ​​the first image, and the third image is the second image after the content in the first area is transferred to the second area; The third label is set for the third image to obtain the third training data.

3. The method according to claim 2, characterized in that The transferring the content in the first area in the first image to the second area in the second image to obtain the third image comprises: Identify the location of a face in the first image, and identify the location of a face in the second image; adjusting the position of the face in the first image based on a preset means so that the position of the face in the first image is aligned with the position of the face in the second image; Acquire content within the first area in the first image; Determining position information of the second area in the second image based on position information of the first area in the first image; The content in the first area is transferred to the second area in the second image to obtain the third image.

4. The method according to claim 2, characterized in that: The target training data set further includes fourth training data other than the initial training data set, and the data processing of the initial training data set to obtain the target training data set further includes: Transferring the content in the second area of ​​the second image to the first area of ​​the first image to obtain a fourth image, wherein the fourth image is the first image after the content in the second area is transferred to the first area; A fourth label is set for the fourth image to obtain the fourth training data.

5. The method according to claim 2, characterized in that: The third label is a third truth image corresponding to the third image, and setting the third label for the third image includes: The content in the third area in the first truth map is transferred to the fourth area in the second truth map to obtain the third truth map, wherein the position of the third area corresponds to the position of the first area, and the position of the fourth area corresponds to the position of the second area. The third truth map is the second truth map after the content in the third area is transferred to the fourth area.

6. The method according to claim 1, characterized in that The target training data set includes at least one training data group, each of the training data groups includes the first training data and the second training data, and in any one of the training data groups, the faces in all the training data are the same face.

7. The method according to claim 6, characterized in that In the training data group, the number of training data corresponding to the living body images is the same as the number of training data corresponding to the non-living body images.

8. A method for detecting a living body, characterized in that: include: The image to be detected is input into the target model to obtain a detection result output by the target model, wherein the detection result is used to characterize whether the image to be detected is a living body image, and the target model is a model trained by the model training method described in any one of claims 1 to 7.

9. A living body detection device, characterized in that: include: A detection module is used to input the image to be detected into a target model to obtain a detection result output by the target model, wherein the detection result is used to characterize whether the image to be detected is a living image, and the target model is a model trained based on the model training method described in any one of claims 1 to 7.

10. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the method steps according to any one of claims 1 to 8 when executed by the processor.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps according to any one of claims 1 to 8 are implemented.