Safe wearing detection method
The human body detection model obtains the position and contour of the personnel, detects the safety helmet and reflective clothing in stages, and uses the improved FCOS model and deep learning convolutional neural network for feature extraction and classification, solving the problem of low detection accuracy in the existing technology, and achieving efficient and accurate safe wear detection.
Patent Information
- Application Number
- CN202510117226.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-24
- Publication Date
- 2025-05-02
AI Technical Summary
The existing safety wear detection algorithm has low detection accuracy under complex backgrounds and varied postures, which can easily lead to missed or missed detection. When the person's body is blocked, the alarm repetition rate is high, reducing monitoring efficiency.
A safe wear detection method is adopted to obtain the personnel position and contour through the human detection model, detect the safety helmet and reflective clothing in stages, and use the improved FCOS model and deep learning convolutional neural network for feature extraction and classification, and match it with Hungarian algorithms to improve detection accuracy.
It significantly optimizes the detection efficiency, improves the accuracy of detection of safety helmets and reflective clothing, reduces the probability of false detection and missed detection, and can quickly process large amounts of image or video data to meet real-time detection needs.
Smart Images

Figure CN119919735A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision technology, and in particular to a safety wear detection method. Background Art
[0002] With the acceleration of urbanization and the booming infrastructure development, construction sites have become high-risk work environments. Workers in these environments face a variety of safety threats, with mechanical injuries being particularly prominent. Hard hats and reflective vests are key components of workers' personal protective equipment (PPE) at various construction sites. Hard hats provide head protection, while reflective vests enhance visibility in low-light conditions or high-risk work areas. Therefore, verifying that on-site workers are wearing hard hats and reflective vests as required is a crucial component of safety management.
[0003] At construction sites, managers typically conduct inspections and review on-site videos to verify that workers are wearing safety helmets and reflective clothing as required. While these inspection methods have achieved certain safety management benefits, they also suffer from low efficiency and missed detections. With the widespread adoption of surveillance equipment, intelligent detection equipment utilizes captured surveillance video footage to extract, process, and analyze features, enabling detection of workers wearing safety helmets and reflective clothing. However, in complex construction site environments, traditional target detection algorithms often lack high accuracy when detecting safety helmets and reflective clothing due to factors such as changing worker postures, fluctuating lighting conditions, and occlusions, leading to missed or false detections. Furthermore, existing detection algorithms can easily generate high alarm repetition rates when workers are obscured, reducing monitoring efficiency. Summary of the Invention
[0004] In view of the above analysis, the embodiments of the present invention aim to provide a safety wear detection method to solve the problem that the existing safety wear detection algorithm has low detection accuracy in complex backgrounds and changing postures, resulting in missed detection or false detection.
[0005] The purpose of the present invention is mainly achieved through the following technical solutions:
[0006] The present invention provides a safety wear detection method, comprising the following steps:
[0007] Obtain an image of the person to be detected captured by the surveillance video;
[0008] Inputting the image into a trained human body detection model to obtain a human body detection result in the image; wherein the human body detection result includes the position of the human body detection frame and the category of the human body detection frame;
[0009] Based on the human body detection results, a head region image and / or a body region image of each person to be detected is captured in the target detection image;
[0010] The head area image and body area image of each inspected person are respectively input into the trained safety helmet classification model and reflective clothing classification model to obtain the classification results output by each classification model; wherein the classification results output by the safety helmet classification model include whether the person is wearing a safety helmet; the classification results output by the reflective clothing classification model include whether the person is wearing reflective clothing.
[0011] Furthermore, the categories of the human body detection frame include a complete human body detection frame, a head-dominated human body detection frame, and a single body human body detection frame;
[0012] The complete human body detection frame includes a head detection frame and a corresponding body detection frame, both of which are detected by the detection head of the human body detection model;
[0013] The head-dominated human body detection frame includes a head detection frame detected by the detection head of the human body detection model and a body detection frame corresponding to the head detection frame predicted by the human body detection model based on the head detection frame;
[0014] The single body human detection frame only includes a body detection frame detected by the detection head of the human detection model, and does not have a head detection frame matching the body detection frame.
[0015] Furthermore, based on the human body detection result, the head region image and the body region image of each object to be detected are respectively intercepted in the target detection image, including:
[0016] When the category of the human body detection frame is a complete human body frame, based on the position of its head detection frame and the position of its body detection frame, intercepting its head region image and body region image;
[0017] When the category of the human body detection frame is a head-dominated human body detection frame, based on the position of its head detection frame, intercepting its head area image;
[0018] When the category of the human body detection frame is a single body human body detection frame, the body region image is captured based on the position of the body detection frame.
[0019] Furthermore, the helmet classification model is a convolutional neural network based on deep learning, including: a convolutional layer, a batch normalization layer, a ReLU activation function, a pooling layer, a fully connected layer and a softmax function;
[0020] The head area image is sequentially processed through the convolution layer, the batch normalization layer, and the ReLU activation function to extract local features of the image, and then the size of the feature map is reduced through the pooling layer. The feature map is then converted into a classification result through the fully connected layer, and finally the softmax function is used to obtain the probability value of whether a helmet is worn.
[0021] Furthermore, the reflective clothing classification model is a convolutional neural network model based on deep learning, including: a convolutional layer, a batch normalization layer, a ReLU activation function, a pooling layer, a fully connected layer and a softmax function;
[0022] The body area image is sequentially processed through the convolution layer, the batch normalization layer, and the ReLU activation function to extract local features of the image, and then the size of the feature map is reduced through the pooling layer. The feature map is then converted into a classification result through the fully connected layer, and finally the softmax function is used to obtain the probability value of whether the reflective clothing is worn.
[0023] Furthermore, the human body detection model is an improved FCOS model, which simultaneously constructs a head detection branch and a body detection branch in each detection head, and binds the head and body information in the detection head; wherein,
[0024] The head detection branch is used to obtain a head detection frame in the image and a body prediction frame corresponding to the head detection frame;
[0025] The body detection branch is used to obtain a body detection frame in the image;
[0026] The body prediction frame and the body detection frame are matched, and the matching result is used as the human body detection result.
[0027] Furthermore, matching the body prediction frame with the body detection frame, and using the matching result and the head detection frame corresponding to the body prediction frame as a human detection result, includes:
[0028] Constructing a matching matrix based on the matching degree between the body prediction frame and the body detection frame;
[0029] Solve the matching matrix using the Hungarian algorithm to obtain the best matching body detection frame for the head detection frame, which together with the head detection frame constitutes a human body detection result;
[0030] For the unmatched head detection frame, the corresponding body prediction frame is used as the human detection result;
[0031] For the unmatched body detection frame, it is directly used as the human detection result.
[0032] Furthermore, when training the human body detection model, the positive samples of the detection frame are screened and their weight values are calculated based on the intersection-over-union ratio of the detection frame with the head annotation frame and the body annotation frame to perform weighted coordinate regression loss, and a loss function is constructed based on the weighted coordinate regression loss; wherein, the positive samples of the detection frame include positive samples of the head detection frame, positive samples of the body detection frame, and positive samples of multi-category detection frames.
[0033] Furthermore, the screening of positive samples of the detection box and calculating their weight values include:
[0034] Based on the intersection-over-union ratio of the detection frame and the head annotation frame, a positive sample of the head detection frame is screened, and based on the distance between the positive sample of the head detection frame and the center of the head annotation frame, a head weight value of the positive sample of the head detection frame is calculated;
[0035] Based on the intersection-over-union ratio of the detection frame and the body annotation frame, a positive sample of the body detection frame is screened, and based on the distance between the positive sample of the body detection frame and the center of the body annotation frame, a body weight value of the positive sample of the body detection frame is calculated; wherein, when the positive sample of the head detection frame and the positive sample of the body detection frame are the same detection frame, the detection frame is set as a positive sample of the multi-category detection frame, and its body weight value is updated to the sum of the corresponding head weight value and body weight value;
[0036] The head weight value and the body weight value of the positive sample of the detection frame are added together to obtain the weight value of the positive sample of the detection frame.
[0037] Furthermore, the human body detection model is trained using the following method:
[0038] Constructing a training data set for the human body detection model; wherein the training data set includes a set of images with human bodies, and the category labels, bounding boxes, and center point locations corresponding to the annotated heads and bodies in each image;
[0039] The training data set is loaded, and the human body detection model is trained using a total loss function consisting of a classification loss function, a center point loss function, and a weighted coordinate regression loss function. The model parameters are updated using gradient back propagation, and the training is terminated when the loss function value converges to obtain a trained human body detection model; wherein, based on the weight value of the positive sample of the detection box and the coordinate loss function, the weighted coordinate regression loss of the positive sample of each detection box is obtained.
[0040] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects:
[0041] 1. The technical solution of the present invention separates the human body detection model from the helmet and reflective clothing detection model, significantly optimizing detection efficiency. Traditional single models are bulky and require long training times. Furthermore, directly detecting helmets and reflective clothing in the entire image requires a significant amount of computation. The human body detection model of the present invention processes only the human body portion of the image, significantly reducing the amount of computation. After obtaining the human body detection results, it further focuses on specific head and body areas for helmet and reflective clothing detection, significantly narrowing the detection range. This phased detection approach not only reduces the computational burden of the classification model but also improves overall detection efficiency. It can quickly process large amounts of image or video data to meet real-time detection requirements.
[0042] 2. In the technical solution of the present invention, the human body detection model focuses on accurately locating the position and outline of the human body in the image, including key parts such as the head and body. This precise positioning provides a more accurate detection area for subsequent safety helmet and reflective vest detection, avoiding the false detection or missed detection of safety helmets and reflective vests in complex backgrounds, thereby improving the detection accuracy of safety helmets and reflective vests.
[0043] 3. In the technical solution of the present invention, the human body detection model uses an improved FCOS model to simultaneously construct a head detection branch and a body detection branch in each detection head, and binds the head and body information in the head detection branch, so that the detection model can more accurately identify and associate the head and body parts of the human body. Compared with the traditional separate detection method, the detection accuracy is higher.
[0044] 4. The technical solution of the present invention achieves the best matching between the body prediction frame and the body detection frame by constructing a matching matrix and solving it using the Hungarian algorithm, ensuring that the head detection frame and the matched body detection frame are used as the human detection result. Even when the person's body is obscured, it can effectively reduce the ID switching of the same violator.
[0045] 5. According to the technical solution of the present invention, in the process of matching positive samples, the size of the human body is often larger than the human head. Therefore, the number of anchor frames for human body matching is much higher than that of the human head, which reduces the accuracy of head detection. Therefore, in the process of matching anchor frames with real frames, a layered positive sample matching mechanism is proposed to adaptively adjust the matching of anchor frames with real frames. Through this mechanism, higher quality positive samples can be obtained and the weights of the anchor frames can be updated, thereby highlighting the importance of the overlapping area between the head and the body, which can improve the convergence speed and target positioning accuracy.
[0046] In the present invention, the above-mentioned technical solutions can be combined with each other to achieve more preferred combinations. Other features and advantages of the present invention will be described in the following description, and some advantages will become apparent from the description or be learned through practice of the present invention. The objectives and other advantages of the present invention can be realized and obtained through the contents particularly pointed out in the description and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The accompanying drawings are only for the purpose of illustrating particular embodiments and are not to be considered limiting of the present invention. Like reference symbols denote like parts throughout the drawings.
[0048] Figure 1 Schematic diagram of a safety wear detection method according to an embodiment of the present invention;
[0049] Figure 2 Schematic diagram of the safety wear detection results in an embodiment of the present invention. DETAILED DESCRIPTION
[0050] The preferred embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, and are not used to limit the scope of the present invention.
[0051] A specific embodiment of the present invention discloses a safety wear detection method, such as Figure 1 As shown, the method includes the following steps S1 to S4:
[0052] Step S1: Acquire an image of a person to be detected captured by a surveillance video.
[0053] Specifically, a scene image including a person to be identified, taken by a surveillance camera installed at a production project site, is obtained, and the image is preprocessed, including but not limited to noise removal and image enhancement, to facilitate subsequent image recognition.
[0054] Step S2: input the image into a trained human body detection model to obtain a human body detection result in the image; wherein the human body detection result includes the position of the human body detection frame and the category of the human body detection frame.
[0055] Specifically, the human body detection model is used to detect the position and outline of the human body in the image, including the specific position of the head and body.
[0056] Furthermore, the human body detection model is an improved FCOS model, which simultaneously constructs a head detection branch and a body detection branch in each detection head, and binds the head and body information in the detection head; wherein,
[0057] The head detection branch is used to obtain a head detection frame in the image and a body prediction frame corresponding to the head detection frame;
[0058] The body detection branch is used to obtain a body detection frame in the image;
[0059] The body prediction frame and the body detection frame are matched, and the matching result is used as the human body detection result.
[0060] Specifically, the human body detection model of this embodiment is an improved FCOS model, which constructs a multi-branch detection head to extract head and body features respectively, and performs prediction to ensure that both body and head information are included, while establishing the correlation between them.
[0061] More specifically, the FCOS model is a fully convolutional single-stage anchor-free detection model. Unlike traditional anchor-based methods (such as YOLO), FCOS does not use predefined anchor boxes. Instead, it directly predicts the position and category of objects at each position in the feature map. FCOS can process input images of any size and output feature maps of the corresponding size.
[0062] The human body detection model includes a backbone network, a neck network and a head network.
[0063] The backbone network is used to extract image features and downsample the image to generate multiple feature maps of different sizes. The backbone network in this embodiment adopts a pre-trained classification network. Exemplarily, a ResNet50 structure can be used; wherein, the backbone network includes an initial convolution module and three convolution modules connected in sequence to generate feature maps of different sizes.
[0064] Specifically, in the initial convolution module of the backbone network, the image passes through a convolution layer with a convolution kernel size of 7x7 and a stride of 2, a batch normalization layer, a ReLU activation function, and a pooling layer in sequence to perform preliminary feature extraction and downsampling on the image to reduce the resolution of the feature map.
[0065] In the first convolution module of the backbone network, the output feature map of the initial convolution module is sequentially passed through several convolution blocks to gradually extract the detailed features of the image. Each convolution block includes a convolution layer with a convolution kernel of 3x3, a batch normalization layer and a ReLU activation function. After each convolution block, a residual block structure is used to directly add the input to the output through a jump connection to alleviate the problems of gradient disappearance and gradient explosion. Finally, it is downsampled through a convolution layer with a stride of 2 to obtain the output feature map C3 of the first convolution module.
[0066] In the second convolution module of the backbone network, the output feature map C3 of the first convolution module gradually extracts the detailed features of the image through several convolution blocks in sequence. Each convolution block includes a convolution layer with a convolution kernel of 3x3, a batch normalization layer and a ReLU activation function. After each convolution block, a residual block structure is used to add the input directly to the output through a jump connection to alleviate the problems of gradient disappearance and gradient explosion. Finally, it is downsampled through a convolution layer with a stride of 2 to obtain the output feature map C4 of the second convolution module.
[0067] In the third convolution module of the backbone network, the output feature map C4 of the second convolution module gradually extracts the detailed features of the image through several convolution blocks in sequence. Each convolution block includes a convolution layer with a convolution kernel of 3x3, a batch normalization layer and a ReLU activation function. After each convolution block, a residual block structure is used to add the input directly to the output through a jump connection to alleviate the problems of gradient disappearance and gradient explosion. Finally, it is downsampled through a convolution layer with a stride of 2 to obtain the output feature map C5 of the third convolution module.
[0068] Through the three convolutional modules of the above backbone network, three output feature maps are obtained. Their resolution decreases successively, while the semantic information is gradually enriched. Rich details and semantic information are retained at different scales, providing high-quality features for the subsequent neck network and head network.
[0069] The neck network is used to further fuse the multi-scale feature maps obtained by the backbone network to enhance the expressiveness of features. Exemplarily, the neck network adopts a feature pyramid network (FPN) structure, which transmits high-level semantic information to low-level feature maps through a top-down path and lateral connections, thereby enhancing the semantic information of low-level feature maps.
[0070] Furthermore, in the neck network, 1x1 convolution operations are performed on the output feature map C3 of the first convolution module, the output feature map C4 of the second convolution module, and the output feature map C5 of the third convolution module, respectively, to adjust the number of channels thereof to make them consistent.
[0071] Specifically, in the neck network, the output feature map C5 of the third convolution module is obtained by a 1x1 convolution operation to obtain a fused feature map P5; after upsampling the fused feature map P5, it is element-wise added to the feature map after the 1x1 convolution operation of the output feature map C4 of the second convolution module, and then passes through a convolution layer with a convolution kernel size of 3x3, a batch normalization layer and a ReLU activation function in sequence to obtain the fused feature map P4.
[0072] After upsampling the fused feature map P4, it is element-wise added to the feature map after the 1x1 convolution operation on the output feature map C3 of the first convolution module, and then passed through a convolution layer with a convolution kernel size of 3x3, a batch normalization layer, and a ReLU activation function to obtain the fused feature map P3.
[0073] The fused feature map P5 is downsampled in sequence through a convolution layer with a convolution kernel size of 3x3 and a step size of 2, a batch normalization layer, and a ReLU activation function to obtain a fused feature map P6.
[0074] The fused feature map P6 is downsampled in sequence through a convolution layer with a convolution kernel size of 3x3 and a step size of 2, a batch normalization layer, and a ReLU activation function to obtain a fused feature map P7.
[0075] It should be noted that the neck network effectively integrates feature information of different scales through the above processing flow, and generates a multi-scale feature pyramid through upsampling and downsampling operations, providing rich feature support for subsequent target detection.
[0076] The head network includes 5 detection heads, which are used to detect the fused feature map P3, fused feature map P4, fused feature map P5, fused feature map P6 and fused feature map P7 generated by the neck network respectively, obtain the human body detection results in each fused feature map and merge them to obtain the final human body detection result.
[0077] More specifically, a head detection branch and a body detection branch are constructed simultaneously on each detection head. The detection results include the category information, coordinate information, and center point confidence of the head detection box and the body detection box.
[0078] The head detection branch uses a convolutional block attention module to replace the convolution module of the FCOS model detection head.
[0079] Specifically, the convolutional block attention module (CBAM) is a module that combines channel attention and spatial attention. By connecting the channel attention module and the spatial attention module in series, the attention map of the feature map is calculated from the two dimensions of channel and space, and then multiplied with the input feature map to achieve adaptive learning of features.
[0080] The head detection branch includes a head shared attention convolutional layer, a head regression sub-branch, a head classification sub-branch and a head center sub-branch.
[0081] Each of the fused feature maps passes through the four convolution block attention modules of the head shared attention convolution layer in turn to enhance the features of the feature map.
[0082] Specifically, within each convolutional block attention module, the feature map is processed through a channel attention module to enhance the features of important channels and suppress the features of unimportant channels. In the channel attention module, the feature map is first processed through average pooling and maximum pooling, and then channel attention weights are obtained through a multi-layer perceptron (MLP). The normalized attention weights are obtained through a sigmoid function, and the channel attention weights are multiplied with the original input feature map to enhance the important channels.
[0083] The output feature map of the channel attention module is used to enhance the features of important spatial locations and suppress the features of unimportant spatial locations through the spatial attention module. In the spatial attention module, the output feature map of the channel attention module is first processed through channel average pooling and channel maximum pooling. The two pooling results are then spliced in the channel dimension. Then, after passing through a 7x7 convolution layer and an activation function, spatial attention weights are generated. The spatial attention weights are multiplied with the output feature map of the channel attention module to enhance the features of important spatial locations.
[0084] It should be noted that the use of the attention mechanism in the head detection branch can focus more attention on key parts and discard errors in processing noise and irrelevant information, thereby improving the accuracy and robustness of the model and highlighting the accuracy of head detection.
[0085] Furthermore, the output feature map of the head shared attention convolution layer is passed through the 1x1 convolution layer and linear activation function of the head regression sub-branch to obtain 8 coordinate values of each pixel in the feature map, where the first 4 coordinate values represent the head detection frame, and the last 4 coordinate values represent the body prediction frame corresponding to the head detection frame.
[0086] The output feature map of the head shared attention convolutional layer is passed through the 1x1 convolutional layer and Sigmoid activation function of the head classification sub-branch to obtain the probability value of each pixel point in the feature map belonging to each category.
[0087] The output feature map of the head shared attention convolution layer is passed through the 1x1 convolution layer and Sigmoid activation function of the head center degree sub-branch to obtain the center point confidence of each pixel in the feature map.
[0088] More specifically, the body detection branch includes a body shared convolutional layer, a body regression sub-branch, a body classification sub-branch and a body centrality sub-branch.
[0089] The fused feature map is sequentially passed through the four convolution layers with 3×3 convolution kernels of the body shared convolution layer, the batch normalization layer, extraction and ReLU activation to enhance the features of the feature map.
[0090] The output feature map of the body shared convolution layer is passed through the 1x1 convolution layer and linear activation function of the body regression sub-branch to obtain the four coordinate values of each pixel in the feature map, representing the body detection frame.
[0091] The output feature map of the body shared convolutional layer is passed through the 1x1 convolutional layer and Sigmoid activation function of the body classification sub-branch to obtain the probability value of each pixel point in the feature map belonging to each category.
[0092] The output feature map of the body-sharing convolutional layer is passed through the 1x1 convolutional layer and Sigmoid activation function of the body center sub-branch to obtain the center point confidence of each pixel in the feature map.
[0093] Furthermore, matching the body prediction frame with the body detection frame, and using the matching result and the head detection frame corresponding to the body prediction frame as a human detection result, includes steps S211 to S214:
[0094] Step S211: construct a matching matrix based on the matching degree between the body prediction frame corresponding to one detection head and the body detection frame.
[0095] Specifically, for each body prediction frame corresponding to the head detection frame detected by the head detection branch in one detection head, the intersection-and-union ratio (IoU) of the body prediction frame and all body detection frames obtained by the body detection branch is calculated to construct a matrix. For example, the rows represent the body prediction frames, the columns represent the body detection frames, and each element in the matrix represents the IoU ratio between the body prediction frame and the body detection frame.
[0096] Step S212: Use the Hungarian algorithm to solve the matching matrix to obtain the best matching body detection frame of the head detection frame, which together with the head detection frame constitutes a human body detection result.
[0097] Specifically, the Hungarian algorithm finds the minimum weighted match in a weighted bipartite graph. While the Hungarian algorithm seeks a minimum value, this embodiment aims to maximize the intersection over union (IoU). Therefore, the negative value of the IoU is used as a weight to find the optimal match using the Hungarian algorithm. Based on the results of the Hungarian algorithm, each head detection box is assigned a body detection box. If multiple head detection boxes have similar IoU values with the same body detection box, the pair with the highest IoU is selected.
[0098] Step S213: For the unmatched head detection frame, use it and the corresponding body prediction frame as the human body detection result.
[0099] Specifically, for each successfully matched head detection frame, it is combined with the corresponding body detection frame to form a complete human detection result. Because some body parts corresponding to head detection frames are occluded, missing, or detection fails in the image, for unmatched head detection frames, the corresponding body prediction frame is selected as the human detection result.
[0100] More specifically, for the human detection result obtained in step S212, the categories of the head detection frame and the body detection frame are both marked as "detection frame" and assigned the same person identifier;
[0101] For the human body detection result obtained in step S213, the category of the head detection frame is set to "detection frame", the category of the body prediction frame is set to "prediction frame", and the same person identifier is also assigned.
[0102] Step S214: For the body detection frame that is not matched to the head detection frame, treat it as a separate human detection result, mark its category as "detection frame", and assign it a unique person identifier.
[0103] Specifically, when the camera is far away from the person being photographed, due to the limitations of resolution and viewing angle, the head may occupy too few pixels in the image, making it difficult to be clearly identified and detected. At this time, the detected body detection frame is used as the human detection result.
[0104] Furthermore, the categories of the human body detection frame include a complete human body detection frame, a head-dominated human body detection frame, and a single body human body detection frame.
[0105] The complete human body detection frame includes a head detection frame and a corresponding body detection frame, both of which are detected by the detection head of the human body detection model.
[0106] Specifically, as described in the detection results of step S212 above, when the posture of the person in the image is normal, unobstructed or less obstructed, and the camera shooting angle and distance are appropriate, the head and body of the person can be captured clearly and completely. At this time, the human body detection model can output a complete human body detection frame.
[0107] The head-dominated human body detection frame includes a head detection frame detected by the detection head of the human body detection model and a body detection frame corresponding to the head detection frame predicted by the human body detection model based on the head detection frame.
[0108] Specifically, as described in the detection results of step S213 above, when the body of the person in the image is partially blocked, or the features of some parts of the body are not obvious due to factors such as shooting angle and distance, and it is difficult to directly detect the complete body, the human body detection model can output a head-dominated human body detection frame.
[0109] The single body human detection frame only includes a body detection frame detected by the detection head of the human detection model, and does not have a head detection frame matching the body detection frame.
[0110] Specifically, as described in the detection results of step S214 above, when the head of the person in the image is completely blocked, or the head is outside the camera shooting range, or the model cannot accurately detect the head due to reasons such as a small head or a special posture, the human body detection model can only output a single body human body detection frame.
[0111] Furthermore, the human body detection model is trained using the following method:
[0112] Construct a training data set for the human body detection model; wherein the training data set includes a set of images with human bodies, category labels corresponding to the annotated head and body in each image, bounding boxes, and center point positions.
[0113] Specifically, image data is obtained from multiple sources, including public datasets, self-taken photos, or online images. The head and body in each image are annotated, corresponding bounding boxes are drawn, and each bounding box is assigned a corresponding category label. For example, the head and body in the image data are annotated separately, and the center position of each bounding box is annotated. It should be noted that data augmentation techniques such as random cropping, rotation, scaling, color transformation, noise addition, and affine transformation are used to increase the diversity of the training data to improve the robustness of the model.
[0114] It should be noted that the head of the human body in the image set includes images of the human body wearing a helmet, not wearing a helmet, and wearing various hats; the body of the human body in the image set includes images of the human body wearing reflective clothing and not wearing reflective clothing.
[0115] The training data set is loaded, and the human body detection model is trained using a total loss function consisting of a classification loss function, a center point loss function, and a weighted coordinate regression loss function. The model parameters are updated using gradient back propagation, and the training is terminated when the loss function value converges to obtain a trained human body detection model; wherein, based on the weight value of the positive sample of the detection box and the coordinate loss function, the weighted coordinate regression loss of the positive sample of each detection box is obtained.
[0116] Furthermore, when training the human body detection model, the positive samples of the detection frame are screened and their weight values are calculated based on the intersection-over-union ratio of the detection frame with the head annotation frame and the body annotation frame to perform weighted coordinate regression loss, and a loss function is constructed based on the weighted coordinate regression loss; wherein, the positive samples of the detection frame include positive samples of the head detection frame, positive samples of the body detection frame, and positive samples of multi-category detection frames.
[0117] Specifically, during the positive sample matching process, the human body is often larger than the head to a certain extent. Therefore, the number of anchor frames in traditional human matching is much higher than that of the head, which reduces the accuracy of head detection. Therefore, this embodiment uses a layered positive sample matching mechanism to adaptively adjust the matching between anchor frames and ground truth frames. This mechanism can obtain higher-quality positive samples and update the weights of anchor frames to emphasize the importance of the overlapping area between the head and body, thereby improving convergence speed and target positioning accuracy.
[0118] Furthermore, the method of screening the positive samples of the detection box and calculating the weight value thereof includes steps S221 to S223:
[0119] Step S221: Based on the intersection-over-union ratio of the detection frame and the head annotation frame, a positive sample of the head detection frame is screened, and based on the distance between the positive sample of the head detection frame and the center of the head annotation frame, a head weight value of the positive sample of the head detection frame is calculated.
[0120] Specifically, through intersection-over-union screening, it can ensure that the selected positive samples have a high degree of overlap with the actual head position, thereby improving the accuracy of detection and removing negative samples in the detection frame to reduce computational costs and reduce the risk of overfitting of the model during training. At the same time, by calculating the head weight value through the distance between the positive sample of the head detection frame and the center of the head annotation frame, the detection results can be further refined, so that the detection frame closer to the actual head center obtains a higher weight, which is easier to be identified and retained in subsequent processing, helping to improve the overall detection performance.
[0121] Furthermore, the positive samples of the head detection frame are screened and their head weight values are calculated, including steps S2211 to S2215:
[0122] Step S2211: Calculate the distance between the center point of each detection frame and the center point of the head annotation frame, select the first k1 detection frames with the closest distance as candidate head detection frame positive samples, and calculate the intersection-over-union ratio between them and the head annotation frame.
[0123] Specifically, for each detection box, the coordinates of its center point C are calculated based on the coordinate values of its four corner points. det,a ; For each head annotation box, the coordinates of its center point C are calculated based on the coordinate values of its four corner points gt,j ; Use the Euclidean distance formula to calculate the distance d between the center point of each detection box and the center point of the head annotation box a,j Based on the distance d a,j, select the first k1 closest detection boxes as candidate head detection box positive samples; k1 is a hyperparameter that can be adjusted based on actual conditions. By selecting the first k1 detection boxes closest to the center point of the head annotation box as candidate head detection box positive samples, we can preliminarily screen out areas that are unlikely to contain the object, reducing the number of detection boxes that need to be processed and reducing subsequent computational cost and time.
[0124] More specifically, for each candidate head detection frame positive sample, the intersection-over-union ratio between it and each head annotation frame is calculated to further evaluate the degree of matching.
[0125] Step S2212: Based on the intersection-over-union ratios (IoUs) between the positive samples of the candidate head detection frames and the head annotation frame, obtain the mean and variance of the IoUs of the positive samples of the candidate head detection frames.
[0126] Specifically, the mean and variance of the intersection-over-union ratios of the positive samples of the candidate head detection frames that match each head annotation frame as a positive sample are calculated; wherein the variance reflects the degree of dispersion of the intersection-over-union ratio, that is, the consistency of the degree of matching between the positive samples of the candidate head detection frames and the head annotation frames; and a high mean value indicates that the candidate frames have a good average match.
[0127] Step S2213: Using the mean and the sum of the variances of the intersection-over-union ratios of the candidate head detection frame positive samples as a threshold, further filter the head detection frame positive samples to obtain the final head detection frame positive samples.
[0128] Step S2214: Set the category value of the detection box that is a positive sample of the head detection box to head and record its index value.
[0129] Specifically, by setting the category value, the model can clearly know the target category corresponding to each positive detection box example, which helps the model learn to distinguish objects of different categories. The index value of the detection box that serves as the head detection box positive example is saved in the positive sample index set POS, which is used to quickly locate and reference these positive examples in subsequent calculations.
[0130] Step S2215: Based on the center point position of the head detection frame positive sample, calculate the weight of the head detection frame positive sample as the head weight value of the detection frame positive sample.
[0131] Furthermore, the head weight value is calculated using the following formula:
[0132]
[0133] Among them, W head,i Indicates the head weight of the i-th detection box; dist i,j Indicates the distance between the i-th detection box and the j-th head annotation box; (GT w,j ,GTh,j ) represents the width and height of the j-th head annotation box.
[0134] Specifically, by assigning higher weights to positive samples of detection boxes that are closer to the true annotation boxes, the model can pay more attention to these key samples, thereby improving learning efficiency and detection accuracy.
[0135] Step S222: Based on the intersection-and-union ratio of the detection frame and the body annotation frame, the body detection frame positive sample is screened, and based on the distance between the body detection frame positive sample and the center of the body annotation frame, the body weight value of the body detection frame positive sample is calculated; wherein, when the head detection frame positive sample and the body detection frame positive sample are the same detection frame, the detection frame is set as a multi-category detection frame positive sample, and its body weight value is updated to the sum of the corresponding head weight value and body weight value.
[0136] Specifically, since the head and body may have size differences, relative position changes, and mutual occlusion in the image, the detection frames of the head and body may have different best matching anchor frames and different feature representations; therefore, in order to more accurately reflect the degree of matching between each detection frame and the true annotation frame, and to improve the model's ability to recognize different target parts, independent positive sample screening and weight calculation are performed on the head detection frame and the body detection frame respectively, so that the model can optimize its learning process for different target parts, and ultimately improve the overall detection performance and robustness.
[0137] Furthermore, the positive samples of the body detection frame are screened and their body weight values are calculated, including steps S2221 to S2226:
[0138] Step S2221: Calculate the distance between the center point of each detection frame and the center point of the body annotation frame, select the first k2 detection frames with the closest distance as candidate body detection frame positive samples, and calculate the intersection-over-union ratio between them and the body annotation frame.
[0139] Specifically, similar to the above head detection frame processing steps, for each detection frame, the coordinates of its center point C are calculated based on the coordinate values of its four corner points. det,a ; For each body annotation box, the coordinates of its center point C are calculated based on the coordinate values of its four corner points gt,m ; Use the Euclidean distance formula to calculate the distance d between the center point of each detection box and the center point of the body annotation box a,m Based on the distance d a,m ; Select the first k2 detection frames closest to the body as the candidate body detection frame positive samples, where k2 is a hyperparameter.
[0140] Step S2222: Based on the intersection-over-union (IoU) ratios between the positive samples of the candidate body detection frames and the body annotation frames, obtain the mean and variance of the IoU ratios of the positive samples of the candidate body detection frames.
[0141] Step S2223 : Using the mean and the sum of the variances of the intersection-over-union ratios of the candidate body detection frame positive samples as a threshold, further filter the body detection frame positive samples to obtain the final body detection bounding box positive samples.
[0142] Step S2224: Set the category value of the detection frame that is a positive sample of the body detection frame to body and record its index value.
[0143] Similarly, the index values of the detection boxes that are positive samples of the body detection boxes are saved in the positive sample index set POS for fast positioning and referencing of these positive samples in subsequent calculations.
[0144] Step S2225: Calculate the body weight value of the positive sample of the body detection frame based on the center point position of the positive sample of the body detection frame.
[0145] Furthermore, the body weight value is calculated using the following formula:
[0146]
[0147] Among them, W body,i represents the body weight of the i-th detection box; dist i,m Represents the distance between the i-th detection bounding box and the m-th body annotation box; (GT w,m ,GT h,m ) represents the width and height of the mth body annotation box.
[0148] Step S2226: When the index value of the body detection frame positive sample is the same as the index value of the head detection frame positive sample, it is determined that they are the same detection frame.
[0149] Specifically, in some cases, when the detection box is large enough, it not only covers the head area but also covers part of the body area, so that the detection box is judged as a positive sample in both the head and body detection tasks.
[0150] When it is determined to be the same detection frame, the body weight value of the positive sample of the detection frame is updated to the sum of the corresponding head weight value and body weight value, and its category value is set to multi-category.
[0151] Step S223: Add the head weight value and the body weight value of the positive sample of the detection frame to obtain the weight value of the positive sample of the detection frame.
[0152] Specifically, the calculated weight values can highlight those detection boxes with high prediction accuracy and good matching with the true annotation boxes, so that the model pays more attention to these important samples during the training process. When calculating the loss, the weight values are used to weight the loss function to ensure that the model pays more attention to the contribution of high-quality positive samples during the optimization process, thereby improving the learning efficiency and accuracy of the model.
[0153] It should be noted that when the category of the detection frame positive sample is head, only its head weight value is calculated. At this time, the body weight value of the current detection frame positive sample is 0, and the weight value of the detection frame positive sample is its head weight value; when the category of the detection frame positive sample is body, only its body weight value is calculated. At this time, the head weight value of the current detection frame positive sample is 0, and the weight value of the detection frame positive sample is its body weight value; when the category of the detection frame positive sample is multi-category, the head weight value and the body weight value are calculated at the same time. Therefore, the weight value of the multi-category detection frame positive sample is the sum of the head weight value and the body weight value.
[0154] For example, the weight value formula of the positive sample of the detection box is expressed as:
[0155] W i =W head,i +W body,i
[0156] Among them, W i Represents the weight value of the positive sample of the i-th detection box; W head,i Represents the head weight value of the positive sample of the i-th detection box; W body,i Represents the body weight value of the positive sample of the i-th detection box.
[0157] Using higher weights for multi-category detection box positive samples can improve the model's performance when dealing with objects with complex relationships or overlapping areas. This allows the model to pay more attention to samples that are difficult to distinguish but rich in information, thereby optimizing the decision boundary during training and improving overall detection accuracy and generalization capabilities. This is especially true when there is mutual occlusion or proximity between objects, enabling more effective identification and location of objects of different categories.
[0158] Furthermore, in the head detection branch, when there is no body annotation box that matches the head annotation box, its coordinate regression loss function is:
[0159] L offsethead =α(|lh * -lh|+|th * -th|+|rh * -rh|+|bh * -bh|)
[0160] Among them, α represents a hyperparameter, which can be set according to the training situation; Represents the corner coordinates of the head detection box; (lh, th, rh, bh) represents the corner coordinates of the head annotation box.
[0161] When there is a body annotation box that matches the head annotation box, its coordinate regression loss function is:
[0162] L offsethead =α(|lh * -lh|+|th * -th|+|rh * -rh|+|bh * -bh|)+β(|lp * -lp|+|tp * -tp|+|rp * -rp|+|bp * -bp|)
[0163] Among them, β represents a hyperparameter, which can be set according to the training situation; (lp * , tp * , rp * , bp * ) represents the corner coordinates of the predicted body box; (lp, tp, rp, bp) represents the corner coordinates of the body annotation box.
[0164] Specifically, the coordinate regression loss function is used to measure the difference between the detection box predicted by the model and the true annotation box. Due to occlusion and other reasons, when annotating the bounding box in the image, only the head bounding box may be annotated without the body bounding box. In the head detection branch, the obtained detection box includes the head detection box and the predicted body box. Therefore, when the detection box positive sample is a head detection box positive sample, it means that there is no body annotation box corresponding to the head annotation box. The accuracy of the head detection box predicted by the model is measured by only calculating the sum of the absolute values of the difference between the head detection box corner coordinates and the head annotation box corner coordinates; when the detection box positive sample is a multi-classification detection box positive sample and there is a body annotation box corresponding to the head annotation box in the image, the sum of the absolute values of the difference between the head detection box corner coordinates and the head annotation box corner coordinates, as well as the sum of the absolute values of the difference between the body prediction box corner coordinates and the body annotation box corner coordinates are calculated at the same time to measure the accuracy of the detection box predicted by the model.
[0165] When the coordinates of the predicted box differ significantly from those of the labeled box, the value of the loss function increases. During training, the model reduces the value of this loss function through optimization algorithms such as gradient descent, so that the predicted detection box is as close as possible to the true labeled box, thereby improving the detection accuracy.
[0166] It should be noted that α and β in the coordinate regression loss function are hyperparameters and can be adjusted according to the training situation.
[0167] In the body detection branch, its coordinate regression loss function is:
[0168]
[0169] in, Represents the corner coordinates of the body detection box; (lp, tp, rp, bp) represents the corner coordinates of the body annotation box.
[0170] Specifically, since the body detection branch only obtains the body detection frame, in the body detection branch, for the positive sample of the body detection frame, its coordinate regression loss function only calculates the distance between the body detection frame and the body annotation frame.
[0171] It should be noted that based on the weight value of the positive sample of the detection box and the coordinate loss function, the weighted coordinate regression loss of the positive sample of each detection box is obtained.
[0172] During the training process, the classification loss function used in this embodiment is a standard cross entropy loss function, which is used to measure the model's prediction ability for the head and body. The center point loss function uses a binary cross entropy loss function to measure the prediction accuracy of the target center point.
[0173] The total loss function is the sum of the classification loss function, center point loss function and weighted coordinate regression loss function of the head detection branch and the classification loss function, center point loss function and weighted coordinate regression loss function of the body detection branch.
[0174] Step S3, based on the human body detection result, intercepting the head region image and / or body region image of each person to be detected in the target detection image, including:
[0175] When the category of the human body detection frame is a complete human body frame, based on the position of its head detection frame and the position of its body detection frame, intercepting its head region image and body region image;
[0176] When the category of the human body detection frame is a head-dominated human body detection frame, based on the position of its head detection frame, intercepting its head area image;
[0177] When the category of the human body detection frame is a single body human body detection frame, the body region image is captured based on the position of the body detection frame.
[0178] Specifically, when the human body detection frame is complete, it means that the human detection model has detected both the head and body, and each has a corresponding detection frame. In this case, the head region image is cropped from the target detection image based on the position coordinates of the head detection frame; simultaneously, the body region image is cropped based on the position coordinates of the body detection frame.
[0179] When the human detection frame is dominated by the head, only the head detection frame is directly detected, while the body detection frame is predicted based on the head detection frame. In this case, the head region image is cropped from the target detection image based only on the position coordinates of the head detection frame.
[0180] When the human body detection frame is a single body detection frame, only the body detection frame is detected without a matching head detection frame. In this case, the body region image is extracted from the target detection image based only on the position coordinates of the body detection frame.
[0181] More specifically, the method of intercepting images of corresponding areas according to different human detection frame categories fully considers the various complex situations that may be encountered in actual detection. By accurately intercepting images of the head and body areas, it ensures the comprehensiveness and accuracy of subsequent safety helmet and reflective clothing inspections, thereby ensuring timely detection and warning of safety wearing violations by workers and ensuring the safety of the construction site.
[0182] Step S4: Input the head area image and body area image of each inspected person into the trained helmet classification model and reflective clothing classification model respectively, and obtain the classification results output by each classification model; wherein the classification results output by the helmet classification model include whether the person is wearing a helmet; the classification results output by the reflective clothing classification model include whether the person is wearing reflective clothing.
[0183] Specifically, such as Figure 2 As shown, this embodiment obtains the safety wearing detection results in the image by performing safety helmet classification detection and reflective clothing classification detection on the head area image and body area image of each detection person respectively.
[0184] Furthermore, the helmet classification model is a convolutional neural network based on deep learning, including: a convolutional layer, a batch normalization layer, a ReLU activation function, a pooling layer, a fully connected layer and a softmax function.
[0185] The head area image is sequentially processed through the convolution layer, the batch normalization layer, and the ReLU activation function to extract local features of the image, and then the size of the feature map is reduced through the pooling layer. The feature map is then converted into a classification result through the fully connected layer, and finally the softmax function is used to obtain the probability value of whether a helmet is worn.
[0186] Specifically, the helmet classification model is trained using the following method:
[0187] Constructing a training data set for the helmet classification model, including: a set of images of people's heads from various angles, a set of images of people wearing various hats and helmets, and a label in each image indicating whether a helmet is worn;
[0188] The training data set is loaded, the hard hat classification model is trained using a binary cross entropy loss function, the model parameters are updated using gradient back propagation, and the training is terminated when the loss function value converges to obtain a trained hard hat classification model.
[0189] Furthermore, the reflective clothing classification model is a convolutional neural network model based on deep learning, including: a convolutional layer, a batch normalization layer, a ReLU activation function, a pooling layer, a fully connected layer and a softmax function;
[0190] The body area image is sequentially processed through the convolution layer, the batch normalization layer, and the ReLU activation function to extract local features of the image, and then the size of the feature map is reduced through the pooling layer. The feature map is then converted into a classification result through the fully connected layer, and finally the softmax function is used to obtain the probability value of whether the reflective clothing is worn.
[0191] Specifically, the reflective clothing classification model is trained using the following method:
[0192] Constructing a training data set for the reflective clothing classification model, including: a set of images of people's bodies from various angles, a set of images of people wearing or not wearing reflective clothing, and a label in each image indicating whether the person is wearing reflective clothing;
[0193] The training data set is loaded, the reflective clothing classification model is trained using a binary cross entropy loss function, the model parameters are updated using gradient back propagation, and the training is terminated when the loss function value converges to obtain a trained reflective clothing classification model.
[0194] Exemplarily, both the helmet classification model and the reflective clothing classification model can use the ResNet50 model structure.
[0195] In summary, the safety wear detection method according to an embodiment of the present invention has the following beneficial effects:
[0196] 1. In the technical solution of the present invention, the human body detection model usually only needs to process the human body part in the image, which greatly reduces the amount of calculation compared to directly detecting safety helmets and reflective vests in the entire image. After obtaining the human body detection results, safety helmets and reflective vests are detected in specific head areas and body areas, further narrowing the detection range and reducing the computational burden of the classification model, thereby improving the overall detection efficiency and being able to process large amounts of image or video data more quickly to meet the needs of real-time detection.
[0197] 2. The human body detection model in the technical solution of the present invention can focus on accurately detecting the position and outline of the human body in the image, including key parts such as the head and body. This can provide a more accurate detection area for subsequent safety helmet and reflective vest detection, avoiding the interference that may be encountered when directly searching for safety helmets and reflective vests in the entire image, thereby improving the accuracy of safety helmet and reflective vest detection and effectively reducing the probability of false detection and missed detection.
[0198] 3. In the technical solution of the present invention, the human body detection model uses an improved FCOS model to simultaneously construct a head detection branch and a body detection branch in each detection head, and binds the head and body information in the head detection branch, so that the detection model can more accurately identify and associate the head and body parts of the human body. Compared with the traditional separate detection method, the detection accuracy is higher.
[0199] 4. The technical solution of the present invention achieves the best matching between the body prediction frame and the body detection frame by constructing a matching matrix and solving it using the Hungarian algorithm, ensuring that the head detection frame and the matched body detection frame are used as the human detection result. Even when the person's body is obscured, it can effectively reduce the ID switching of the same violator.
[0200] 5. According to the technical solution of the present invention, in the process of matching positive samples, the size of the human body is often larger than the human head. Therefore, the number of anchor frames for human body matching is much higher than that of the human head, which reduces the accuracy of head detection. Therefore, in the process of matching anchor frames with real frames, a layered positive sample matching mechanism is proposed to adaptively adjust the matching of anchor frames with real frames. Through this mechanism, higher quality positive samples can be obtained and the weights of the anchor frames can be updated, thereby highlighting the importance of the overlapping area between the head and the body, which can improve the convergence speed and target positioning accuracy.
[0201] The above description is only a preferred specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by any technician familiar with this technical field within the technical scope disclosed by the present invention should be covered by the scope of protection of the present invention.
Claims
1. A safety wear detection method, characterized in that: The steps include: Acquire an image of a person to be detected captured by a surveillance video; Inputting the image into a trained human body detection model to obtain a human body detection result in the image; wherein the human body detection result includes the position of the human body detection frame and the category of the human body detection frame; Based on the human body detection result, a head region image and / or a body region image of each person to be detected is captured in the target detection image; The head area image and body area image of each detected person are respectively input into the trained safety helmet classification model and reflective clothing classification model to obtain the classification results output by each classification model; wherein the classification results output by the safety helmet classification model include whether the safety helmet is worn; the classification results output by the reflective clothing classification model include whether the reflective clothing is worn.
2. The method according to claim 1, characterized in that: The categories of the human body detection frame include a complete human body detection frame, a head-dominated human body detection frame and a single body human body detection frame; The complete human body detection frame includes a head detection frame and a corresponding body detection frame both detected by the detection head of the human body detection model; The head-dominated human body detection frame includes a head detection frame detected by the detection head of the human body detection model and a body detection frame corresponding to the head detection frame predicted by the human body detection model based on the head detection frame; The single body human detection frame only includes a body detection frame detected by the detection head of the human detection model, and does not have a head detection frame matching the body detection frame.
3. The method according to claim 2, characterized in that: Based on the human body detection result, the head region image and the body region image of each object to be detected are respectively intercepted in the target detection image, including: When the category of the human body detection frame is a complete human body frame, based on the position of the head detection frame and the position of the body detection frame, intercepting the head area image and the body area image; When the category of the human body detection frame is a head-dominated human body detection frame, based on the position of its head detection frame, intercepting its head area image; When the category of the human body detection frame is a single body human body detection frame, its body area image is captured based on the position of its body detection frame.
4. The method according to claim 3, characterized in that: The helmet classification model is a convolutional neural network based on deep learning, including: a convolutional layer, a batch normalization layer, a ReLU activation function, a pooling layer, a fully connected layer and a softmax function; The head area image is sequentially passed through the convolution layer, the batch normalization layer and the ReLU activation function to extract local features of the image, and then the size of the feature map is reduced through the pooling layer. The feature map is then converted into a classification result through the fully connected layer, and finally the softmax function is used to obtain the probability value of whether a helmet is worn.
5. The method according to claim 4, characterized in that: The reflective clothing classification model is a convolutional neural network model based on deep learning, including: a convolution layer, a batch normalization layer, a ReLU activation function, a pooling layer, a fully connected layer and a softmax function; The body area image is sequentially passed through the convolution layer, the batch normalization layer and the ReLU activation function to extract local features of the image, and then the size of the feature map is reduced through the pooling layer. The feature map is then converted into a classification result through the fully connected layer, and finally the softmax function is used to obtain the probability value of whether the reflective clothing is worn.
6. The method according to any one of claims 1 to 5, characterized in that: The human body detection model is an improved FCOS model, which simultaneously constructs a head detection branch and a body detection branch in each detection head, and binds the head and body information in the detection head; wherein, The head detection branch is used to obtain a head detection frame in the image and a body prediction frame corresponding to the head detection frame; The body detection branch is used to obtain a body detection frame in the image; The body prediction frame and the body detection frame are matched, and the matching result is used as the human body detection result.
7. The method according to claim 6, characterized in that: The matching of the body prediction frame and the body detection frame, and using the matching result and the head detection frame corresponding to the body prediction frame as the human body detection result, includes: Based on the matching degree between the body prediction frame and the body detection frame, constructing a matching matrix; The matching matrix is solved using the Hungarian algorithm to obtain the best matching body detection frame for the head detection frame, which constitutes a human body detection result together with the head detection frame; For the unmatched head detection frame, the corresponding body prediction frame is used as the human detection result; For the unmatched body detection frame, it is directly used as the human detection result.
8. The method according to claim 7, characterized in that: When training the human body detection model, based on the intersection-and-union ratio of the detection box with the head annotation box and the body annotation box, the detection box positive samples are screened and their weight values are calculated to perform weighted coordinate regression loss, and a loss function is constructed based on the weighted coordinate regression loss; wherein the detection box positive samples include head detection box positive samples, body detection box positive samples and multi-category detection box positive samples.
9. The method according to claim 8, characterized in that: The screening of positive samples of the detection box and calculating the weight value thereof includes: Based on the intersection-and-union ratio of the detection frame and the head annotation frame, a positive sample of the head detection frame is screened, and based on the distance between the positive sample of the head detection frame and the center of the head annotation frame, a head weight value of the positive sample of the head detection frame is calculated; Based on the intersection-and-union ratio of the detection frame and the body annotation frame, the body detection frame positive sample is screened, and based on the distance between the body detection frame positive sample and the center of the body annotation frame, the body weight value of the body detection frame positive sample is calculated; wherein, when the head detection frame positive sample and the body detection frame positive sample are the same detection frame, the detection frame is set as a multi-category detection frame positive sample, and its body weight value is updated to be the sum of the corresponding head weight value and the body weight value; The head weight value and the body weight value of the positive sample of the detection frame are added together to obtain the weight value of the positive sample of the detection frame.
10. The method according to claim 9, characterized in that: The human body detection model is trained using the following method: Constructing a training data set for the human body detection model; wherein the training data set includes a set of images with human bodies, category labels corresponding to the annotated heads and bodies in each image, bounding boxes, and center point positions; The training data set is loaded, and the human body detection model is trained using a total loss function consisting of a classification loss function, a center point loss function, and a weighted coordinate regression loss function. The model parameters are updated using gradient back propagation, and the training is terminated when the loss function value converges to obtain a trained human body detection model; wherein, based on the weight value of the positive sample of the detection box and the coordinate loss function, the weighted coordinate regression loss of the positive sample of each detection box is obtained.
Citation Information
Cited By
Model training method, target measurement method, device, equipment, medium and product
CN120563621A
Model training method, target measurement method, device, equipment, medium and product
CN120563621B