A model iteration method based on incremental data, a living body detection method and device
By using an incremental data-based model iteration method, the first liveness detection model is used to detect and classify samples, calculate the loss, and iteratively update the model. This solves the overfitting problem of the liveness detection model, improves the training effect and generalization ability of the model, and enhances the accuracy of the detection results.
Patent Information
- Application Number
- CN202310499189.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-05
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2043-05-05
AI Technical Summary
Existing liveness detection models are prone to overfitting to a certain batch of data during training, which affects the model's training performance and generalization ability.
An incremental data-based model iteration method is adopted. By acquiring the first and second datasets, the first liveness detection model is used to detect and classify the samples, calculate the loss and iteratively update it. The loss of labels that are irrelevant to the liveness detection task is set to be larger, while the focus is on features that are relevant to the liveness detection task.
It alleviates overfitting during data iteration, improves model training effectiveness and generalization ability, and enhances the accuracy of detection results.
Smart Images

Figure CN118898735B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computers, and in particular to a model iteration method based on incremental data, and a living body detection method and device. BACKGROUND
[0002] Living body detection is a technology for determining whether a user in front of a camera lens is a real person through portrait recognition technology. At present, a living body detection model composed of a neural network (NN) and the like is generally trained through a deep learning algorithm. In the training process, training data is a decisive factor for determining the upper limit of the performance of the living body detection model obtained through training. The training data is generally collected or purchased in batches, which makes the training data more and more complex. At present, different batches of data are directly mixed according to a certain proportion, and the mixed data are used to train the living body detection model. However, in this way, the model trained often overfits to a certain batch of data, affecting the training effect of the model. SUMMARY
[0003] The present application provides a model iteration method based on incremental data, a living body detection method, a device, an electronic device, a computer storage medium, and a computer program product containing instructions, which can alleviate the phenomenon of overfitting of certain data in the data iteration process, improve the training effect of the model, and improve the generalization ability of the model.
[0004] In a first aspect, the present application provides a model iteration method based on incremental data, comprising: obtaining a first data set and a second data set, the samples in the second data set being incremental data, the samples in the first data set having a first label and a second label, the samples in the second data set having a third label, the first label and the third label both being related to a living body detection task, and the second label being unrelated to the living body detection task; detecting and processing the samples in the first data set and the second data set by using a first living body detection model to obtain a first detection result, and performing loss calculation based on the first detection result, the first label, and the third label to obtain a first loss, wherein the first living body detection model is trained based on the first data set and the first label; at least by using the first living body detection model, classifying and processing the samples in the first data set to obtain a first classification result, and performing loss calculation based on the first classification result and the second label to obtain a second loss; and iteratively updating the first living body detection model based on the first loss and the second loss to obtain a second living body detection model.
[0005] In this way, by setting the label irrelevant to the living body detection task in the training data, and increasing the loss corresponding to the label, the model is forced to ignore the negative influence of different data distribution on the training task, thereby reducing the overfitting of the model to the features irrelevant to the living body detection task; and by reducing the loss corresponding to the label related to the living body detection task, the model can pay more attention to the features related to the living body detection task. Thus, while alleviating the phenomenon of overfitting of some data in the data iteration process, the training effect of the model and the generalization ability of the model are improved.
[0006] In a possible implementation, the first data set includes a first sample. At least by the first living body detection model, the sample in the first data set is classified to obtain a first classification result, including: using the first living body detection model to extract features of the first sample to obtain first sample features; and classifying the first sample features to obtain a classification result of the first sample.
[0007] Based on the first classification result and the second label, a second loss is calculated, including: based on the classification result of the first sample and the second label of the first sample, a second loss is calculated.
[0008] Based on the first loss and the second loss, the first living body detection model is iteratively updated to obtain a second living body detection model, including: iteratively updating the first living body detection model to reduce the first loss and increase the second loss.
[0009] In a possible implementation, the first data set includes a first sample, and the second data set includes a second sample. Using the first living body detection model, the samples in the first data set and the second data set are detected to obtain a first detection result, including: using the first living body detection model to extract features of the first sample and the second sample respectively to obtain first sample features of the first sample and second sample features of the second sample; and using the first living body detection model to detect the first sample features and the second sample features respectively to obtain a detection result of the first sample and a detection result of the second sample.
[0010] Based on the first detection result, the first label and the third label, a first loss is calculated, including: based on the detection result of the first sample and the first label of the first sample, a first sub-loss is calculated, and based on the detection result of the second sample and the third label of the second sample, a second sub-loss is calculated; and the first sub-loss and the second sub-loss are weighted to obtain the first loss.
[0011] In a possible implementation, before the first sub-loss and the second sub-loss are weighted and calculated, the method further includes: setting weights of the first sub-loss and the second sub-loss, so that the first sub-loss is greater than the second sub-loss.
[0012] In a possible implementation, the second label includes labels of multiple categories, and the multiple categories include at least two of a category of the sample collection device, a category of sample collection illumination, a category of an attribute of the target object in the sample, and a category of sample image quality.
[0013] In a possible implementation, the label corresponding to at least one category in the second label includes a first sub-label and a second sub-label, and a proportion of samples having the first sub-label and a proportion of samples having the second sub-label in the first data set are both greater than a preset threshold.
[0014] In a possible implementation, the sample in the second data set further has a fourth label irrelevant to the living body detection task, and a category corresponding to the fourth label is consistent with a category corresponding to the second label. The method further includes: performing classification processing on the sample in the second data set by at least the first living body detection model to obtain a second classification result, performing loss calculation based on the second classification result and the fourth label to obtain a third loss, and iteratively updating the first living body detection model with the aim of increasing the third loss.
[0015] In a second aspect, the present application provides a living body detection method, including: obtaining a to-be-detected image; processing the to-be-detected image through a living body detection model, the living body detection model being obtained by iteration of the method provided in the first aspect; and outputting a detection result of whether the to-be-detected image is a living body.
[0016] In a third aspect, the present application provides a model iteration device based on incremental data, comprising an acquisition module and a processing module. The acquisition module is configured to acquire a first data set and a second data set. The samples in the second data set are incremental data. The samples in the first data set have a first label and a second label. The samples in the second data set have a third label. The first label and the third label are related to a living body detection task. The second label is irrelevant to the living body detection task. The processing module is configured to detect and process the samples in the first data set and the second data set by using a first living body detection model to obtain a first detection result, and perform loss calculation based on the first detection result, the first label and the third label to obtain a first loss, wherein the first living body detection model is trained based on the first data set and the first label. The processing module is further configured to classify the samples in the first data set by at least using the first living body detection model to obtain a first classification result, and perform loss calculation based on the first classification result and the second label to obtain a second loss. The processing module is further configured to update the first living body detection model based on the first loss and the second loss to obtain a second living body detection model.
[0017] In a possible implementation, the first data set includes a first sample. When the processing module classifies the samples in the first data set by at least using the first living body detection model to obtain a first classification result, the processing module is specifically configured to extract features of the first sample by using the first living body detection model to obtain first sample features, and classify the first sample features to obtain a classification result of the first sample.
[0018] When the processing module performs loss calculation based on the first classification result and the second label to obtain a second loss, the processing module is specifically configured to perform loss calculation based on the classification result of the first sample and the second label of the first sample to obtain the second loss.
[0019] When the processing module updates the first living body detection model based on the first loss and the second loss to obtain a second living body detection model, the processing module is specifically configured to update the first living body detection model in a manner that reduces the first loss and increases the second loss.
[0020] In a possible implementation, the first data set includes a first sample, and the second data set includes a second sample. When the processing module detects and processes the samples in the first data set and the second data set by using the first living body detection model to obtain a first detection result, the processing module is specifically configured to extract features of the first sample and the second sample by using the first living body detection model respectively to obtain first sample features of the first sample and second sample features of the second sample, and detect the first sample features and the second sample features by using the first living body detection model respectively to obtain a detection result of the first sample and a detection result of the second sample.
[0021] In a possible implementation, when the processing module performs the loss calculation based on the first detection result, the first label and the third label to obtain the first loss, the processing module is specifically configured to: perform the loss calculation based on the detection result of the first sample and the first label of the first sample to obtain a first sub-loss, and perform the loss calculation based on the detection result of the second sample and the third label of the second sample to obtain a second sub-loss; and perform the weighted calculation on the first sub-loss and the second sub-loss to obtain the first loss.
[0022] In a possible implementation, before the processing module performs the weighted calculation on the first sub-loss and the second sub-loss, the processing module is further configured to: set the weights of the first sub-loss and the second sub-loss, so that the first sub-loss is greater than the second sub-loss.
[0023] In a possible implementation, the second label includes labels of multiple categories, and the multiple categories include at least two of a category of a sample collection device, a category of sample collection illumination, a property category of a target object in a sample, and a category of sample image quality.
[0024] In a possible implementation, the label corresponding to at least one category in the second label includes a first sub-label and a second sub-label, and the proportion of samples having the first sub-label and the proportion of samples having the second sub-label in the first data set are both greater than a preset threshold.
[0025] In a possible implementation, the sample in the second data set further has a fourth label irrelevant to the living body detection task, and a category corresponding to the fourth label is consistent with a category corresponding to the second label. At this time, the processing module is further configured to: perform the classification processing on the sample in the second data set by at least the first living body detection model to obtain a second classification result, perform the loss calculation based on the second classification result and the fourth label to obtain a third loss, and iteratively update the first living body detection model to increase the third loss.
[0026] In a fourth aspect, the present application provides a living body detection device, comprising: an acquisition module and a processing module. The acquisition module is configured to acquire a to-be-detected image. The processing module is configured to process the to-be-detected image through a living body detection model, and the living body detection model is obtained by iteratively performing the method provided in the first aspect. The processing module is further configured to output a detection result of whether the to-be-detected image is a living body.
[0027] In a fifth aspect, the present application provides an electronic device, comprising: one or more processors; and a memory configured to store one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in the first aspect or the second aspect.
[0028] In a sixth aspect, the present application provides a computer storage medium, wherein the computer storage medium stores instructions, and the instructions, when executed on a computer, cause the computer to perform the method provided in the first aspect or the second aspect.
[0029] In a seventh aspect, the present application provides a computer program product comprising instructions which, when executed on a computer, cause the computer to perform the method provided in the first aspect or the second aspect.
[0030] It can be understood that the beneficial effects of the second aspect to the seventh aspect can be referred to the related description in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF DRAWINGS
[0031] Figure 1 is a flow diagram of a model iteration method based on incremental data provided by an embodiment of the present application;
[0032] Figure 2 is a flow diagram of a living body detection method provided by an embodiment of the present application;
[0033] Figure 3 is a structural diagram of a model iteration device based on incremental data provided by an embodiment of the present application;
[0034] Figure 4 is a structural diagram of a living body detection device provided by an embodiment of the present application;
[0035] Figure 5 is a structural diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0036] The term "and / or" in the present document is a description of the association relationship between the associated objects, which means that there can be three relationships, for example, A and / or B can represent the following three cases: A exists alone, A and B exist together, and B exists alone. The symbol " / " in the present document represents the relationship of or, for example, A / B represents A or B.
[0037] The terms "first" and "second" and the like in the description and claims of the present document are used to distinguish different objects, and are not used to describe the specific order of the objects. For example, the first response message and the second response message are used to distinguish different response messages, and are not used to describe the specific order of the response messages.
[0038] In the embodiments of the present application, the word "exemplary" or "for example" is used to mean serving as an example, instance, or illustration, at 99 least with respect to the matters described at that point in the disclosure. The use of any of these terms in the description is not intended to relate to the relative quality of the example, but rather a representation by example by way of disclosure.
[0039] In the description of the embodiments of the present application, unless otherwise specified, "a plurality of" means two or more, for example, a plurality of processing units means two or more processing units, and the like, a plurality of elements means two or more elements, and the like.
[0040] Exemplary, Figure 1 A flowchart of a model iteration method based on incremental data provided by the embodiments of the present application. The method can be performed by a model iteration device based on incremental data, which can be implemented by software and / or hardware, and can be configured in an electronic device, typically in a computer or other computing device. As shown in the figure, the model iteration method based on incremental data can include the following steps: Figure 1
[0041] S101, obtain a first data set and a second data set, the samples in the second data set are incremental data, the samples in the first data set have first labels and second labels, the samples in the second data set have third labels, the first labels and the third labels are related to the live body detection task, and the second labels are irrelevant to the live body detection task.
[0042] In the embodiments, the first data set can be a set of original training data. The second data set can be a set of newly added data, i.e. incremental data, such as newly purchased data. The samples in the first data set and the second data set can be, but are not limited to, pictures.
[0043] The samples in the first data set can have first labels and second labels. The first labels are labels related to the live body detection task, and the second labels are labels irrelevant to the live body detection task. The samples in the second data set can have third labels. The third labels are also labels related to the live body detection task.
[0044] In some embodiments, the second label can include a plurality of categories of labels. Here, the category refers to a category irrelevant to the live body detection task. The category irrelevant to the live body detection task is a category that the sample itself has in the training data set, but is irrelevant to the live body detection task. The category includes at least two of the following: a category of sample collection equipment, a category of sample collection illumination, a category of attributes of a target object in the sample, and a category of sample image quality. The category of sample collection equipment can be directly obtained from the equipment information carried by the sample. The category of sample collection illumination can be determined by performing illumination estimation on the sample and according to a preset threshold value based on the sample estimation result. The category of attributes of the target object in the sample can be determined by using a target object recognition model to recognize the attributes of the target object, such as whether the target object wears glasses or not. The category of sample image quality can be determined by performing quality estimation on the sample and according to a preset threshold value based on the estimation result.
[0045] In other embodiments, the label corresponding to at least one category in the second label includes a first sub-label and a second sub-label, and the proportion of samples with the first sub-label and the proportion of samples with the second sub-label in the first data set are both greater than a preset threshold value. For example, when the second label is the category of sample collection equipment, the first sub-label can be collection equipment X, and the second sub-label can be collection equipment Y. Thus, the proportions of samples with different attributes (e.g., collection equipment X and collection equipment Y) under the same category in the first data set are both greater than the preset threshold value, that is, the sample distribution under different sub-labels of the same category is relatively uniform, thereby ensuring that the model can first learn the ability to distinguish different attributes (e.g., collection equipment X and collection equipment Y) under the corresponding category, and then iteratively towards the direction of ignoring the category attribute irrelevant to the live body detection task. For example, if 99% of the samples are collection equipment X and 1% of the samples are collection equipment Y, the model is difficult to learn the ability to distinguish the collection equipment category from these samples; and if 51% of the samples are collection equipment X and 49% of the samples are collection equipment Y, the model can easily learn the ability to distinguish X and Y from these samples.
[0046] S102, detecting the samples in the first data set and the second data set by using a first live body detection model to obtain a first detection result, and performing loss calculation based on the first detection result, the first label, and a third label to obtain a first loss, wherein the first live body detection model is trained based on the first data set and the first label.
[0047] In this embodiment, the samples in the first data set and the second data set can be input into the first living body detection model trained based on the first data set and the first label at the same time or at different times, etc. For example, the samples in the first data set can be input into the first living body detection model first, and then the samples in the second data set can be input into the first living body detection model. Alternatively, the samples in the second data set can be input into the first living body detection model first, and then the samples in the first data set can be input into the first living body detection model. Alternatively, the samples in the first data set and the samples in the second data set can be input into the first living body detection model at the same time. Alternatively, samples can be randomly selected from the first data set and the second data set and input into the first living body detection model. Exemplarily, the first living body detection model can be, but is not limited to, a convolutional neural network (CNN). Then, the samples in the first data set and the second data set can be detected and processed by the first living body detection model to obtain a first detection result. The first detection result can be a collection of detection results of each sample in the first data set and the second data set. Further, a pre-configured loss function can be used to calculate the loss of the detection result of each sample and the label related to the living body detection task of the corresponding sample to obtain a first loss.
[0048] In some embodiments, the first living body detection model can mainly consist of a feature extraction module and a feature detection module. At this time, when the first data set includes a first sample and the second data set includes a second sample, the feature extraction module can be used to extract features of the first sample and the second sample respectively to obtain first sample features of the first sample and second sample features of the second sample. Then, the feature detection module can be used to detect the first sample features and the second sample features respectively to obtain a detection result of the first sample and a detection result of the second sample. Further, a loss function can be used to calculate the loss of the detection result of the first sample and the first label of the first sample to obtain a first sub-loss, and the loss function can be used to calculate the loss of the detection result of the second sample and the third label of the second sample to obtain a second sub-loss. Finally, the first sub-loss and the second sub-loss can be weighted to obtain the first loss. In this embodiment, the loss function is not limited, for example, a cross-entropy loss function or an L2 loss function can be used.
[0049] In addition, considering that the first living body detection model is trained by using the samples in the first data set, and it is found in the research process that the incremental data (i.e., the data in the second data set) is often uncontrollable. Therefore, the weights of the first sub-loss and the second sub-loss can be set so that the first sub-loss is greater than the second sub-loss, thereby reducing the influence of the incremental data, and further making the model iterate in a positive direction after the incremental data is introduced, such as improving the detection ability and the generalization ability.
[0050] In S103, at least by the first living body detection model, the samples in the first data set are classified to obtain a first classification result, and a second loss is calculated based on the first classification result and the second label.
[0051] In the embodiment, the samples in the first data set can be input into the first living body detection model at the same time or at different times, so as to at least classify the samples by the first living body detection model, thereby obtaining the categories of the samples, i.e., obtaining the first classification result. In some embodiments, when the first data set includes a first sample, the first sample can be input into the first living body detection model first to extract features of the first sample by the model. The first sample features can be intermediate outputs of the first living body detection model. For example, when the first living body detection model mainly includes a feature extraction module and a feature detection module, the first sample features can be outputs of the feature extraction module. After obtaining the first sample features, the first sample features can be classified to obtain the classification result of the first sample. For example, a data domain alignment module can be provided for use with the first living body detection model. The data domain alignment module can include a classification module, which can be used to classify sample data and align features of different data based on the classification result. The input of the data domain alignment module can be the sample features extracted by the feature extraction module of the first living body detection model. The data domain alignment module can process the sample features by using algorithms such as contrastive domain description, correlation alignment, maximum mean discrepancy (MMD), Wasserstein, etc. In addition, after the iterative update of the living body detection model is completed and the updated model is put into application, the data domain alignment module can be discarded, so that the detection ability and the generalization ability of the model can be improved by using the incremental data on the premise of maintaining the original model architecture, and the difficulty of deploying the model can be avoided.
[0052] Further, the classification results of the samples and the labels unrelated to the living body detection task of the corresponding samples can be calculated by using a pre-configured loss function to obtain a second loss.
[0053] S104, iteratively update the first living body detection model based on the first loss and the second loss to obtain a second living body detection model.
[0054] In this embodiment, after obtaining the first loss and the second loss, the first living body detection model can be iteratively updated to obtain the second living body detection model, but is not limited to reducing the first loss and increasing the second loss.
[0055] In this way, by setting the label irrelevant to the living body detection task in the training data, and increasing the loss corresponding to the label, the model is forced to ignore the negative effects of different data distributions on the training task, thereby reducing the overfitting of the model to features irrelevant to the living body detection task; and by reducing the loss corresponding to the label related to the living body detection task, the model can pay more attention to features related to the living body detection task in the incremental data. Thus, while alleviating the phenomenon of overfitting of some data in the data iteration process, the training effect of the model and the generalization ability of the model are improved.
[0056] In some embodiments, the samples in the second data set can also have a fourth label. The fourth label is also a label irrelevant to the living body detection task. In addition, the category corresponding to the fourth label is consistent with the category corresponding to the second label, such as the category of the sample collection device or the category of the sample collection light, etc., that is, if the second label includes a label corresponding to the collection device category, the fourth label also includes a label corresponding to the collection device category. At this time, the first living body detection model can also be used to extract features of the samples in the second data set to obtain sample features of the samples in the second data set. Then, the sample features of the samples in the second data set can be classified to obtain the classification results of the samples in the second data set. Then, the loss function can be used to calculate the loss of the fourth label of the samples in the second data set and the classification results of the samples to obtain a third loss. Finally, the first living body detection model can be iteratively updated to increase the third loss. In this way, the overfitting of the model to the features irrelevant to the living body detection task in the second data set can be reduced, and the training effect of the model is improved. For example, considering that the incremental data is relatively small compared to the original training data, the second label can be annotated only for the original training data; and in the case of a large amount of incremental data, the fourth label can be annotated for the incremental data, which can be determined according to the actual situation, which is not limited here.
[0057] Further, when the sample in the second data set has a fourth label, the fourth label can also have a first sub-label and a second sub-label. Meanwhile, in the union set of the first data set and the second data set, the proportion of samples with the first sub-label and the proportion of samples with the second sub-label are both greater than a preset threshold. For example, when the second label and the fourth label are both the category of the sample collection device, the first sub-label can be collection device X, and the second sub-label can be collection device Y. Thus, the proportions of samples with different attributes (for example, collection device X and collection device Y) in the same category in the data set are both greater than the preset threshold, that is, the sample distribution of different sub-labels in the same category is relatively uniform, thereby ensuring that the model can first learn the ability to distinguish different attributes (for example, collection device X and collection device Y) in the corresponding category, and then iterates towards the direction of ignoring the category attribute irrelevant to the live body detection task.
[0058] The above is the introduction of the model iteration method based on incremental data provided by the embodiments of the present application. Next, a live body detection method provided by the embodiments of the present application is introduced.
[0059] Exemplarily, Figure 2 A flowchart of a live body detection method provided by the embodiments of the present application is shown. The method can be executed by a live body detection device, wherein the device can be implemented by software and / or hardware, and can be configured in an electronic device, typically, in a computer or the like computing device. As shown in Figure 2 The live body detection method provided by the embodiments of the present application can include:
[0060] S201, acquiring a to-be-detected image.
[0061] In this embodiment, the to-be-detected image can be real-time collected or pre-stored, which is not limited here. For example, the to-be-detected image can be a face image collected in a scenario where identity recognition and authentication are required. For example, in the scenarios of account login or transaction information determination, facial recognition verification is required, and the face image of the target object is collected in real time by the image collection function module of the terminal device where the application client is located. Of course, the to-be-detected image can also be a non-living face image, such as a pre-stored face image in the terminal device or an image of a collected face image. It can be understood that before using the technical solutions disclosed in the embodiments of the present disclosure, the type, use range, use scenario, etc. of the personal information involved in the present disclosure should be informed to the user and the authorization of the user should be obtained according to relevant laws and regulations. For example, when responding to the active request of the user, a prompt information is sent to the user to explicitly prompt the user that the operation requested to be executed will require the acquisition and use of the personal information of the user. Thus, the user can voluntarily choose whether to provide personal information to the electronic device, application program, server or storage medium, etc. software or hardware that performs the operation of the technical solutions of the present disclosure according to the prompt information. As an optional but non-limiting implementation manner, in response to receiving the active request of the user, the prompt information can be sent to the user in the form of a pop-up window, and the prompt information can be presented in the form of text in the pop-up window. In addition, the pop-up window can also carry a selection control for the user to select "agree" or "disagree" to provide personal information to the electronic device. It can be understood that the above notification and user authorization process is only illustrative, and does not limit the implementation manner of the present disclosure, and other manners that meet the relevant laws and regulations can also be applied to the implementation manner of the present disclosure.
[0062] S202, processing the to-be-detected image by the living body detection model.
[0063] In this embodiment, the to-be-detected image can be input into the living body detection model obtained by iteration in the foregoing embodiments, and processed by the living body detection model to obtain the detection result of whether the to-be-detected image is a living body.
[0064] S203, outputting the detection result of whether the to-be-detected image is a living body.
[0065] In this embodiment, after obtaining the detection result of whether the to-be-detected image is a living body, the result can be output, such as being displayed on the display screen of the electronic device.
[0066] In this way, since the detection effect of the foregoing living body detection model is improved, the detection result obtained by the living body detection model is also more accurate, and the accuracy of the detection result is improved.
[0067] Based on the method in the above embodiments, the embodiments of the present application further provide a model iteration device based on incremental data. As shown in Figure 3 The model iteration device based on incremental data 300 includes an acquisition module 301 and a processing module 302. The acquisition module 301 is configured to acquire a first data set and a second data set. The samples in the second data set are incremental data. The samples in the first data set have a first label and a second label. The samples in the second data set have a third label. The first label and the third label are both related to a living body detection task. The second label is not related to the living body detection task. The processing module 302 is configured to perform detection processing on the samples in the first data set and the second data set by using a first living body detection model to obtain a first detection result, and perform loss calculation based on the first detection result, the first label and the third label to obtain a first loss, wherein the first living body detection model is obtained by training based on the first data set and the first label. The processing module 302 is further configured to perform classification processing on the samples in the first data set by at least using the first living body detection model to obtain a first classification result, and perform loss calculation based on the first classification result and the second label to obtain a second loss. The processing module 302 is further configured to perform iterative updating on the first living body detection model based on the first loss and the second loss to obtain a second living body detection model.
[0068] In a possible implementation, the first data set includes a first sample. When the processing module 302 performs classification processing on the samples in the first data set by at least using the first living body detection model to obtain a first classification result, the processing module 302 is specifically configured to perform feature extraction on the first sample by using the first living body detection model to obtain first sample features, and perform classification processing on the first sample features to obtain a classification result of the first sample.
[0069] When the processing module 302 performs loss calculation based on the first classification result and the second label to obtain a second loss, the processing module 302 is specifically configured to perform loss calculation based on the classification result of the first sample and the second label of the first sample to obtain the second loss.
[0070] When the processing module 302 performs iterative updating on the first living body detection model based on the first loss and the second loss to obtain a second living body detection model, the processing module 302 is specifically configured to perform iterative updating on the first living body detection model in order to reduce the first loss and increase the second loss.
[0071] In a possible implementation, the first data set includes a first sample, and the second data set includes a second sample. When performing detection processing on the samples in the first data set and the second data set by using the first living body detection model to obtain a first detection result, the processing module 302 is specifically configured to: perform feature extraction on the first sample and the second sample respectively by using the first living body detection model to obtain first sample features of the first sample and second sample features of the second sample; and perform detection on the first sample features and the second sample features respectively by using the first living body detection model to obtain a detection result of the first sample and a detection result of the second sample.
[0072] When performing loss calculation based on the first detection result, the first label, and the third label to obtain a first loss, the processing module 302 is specifically configured to: perform loss calculation based on the detection result of the first sample and the first label of the first sample to obtain a first sub-loss, and perform loss calculation based on the detection result of the second sample and the third label of the second sample to obtain a second sub-loss; and perform weighted calculation on the first sub-loss and the second sub-loss to obtain the first loss.
[0073] In a possible implementation, before performing weighted calculation on the first sub-loss and the second sub-loss, the processing module 302 is further configured to: set weights of the first sub-loss and the second sub-loss, so that the first sub-loss is greater than the second sub-loss.
[0074] In a possible implementation, the second label includes labels of multiple categories, and the multiple categories include at least two of a category of a sample collection device, a category of sample collection illumination, an attribute category of a target object in a sample, and a category of sample image quality.
[0075] In a possible implementation, the label corresponding to at least one category in the second label includes a first sub-label and a second sub-label, and a proportion of samples having the first sub-label and a proportion of samples having the second sub-label in the first data set are both greater than a preset threshold.
[0076] In a possible implementation, the sample in the second data set further has a fourth label irrelevant to the living body detection task, and a category corresponding to the fourth label is consistent with a category corresponding to the second label. At this time, the processing module 302 is further configured to: perform classification processing on the sample in the second data set by using at least the first living body detection model to obtain a second classification result, perform loss calculation based on the second classification result and the fourth label to obtain a third loss, and iteratively update the first living body detection model to increase the third loss.
[0077] It should be understood that the above device is used to execute the method in the above embodiment, the corresponding program module in the device, the implementation principle and technical effect are similar to the description in the above method, and the working process of the device can refer to the corresponding process in the above method, which will not be described here.
[0078] Based on the method in the above embodiment, the embodiment of the present application further provides a living body detection device. As shown in the figure, Figure 4 The living body detection device 400 includes an acquisition module 401 and a processing module 402. The acquisition module 401 is configured to acquire a to-be-detected image. The processing module 402 is configured to process the to-be-detected image by using a living body detection model, and the living body detection model is obtained by using the model iteration method based on the incremental data. The processing module 402 is further configured to output a detection result of whether the to-be-detected image is a living body.
[0079] It should be understood that the above device is used to execute the method in the above embodiment, the corresponding program module in the device, the implementation principle and technical effect are similar to the description in the above method, and the working process of the device can refer to the corresponding process in the above method, which will not be described here.
[0080] The following refers to Figure 5 which shows a structural schematic diagram of an electronic device 500 suitable for implementing the embodiments of the present application. Figure 5 The electronic device shown is only an example, and should not impose any limitation on the functions and use range of the embodiments of the present application.
[0081] As shown in the figure, Figure 5 The electronic device 500 can include a processing device (such as a central processor, a graphics processor, etc.) 501, which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 502 or programs loaded from a storage device 506 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other through a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0082] Generally, the following devices can be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 506 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 can allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 5Electronic device 500 is shown with various means, but it is understood that not all of the shown means need be implemented or present. More or less means can alternatively be implemented or present.
[0083] In particular, in accordance with embodiments of the present disclosure, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program comprising program code for executing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 509, or installed from storage device 506, or installed from ROM 502. When the computer program is executed by processing device 501, the above-mentioned functions defined in the methods of the embodiments of the present disclosure are performed.
[0084] It should be noted that the computer-readable medium described above in the present disclosure can be a computer-readable signal medium or a computer-readable storage medium or any combination thereof. The computer-readable storage medium, for example, can be, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or apparatus, or any suitable combination thereof. More specific examples of the computer-readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program used by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, the computer-readable signal medium can include a data signal propagated in baseband or propagated as a carrier wave in a propagated data signal, in which the computer-readable program code is carried. Such a propagated data signal can take a variety of forms, including but not limited to electro-magnetic, optical, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium that is not a computer-readable storage medium and that can be used to carry or store program code used by or in connection with an instruction execution system, apparatus, or device. Program code contained in the computer-readable medium can be transmitted using any suitable medium, including but not limited to wire, cable, optical fiber, RF (radio frequency), etc., or any suitable combination thereof.
[0085] In some embodiments, the client, server, or other computing machines utilized by the embodiments can communicate information using any known or future developed end-to-end communications protocol, such as the HyperText Transfer Protocol (HTTP), and can be interconnected via any form or medium of digital data communication (for example, a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the Internet, and peer-to-peer networks (for example, ad hoc peer-to-peer networks), as well as any current or future developed network.
[0086] The computer-readable medium described above can be included in the electronic device described above; alternatively, the computer-readable medium can exist as a standalone entity.
[0087] The computer-readable medium described above can be included in the electronic device described above; alternatively, the computer-readable medium can exist as a standalone entity.
[0088] Computer program code for carrying out operations of the present disclosure can be written in any of one or more programming languages, including object or visual programming languages such as Java, Smalltalk, C++, or conventional procedural programming languages such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network ("LAN") or a wide area network ("WAN"), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0089] The computer program product of the first aspect can include one or more non-transitory computer-readable media storing instructions that, when executed, cause one or more processors to perform the operations of the first aspect. The computer program product of the first aspect can include a non-transitory computer-readable medium storing code that, when executed, causes a computer to perform operations for the first aspect.
[0090] The units described in the embodiments of the present application can be implemented by software, or by hardware. In some cases, the name of the module does not constitute a limitation on the unit itself.
[0091] The functions described above in the specification can be performed by one or more hardware logic components. For example, and without limitation, illustrative types of hardware logic components that can be used include Field-programmable Gate Arrays (FPGAs), Program-specific Integrated Circuits (ASICs), Program-specific Standard Products (ASSPs), System-on-a-chip systems (SOCs), Complex Programmable Logic Devices (CPLDs), etc.
[0092] In the context of the present disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium will include one or more lines of electrical connections, portable computer disks, hard disk drives, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or Flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0093] It can be understood that the processor in the embodiments of the present application can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. The general-purpose processor can be a microprocessor or any conventional processor.
[0094] The method steps in the embodiments of the present application can be realized by hardware or by the processor executing software instructions. The software instructions can be composed of corresponding software modules, and the software modules can be stored in a random access memory (RAM), a flash memory, a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically EPROM (EEPROM), a register, a hard disk, a mobile hard disk, a CD-ROM or any other form of storage medium well known in the art. An exemplary storage medium is coupled to the processor, so that the processor can read information from and write information to the storage medium. Of course, the storage medium can also be an integral part of the processor. The processor and the storage medium can be located in an ASIC.
[0095] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated. The computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions can be stored in or transmitted by a computer readable storage medium. The computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through a wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) manner. The computer readable storage medium can be any available medium accessible by a computer or a data storage device such as a server, data center, etc. integrated with one or more available media. The available media can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk (SSD)) and the like.
[0096] It can be understood that various numerical numbers involved in the embodiments of the present application are only distinguished for convenience of description, and are not used to limit the scope of the embodiments of the present application.
Claims
1. A model iteration method based on incremental data, comprising: obtaining a first data set and a second data set, samples in the second data set being incremental data, samples in the first data set having a first label and a second label, samples in the second data set having a third label, the first label and the third label both being related to a living body detection task, and the second label being irrelevant to the living body detection task; detecting samples in the first data set and the second data set by using a first living body detection model to obtain a first detection result, and performing loss calculation based on the first detection result, the first label and the third label to obtain a first loss, wherein the first living body detection model is trained based on the first data set and the first label; classifying samples in the first data set by at least using the first living body detection model to obtain a first classification result, and performing loss calculation based on the first classification result and the second label to obtain a second loss; updating the first living body detection model based on the first loss and the second loss to obtain a second living body detection model.
2. The method of claim 1, wherein, The first data set includes first samples. The classifying samples in the first data set by at least using the first living body detection model to obtain a first classification result comprises: extracting features of the first samples by using the first living body detection model to obtain first sample features, and classifying the first sample features to obtain a classification result of the first samples; The loss calculation based on the first classification result and the second label to obtain a second loss comprises: performing loss calculation based on the classification result of the first samples and the second label of the first samples to obtain the second loss; The updating the first living body detection model based on the first loss and the second loss to obtain a second living body detection model comprises: updating the first living body detection model to reduce the first loss and increase the second loss.
3. The method of claim 1, wherein, The first data set includes first samples, and the second data set includes second samples. The detecting samples in the first data set and the second data set by using a first living body detection model to obtain a first detection result comprises: extracting features of the first samples and the second samples by using the first living body detection model respectively to obtain first sample features of the first samples and second sample features of the second samples, and detecting the first sample features and the second sample features by using the first living body detection model respectively to obtain a detection result of the first samples and a detection result of the second samples; The loss calculation based on the first detection result, the first label and the third label to obtain a first loss comprises: perform loss calculation based on the detection result of the first sample and the first label of the first sample to obtain a first sub-loss, and perform loss calculation based on the detection result of the second sample and the third label of the second sample to obtain a second sub-loss; and perform weighted calculation on the first sub-loss and the second sub-loss to obtain the first loss.
4. The method of claim 3, wherein, Before the weighted calculation on the first sub-loss and the second sub-loss, the method further comprises: setting weights of the first sub-loss and the second sub-loss to make the first sub-loss greater than the second sub-loss.
5. The method of claim 1, wherein, The second label comprises labels of multiple categories, and the multiple categories comprise at least two of a category of a sample collection device, a category of sample collection illumination, an attribute category of a target object in a sample, and a category of sample image quality.
6. The method of claim 1, wherein, At least one category in the second label comprises a first sub-label and a second sub-label, and a proportion of samples having the first sub-label and a proportion of samples having the second sub-label in the first data set are both greater than a preset threshold.
7. The method of claim 1, wherein, The sample in the second data set further has a fourth label irrelevant to the living body detection task, and a category corresponding to the fourth label is consistent with a category corresponding to the second label. The method further comprises: performing classification processing on the sample in the second data set by at least the first living body detection model to obtain a second classification result, and performing loss calculation based on the second classification result and the fourth label to obtain a third loss; iteratively updating the first living body detection model to increase the third loss.
8. A method of detecting living matter, wherein, comprise: obtaining a to-be-detected image; processing the to-be-detected image by a living body detection model, the living body detection model being iteratively obtained by the method of any one of claims 1-7; outputting a detection result of whether the to-be-detected image is a living body. 9.A model iteration device based on incremental data, comprising: an obtaining module, configured to obtain a first data set and a second data set, samples in the second data set being incremental data, samples in the first data set having a first label and a second label, samples in the second data set having a third label, the first label and the third label both being related to a living body detection task, and the second label being irrelevant to the living body detection task; a processing module, configured to perform detection processing on the samples in the first data set and the second data set by a first living body detection model to obtain a first detection result, and perform loss calculation based on the first detection result, the first label and the third label to obtain a first loss, wherein the first living body detection model is trained based on the first data set and the first label; the processing module is further configured to perform classification processing on the samples in the first data set by at least the first living body detection model to obtain a first classification result, and perform loss calculation based on the first classification result and the second label to obtain a second loss. The processing module is further configured to iteratively update the first living body detection model based on the first loss and the second loss to obtain a second living body detection model.
10. A living body detecting apparatus, wherein, The method comprises: An acquisition module configured to acquire a to-be-detected image; A processing module configured to process the to-be-detected image by using a living body detection model, wherein the living body detection model is obtained by iteratively using the method according to any one of claims 1-7. The processing module is further configured to output a detection result of whether the to-be-detected image is a living body. 11.An electronic device, comprising: one or more processors; memory storing one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the method according to any one of claims 1-7, or implement the method according to claim 8. 12.A computer storage medium having stored instructions, when the instructions are executed on a computer, the computer is caused to implement the method according to any one of claims 1-7, or implement the method according to claim 8. 13.A computer program product comprising instructions, when the instructions are executed on a computer, the computer is caused to implement the method according to any one of claims 1-7, or implement the method according to claim 8.
Citation Information
Patent Citations
Detection model training method, living body detection method, device, equipment and medium
CN114360074A
Method and device for training target image retrieval model
CN114565807A