Skin detection model training method, skin detection method, device and electronic equipment

By iteratively optimizing the teacher and student models and combining multiple loss functions, the problems of slow convergence speed and low accuracy in skin detection model training were solved, achieving more efficient and stable skin detection model training and improving the ability to recognize deformed images.

CN116502700BActive Publication Date: 2026-02-27XIAMEN MEITUEVE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310410734.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-17
Publication Date
2026-02-27
Estimated Expiration
2043-04-17

AI Technical Summary

Technical Problem

In existing technologies, skin detection models suffer from slow training convergence speed, low accuracy, and poor stability and generalization.

Method used

A method of iterative optimization between the teacher model and the student model is adopted. The network parameters are updated by combining contrast loss, segmentation loss and deformation loss. The network parameters of the teacher model are updated using the network parameters of the student model. The parameters of the teacher model are optimized by using the exponential moving average algorithm.

Benefits of technology

It improves the training efficiency and accuracy of the model, enhances the model's stability and generalization, especially in deformable image recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116502700B_ABST
    Figure CN116502700B_ABST
Patent Text Reader

Abstract

The application provides a skin detection model training method, a skin detection method, a device and an electronic device, and relates to the technical field of image processing. The method comprises the following steps: acquiring a first sample facial image; identifying the first sample facial image by using a teacher model and a student model to obtain a first predicted facial sensitive area and a second predicted facial sensitive area; calculating a first contrast loss function value according to the first predicted facial sensitive area and the second predicted facial sensitive area; calculating a first segmentation loss function value according to the second predicted facial sensitive area and a sample facial sensitive area; calculating a total loss function value according to the first contrast loss function value and the first segmentation loss function value; updating network parameters of the student model according to the total loss function value; updating network parameters of the teacher model according to the updated network parameters of the student model to obtain a skin detection model. The application can improve the training efficiency of the model, improve the model precision, and enhance the stability and generalization of the model.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image processing, in particular to a skin detection model training method, a skin detection method, a device and an electronic device. BACKGROUND

[0002] The sensitive area of the face skin is the main external manifestation of the face skin sensitivity, and is an important indicator for measuring the face skin sensitivity.

[0003] Please refer to Figure 1 The traditional network training process is shown in FIG. 1, wherein the segmentation loss of the network output result is used for reverse gradient propagation to update the network parameters. Figure 1 The traditional network training process has a slow training convergence speed, low model accuracy, and poor stability and generalization. SUMMARY

[0004] The present application aims to improve the training efficiency of the model, improve the model accuracy, and enhance the stability and generalization of the model.

[0005] To achieve the above-mentioned purposes, the technical solutions adopted by the embodiments of the present application are as follows:

[0006] In a first aspect, the embodiments of the present application provide a skin detection model training method, which comprises the following steps:

[0007] Obtaining a sample face image set for the current training, wherein the sample face image set comprises a first sample face image with a sample label, and the sample label is used to indicate a sample face sensitive area in the first sample face image.

[0008] Using a teacher model to be trained and a student model to be trained to identify the first sample face image, to obtain a first predicted face sensitive area and a second predicted face sensitive area.

[0009] Calculating a first contrast loss function value according to the first predicted face sensitive area and the second predicted face sensitive area.

[0010] Calculating a first segmentation loss function value according to the second predicted face sensitive area and the sample face sensitive area.

[0011] Calculating a total loss function value according to the first contrast loss function value and the first segmentation loss function value.

[0012] Updating the network parameters of the student model according to the total loss function value.

[0013] updating the network parameters of the teacher model according to the updated network parameters of the student model, to obtain a skin detection model.

[0014] Optionally, the method further comprises:

[0015] performing random affine transformation on the first sample face image to generate a first sample morphing image;

[0016] identifying the first sample morphing image by using the student model to obtain a third predicted face sensitive region;

[0017] calculating a first morphing loss function value according to the second predicted face sensitive region and the third predicted face sensitive region;

[0018] calculating a total loss function value according to the first contrast loss function value and the first segmentation loss function value, comprises:

[0019] calculating a total loss function value according to the first contrast loss function value, the first segmentation loss function value and the first morphing loss function value.

[0020] Optionally, the first sample morphing image is labeled with a sample morphing sensitive region, and the method further comprises:

[0021] calculating a second segmentation loss function value according to the third predicted face sensitive region and the sample morphing sensitive region;

[0022] calculating a total loss function value according to the first contrast loss function value and the first segmentation loss function value, comprises:

[0023] calculating a total loss function value according to the first contrast loss function value, the first segmentation loss function value, the first morphing loss function value and the second segmentation loss function value.

[0024] Optionally, the sample face image set further comprises: a second sample face image without a sample label, and the method further comprises:

[0025] identifying the second sample face image by using the teacher model and the student model respectively to obtain a fourth predicted face sensitive region and a fifth predicted face sensitive region;

[0026] calculating a second contrast loss function value according to the fourth predicted face sensitive region and the fifth predicted face sensitive region;

[0027] calculating a total loss function value according to the contrast loss function value and the first segmentation loss function value, comprises:

[0028] According to the first contrast loss function value, the first segmentation loss function value, and the second contrast loss function value, a total loss function value is calculated.

[0029] Optionally, the method further comprises:

[0030] Optionally, the method further comprises:

[0031] Optionally, the method further comprises:

[0032] Optionally, the method further comprises:

[0033] The calculating of the total loss function value according to the first contrast loss function value and the first segmentation loss function value comprises:

[0034] The calculating of the total loss function value according to the first contrast loss function value, the first segmentation loss function value, the second contrast loss function value, and the second deformation loss function value comprises:

[0035] Optionally, the updating of the network parameters of the teacher model according to the updated network parameters of the student model to obtain the skin detection model comprises:

[0036] Optionally, the updating of the network parameters of the teacher model according to the updated network parameters of the student model to obtain the skin detection model comprises:

[0037] In a second aspect, an embodiment of the present application further provides a skin detection method, and the method comprises:

[0038] Obtaining a face image to be recognized;

[0039] Recognizing the face image to be recognized by using the skin detection model to determine a face sensitive region; wherein the skin detection model is trained by using the skin detection model training method in any one of the first aspect.

[0040] In a third aspect, an embodiment of the present application further provides a skin detection model training device, and the device comprises:

[0041] A sample image acquisition module is configured to acquire a sample face image set for a current training, and the sample face image set comprises a first sample face image with a sample label, wherein the sample label is used to indicate a sample face sensitive region in the first sample face image.

[0042] The sample recognition module uses the teacher model to be trained and the student model to be trained to recognize the first sample facial image, respectively, to obtain the first predicted facial sensitive region and the second predicted facial sensitive region.

[0043] The contrast loss calculation module is used to calculate the first contrast loss function value based on the first predicted facial sensitive region and the second predicted facial sensitive region.

[0044] The segmentation loss calculation module is used to calculate the first segmentation loss function value based on the second predicted facial sensitive region and the sample facial sensitive region;

[0045] The total loss calculation module is used to calculate the total loss function value based on the first comparison loss function value and the first segmentation loss function value;

[0046] The student model update module is used to update the network parameters of the student model based on the total loss function value.

[0047] The teacher model update module is used to update the network parameters of the teacher model based on the updated network parameters of the student model, thereby obtaining a skin detection model.

[0048] Optionally, the device further includes:

[0049] The deformation module is used to perform a random affine transformation on the first sample facial image to generate a first sample deformed image.

[0050] The sample recognition module is also used to recognize the first sample deformation image using the student model to obtain a third predicted facial sensitive region;

[0051] The deformation loss calculation module is used to calculate the first deformation loss function value based on the second predicted facial sensitive region and the third predicted facial sensitive region;

[0052] The total loss calculation module is specifically used to calculate the total loss function value based on the first comparison loss function value, the first segmentation loss function value, and the first deformation loss function value.

[0053] Optionally, the first sample deformation image is marked with sample deformation-sensitive areas, and the device further includes:

[0054] The segmentation loss calculation module is also used to calculate the second segmentation loss function value based on the third predicted facial sensitive region and the sample deformation sensitive region;

[0055] The total loss calculation module is specifically configured to calculate a total loss function value according to the first contrast loss function value, the first segmentation loss function value, the first deformation loss function value and the second segmentation loss function value.

[0056] Optionally, the set of sample face images further includes second sample face images without sample labels, and the device further includes:

[0057] The sample identification module is further configured to identify the second sample face images by using the teacher model and the student model respectively to obtain a fourth predicted face sensitive region and a fifth predicted face sensitive region.

[0058] The contrast loss calculation module is further configured to calculate a second contrast loss function value according to the fourth predicted face sensitive region and the fifth predicted face sensitive region.

[0059] The total loss calculation module is specifically configured to calculate a total loss function value according to the first contrast loss function value, the first segmentation loss function value and the second contrast loss function value.

[0060] Optionally, the deformation module is further configured to perform random affine transformation on the second sample face images to generate second sample deformation images.

[0061] The sample identification module is further configured to identify the second sample deformation images by using the student model to obtain a sixth predicted face sensitive region.

[0062] The deformation loss calculation module is further configured to calculate a second deformation loss function value according to the fifth predicted face sensitive region and the sixth predicted face sensitive region.

[0063] The total loss calculation module is specifically configured to calculate a total loss function value according to the first contrast loss function value, the first segmentation loss function value, the second contrast loss function value and the second deformation loss function value.

[0064] Optionally, the teacher model updating module is specifically configured to update network parameters of the teacher model by using a preset exponential moving average algorithm according to the updated network parameters of the student model to obtain a skin detection model.

[0065] In a fourth aspect, the embodiments of the present application further provide a skin detection device, which comprises:

[0066] An image acquisition module is configured to acquire a face image to be identified.

[0067] The identification module is configured to identify the face image to be identified by using a skin detection model to determine a face sensitive region, wherein the skin detection model is trained by using the skin detection model training method of any one of the first aspect.

[0068] In a fifth aspect, the embodiments of the present application further provide an electronic device, comprising a processor, a storage medium and a bus, the storage medium stores program instructions executable by the processor, when the electronic device is running, the processor and the storage medium communicate through the bus, and the processor executes the program instructions to perform the steps of the skin detection model training method according to any one of the first aspect or perform the steps of the skin detection method according to the second aspect.

[0069] In a sixth aspect, the embodiments of the present application further provide a computer readable storage medium, the storage medium stores a computer program, when the computer program is run by a processor, the steps of the skin detection model training method according to any one of the first aspect or the steps of the skin detection method according to the second aspect are performed.

[0070] The beneficial effects of the present application are:

[0071] The present application provides a skin detection model training method, a skin detection method, a device and an electronic device, which iteratively optimizes the teacher model and the student model, ensures the stability of the training process, improves the training effect and generalization of the model, updates the network parameters of the student model by using the contrast loss and the segmentation loss, which can improve the convergence speed of the student model, and on this basis, updating the parameters of the teacher model by using the network parameters of the student model can also improve the convergence speed of the teacher model, that is, improve the training efficiency of the teacher model; and compared with the existing method of directly updating the model parameters by using back propagation, the training method of the present application for updating the network parameters of the teacher model by using the network parameters of the student model is more stable, the precision of the skin detection model obtained by training is higher, and the effect is better. BRIEF DESCRIPTION OF DRAWINGS

[0072] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed in the embodiments. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as a limitation on the scope, and for those skilled in the art, other related drawings can also be obtained without creative labor on the basis of these drawings.

[0073] Figure 1 The traditional network training flowchart is shown in Figure 1.

[0074] Figure 2 The flowchart of the skin detection model training method provided by the embodiments of the present application is shown in Figure 2. Figure 1;

[0075] Figure 3 A flowchart of a skin detection model training method provided for an embodiment of the present application Figure 2 ;

[0076] Figure 4 A flowchart of a skin detection model training method provided for an embodiment of the present application Figure 3 ;

[0077] Figure 5 A flowchart of a skin detection model training method provided for an embodiment of the present application Figure 4 ;

[0078] Figure 6 A flowchart of a skin detection model training method provided for an embodiment of the present application Figure 5 ;

[0079] Figure 7 A flowchart of a skin detection model training method provided for an embodiment of the present application

[0080] Figure 8 A structural diagram of a skin detection model provided for an embodiment of the present application

[0081] Figure 9 A flowchart of a skin detection method provided for an embodiment of the present application

[0082] Figure 10 A structural diagram of a skin detection model training device provided for an embodiment of the present application

[0083] Figure 11 A structural diagram of a skin detection device provided for an embodiment of the present application

[0084] Figure 12 A schematic diagram of an electronic device provided for an embodiment of the present application. DETAILED DESCRIPTION

[0085] In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application.

[0086] Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.

[0087] Moreover, the terms "first", "second", and the like in the description and in the claims of the present application and above drawings are used for distinguishing between similar objects and not necessarily for describing a specific sequential or chronological order. It is to be understood that the use of such terms can be interchanged, in order to describe the embodiments of the present application, unless otherwise expressly specified and defined. Furthermore, the terms "comprise", "comprising", "include", "including", and the like are intended to cover non-exclusive inclusions, such that a process, method, system, product, or apparatus that comprises a list of steps or units not necessarily comprises only those steps or units, but can include other steps or units not expressly listed or inherent to such process, method, product, or apparatus.

[0088] It should be noted that the features of the embodiments of the present application can be combined with each other without conflict.

[0089] Before the skin detection model training method and the skin detection method provided by the embodiments of the present application are described, the electronic device to which the embodiments of the present application are applied is described.

[0090] The electronic device executing the skin detection model training method and the electronic device executing the skin detection method can be the same electronic device or different electronic devices. If they are different electronic devices, the electronic device executing the skin detection model training method can be a computer device. After the training is completed and the skin detection model is obtained, the skin detection model is deployed in the electronic device executing the skin detection method. The electronic device executing the skin detection method can be a skin detector or a smart terminal. The skin detector and the smart terminal have a camera function and a computing capability. The face image to be recognized is obtained through the skin detector or the smart terminal, and the face image to be recognized is input into the deployed skin detection model for image recognition, and the recognized face sensitive area is output.

[0091] Please refer to Figure 2 The flowchart of the skin detection model training method provided by the embodiments of the present application is shown in Figure 1 As shown in Figure 2 The method can include:

[0092] S101: Obtain a sample face image set for current training.

[0093] The sample face image set includes: a first sample face image with a sample label, and the sample label is used to indicate a sample face sensitive area in the first sample face image.

[0094] In this embodiment, a sample face image set for training a skin detection model is obtained, the sample image set includes a plurality of first sample face images, and part or all of the first sample face images in the sample face image set are used to participate in each round of training (epoch) of the skin detection model. The first sample face image is pre-labeled with a sample face sensitive region.

[0095] In some embodiments, a skin detector, a smart terminal or a camera device can be used to collect a plurality of face images as a sample face image set. In order to ensure the accuracy of the skin sensitive region detection, the face images can be collected in an environment that is closed, well-lit and evenly illuminated. Further, in order to improve the generalization of the skin detection model, the face images can also be collected in some complex light scenes, which is not limited in this embodiment.

[0096] In a possible implementation, before the first sample face image is input into the model, the first sample face image can be gain-processed to obtain a gain-processed first sample face image as the input of the model. The gain processing can include random cropping, random noise addition, blurring and the like.

[0097] S102: The first sample face image is recognized by using the teacher model to be trained and the student model to be trained respectively, and the first predicted face sensitive region and the second predicted face sensitive region are obtained.

[0098] In this embodiment, the teacher model and the student model are two models with the same structure but different network parameters, and the teacher model and the student model are in an untrained state. The sample face image is input into the teacher model and the student model for image recognition, the first preset face sensitive region is input through the teacher model, and the second preset face sensitive region is output through the student model.

[0099] S103: The first contrast loss function value is calculated according to the first predicted face sensitive region and the second predicted face sensitive region.

[0100] In this embodiment, since the output of the teacher model is more accurate and stable than that of the student model, it is expected that the output of the student model can be closer to the output of the teacher model when the inputs of the teacher model and the student model are the same. The first contrast loss function value is determined by calculating the difference between the first predicted face sensitive region and the second predicted face sensitive region.

[0101] For example, the difference between the first predicted face sensitive region and the second predicted face sensitive region can be calculated by using cosinembeddingloss to determine the first contrast loss function value.

[0102] S104: Calculate a first segmentation loss function value according to the second predicted facial sensitive region and the sample facial sensitive region.

[0103] In this embodiment, the sample facial sensitive region is pre-labeled in the first sample facial image, and the difference between the second predicted facial sensitive region and the sample facial sensitive region can be calculated to determine the first segmentation loss function value.

[0104] For example, the CE loss, dice loss, or other loss calculation function can be used to calculate the difference between the second predicted facial sensitive region and the sample facial sensitive region to determine the first segmentation loss function value.

[0105] S105: Calculate a total loss function value according to the first contrast loss function value and the first segmentation loss function value.

[0106] In this embodiment, the total loss of the plurality of first sample facial images is calculated by weighting the first contrast loss function value and the first segmentation loss function value of the plurality of first sample facial images participating in the current round of training, and the total loss of the plurality of first sample facial images is accumulated to calculate the total loss function value of the current round.

[0107] S106: Update the network parameters of the student model according to the total loss function value.

[0108] In this embodiment, the network parameters of the student model are updated using backpropagation according to the total loss function value. Specifically, the loss gradient is calculated using the total loss function value, the network parameter change value is calculated according to the loss gradient, and the updated network parameters of the student model are calculated according to the network parameter change value and the current network parameters of the student model.

[0109] S107: Update the network parameters of the teacher model according to the updated network parameters of the student model to obtain a skin detection model.

[0110] In this embodiment, the updated network parameters of the teacher model are calculated according to the updated network parameters of the student model and the current network parameters of the teacher model.

[0111] The teacher model and the student model after updating the network parameters continue to be trained using the training method of S101-S107 described above for multiple rounds until the teacher model converges, and the training is stopped. The converged teacher model is the skin detection model, which is used for sensitive region recognition of a to-be-recognized facial image and outputs the recognized facial sensitive region.

[0112] In one possible implementation, the above S107 updates the network parameters of the teacher model according to the updated network parameters of the student model to obtain a skin detection model, which can include:

[0113] According to the updated network parameters of the student model, the network parameters of the teacher model are updated by using a preset exponential moving average algorithm, and a skin detection model is obtained.

[0114] In this embodiment, the exponential moving average algorithm (EMA) refers to the reference to the parameters of the previous update of the model, i.e., the parameters used by the model in the current training process. The update of the parameters of the teacher model in this embodiment not only refers to the current network parameters of the teacher model, but also refers to the updated network parameters of the student model.

[0115] Specifically, the updated network parameters of the student model and the current network parameters of the teacher model are weighted and summed to obtain the updated network parameters of the teacher model.

[0116] For example, the calculation formula can be: V_t=beta*V_t-1+(1-beta)*theta_t

[0117] Wherein, Vt-1 is the network parameter of the teacher model in the current round, beta is the update coefficient, which is set to 0.9 in this embodiment, theta_t is the updated network parameter of the student model in the current round, and Vt is the updated network parameter of the teacher model in the current round.

[0118] By performing multiple rounds of model training, the model parameters after each round of training are saved, and the teacher model with the highest precision and the best index is selected from the multiple groups of model parameters as the skin detection model. For example, this embodiment performs more than 200 rounds of training, and the teacher model is stable in the later training period and has relatively high precision. The teacher model with the best precision and index is selected from the last few rounds as the skin detection model.

[0119] Because the effect of the teacher model is better than that of the student model during the training process, the training of the student model is led by the teacher model, so that the effect of the student model is improved. In the case that the effect of the student model is better, the network parameters of the teacher model updated by the EMA algorithm according to the network parameters of the student model are also better than the network parameters of the student model.

[0120] The skin detection model training method provided in the above embodiments iteratively optimizes the teacher model and the student model, ensures the stability of the training process, improves the training effect and generalization of the model, updates the network parameters of the student model using the contrast loss and the segmentation loss, which can improve the convergence speed of the student model, and on this basis, updating the parameters of the teacher model using the network parameters of the student model can also improve the convergence speed of the teacher model, that is, improve the training efficiency of the teacher model; and compared with the existing method of directly updating the model parameters using back propagation, the training method of updating the network parameters of the teacher model using the network parameters of the student model is more stable, and the precision of the skin detection model obtained by training is higher and the effect is better.

[0121] In a possible implementation, refer to Figure 3 The flowchart of the skin detection model training method provided in the embodiments of the present application is shown in Figure 2 As shown in Figure 3 The method can further include the following steps.

[0122] S201: Perform random affine transformation on the first sample face image to generate a first sample morphed image.

[0123] In this embodiment, in order to further improve the generalization ability of the skin detection model and improve the detection accuracy of images with deformation, the first sample face image can be morphed to obtain a first sample morphed image during model training.

[0124] Specifically, the first sample face image is subjected to affine transformation using a preset morphing matrix to obtain the first sample morphed image.

[0125] S202: Identify the first sample morphed image using the student model to obtain a third predicted face sensitive region.

[0126] In this embodiment, the first sample face image and the first sample morphed image are spliced and input into the student model, and the student model identifies the first sample face image and the first sample morphed image respectively to obtain a second predicted face sensitive region and a third predicted face sensitive region.

[0127] S203: Calculate a first morphing loss function value according to the second predicted face sensitive region and the third predicted face sensitive region.

[0128] In this embodiment, in order to ensure that the student model can still maintain stable output when the input image is deformed, the difference between the second predicted face sensitive region and the third predicted face sensitive region can be calculated to determine the first morphing loss function value. The smaller the first morphing loss function value is, the higher the stability of the student model is.

[0129] The difference between the second predicted facial sensitive region and the third predicted facial sensitive region can be calculated by using a loss calculation function such as a transinv loss, a Jacobian loss or the like, and the first deformation loss function value is determined.

[0130] The total loss function value is calculated according to the first contrast loss function value and the first segmentation loss function value in S105.

[0131] S204: The total loss function value is calculated according to the first contrast loss function value, the first segmentation loss function value and the first deformation loss function value.

[0132] In this embodiment, for the plurality of first sample facial images of the labeled sample facial sensitive region in the current round, the total loss of the plurality of first sample facial images is calculated by weighting according to the first contrast loss function value, the first segmentation loss function value and the first deformation loss function value, the total loss of the plurality of first sample facial images is accumulated, and the total loss function value of the current round is calculated.

[0133] The skin detection model training method provided in the above embodiment can recognize the third predicted facial sensitive region from the first sample deformation image obtained by deforming the first sample facial image, calculate the total loss function value according to the first deformation loss function value of the second predicted facial sensitive region and the third predicted facial sensitive region, combine the first contrast loss function value and the first segmentation loss function value, deform the sample image, and add the deformation loss in the loss function. On the one hand, the convergence speed of the student model can be accelerated, thereby accelerating the convergence speed of the teacher model; on the other hand, the student model and the teacher model can have stable output after training in the case of input with slight deformation, and the stability and generalization of the skin detection model are improved, so as to improve the ability and accuracy of recognizing the deformed image.

[0134] In a possible implementation, please refer to Figure 4 The flowchart of the skin detection model training method provided in the embodiment of the present application is shown in Figure 3 As shown in Figure 4 The method can further include:

[0135] S205: The second segmentation loss function value is calculated according to the third predicted facial sensitive region and the sample deformation sensitive region.

[0136] In this embodiment, the first sample facial image is pre-labeled with a sample facial sensitive region, and after the sample facial image is deformed to obtain the first sample deformation image, the sample facial sensitive region is also deformed, the first sample deformation image is labeled with a sample deformation sensitive region, the difference between the third predicted facial sensitive region and the sample facial sensitive region can be calculated, and the second segmentation loss function value is determined.

[0137] In an example, the difference between the third predicted facial sensitive region and the sample facial sensitive region can be calculated by using a loss calculation function such as a CE loss or a dice loss, and the second segmentation loss function value can be determined.

[0138] The total loss function value can be calculated according to the first contrast loss function value and the first segmentation loss function value in S105, including:

[0139] S206: Calculate the total loss function value according to the first contrast loss function value, the first segmentation loss function value, the first deformation loss function value, and the second segmentation loss function value.

[0140] In this embodiment, the first contrast loss function value, the first segmentation loss function value, the first deformation loss function value, and the second segmentation loss function value are calculated for the plurality of first sample facial images of the current round of labeled sample facial sensitive regions and the corresponding first sample deformation images, the total loss of the plurality of first sample facial images is weighted calculated, the total loss of the plurality of first sample facial images is accumulated, and the total loss function value of the current round is calculated.

[0141] The skin detection model training method provided in the above embodiments uses the superposition of the first contrast loss, the first segmentation loss, the first deformation loss, and the second segmentation loss to jointly participate in the update of the network parameters. More types of loss for updating the network parameters can make the training process more stable, faster in convergence, and improve the generalization of the skin detection model.

[0142] In a possible implementation, in order to increase more training samples without increasing the labeling cost, the sample facial image of the unlabeled sample sensitive region can be used as the second sample facial image. The process of the second sample facial image participating in the model training will be described below in combination with the embodiments.

[0143] Please refer to Figure 5 The flowchart of the skin detection model training method provided in the embodiments of the present application is shown in Figure 4 As shown in Figure 5 The method can further include:

[0144] S301: The second sample facial image is identified by using the teacher model and the student model respectively to obtain the fourth predicted facial sensitive region and the fifth predicted facial sensitive region.

[0145] In this embodiment, the second sample facial image is input into the teacher model and the student model for image recognition, the fourth preset facial sensitive region is input through the teacher model, and the fifth preset facial sensitive region is output through the student model.

[0146] S302: Calculate the second contrast loss function value according to the fourth predicted face sensitive region and the fifth predicted face sensitive region.

[0147] In the embodiment, the second contrast loss function value is determined by calculating the difference between the fourth predicted face sensitive region and the fifth predicted face sensitive region.

[0148] In the example, the difference between the fourth predicted face sensitive region and the fifth predicted face sensitive region can be calculated by using cosinembeddingloss to determine the second contrast loss function value.

[0149] The above S105: According to the first contrast loss function value and the first segmentation loss function value, the total loss function value is calculated, which can include:

[0150] S303: Calculate the total loss function value according to the first contrast loss function value, the first segmentation loss function value and the second contrast loss function value.

[0151] In the embodiment, the total loss of the plurality of first sample face images is calculated by weighting the first contrast loss function value and the first segmentation loss function value of the plurality of first sample face images participating in the current round of training, and the total loss of the plurality of first sample face images and the second contrast loss function value of the plurality of second sample face images participating in the current round of training are accumulated to calculate the total loss function value of the current round.

[0152] In the training of the current round, the first contrast loss and the first segmentation loss are calculated for the first sample face image with labeled sample face sensitive region, and only the second contrast loss is calculated for the second sample face image without labeled sample face sensitive region. Through experimental comparison, it is determined that the skin detection model training method provided in the embodiment improves the training index of the traditional model training method by 1.2%. The training based on unlabeled images and labeled images makes the training process become semi-supervised training. Under the condition that the number of labeled images is the same, by adding unlabeled images for semi-supervised training, the training effect and generalization of the model can be further improved, and the training execution is further improved by 0.8%, a total of 2%. And in the case of increasing the number of training samples, it will not increase the time cost and labor cost of labeling.

[0153] The skin detection model training method provided in the above embodiment includes labeled images and unlabeled images, the labeled sample facial images are used to calculate the first contrast loss function value and the first segmentation loss function value, and the unlabeled sample facial images are used to calculate the second contrast loss function value, so that semi-supervised model training is implemented. Compared with the traditional training method using only labeled images, the training effect and generalization of the model can be improved under the condition of the same amount of labeled data, and the training of the unlabeled sample facial images can reduce the labeling cost.

[0154] In a possible implementation, refer to Figure 6 The flowchart of the skin detection model training method provided in the embodiment of the present application is shown in Figure 5 As shown in Figure 6 The method can further include the following steps:

[0155] S304: The second sample facial image is subjected to random affine transformation to generate a second sample morphed image.

[0156] In the embodiment, in order to further improve the generalization ability of the skin detection model and improve the detection accuracy of the image with deformation, the second sample facial image can be subjected to morphing processing to obtain a second sample morphed image during model training.

[0157] Specifically, the second sample facial image can be subjected to affine transformation by using a preset morphing matrix to obtain a second sample morphed image.

[0158] S305: The student model is used to recognize the second sample morphed image to obtain a sixth predicted facial sensitive region.

[0159] In the embodiment, the second sample facial image and the second sample morphed image are spliced and input into the student model, and the student model recognizes the second sample facial image and the second sample morphed image respectively to obtain a fifth predicted facial sensitive region and a sixth predicted facial sensitive region.

[0160] S306: The second morphing loss function value is calculated according to the fifth predicted facial sensitive region and the sixth predicted facial sensitive region.

[0161] In the embodiment, in order to ensure that the student model can still maintain stable output when the input image is deformed, the difference between the fifth predicted facial sensitive region and the sixth predicted facial sensitive region can be calculated to determine the second morphing loss function value. The smaller the second morphing loss function value is, the higher the stability of the student model is.

[0162] The difference between the fifth predicted facial sensitive region and the sixth predicted facial sensitive region can be calculated by using a loss calculation function such as a transinv loss or a Jacobian loss, and a second deformation loss function value can be determined.

[0163] The total loss function value can be calculated according to the first contrast loss function value and the first segmentation loss function value in S105.

[0164] S307: Calculate the total loss function value according to the first contrast loss function value, the first segmentation loss function value, the second contrast loss function value, and the second deformation loss function value.

[0165] In the embodiment, the total loss of the plurality of first sample facial images of the labeled sample facial sensitive region of the current round is weighted and calculated according to the first contrast loss function value and the first segmentation loss function value, the total loss of the plurality of second sample facial images of the unlabeled sample facial sensitive region of the current round is weighted and calculated according to the second contrast loss function value and the second deformation loss function value, and the total loss of the plurality of first sample facial images and the total loss of the plurality of second sample facial images are accumulated to calculate the total loss function value of the current round.

[0166] The skin detection model training method provided in the above embodiments performs deformation on the sample image and adds a deformation loss in the loss function, which can accelerate the convergence speed of the student model and thus accelerate the convergence speed of the teacher model, and can also enable the student model and the teacher model to have stable output after training even when inputting images with slight deformation, thereby improving the stability and generalization of the skin detection model and enhancing the ability and accuracy of recognizing deformed images.

[0167] It should be noted that the above embodiments exemplarily illustrate a scheme of calculating the total loss function value according to various combinations of loss function values, but the combinations of loss function values are not limited to the above embodiments, and each loss function value can be combined according to the needs of the training process.

[0168] Please refer to Figure 7 The flowchart of the skin detection model training method provided in the embodiments of the present application is shown in FIG. 1. Figure 7 The process can include:

[0169] The sample image imgs is subjected to a regular gain to obtain sample image imgs0. Imgs0 is then deformed using a preset deformation matrix M to obtain deformed image imgs1. Imgs0 is input separately into the teacher model, which outputs the predicted facial sensitive region tea_imgs0_out. Imgs0 and deformed image imgs1 are concatenated and input into the student model, which outputs the predicted facial sensitive regions stu_imgs0_out and stu_imgs1_out respectively. The predicted facial sensitive regions tea_imgs0_out and stu_imgs0_out are then compared. The contrast loss is calculated for out, and the deformation loss is calculated for the predicted facial sensitive regions stu_imgs0_out and stu_imgs1_out. If the sample image imgs0 has a sample label mask, the segmentation loss is calculated between the predicted facial sensitive region stu_imgs0_out and the sample label mask. The segmentation loss is calculated between the predicted facial sensitive region stu_imgs1_out and the deformation label corresponding to the sample label mask. The network parameters of the student model are updated based on the contrast loss, deformation loss, and / or segmentation loss. The parameters of the teacher model are updated based on the network parameters of the student model to obtain the skin detection model.

[0170] Please refer to Figure 8 This is a schematic diagram of the structure of the skin detection model provided in the embodiments of this application, as shown below. Figure 8 As shown, the skin detection model provided in this embodiment includes an encoding module, a fusion module, and a decoding module. The encoding module adopts an STDC (Short-Term Dense Concatenate Module) network structure. The encoding module has fewer stages, which can reduce the number of channels and reduce the network size while ensuring network capacity.

[0171] The fusion module is PPM (Pyramid Pooling Module), which can fuse image information of different scales to improve network accuracy.

[0172] The decoding module consists of multiple stacked upsample blocks, each upsample block being composed of ConvBNRelu+Conv+Upsample.

[0173] Based on the aforementioned skin detection model, this application also provides a skin detection method. Please refer to... Figure 9 This is a schematic flowchart of the skin detection method provided in the embodiments of this application, as shown below. Figure 9 As shown, the method may include:

[0174] S201: Obtain a face image to be recognized.

[0175] S202: Identify the face image to be recognized by using a skin detection model to determine a face sensitive region.

[0176] The skin detection model is trained by using the skin detection model training method in the above embodiment.

[0177] In this embodiment, the skin detection model trained by using the above embodiment is deployed into a skin detector or a smart terminal, and the skin detector or the smart terminal performs a skin detection method by using the skin detection model to determine a face sensitive region in the face image to be recognized.

[0178] Based on the above method embodiment, the present embodiment further provides a skin detection model training device. Please refer to Figure 10 The structure diagram of the skin detection model training device provided by the present embodiment is shown in Figure 10 The device can include:

[0179] A sample image acquisition module 11 is configured to acquire a sample face image set for current training, and the sample face image set includes a first sample face image with a sample label, and the sample label is used to indicate a sample face sensitive region in the first sample face image.

[0180] A sample identification module 12 is configured to identify the first sample face image by using a teacher model to be trained and a student model to be trained to obtain a first predicted face sensitive region and a second predicted face sensitive region.

[0181] A contrast loss calculation module 13 is configured to calculate a first contrast loss function value according to the first predicted face sensitive region and the second predicted face sensitive region.

[0182] A segmentation loss calculation module 14 is configured to calculate a first segmentation loss function value according to the second predicted face sensitive region and the sample face sensitive region.

[0183] A total loss calculation module 15 is configured to calculate a total loss function value according to the first contrast loss function value and the first segmentation loss function value.

[0184] A student model updating module 16 is configured to update network parameters of the student model according to the total loss function value.

[0185] A teacher model updating module 17 is configured to update network parameters of the teacher model according to the updated network parameters of the student model to obtain a skin detection model.

[0186] Optionally, the device can further include:

[0187] a deformation module configured to perform random affine transformation on the first sample face image to generate a first sample deformation image;

[0188] The sample recognition module 12 is further configured to recognize the first sample deformation image by using the student model to obtain a third predicted face sensitive region.

[0189] a deformation loss calculation module configured to calculate a first deformation loss function value according to the second predicted face sensitive region and the third predicted face sensitive region.

[0190] The total loss calculation module 15 is specifically configured to calculate a total loss function value according to the first contrast loss function value, the first segmentation loss function value and the first deformation loss function value.

[0191] Optionally, the first sample deformation image is labeled with a sample deformation sensitive region, and the device can further include:

[0192] The segmentation loss calculation module 14 is further configured to calculate a second segmentation loss function value according to the third predicted face sensitive region and the sample deformation sensitive region.

[0193] The total loss calculation module 15 is specifically configured to calculate a total loss function value according to the first contrast loss function value, the first segmentation loss function value, the first deformation loss function value and the second segmentation loss function value.

[0194] Optionally, the sample face image set further includes a second sample face image without a sample label, and the device can further include:

[0195] The sample recognition module 12 is further configured to recognize the second sample face image by using the teacher model and the student model respectively to obtain a fourth predicted face sensitive region and a fifth predicted face sensitive region.

[0196] The contrast loss calculation module 13 is further configured to calculate a second contrast loss function value according to the fourth predicted face sensitive region and the fifth predicted face sensitive region.

[0197] The total loss calculation module 15 is specifically configured to calculate a total loss function value according to the first contrast loss function value, the first segmentation loss function value and the second contrast loss function value.

[0198] Optionally, the deformation module is further configured to perform random affine transformation on the second sample face image to generate a second sample deformation image.

[0199] The sample recognition module 12 is further configured to recognize the second sample deformation image by using the student model to obtain a sixth predicted face sensitive region.

[0200] The deformation loss calculation module is also used to calculate the second deformation loss function value based on the fifth and sixth predicted facial sensitive regions;

[0201] The total loss calculation module 15 is specifically used to calculate the total loss function value based on the first contrast loss function value, the first segmentation loss function value, the second contrast loss function value, and the second deformation loss function value.

[0202] Optionally, the teacher model update module 17 is specifically used to update the network parameters of the teacher model based on the updated network parameters of the student model, using a preset exponential moving average algorithm, to obtain the skin detection model.

[0203] Based on the above method embodiments, this application also provides a skin detection device. Please refer to... Figure 11 This is a schematic diagram of the skin detection device provided in the embodiments of this application, as shown below. Figure 11 As shown, the device may include:

[0204] Image acquisition module 21 is used to acquire the face image to be recognized;

[0205] The recognition module 22 is used to recognize the facial image to be recognized using a skin detection model and determine the sensitive areas of the face; wherein the skin detection model is trained using the skin detection model training method of any one of the first aspects.

[0206] The above-described device is used to execute the method provided in the foregoing embodiments, and its implementation principle and technical effect are similar, so they will not be described again here.

[0207] These modules can be one or more integrated circuits configured to implement the above methods, such as one or more Application Specific Integrated Circuits (ASICs), one or more microprocessors, or one or more Field Programmable Gate Arrays (FPGAs). Alternatively, when a module is implemented using processing element scheduler code, the processing element can be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. Furthermore, these modules can be integrated together as a system-on-a-chip (SOC).

[0208] Please refer to Figure 12 This is a schematic diagram of the electronic device provided in the embodiments of this application, such as... Figure 12As shown, the electronic device 100 includes a processor 110, a storage medium 120, and a bus. The storage medium 120 stores program instructions executable by the processor 110. When the electronic device 100 is running, the processor 110 communicates with the storage medium 120 through the bus. The processor 110 executes the program instructions to perform the embodiments of the skin detection model training method as described above, or perform the embodiments of the skin detection method as described above. The specific implementation and technical effects are similar, and will not be repeated here.

[0209] Optionally, the embodiments of the present application further provide a computer readable storage medium, and the storage medium stores a computer program. The computer program is run by a processor to perform the embodiments of the skin detection model training method as described above, or perform the embodiments of the skin detection method as described above. The specific implementation and technical effects are similar, and will not be repeated here.

[0210] In several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented by other means. For example, the apparatus embodiments described above are only schematic, for example, the division of the units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units or components shown or discussed can be indirect coupling or communication connection through some interfaces, devices or units, and can be electrical, mechanical or other forms.

[0211] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on a plurality of network units. According to actual needs, part or all of the units can be selected to achieve the purpose of the embodiment scheme.

[0212] In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of hardware plus software functional unit.

[0213] The integrated unit in the form of software function unit can be stored in a computer readable storage medium. The software function unit is stored in a storage medium, and includes a plurality of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute part of steps of the method according to various embodiments of the present application. The storage medium includes a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various storage media capable of storing program codes.

[0214] The above merely describes specific embodiments of the present application, but the protection scope of the present application is not limited thereto, and any person skilled in the art can easily think of changes or replacements within the technical scope disclosed by the present application, which should be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A method of training a skin detection model, the method comprising: obtaining a plurality of skin detection model parameters; and training the skin detection model using the plurality of skin detection model parameters. The method comprises: obtaining a sample facial image set of a current training, wherein the sample facial image set comprises a first sample facial image with a sample label, and the sample label is used to indicate a sample facial sensitive region in the first sample facial image; using a teacher model to be trained and a student model to be trained to respectively identify the first sample facial image, to obtain a first predicted facial sensitive region and a second predicted facial sensitive region; calculating a first contrast loss function value according to the first predicted facial sensitive region and the second predicted facial sensitive region; calculating a first segmentation loss function value according to the second predicted facial sensitive region and the sample facial sensitive region; calculating a total loss function value according to the first contrast loss function value and the first segmentation loss function value; updating network parameters of the student model according to the total loss function value; updating network parameters of the teacher model according to the updated network parameters of the student model, to obtain a skin detection model; The method further comprises: performing random affine transformation on the first sample facial image to generate a first sample morphing image; using the student model to identify the first sample morphing image, to obtain a third predicted facial sensitive region; calculating a first morphing loss function value according to the second predicted facial sensitive region and the third predicted facial sensitive region; The total loss function value is calculated according to the first contrast loss function value and the first segmentation loss function value, comprising: The total loss function value is calculated according to the first contrast loss function value, the first segmentation loss function value and the first morphing loss function value.

2. The method of claim 1, wherein, The first sample morphing image is labeled with a sample morphing sensitive region, and the method further comprises: calculating a second segmentation loss function value according to the third predicted facial sensitive region and the sample morphing sensitive region; The total loss function value is calculated according to the first contrast loss function value and the first segmentation loss function value, comprising: The total loss function value is calculated according to the first contrast loss function value, the first segmentation loss function value, the first morphing loss function value and the second segmentation loss function value.

3. The method of claim 1, wherein, The network parameters of the teacher model are updated according to the updated network parameters of the student model, to obtain a skin detection model, comprising: The network parameters of the teacher model are updated according to the updated network parameters of the student model, to obtain a skin detection model, comprising: 4.A method for training a skin detection model, characterized in that, The method comprises: obtaining a sample facial image set of a current training, wherein the sample facial image set comprises a first sample facial image with a sample label, and the sample label is used to indicate a sample facial sensitive region in the first sample facial image; using a teacher model to be trained and a student model to be trained to respectively identify the first sample facial image, to obtain a first predicted facial sensitive region and a second predicted facial sensitive region; calculating a first contrast loss function value according to the first predicted facial sensitive region and the second predicted facial sensitive region; calculate a first segmentation loss function value according to the second predicted facial sensitive region and the sample facial sensitive region; calculate a total loss function value according to the first contrast loss function value and the first segmentation loss function value; update network parameters of the student model according to the total loss function value; update network parameters of the teacher model according to the updated network parameters of the student model to obtain a skin detection model; the sample facial image set further includes a second sample facial image without a sample label, and the method further includes: identify the second sample facial image by using the teacher model and the student model respectively to obtain a fourth predicted facial sensitive region and a fifth predicted facial sensitive region; calculate a second contrast loss function value according to the fourth predicted facial sensitive region and the fifth predicted facial sensitive region; perform random affine transformation on the second sample facial image to generate a second sample morphological image; identify the second sample morphological image by using the student model to obtain a sixth predicted facial sensitive region; calculate a second morphological loss function value according to the fifth predicted facial sensitive region and the sixth predicted facial sensitive region; the total loss function value is calculated according to the first contrast loss function value and the first segmentation loss function value, including: the total loss function value is calculated according to the first contrast loss function value, the first segmentation loss function value, the second contrast loss function value, and the second morphological loss function value.

5. The method of claim 4, wherein, the network parameters of the teacher model are updated according to the updated network parameters of the student model to obtain a skin detection model, including: the network parameters of the teacher model are updated by using a preset exponential moving average algorithm according to the updated network parameters of the student model to obtain a skin detection model.

6. A skin detection method characterized by, the method includes: obtain a to-be-identified facial image; identify the to-be-identified facial image by using a skin detection model to determine a facial sensitive region; wherein the skin detection model is trained by using the skin detection model training method in any one of claims 1 to 5. 7.A skin detection model training apparatus, characterized by comprising: the device includes: a sample image acquisition module, configured to obtain a sample facial image set for current training, the sample facial image set including a first sample facial image with a sample label, the sample label being used to indicate a sample facial sensitive region in the first sample facial image; a sample identification module, configured to identify the first sample facial image by using a teacher model to be trained and a student model to be trained respectively to obtain a first predicted facial sensitive region and a second predicted facial sensitive region; a contrast loss calculation module, configured to calculate a first contrast loss function value according to the first predicted facial sensitive region and the second predicted facial sensitive region; a segmentation loss calculation module, configured to calculate a first segmentation loss function value according to the second predicted facial sensitive region and the sample facial sensitive region; a total loss calculation module, configured to calculate a total loss function value according to the first contrast loss function value and the first segmentation loss function value; The student model updating module is configured to update network parameters of the student model according to the total loss function value. The teacher model updating module is configured to update network parameters of the teacher model according to the updated network parameters of the student model, to obtain the skin detection model. The device further comprises: The deformation module is configured to perform random affine transformation on the first sample face image to generate a first sample deformation image. The sample recognition module is further configured to recognize the first sample deformation image by using the student model to obtain a third predicted face sensitive region. The deformation loss calculation module is configured to calculate a first deformation loss function value according to the second predicted face sensitive region and the third predicted face sensitive region. The total loss calculation module is specifically configured to calculate a total loss function value according to the first contrast loss function value, the first segmentation loss function value, and the first deformation loss function value.

8. A skin detection apparatus, characterized by The device comprises: The image acquisition module is configured to acquire a face image to be recognized. The recognition module is configured to recognize the face image to be recognized by using a skin detection model to determine a face sensitive region, wherein the skin detection model is trained by using the skin detection model training method according to any one of claims 1 to 5.

9. An electronic device, comprising: The device comprises: A processor, a storage medium, and a bus, the storage medium stores program instructions executable by the processor, when the electronic device is running, the processor and the storage medium communicate through the bus, the processor executes the program instructions to execute the steps of the skin detection model training method according to any one of claims 1 to 5, or execute the steps of the skin detection method according to claim 6.

Citation Information

Patent Citations

  • Leukocyte classified counting method based on small sample semi-supervised learning

    CN112801212A

  • Model training method, identification method, device, storage medium and program product

    US20210406579A1