CN-115424294-B - Training method of wearing detection model, wearing detection method and related equipment
Abstract
The application discloses a training method of a wearing detection model, the wearing detection method and related equipment, wherein the wearing detection model comprises a feature extraction layer, an attribute prediction layer and a category prediction layer; the method comprises the steps of inputting a training sample image into a feature extraction layer to obtain sample extraction features, inputting the sample extraction features into an attribute prediction layer to obtain sample wearing attribute features, inputting the sample extraction features into a category prediction layer to obtain sample identity features, calculating training loss corresponding to the training sample image based on the sample wearing attribute features, the sample identity features and the sample extraction features, and training a wearing detection model based on the training loss to obtain a trained wearing detection model. By means of the method, the wearing detection precision of the trained wearing detection model can be improved.
Inventors
- ZHENG HUIZHONG
- TANG BANGJIE
- PAN HUADONG
- YIN JUN
- ZHENG SHAOFEI
Assignees
- 浙江大华技术股份有限公司
- 浙江大华技术股份有限公司
Dates
- Publication Date
- 20260421
- Application Date
- 20220727
- Priority Date
- 20220727
Claims (9)
- 1. A training method of a wearable detection model, wherein the wearable detection model includes a feature extraction layer, an attribute prediction layer, and a category prediction layer, the method comprising: acquiring a training sample image; inputting the training sample image into the feature extraction layer to obtain sample extraction features; Inputting the sample extraction features into the attribute prediction layer to obtain sample wearing attribute features; inputting the sample extraction features into the category prediction layer to obtain sample identity features; calculating training loss corresponding to the training sample image based on the sample wearing attribute features, the sample identity features and the sample extraction features; training the wearing detection model based on the training loss to obtain a trained wearing detection model; The training sample image comprises a target sample image, a positive sample image and a negative sample image, and the step of acquiring the training sample image comprises the following steps: acquiring a preset training sample set and the target sample image, wherein the preset training sample set comprises a plurality of sample image sets; Selecting the positive sample image and the negative sample image from the plurality of sample image sets based on the target sample image; The step of selecting the positive sample image and the negative sample image from the plurality of sample image sets based on the target sample image includes: Selecting a sample image set which has the same wearing attribute characteristics and the same identity characteristics as the target sample image from the preset training sample set to obtain a positive sample image set; Randomly selecting one sample image from the positive sample image set to obtain the positive sample image; selecting a sample image set with different identity characteristics from the preset training sample set to obtain a negative sample image set; randomly selecting a sample image from the negative sample image set to obtain the negative sample image; the step of selecting a sample image set with different identity characteristics from the preset training sample set to obtain a negative sample image set comprises the following steps: Selecting a first preset number of sample image sets which are the same as the wearing attribute features of the target sample image and different in identity features from the preset training sample set to obtain a first negative sample image set; randomly selecting a second preset number of sample image sets which are different from the identity characteristics of the target sample image from the preset training sample set to obtain a second negative sample image set; The step of selecting a first preset number of sample image sets which are the same as the wearing attribute features of the target sample image and different in identity features from the preset training sample set to obtain the first negative sample image set comprises the following steps of: and respectively selecting a plurality of sample image sets which are the same as each sub-attribute feature of the target sample image and different in identity feature from the preset training sample set to obtain the first negative sample image set.
- 2. The method of claim 1, wherein the step of calculating the training loss corresponding to the training sample image based on the sample wearing attribute feature, the sample identity feature, and the sample extraction feature comprises: Calculating attribute identity loss based on the sample wearing attribute features and the sample identity features; calculating a feature loss value based on the sample extracted features; And calculating the training loss based on the attribute identity loss and the characteristic loss value.
- 3. The method of training a wearable detection model according to claim 2, wherein the attribute identity loss includes an attribute loss value and an identity loss value, and the step of calculating an attribute identity loss based on the sample wearable attribute feature and the sample identity feature comprises: Acquiring a wearing attribute label and an identity label corresponding to the training sample image; calculating the loss between the sample wearing attribute characteristics and the wearing attribute labels to obtain the attribute loss value; Calculating the loss between the sample identity characteristic and the identity tag to obtain the identity loss value; The step of calculating the training loss based on the attribute identity loss and the feature loss value includes: and carrying out weighted summation on the attribute loss value, the identity loss value and the characteristic loss value to obtain the training loss.
- 4. A method of training a wear detection model according to claim 3, wherein the sample wear attribute feature comprises a plurality of sub-attribute features, the wear attribute tag comprises a sub-attribute tag corresponding to each of the sub-attributes, and the step of calculating a loss between the sample wear attribute feature and the wear attribute tag to obtain the attribute loss value comprises: Calculating cross entropy loss of each sub-attribute feature and the corresponding sub-attribute label to obtain a plurality of cross entropy loss values; And carrying out weighted summation on the plurality of cross entropy loss values to obtain the attribute loss value.
- 5. The method of training a wearable detection model according to claim 2, wherein the training sample image includes a target sample image, a positive sample image, and a negative sample image, the sample extraction features include features of the target sample image, features of the positive sample image, and features of the negative sample image, and the step of calculating a feature loss value based on the sample extraction features includes: and calculating the characteristics of the target sample image, the characteristics of the positive sample image and the characteristics of the negative sample image by adopting a triplet loss function to obtain the characteristic loss value.
- 6. A wear detection method, comprising: acquiring an image to be identified and a comparison image set; The comparison image set comprises a plurality of comparison images, and wearing attribute labels and identity labels corresponding to each comparison image; Inputting the image to be identified into a trained wearing detection model to obtain the feature to be identified corresponding to the image to be identified, wherein the trained wearing detection model is obtained by training the wearing detection model according to any one of the claims 1-5; inputting the comparison image into the trained wearing detection model to obtain comparison features corresponding to the comparison image; Based on the feature to be identified, the comparison feature and the wearing attribute tag, a wearing detection result is obtained, wherein the wearing detection result comprises whether the wearing of the target object in the image to be identified meets the wearing requirement corresponding to the identity tag or not; the step of obtaining a wearing detection result based on the feature to be identified, the comparison feature and the wearing attribute tag includes: Calculating the similarity between the feature to be identified and the comparison feature corresponding to each comparison image to obtain a plurality of similarities; calculating the maximum value of the multiple similarities to obtain the maximum similarity; Responding to the fact that the maximum similarity is larger than a first preset similarity threshold value, and adjusting the maximum similarity based on the wearing attribute tag to obtain a similarity adjustment value; Determining that the wearing detection result is that the wearing of the target object meets the wearing requirement in response to the similarity adjustment value being greater than a second preset similarity threshold; the step of adjusting the maximum similarity based on the wearable attribute tag to obtain a similarity adjustment value comprises the following steps: Calculating the product of the confidence coefficient corresponding to each sub-attribute label to obtain a confidence coefficient product; and calculating the product of the confidence coefficient product and the maximum similarity to obtain the similarity adjustment value.
- 7. Model training device, characterized by comprising a memory and a processor connected to each other, wherein the memory is adapted to store a computer program for implementing the training method of the wearing detection model according to any of claims 1-5 when executed by the processor.
- 8. A wear detection device comprising a memory and a processor connected to each other, wherein the memory is configured to store a computer program which, when executed by the processor, is configured to implement the wear detection method of claim 6.
- 9. A computer readable storage medium storing a computer program, characterized in that the computer program, when being executed by a processor, is adapted to implement the training method of the wear detection model of any one of claims 1-5 or the wear detection method of claim 6.
Description
Training method of wearing detection model, wearing detection method and related equipment Technical Field The application relates to the technical field of detection, in particular to a training method of a wearing detection model, a wearing detection method and related equipment. Background At present, whether a target object wears target clothes is determined by a feature comparison method, but in practical application of wearing detection, similar clothes are easily confused in the wearing detection process due to the fact that the clothes are large in variety, the similar clothes are easy to mix up in the wearing detection process, and the wearing detection precision is low. Disclosure of Invention The application provides a training method of a wearing detection model, a wearing detection method and related equipment, which can improve the wearing detection precision of the wearing detection model after training. The technical scheme includes that the wearable detection model comprises a feature extraction layer, an attribute prediction layer and a category prediction layer, the training method comprises the steps of obtaining training sample images, inputting the training sample images into the feature extraction layer to obtain sample extraction features, inputting the sample extraction features into the attribute prediction layer to obtain sample wearable attribute features, inputting the sample extraction features into the category prediction layer to obtain sample identity features, calculating training loss corresponding to the training sample images based on the sample wearable attribute features, the sample identity features and the sample extraction features, and training the wearable detection model based on the training loss to obtain a trained wearable detection model. The wearing detection method comprises the steps of obtaining an image to be identified and a comparison image set, wherein the comparison image set comprises a plurality of comparison images, wearing attribute tags and identity tags corresponding to the comparison images, inputting the image to be identified into a trained wearing detection model to obtain characteristics to be identified corresponding to the image to be identified, training the trained wearing detection model by using the training method of the wearing detection model in the technical scheme, inputting the comparison images into the trained wearing detection model to obtain comparison features corresponding to the comparison images, obtaining wearing detection results based on the characteristics to be identified, the comparison features and the wearing attribute tags, and judging whether wearing of a target object in the image to be identified meets wearing requirements corresponding to the identity tags or not. In order to solve the technical problem, the application adopts a further technical scheme that a model training device is provided, the model training device comprises a memory and a processor which are connected with each other, wherein the memory is used for storing a computer program, and the computer program is used for realizing the training method of the wearing detection model in the technical scheme when being executed by the processor. In order to solve the technical problem, the application adopts a further technical scheme that the wearing detection device comprises a memory and a processor which are connected with each other, wherein the memory is used for storing a computer program, and the computer program is used for realizing the wearing detection method in the technical scheme when being executed by the processor. In order to solve the technical problem, the application adopts a further technical scheme that a computer readable storage medium is provided, the computer readable storage medium is used for storing a computer program, and the computer program is used for realizing the training method or the wearing detection method of the wearing detection model in the technical scheme when being executed by a processor. According to the scheme, the method has the beneficial effects that the sample extraction characteristics are obtained by inputting the training sample image into the characteristic extraction layer, the sample extraction characteristics are respectively input into the attribute prediction layer and the category prediction layer to obtain the sample wearing attribute characteristics and the sample identity characteristics, then the training loss corresponding to the training sample image is calculated based on the sample wearing attribute characteristics, the sample identity characteristics and the sample extraction characteristics, so that the wearing detection model is trained by utilizing the training loss to obtain the trained wearing detection model, and the training effect of the wearing detection model is greatly improved by training the wearing detection model from three aspects of the wearing attribute, the