Lightweight work clothes identification method based on template matching

Through the lightweight work clothing recognition method based on template matching, combined with the lightweight full-scale model OSNet and ArcFace loss function, the recognition difficulties of traditional algorithms under lighting, posture and diverse clothing are solved, and higher recognition accuracy and generalization capabilities are achieved.

CN119888779APending Publication Date: 2025-04-25HANGZHOU ARCVIDEO TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411675491.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

When traditional work clothes detection algorithms face lighting changes, posture changes and occlusions, as well as diverse clothing and textures, it is difficult to accurately identify the position and characteristics of work clothes, resulting in a decrease in recognition accuracy.

Method used

A lightweight work clothes recognition method based on template matching is adopted. Through feature comparison of work clothes base library features, complex model training and parameter tuning are avoided, and the loss function is designed to improve feature distinction, and the lightweight full-scale models OSNet and ArcFace loss function are used for feature extraction and matching.

Benefits of technology

It improves the accuracy and generalization ability of work clothes recognition, enhances the ability to identify work clothes in different work scenarios, and reduces the calculation complexity and parameter quantity of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119888779A_ABST
    Figure CN119888779A_ABST
Patent Text Reader

Abstract

The invention discloses a lightweight work clothes identification method based on template matching. The lightweight work clothes identification method comprises the following steps: S10, preparing human body data, human body weight identification data and work clothes data; s20, designing a human body detection network architecture for detecting a human body frame; s30, establishing a data merging process taking clothes as a small category and taking a color system as a large category; s40, constructing a lightweight full-scale model for extracting human body work clothes features; s50, designing an optimization loss function for improving feature discrimination; and S60, registering a work clothes template, and carrying out human body sequence matching to obtain a matching result. According to the method, the key features of the work clothes can be more accurately captured, the complex model training and parameter adjusting and optimizing process is avoided through a work clothes base library feature comparison mode, the generalization ability is enhanced, and the work clothes identification requirements in different work scenes can be met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of computer vision, and in particular relates to a lightweight work clothes recognition method based on template matching. Background Art

[0002] With the rapid development of technology, edge computing is rapidly becoming a key technology that is changing multiple industries, especially in the fields of AI and security. The core advantage of edge computing is that it can process data instantly at the location where the data is generated, which is particularly important for application scenarios that require a quick response. When this capability is combined with artificial intelligence (AI), especially when visual AI algorithms are applied in security systems, its potential and impact are enormous. This includes real-time monitoring, which can monitor work scenes in real time and promptly detect situations where employees' uniforms do not comply with regulations. Once abnormal uniforms are detected, the system can immediately issue an alarm to remind relevant personnel to deal with it.

[0003] Traditional algorithms for detecting work clothes use target detection methods, which face the following challenges in actual application scenarios: (1) Lighting and shadow issues. Lighting conditions may vary greatly in different workplaces and time periods, from bright sunlight to dim lights or even strong backlight. Such lighting changes can cause the color and texture of work clothes to appear different, which in turn affects the accuracy of the detection algorithm. (2) Posture changes and occlusions. Employees may adopt a variety of postures at work. Different postures can cause the shape and position of work clothes in the image to change, making it difficult for the detection algorithm to accurately identify the position and features of the work clothes. (3) Diverse clothing and textures. Different industries use work clothes of different styles, colors, and designs, which requires the work clothes recognition algorithm to have strong generalization capabilities. Secondly, the textures and patterns on work clothes can also be very rich and complex, such as logos, stripes, patterns, etc., which increases the complexity of the work clothes detection algorithm in identifying and analyzing texture features. Summary of the invention

[0004] In view of the above problems, the present invention provides a lightweight work clothes recognition method based on template matching, which can more accurately capture the key features of work clothes. By comparing the features of the work clothes database, it avoids the complicated model training and parameter tuning process, enhances the generalization ability, and can meet the work clothes recognition needs in different work scenarios.

[0005] In order to solve the above technical problems, the present invention adopts the following technical solutions:

[0006] A lightweight work clothes recognition method based on template matching includes the following steps:

[0007] S10, preparing human body data, human weight recognition data and work clothes data;

[0008] S20, design a human body detection network architecture to detect human body frames;

[0009] S30, establish a data merging process with clothing as a small category and color as a large category;

[0010] S40, builds a lightweight full-scale model for extracting human workwear features;

[0011] S50, design and optimize loss function to improve feature discrimination;

[0012] S60, registering the work uniform template, performing human body sequence matching to obtain matching results, specifically including:

[0013] S601, selecting work uniform template images: selecting two postures of standing and sitting for each work uniform, and selecting four angles of front, left, right and back for each posture;

[0014] S602, feature extraction and template registration: the selected work uniform template is used to extract work uniform features using the lightweight model, each image is extracted into a feature vector with a dimension of 512, and normalized and stored in the base database feature;

[0015] S603, video source input, human body frame detection: connect the video source, use the human body detection network to detect the human body frame, and store the human body information;

[0016] S604, extracting work clothes features: after obtaining the human frame information, crop the human body picture and feed it into the feature extraction model, extract the 512-dimensional feature vector and normalize it, compare the normalized features with the base database features by cosine similarity, and save the comparison results;

[0017] S605, perform human body sequence matching results and output warning information: perform multi-frame similarity analysis on the work clothes matching results of the human body in the same sequence, and comprehensively judge whether it matches the base database. If it does not match, output a warning message of not wearing work clothes and mark the human body position information.

[0018] In a possible implementation, in S10, the human body data includes public data sets VOC, COCO and MPII human posture data sets, the human weight recognition public data sets include Market-1501 and DukeMTMC data sets, and the work clothes data sets include power clothing, kitchen work clothes, life jackets, reflective clothing, and ship work clothes.

[0019] In a possible implementation, the S20 includes: using yolov8 to perform human target detection, and in terms of loss function, adding a DFL (Distribution Focal Loss) loss function to the regression loss, which is defined as follows:

[0020]

[0021] y is the true category label, p y is the predicted probability of the y category, p k is the predicted probability of the k category, k = 1, 2, ..., N represents all categories, α, γ are hyperparameters used to control the rate of change of the function.

[0022] In a possible implementation manner, the S30 specifically includes:

[0023] S301, using human_parsing to segment the human body data, distinguishing the upper and lower body and limb positions, and obtaining a mask area of ​​the upper body;

[0024] S302, using kmeans method to extract the main colors of the clothes on the upper body of the human body, and extracting 3 to 4 main colors of the upper body;

[0025] S303, converting the main color bgr format into the lab color format, and clustering different color categories based on the lab distance metric;

[0026] S304: Based on the clustering result, the human weight recognition data is combined into the same clothing and the clothing of the same color.

[0027] In a possible implementation, the S40 includes: using a lightweight full-scale model OSNet to perform feature extraction.

[0028] In one possible implementation, the lightweight full-scale model OSNet includes five convolutional layers, two transition layers, a global pooling layer, and a fully connected layer, and the processing steps are as follows: the input is a picture of a human body wearing work clothes, which is first subjected to two convolutional layers for large-scale feature extraction such as color, and then subjected to a transition layer for feature enhancement, followed by a convolutional layer for medium-scale feature extraction such as style, and feature enhancement using a transition layer, and then subjected to two convolutional layers for fine-grained feature extraction such as texture, and after the coarse features are extracted, the pooling layer is used to fuse the multi-scale features of the work clothes, and finally the fully connected layer is used for classification to output a unique feature vector for each work uniform, and the vector dimension is 512 dimensions.

[0029] In a possible implementation, the S40 includes: selecting an ArcFace function as a loss function.

[0030] The present invention has the following beneficial effects:

[0031] (1) The proposed method based on template feature matching avoids complex model training and parameter tuning in multiple scenarios, saves a lot of data annotation, greatly enhances the generalization ability and scenario applicability of work clothes recognition, and improves the accuracy of work clothes recognition.

[0032] (2) The lightweight full-scale model OSNet is adopted. The full-scale feature learning module can extract features from fine-grained local information to global overall information. The hierarchical feature fusion enables the model to have a high perception ability for both details and overall information in the image. The lightweight design greatly reduces the number of parameters and extracts features efficiently and accurately.

[0033] (3) The ArcFace loss function is used for optimization and the angle interval parameter is introduced to constrain the angle relationship between the feature and the category center, making the clusters within the category closer and the intervals between categories larger, thus improving the distinguishability of the features.

[0034] (4) Select multiple posture angles as the registration base, and make the matching results more accurate by analyzing the multi-sequence alignment results of the human body. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 A flowchart of a lightweight work clothes recognition method based on template matching according to an embodiment of the present invention;

[0036] Figure 2 It is a structural diagram of Osnet in a specific application example of the present invention;

[0037] Figure 3 It is a feature distribution diagram after the dimension reduction of work clothes features under the softmax function in the prior art;

[0038] Figure 4 This is a feature distribution diagram of work clothes features after dimensionality reduction under the arcface loss function in a specific application example of the present invention. DETAILED DESCRIPTION

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

[0040] Reference Figure 1 , which is a flowchart of a method for lightweight work clothes recognition based on template matching according to an embodiment of the present invention, comprising the following steps:

[0041] S10, preparing human body data, human weight recognition data and work clothes data;

[0042] S20, design a human body detection network architecture to detect human body frames;

[0043] S30, establish a data merging process with clothing as a small category and color as a large category;

[0044] S40, builds a lightweight full-scale model for extracting human workwear features;

[0045] S50, design and optimize loss function to improve feature discrimination;

[0046] S60, registering the work uniform template, performing human body sequence matching to obtain matching results, specifically including:

[0047] S601, selecting work uniform template images: selecting two postures of standing and sitting for each work uniform, and selecting four angles of front, left, right and back for each posture;

[0048] S602, feature extraction and template registration: the selected work uniform template is used to extract work uniform features using the lightweight model, each image is extracted into a feature vector with a dimension of 512, and normalized and stored in the base database feature;

[0049] S603, video source input, human body frame detection: connect the video source, use the human body detection network to detect the human body frame, and store the human body information;

[0050] S604, extracting work clothes features: after obtaining the human frame information, crop the human body picture and feed it into the feature extraction model, extract the 512-dimensional feature vector and normalize it, compare the normalized features with the base database features by cosine similarity, and save the comparison results;

[0051] S605, perform human body sequence matching results and output warning information: perform multi-frame similarity analysis on the work clothes matching results of the human body in the same sequence, and comprehensively judge whether it matches the base database. If it does not match, output a warning message of not wearing work clothes and mark the human body position information.

[0052] A specific application example, in S10, human body data includes public datasets VOC, COCO and MPII human body pose datasets, public datasets for human weight recognition include Market-1501 and DukeMTMC datasets, and work clothes datasets include power clothing, kitchen work clothes, life jackets, reflective clothing, and ship work clothes. The VOC dataset has a total of 20 categories, divided into two datasets, VOC2007 and VOC2012. The data of the person category is screened out, with a total of 9963 images in VOC2007 and 17125 images in VOC2012. The COCO dataset is a large-scale dataset that can be used for image detection, semantic segmentation, and image captioning, with a total of 66,697 images containing human bodies. The MPII human pose dataset is the most advanced benchmark for evaluating articulated human pose estimation. The dataset includes approximately 25,000 images, including body joint annotations for more than 40,000 people. The Market-1501 dataset in the public dataset for human weight recognition was collected on the campus of Tsinghua University, shot in the summer, built and made public in 2015. It includes 32,217 images of 1,501 pedestrians taken by 6 cameras (5 HD cameras and 1 low-definition camera). The DukeMTMC dataset is a large-scale labeled multi-target multi-camera pedestrian tracking dataset. It provides a new large-scale HD video dataset recorded by 8 synchronized cameras, with more than 7,000 single-camera trajectories and more than 2,700 independent people.

[0053] A specific application example, S20 includes: using yolov8 for human target detection. Yolov8 is a sota model proposed by ultralytics. Compared with yolov5, yolov8 adopts the Anchor-Free mechanism, without a priori anchor frame, and directly obtains the anchor frame by predicting specific points. Anchor-Free does not require manual design of anchors (aspect ratio, scale size, number of anchors), thus avoiding tedious design for different data sets. In terms of loss function, the DFL (Distribution Focal Loss) loss function is added to the regression loss, which is defined as follows:

[0054]

[0055] y is the true category label, p y is the predicted probability of the y category, p kis the predicted probability of the k category, k = 1, 2, ..., N represents all categories, α, γ are hyperparameters used to control the rate of change of the function.

[0056] The DFL function optimizes the probability of the two positions closest to the label y in the form of cross entropy, so that the network can focus on the distribution of the neighboring area of ​​the target position more quickly; that is, the learned distribution is theoretically near the real floating point coordinates, and the weights of the integer coordinates to the left and right are obtained in a linear interpolation mode. The DFL function provides more information and accurate predictions by modeling the distribution of the predicted box position.

[0057] A specific application example: Since there is no dataset classified by work clothes in the public dataset, and the self-made dataset has fewer categories, the number of categories is not enough to train a stable feature extraction model for the feature matching model. Therefore, based on the human weight recognition data, a data merging process is established with clothing as a small category and color as a large category. The data originally classified by personnel ID is integrated into data classified by clothing and color, which is used for subsequent work clothes feature extraction data. S30 specifically includes:

[0058] S301, using human_parsing to segment the human body data, distinguishing the upper and lower body and limb positions, and obtaining a mask area of ​​the upper body;

[0059] S302, using kmeans method to extract the main colors of the clothes on the upper body of the human body, and extracting 3 to 4 main colors of the upper body;

[0060] S303, converting the main color bgr format into the lab color format, and clustering different color categories based on the lab distance metric;

[0061] S304: Based on the clustering result, the human weight recognition data is combined into the same clothing and the clothing of the same color.

[0062] In a specific application example, S40 includes using a lightweight full-scale model OSNet for feature extraction. OSNe Omni-Scale Network (OSNet) is a deep convolutional neural network for person re-identification (ReID) tasks. OSNet uses an innovative multi-scale feature fusion module to extract workwear features of different scales in images at a low computational cost.

[0063] OSNet introduces an "Omni-Scale Feature Blocks" module that can simultaneously learn the features of work clothes of different scales. By combining multiple convolution kernels of different scales (such as 1×1, 3×3, and 5×5), OSNet can learn the features of various scales such as color, texture, and style of work clothes, covering large-scale color features and fine-grained texture features. This full-scale feature learning method is more efficient and accurate than traditional multi-scale feature extraction. OSNet combines features from different convolution kernels through hierarchical fusion, so that it can effectively integrate the feature information of work clothes of different scales, form unique feature information for each type of work clothes, and retain important scale information for each type of work clothes, so that OSNet can locate and focus on the color, style, etc. of work clothes. OSNet greatly reduces the number of parameters by flexibly using 1×1 convolution layers and point-by-point convolution. Compared with traditional convolutional neural networks such as ResNet, OSNet has less computational complexity and can quickly extract features while maintaining a high accuracy rate. This makes OSNet very suitable for application scenarios with limited devices (such as mobile devices and real-time video surveillance).

[0064] like Figure 2 This is the structure diagram of Osnet, which includes five convolutional layers, two transition layers, a global pooling layer and a fully connected layer. The specific working steps are as follows: the input is a human body picture wearing work clothes, which first passes through two convolutional layers to extract large-scale features such as color, and then passes through the transition layer to enhance the features, then passes through a convolutional layer to extract medium-scale features such as style, and uses the transition layer to enhance the features, and then passes through two convolutional layers to extract fine-grained features such as texture. After the coarse features are extracted, the pooling layer is used to fuse the multi-scale features of the work clothes, and finally the fully connected layer is used for classification to output the unique feature vector of each work clothes, and the vector dimension is 512 dimensions.

[0065] In a specific application example, S40 includes selecting the ArcFace function as the loss function. The traditional human body weight recognition training loss function uses the form of classification cross entropy for loss constraint. Such loss constraint cannot separate the features well and has a great interference effect on the subsequent feature comparison. The ArcFace loss function adds an angular margin to the Softmax function, thereby constraining the angular relationship between the feature and the category center. The formula is as follows:

[0066]

[0067] is the angle between sample i and the center of its category; s is a scale factor used to control the convergence speed of training; m is the angle margin, which makes samples of the same category closer and expands the difference between categories. ArcFace increases the angle margin of samples of the same category to make the distribution of features of the same category of work clothes more concentrated; for features of different categories of work clothes, the angle interval increases their distance to reduce misidentification; the angle margin of ArcFace is easier to optimize and converge than other methods (such as SphereFace and CosFace), thereby improving training efficiency.

[0068] like Figure 3 It is the feature distribution diagram after the dimensionality reduction of the traditional softmax function line service feature. Figure 4 This is the feature distribution diagram of the work clothes after dimensionality reduction under the ArcFace loss function. From the figure, we can observe that the ArcFace loss function can make the work clothes of the same style more clustered and the work clothes of different styles more spaced, laying a solid foundation for the subsequent accurate feature matching.

[0069] The above-mentioned lightweight work clothes recognition method based on template matching can avoid complex model training and parameter tuning in multiple scenarios based on template feature matching, save a lot of data annotation, greatly enhance the generalization ability and scene applicability of work clothes recognition, and improve the accuracy of work clothes recognition. Using the lightweight full-scale model OSNet, the full-scale feature learning module can extract features from fine-grained local information to global overall information. The hierarchical feature fusion enables the model to have a high perception of details and overall information in the image. The lightweight design greatly reduces the number of parameters and extracts features efficiently and accurately. The ArcFace loss function is used for optimization, and the angle interval parameter is introduced to constrain the angle relationship between the feature and the category center, making the class more clustered and the class interval larger, thereby improving the distinguishability of the feature. Select a variety of posture angles as the registration base, and make the matching results more accurate by analyzing the results of human multi-sequence alignment.

[0070] It should be understood that the exemplary embodiments described herein are illustrative rather than restrictive. Although one or more embodiments of the present invention are described in conjunction with the accompanying drawings, it should be understood by those skilled in the art that various changes in form and detail may be made without departing from the spirit and scope of the present invention as defined by the appended claims.

Claims

1. A lightweight work clothes recognition method based on template matching, characterized in that: The following steps are involved: S10, preparing human body data, human weight recognition data and work clothes data; S20, design a human body detection network architecture to detect human body frames; S30, establish a data merging process with clothing as a small category and color as a large category; S40, builds a lightweight full-scale model for extracting human workwear features; S50, design and optimize loss function to improve feature discrimination; S60, registering the work uniform template, performing human body sequence matching to obtain matching results, specifically including: S601, selecting work uniform template images: selecting two postures of standing and sitting for each work uniform, and selecting four angles of front, left, right and back for each posture; S602, feature extraction and template registration: the selected work uniform template is used to extract work uniform features using the lightweight model, each image is extracted into a feature vector with a dimension of 512, and normalized and stored in the base database feature; S603, video source input, human body frame detection: connect the video source, use the human body detection network to detect the human body frame, and store the human body information; S604, extracting work clothes features: after obtaining the human frame information, crop the human body picture and feed it into the feature extraction model, extract the 512-dimensional feature vector and normalize it, compare the normalized features with the base database features by cosine similarity, and save the comparison results; S605, perform human body sequence matching results and output warning information: perform multi-frame similarity analysis on the work clothes matching results of the human body in the same sequence, and comprehensively judge whether it matches the base database. If it does not match, output a warning message of not wearing work clothes and mark the human body position information.

2. The lightweight work clothes recognition method based on template matching according to claim 1, characterized in that: In S10, the human body data includes the public datasets VOC, COCO and MPII human posture datasets, the public datasets for human weight recognition include Market-1501 and DukeMTMC datasets, and the work clothes datasets include power clothes, kitchen clothes, life jackets, reflective clothes, and ship clothes.

3. The lightweight work clothes recognition method based on template matching as claimed in claim 1, characterized in that: The S20 includes: using yolov8 to detect human targets, and in terms of loss function, adding a DFL (Distribution Focal Loss) loss function to the regression loss, which is defined as follows: y is the true category label, p y is the predicted probability of the y category, p k is the predicted probability of the k category, k = 1, 2, ..., N represents all categories, α, γ are hyperparameters used to control the rate of change of the function.

4. The lightweight work clothes recognition method based on template matching according to claim 1, characterized in that: The S30 specifically includes: S301, using human_parsing to segment the human body data, distinguishing the upper and lower body and limb positions, and obtaining a mask area of ​​the upper body; S302, using kmeans method to extract the main colors of the clothes on the upper body of the human body, and extracting 3 to 4 main colors of the upper body; S303, converting the main color bgr format into the lab color format, and clustering different color categories based on the lab distance metric; S304: Based on the clustering result, the human weight recognition data is combined into the same clothing and the clothing of the same color.

5. The lightweight work clothes recognition method based on template matching according to claim 1, characterized in that: The S40 includes: using a lightweight full-scale model OSNet to perform feature extraction.

6. The lightweight work clothes recognition method based on template matching as claimed in claim 5, characterized in that: The lightweight full-scale model OSNet includes five convolutional layers, two transition layers, a global pooling layer, and a fully connected layer. The processing steps are as follows: the input is a human body picture wearing work clothes. It first passes through two convolutional layers to extract large-scale features such as color, and then passes through a transition layer to enhance the features. Then, it passes through a convolutional layer to extract medium-scale features such as style, and uses a transition layer to enhance the features. Then, it passes through two convolutional layers to extract fine-grained features such as texture. After the coarse features are extracted, the pooling layer is used to fuse the multi-scale features of the work clothes. Finally, it passes through a fully connected layer for classification and outputs a unique feature vector for each work clothes. The vector dimension is 512 dimensions.

7. The lightweight work clothes recognition method based on template matching according to claim 1, characterized in that: The S40 includes: selecting an ArcFace function as a loss function.