A safety helmet wearing recognition method and system based on multi-scale feature fusion
By combining a panoramic feature pyramid network, a dual-layer target enhancement mechanism, and a multi-scale detection head, the problems of insufficient multi-scale feature fusion and background interference in helmet wearing recognition are solved, achieving high-precision recognition in complex environments.
Patent Information
- Application Number
- CN202510489708.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-18
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2045-04-18
AI Technical Summary
Existing helmet wearing recognition methods have low accuracy in complex backgrounds or at different angles, insufficient multi-scale feature fusion, severe background interference, and are unable to effectively focus on the target area, resulting in false detections and false negatives.
A panoramic feature pyramid network is used for multi-scale feature fusion. Combined with a two-layer target enhancement mechanism and a multi-scale detection head, the regression loss function is optimized through spatial and channel attention mechanisms to improve recognition accuracy.
It significantly improves the accuracy and robustness of helmet wearing recognition, enabling stable detection in complex environments, reducing false detection and false negative rates, and enhancing the applicability and safety of the recognition system.
Smart Images

Figure CN120339592B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and deep learning technology, and in particular to a method and system for helmet wearing recognition based on multi-scale feature fusion. Background Technology
[0002] In the field of helmet-wearing recognition, single-scale or simple multi-scale methods are commonly used for target detection, such as traditional Feature Pyramid Networks (FPN) and Path Aggregation Networks (PANet). While these methods can handle targets at different scales, they often perform poorly in complex backgrounds or from different angles, leading to significant false positives and false negatives. Existing detection methods mainly suffer from the following problems:
[0003] 1. Insufficient multi-scale feature fusion: Existing methods use simple feature fusion strategies (such as feature summation or direct splicing), which cannot fully explore the relationship between different scales, resulting in low recognition accuracy when dealing with targets with large size differences.
[0004] 2. Background interference problem: Traditional target detection methods have poor suppression effect on complex backgrounds and cannot effectively ignore the interference of irrelevant backgrounds, which easily introduces noise and reduces recognition accuracy.
[0005] 3. Insufficient focus on the target area: Existing methods often fail to accurately focus on the target area in multi-target scenarios, and are easily affected by interference from other objects, which affects recognition performance. Summary of the Invention
[0006] The purpose of this invention is to provide a helmet wearing recognition method and system based on multi-scale feature fusion, thereby solving the aforementioned problems existing in the prior art.
[0007] To achieve the above objectives, the technical solution adopted by the present invention is as follows:
[0008] A helmet-wearing recognition method based on multi-scale feature fusion includes the following steps:
[0009] S1. Multi-scale feature fusion: The target detection model uses a panoramic feature pyramid network to stitch and weight feature maps of different scales in order to fuse feature maps of different scales.
[0010] S2, Dual-layer target enhancement: The target detection model uses a dual-layer target enhancement mechanism based on spatial attention and channel attention to perform weighted operations on the fused feature map in order to focus attention on the target region;
[0011] S3. Introduction of multi-scale detection heads: Multi-scale detection heads are introduced into the target detection model. Multiple detection heads process targets of different sizes through anchor boxes and feature maps of different scales to optimize the accuracy of target detection.
[0012] S4. Optimization of regression loss function: Construct a total regression loss function for the object detection model using the position regression loss function and the category regression loss function. During the training process of the object detection model, continuously adjust the parameters using optimization methods to minimize the total regression loss function, thereby obtaining a well-trained object detection model.
[0013] Preferably, the panoramic feature pyramid network achieves multi-scale information fusion by stitching together and weighted summing feature maps at multiple scales. The calculation formula is as follows:
[0014] PFPN i =concat(W i ·F i ,∑(a j ·F j ))
[0015] Among them, PFPN i For multi-scale information fusion results; F i and F j These are the feature maps of the i-th and j-th layers, respectively; W i Let a be the weighting matrix of the feature maps of the i-th layer, used to perform weighting operations on the feature maps of the i-th layer; j The weighting coefficients of the feature map at layer j; ∑(a i ·F j For feature maps F at all scales j Perform a weighted summation; concat is an operation that concatenates multiple feature maps along the channel dimension;
[0016] Preferably, a loss function is constructed for the panoramic feature pyramid network, and the panoramic feature pyramid network is trained through backpropagation based on the loss function, thereby continuously adjusting the weighting matrix W of the feature maps. i The weighting coefficient a of the feature map j .
[0017] Preferably, step S2 specifically includes the following:
[0018] S21. The spatial attention mechanism weights each spatial location in the feature map based on the importance of different locations in the image; the calculation formula is as follows:
[0019] Attention spatial =σ(Conv(F))
[0020] Among them, Attention spatialσ represents the spatial weighting coefficients obtained through the spatial attention mechanism; F represents the input feature map; Conv(F) represents the spatial weighting coefficients extracted from the feature map through convolution operations; σ is the activation function used to map the spatial weighting coefficients extracted from the feature map through convolution operations to the [0,1] interval;
[0021] S22. The channel attention mechanism emphasizes the importance of different channels in a specific task by weighting each channel of the feature map; the calculation formula is as follows:
[0022] Attention channel =σ(FC(f))
[0023] Among them, Attention channel is the channel weighting coefficient obtained through the channel attention mechanism; FC(F) is the weighting coefficient of each channel extracted from the feature map through the fully connected layer; σ is the activation function used to map the weighting coefficient of each channel extracted from the feature map through the fully connected layer to the interval [0,1].
[0024] S23. Spatial attention and channel attention are weighted separately on the feature map, and the weighted results of the two are fused to enhance the network's ability to focus on the target region; the calculation formula is as follows:
[0025] Attention fused =Attention spatial Attention channel ·F
[0026] Among them, Attention fused This is the final fusion result.
[0027] Preferably, a loss function is constructed for the two-layer target enhancement mechanism, and the two-layer target enhancement mechanism is trained through backpropagation based on the loss function, thereby continuously adjusting the weighting coefficients of the space, Attention. spatial Attention and channel weighting coefficients channel .
[0028] Preferably, the multi-scale detection head optimizes target accuracy by adding anchor boxes of different scales to the network and processing them with different feature maps for each scale; the calculation formula is as follows:
[0029] Detection output =∑(Anchor) t Feature_map t )
[0030] Among them, Detection outputThe processing results of the multi-scale detection head; Anchor i The anchor box at the t-th scale; Feature_map t Let be the feature map at the t-th scale.
[0031] Preferably, the total regression loss function is constructed by weighting the location regression loss function and the category regression loss function, and the calculation formula is as follows:
[0032] L total =λ1·L bbox +λ2·L class
[0033] L bbox =∑(1-IOU(predict,ground) truth ))
[0034]
[0035] L class =-∑(y·log(p)+(1-y)·log(1-p))
[0036] Among them, L total L is the total regression loss function; bbox and L class λ1 and λ2 are the location regression loss function and the class regression loss function, respectively; λ1 and λ2 are the weight coefficients of the location regression loss function and the class regression loss function, respectively; IOU is the intersection-union ratio used to measure the degree of overlap between the predicted box and the ground truth box; predict is the predicted box; ground truth For the actual bounding box; Area_of Intersection Area_of is the area of the intersection of the predicted bounding box and the ground truth bounding box. Union y is the area of the union of the predicted bounding box and the ground truth bounding box; y is the ground truth class label, which is 1 when the target belongs to a certain class and 0 when the target does not belong to that class; p is the predicted probability of the target belonging to a certain class by the object detection model.
[0037] Preferably, step S4 is followed by:
[0038] S5. Helmet Wearing Recognition: Uses a trained target detection model to identify helmet wearing status and outputs the helmet wearing recognition result.
[0039] Preferably, the procedure before step S1 includes:
[0040] S0. Dataset preparation: Manually label the helmet wearing status in the collected images to construct a helmet wearing status dataset.
[0041] The present invention also aims to provide a helmet wearing recognition system based on multi-scale feature fusion. This recognition system can implement the method described above. The recognition system includes...
[0042] Multi-scale feature fusion module: The target detection model uses a panoramic feature pyramid network to stitch and weight feature maps of different scales in order to fuse feature maps of different scales;
[0043] Dual-layer target enhancement module: The target detection model uses a dual-layer target enhancement mechanism based on spatial attention and channel attention to perform weighted operations on the fused feature map in order to focus attention on the target region;
[0044] Multi-scale detection head introduction module: A multi-scale detection head is introduced into the target detection model. Multiple detection heads process targets of different sizes through anchor boxes and feature maps of different scales to optimize the accuracy of target detection.
[0045] The regression loss function optimization module constructs a total regression loss function for the object detection model using the location regression loss function and the category regression loss function. During the training process of the object detection model, the parameters are continuously adjusted using optimization methods to minimize the total regression loss function, thereby obtaining a well-trained object detection model.
[0046] The beneficial effects of this invention are as follows: 1. By introducing a panoramic feature pyramid network (PFPN), a two-layer target enhancement mechanism (BGA), and optimizing a multi-scale detection head, this invention solves the problems of low accuracy and poor robustness in the recognition of helmet wearing status in complex backgrounds and at different angles in existing technologies, thereby improving the accuracy and stability of target detection. 2. Through the panoramic feature pyramid network of PFPN, this invention can better integrate features of different scales, reduce information loss, and significantly improve the ability to recognize targets of different sizes, thereby improving the accuracy of helmet wearing status, especially for targets with large size variations. 3. The two-layer target enhancement mechanism (BGA), combined with spatial and channel attention, effectively improves the model's ability to focus on the target region, reduces the interference of background noise, and significantly improves the detection accuracy in complex environments. 4. By introducing a multi-scale detection head, the model can better adapt to targets of different scales, optimize the anchor frame scale, further improve the detection accuracy of helmets of different sizes, and reduce the incidence of missed detections and false detections. 5. In dynamically changing working environments, this invention can stably cope with various complex scenarios, including different shooting angles, background changes, and lighting conditions, thereby improving the robustness and applicability of the overall recognition system. 6. This invention can significantly improve the accuracy and efficiency of safety helmet wearing recognition in construction sites, industrial production, and other fields, reducing the need for human intervention, and further ensuring the safety of workers through high-precision recognition. Attached Figure Description
[0047] Figure 1 This is a flowchart of the identification method in an embodiment of the present invention. Detailed Implementation
[0048] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0049] This embodiment provides a helmet wearing recognition method based on multi-scale feature fusion, aiming to improve the accuracy and robustness of helmet wearing status recognition in complex backgrounds and at different angles. This method significantly enhances target recognition capabilities by introducing an improved target detection framework and combining it with a panoramic feature pyramid network (PFPN), a two-layer target enhancement mechanism (BGA), and optimization of a multi-scale detection head. First, the panoramic feature pyramid network (PFPN) performs stitching and weighting operations on multi-level feature maps, achieving effective fusion of features at different scales and enhancing the perception of multi-scale targets. Then, the two-layer target enhancement mechanism (BGA) introduces spatial and channel attention mechanisms to effectively focus on the target region, ignoring background noise, further improving the model's focus on the target and recognition accuracy. Next, the multi-scale detection head optimizes the network's ability to detect helmets of different sizes. Finally, the optimized regression loss function combines position loss and category loss, further improving the target localization and classification accuracy. The comprehensive technical solution of this invention shows significant improvement in helmet wearing recognition tasks, especially in target detection in complex environments and at different angles, and has high practicality and promotional value. Figure 1 As shown, the method of the present invention mainly includes the following parts:
[0050] I. Dataset Preparation
[0051] The helmet wearing status in the collected images is labeled manually to construct a helmet wearing status dataset.
[0052] II. Multi-scale feature fusion
[0053] The object detection model uses a panoramic feature pyramid network to stitch and weight feature maps of different scales in order to fuse feature maps of different scales.
[0054] Panoramic Feature Pyramid Network (PFPN) is a method for enhancing multi-scale feature fusion. It improves the ability of deep learning models to recognize multi-scale targets through inter-layer stitching operations and dense feature connections. This network is particularly suitable for object detection tasks, especially when dealing with targets of different scales and complex backgrounds, effectively improving model performance. PFPN primarily enhances the network's ability to perceive targets of different sizes by weighting and stitching feature maps at different scales.
[0055] 2.1 Feature Map and Scale
[0056] The core idea of PFPN is to improve the detection capability of targets of different sizes by fusing feature maps at multiple scales. Targets in images vary significantly in scale, requiring the model to simultaneously consider the features of both small and large targets. In traditional convolutional neural networks (CNNs), the spatial resolution of feature maps gradually decreases as the number of network layers increases, leading to a weakening of the ability to detect small targets. PFPN effectively solves this problem by fusing feature maps at multiple scales. Assume there are n feature maps at different scales, where the feature map Fi at the i-th layer corresponds to a feature map of one scale. For each layer's feature map, a weighting coefficient Wi is introduced to weight the feature maps, ensuring that the feature maps from different layers are adjusted according to their importance during fusion.
[0057] 2.2 Feature Map Fusion and Weighting
[0058] The core operations of PFPN are feature map concatenation (concat) and weighted summation (Σ). Specifically, PFPN achieves multi-scale information fusion by concatenating and weighted summing feature maps at multiple scales. The formula can be expressed as:
[0059] PFPN i =concat(W i ·F i ,∑(a j ·F j ))
[0060] Among them, PFPN i For multi-scale information fusion results; F i and F j These are the feature maps of the i-th and j-th layers, respectively, typically high-dimensional feature matrices generated by convolutional layers; F i The dimensions are (Wi, Hi, Ci), where Wi and Hi represent the width and height of the feature map, respectively, and Ci represents the number of channels in the feature map; F jEach feature map layer also has dimensions (Wj, Hj, Cj), but feature maps at different scales may have different spatial resolutions and number of channels. i W is the weighting matrix for the feature maps of the i-th layer, used to perform weighting operations on the feature maps of the i-th layer. i The dimension is (Ci, Ci'), which means it transforms the number of channels in the feature map to ensure that the weighted feature map has the same number of channels when concatenated with feature maps of other scales. j denoted as the weighting coefficient of the j-th layer feature map, representing the importance of that layer's feature map in feature fusion. j The value of is typically adjusted based on the layer depth, feature quality, and contribution to object recognition. The value of aj can be a scalar or a vector used to adjust the feature map of each layer. ∑(a i ·F j For feature maps F at all scales j Weighted summation, by summing the feature maps Fj of each layer using weights, aggregates useful information from different scales, thus avoiding information loss due to scale differences. `concat` is an operation that concatenates multiple feature maps along the channel dimension. The concatenated feature map contains feature information from different scales, which is then used in subsequent object detection tasks.
[0061] Through this splicing and weighted summation operation, PFPN can integrate multi-scale information, significantly enhancing the network's ability to perceive targets of different sizes. In particular, when faced with targets of different sizes and complex backgrounds, the model can more accurately locate and classify targets.
[0062] 2.3 Optimization and Training
[0063] To better learn the feature map weighting coefficients W i and a j PFPN networks are typically trained end-to-end. The network's loss function combines common loss terms used in object detection, such as classification loss and regression loss. Classification loss measures the model's accuracy in predicting the object's category, while regression loss measures the model's accuracy in predicting the object's location (e.g., the bounding box).
[0064] For example, the loss function L can be expressed as:
[0065] L = L classification +L regression
[0066] Among them, L classification and L regression These are the classification error used to calculate the target category and the regression error used to calculate the target location (bounding box), respectively.
[0067] Through backpropagation, the model continuously adjusts the feature weighting coefficients W. i and a j This enables the network to more effectively integrate multi-scale features, thereby improving overall detection performance.
[0068] 2.4 Practical Application
[0069] PFPN's multi-scale feature fusion capabilities have demonstrated outstanding performance in many practical applications, particularly in target detection tasks. For example, in fields such as industrial safety monitoring, intelligent transportation, and medical image analysis, PFPN can effectively identify targets of different sizes, such as traffic signs, human bodies, and vehicles. In helmet detection scenarios, PFPN helps the model identify helmets at different angles and scales, effectively processing and accurately identifying both small targets at close range and large targets at a distance.
[0070] The Panoramic Feature Pyramid Network (PFPN) plays a crucial role in multi-scale feature fusion in the method of this invention. By stitching and weighting feature maps at different scales, PFPN effectively fuses feature information from different levels, enhancing the network's ability to handle targets of varying sizes and backgrounds. In helmet wearing recognition, different shooting angles and image sizes can lead to scale differences in the target. PFPN enhances the network's robustness to these scale differences through dense feature connections, ensuring the model can accurately detect helmet wearing status in various scenarios. PFPN provides high-quality feature input for subsequent two-layer target augmentation (BGA) and multi-scale detection heads. PFPN enhances the expressive power of features, while BGA and multi-scale detection heads use these enhanced features to further optimize detection accuracy and regression capabilities. PFPN provides multi-scale information fusion for the entire model, which is the foundation for the model to work better in complex backgrounds.
[0071] III. Two-tiered target enhancement
[0072] The target detection model employs a two-layer target enhancement mechanism based on spatial attention and channel attention to perform weighted operations on the fused feature map, thereby focusing attention on the target region.
[0073] The Bilateral Goal Attention Mechanism (BGA) is a weighted operation combining spatial and channel attention mechanisms, designed to enhance the network's ability to focus on important target regions. By introducing weighted strategies at two levels—spatial and channel attention—this mechanism helps the network more effectively focus on target regions when processing complex images, while suppressing interference from irrelevant backgrounds, thereby improving the model's target recognition accuracy.
[0074] 3.1 Spatial Attention Mechanism
[0075] The core idea of spatial attention is to weight each spatial location in the feature map according to its importance within the image. Spatial attention aims to enhance the network's focus on the target region and reduce the interference of background information on the model's judgment. The formula is expressed as:
[0076] Attention spatial =σ(Conv(F))
[0077] Among them, Attention spatial The spatial weighting coefficients, with dimensions (W, H, 1), are obtained through a spatial attention mechanism. F is the input feature map, with dimensions (W, H, C), where W and H are the width and height of the feature map, respectively, and C is the number of channels. Conv(F) represents the spatial weighting coefficients extracted from the feature map F through a convolution operation. The convolution operation learns filters (kernels) to capture the distribution patterns of spatial information in the image. The output after convolution is a spatial weighting coefficient map with dimensions (W, H, 1), where each element represents the importance of that spatial location. σ is the activation function used to map the convolution output to the interval [0, 1], representing the attention weight for each spatial location. In this way, higher values assign higher attention weights to important regions, while lower values suppress the influence of background regions.
[0078] Spatial attention mechanisms enable the network to focus on target regions in an image by weighting various locations in the spatial feature map, thereby improving the ability to identify target locations.
[0079] 3.2 Channel Attention Mechanism
[0080] The goal of channel attention is to weight each channel of a feature map, thereby emphasizing the importance of different channels in a specific task. Through channel weighting, the model can selectively focus on the features most valuable for target recognition based on the information contribution of different channels. The formula is expressed as:
[0081] Attention channel =σ(FC(F))
[0082] Among them, Attention channelThe channel weighting coefficients, with dimensions (1,1,C), are obtained through the channel attention mechanism. FC(F) processes the input feature map F through a fully connected layer to obtain the weighting coefficients for each channel. The fully connected layer typically first performs global average pooling on the input feature map to obtain the global features for each channel, and then calculates the attention coefficients for each channel. σ is the activation function used to map the channel weighting coefficients to the [0,1] interval. For each channel, a larger value indicates higher importance, and a smaller value indicates lower contribution.
[0083] The channel attention mechanism weights the features of different channels, enabling the network to focus on the features of key channels and suppress interference from irrelevant channel information based on the importance of the channels.
[0084] 3.3 Two-tiered target enhancement mechanism
[0085] In the BGA mechanism, spatial and channel attention are weighted separately on the feature map, and then the weighted results are fused to further enhance the network's ability to focus on the target region. Specifically, the fused feature map is obtained by element-wise multiplying the weighting coefficients of spatial and channel attention with the original feature map. The fused formula is expressed as:
[0086] Attention fused =attention spatial Attention channel ·F
[0087] Among them, Attention fused This is the final fusion result.
[0088] Through this element-wise multiplication operation, the weighted information in space and channels is integrated into the feature map, so that the features of each spatial location and each channel are weighted accordingly, thereby improving the model's ability to identify target regions.
[0089] 3.4 Optimization and Implementation of the Two-Tier Target Enhancement Mechanism
[0090] In practice, the BGA mechanism is often used in conjunction with convolutional neural networks (CNNs) as a module to enhance features. Specifically, spatial attention and channel attention can be learned through independent convolutional and fully connected layers, while the fused feature map can be used for subsequent object detection tasks. The training process for BGA typically employs an end-to-end approach, using various loss functions such as cross-entropy loss and regression loss for optimization. Through backpropagation, the model can adaptively adjust the spatial and channel weighting coefficients, continuously improving the ability to recognize target regions.
[0091] 3.5 Practical Application
[0092] BGA has demonstrated excellent performance in many practical applications, especially in target detection tasks with complex backgrounds. For example, in tasks such as helmet wearing detection, traffic sign recognition, and human pose estimation, BGA can effectively focus on the target region, suppress background interference, and improve target detection accuracy. In specific applications, BGA can accurately identify targets under dynamic lighting, different angles, and complex backgrounds, even if the target is small or partially occluded in the image. In helmet wearing detection systems, BGA uses spatial attention mechanisms to help the network focus on the head region, while channel attention strengthens key features related to the helmet wearing status, thus significantly improving detection accuracy and robustness.
[0093] By introducing a two-layer target augmentation mechanism (BGA), the model can focus more on the target region and suppress interference from irrelevant information, thereby improving the accuracy and robustness of target recognition, and is especially suitable for target detection tasks in complex scenarios.
[0094] The Two-Layer Target Augmentation (BGA) mechanism combines spatial and channel attention mechanisms. It highlights the target region by weighting the feature map, ignoring background and irrelevant parts. Spatial attention allows the model to focus more attention on the target's location; channel attention further optimizes the feature response of each channel, enhancing the model's focus on key areas (such as the helmet). BGA directly operates on the feature map output by the Panoramic Feature Pyramid Network (PFPN), further strengthening the feature representation of the helmet-wearing area through weighting. Its role is to improve the network's focus on the target region, ensuring accurate target identification even in complex backgrounds. Through this weighting, BGA enhances the performance of the Panoramic Feature Pyramid Network, thus forming an effective synergy with PFPN.
[0095] IV. Introduction of Multi-Scale Detection Head
[0096] A multi-scale detection head is a method that optimizes a neural network's ability to detect targets of different sizes by introducing anchor boxes at multiple scales. In target detection tasks, especially when detecting objects of different sizes, a single-scale detection head often cannot effectively handle large differences in target size. By introducing multiple detection heads into the network, each responsible for processing targets of different scales, the network's detection performance in complex scenes can be significantly improved, particularly in the detection accuracy of small or large objects against complex backgrounds.
[0097] 4.1 Working principle of multi-scale detection head
[0098] Multi-scale detection heads optimize object detection accuracy by adding anchor boxes of different scales to the network and processing each scale using different feature maps. Anchor boxes are rectangular boxes used to represent objects of different sizes, while feature maps are features extracted from the original image at different levels by a convolutional neural network (CNN). In traditional object detection methods, a single detection head is typically used to process targets of different sizes. However, due to the large differences in target size, a single-scale anchor box often fails to accurately match all targets. The introduction of multi-scale detection heads solves this problem, with each detection head specifically processing targets of different sizes using anchor boxes and feature maps of different scales. The formula is as follows:
[0099] Detection output =∑(Anchor) t Feature_map t )
[0100] Among them, Detection output The processing results of the multi-scale detection head; Anchor i Let be the anchor box at scale t. The anchor box is a predefined rectangle used to match possible target objects in the image. The size and aspect ratio of each anchor box are typically adjusted based on the actual size and distribution of the target objects. The size and position of the anchor boxes will also vary for different scales. Feature_map t Let be the feature map at scale t. Each scale's feature map is extracted through a convolutional network and contains feature information at different levels. Deeper feature maps typically contain high-level information about larger targets, while shallower feature maps focus more on low-level information about smaller targets. Σ represents a weighted sum of anchor boxes and feature maps across all scales. This operation allows the network to make comprehensive judgments based on the outputs of anchor boxes and feature maps at different scales, thereby improving the accuracy of target detection.
[0101] 4.2 Advantages of Multi-Scale Detection Heads
[0102] Improving small object detection accuracy: Since each scale detection head focuses on targets within a specific size range, it avoids the accuracy problems of traditional single-scale methods for small object detection. Especially in complex backgrounds, small objects are often easily obscured by background noise. Using multi-scale detection heads can improve the recognition accuracy of small objects by using reinforcement learning based on features from multiple scales.
[0103] Enhancing large object detection capabilities: By introducing larger-scale anchor boxes for large objects, the network can better adapt to the localization and regression tasks of large objects. Anchor boxes of different scales can help the network capture more detailed features of large objects, improving the accuracy of large object detection.
[0104] Enhancing model robustness: The multi-scale detection head synthesizes feature maps at different scales through weighted aggregation, making the model more robust to various scenarios. Whether it's a large or small object, or a target at different distances or angles, the network can accurately identify it based on features at different scales.
[0105] 4.3 Implementation of Multi-Scale Detection Head
[0106] In practice, each multi-scale detection head is connected to certain convolutional layers in the network. These convolutional layers are responsible for extracting feature maps from the input image and assigning appropriate weights to anchor boxes at each scale. In object detection frameworks such as YOLO, deep feature maps are often used to detect large objects, while shallow feature maps are suitable for detecting small objects. The anchor box size and aspect ratio at each scale are optimized based on prior experience and the target size in the training set. During network training, the loss function for each scale is calculated separately and weighted according to the detection task at each scale. Finally, the loss functions for all scales are summed for overall network optimization. This allows the network to optimize independently for each scale, improving the recognition accuracy for targets of different sizes. Specifically, during the training phase, an image dataset labeled with target bounding boxes is first used. In each image, the network selects a suitable anchor box based on the degree of overlap between the anchor box and the target (usually measured using IoU—Intersection over Union). If the IoU between the anchor box and the target exceeds a preset threshold, the anchor box is considered to have successfully detected the target. Each detection head at each scale is responsible for processing targets within its corresponding scale range.
[0107] 4.4 Practical Application
[0108] In practical applications, the introduction of multi-scale detection heads is particularly suitable for scenarios with significant differences in target size. For example, in helmet detection, the network needs to detect helmets in images taken from different distances and angles. Due to the large variations in helmet size and angle, a single-scale detection head struggles to handle diverse target sizes. However, by introducing a multi-scale detection head, the network can process small helmets (e.g., helmets worn by people at a distance) and large helmets (e.g., helmets photographed at close range) separately, thereby greatly improving detection accuracy and robustness. Furthermore, traffic sign recognition is another typical application scenario, where traffic signs of different sizes require efficient recognition using multi-scale detection heads. In this application, the system can automatically adjust anchor boxes of different scales to quickly detect traffic signs from far to near, ensuring the accuracy and real-time performance of the detection process.
[0109] By introducing multi-scale detection heads, the network can perform target detection at different scales, thus significantly improving its ability to detect targets of various sizes. Especially in complex scenes, anchor boxes at multiple scales can effectively compensate for the shortcomings of traditional single-scale detection methods, improving detection accuracy, particularly for small objects or large objects against complex backgrounds. This method is widely applicable to target detection tasks such as helmet wearing detection and traffic sign recognition, enhancing the system's robustness and practicality.
[0110] A multi-scale detection head optimizes the network's ability to recognize targets of various sizes by performing detection at different scales. In this invention, a fourth detection head is added to address the size differences of safety helmets, optimizing the model's detection of targets at different scales. This detection head not only enhances the network's ability to handle targets of different sizes but also further improves the detection accuracy of the safety helmet wearing status by fusing multi-scale features. The multi-scale detection head complements the PFPN and BGA mechanisms. PFPN provides rich multi-scale features, BGA further strengthens the expression of these features, and the multi-scale detection head optimizes the model's detection accuracy and regression ability by performing target detection at multiple scales. Through this design, the model can more accurately identify the wearing status of safety helmets when handling multi-scale targets.
[0111] V. Optimization of Regression Loss Function
[0112] In object detection tasks, the regression loss function is an important tool for measuring the difference between the model's predicted location and class and the true label. To improve the accuracy of object detection models in regressing the target's location and class, it is necessary to optimize the regression loss function to enhance detection accuracy. In the helmet-wearing detection problem, accurately locating the target (helmet) and determining its wearing status are crucial; therefore, it is necessary to comprehensively consider both location regression loss and class regression loss in the regression loss function.
[0113] 5.1 Total Regression Loss Function
[0114] To enable the model to better regress the target's location and category, the location regression loss (L) is used. bbox ) and category regression loss (L class This is combined into a total regression loss function L. total The expression for the loss function is:
[0115] L total =λ1·L bbox +λ2·L class
[0116] Among them, L total This is the total loss function, which includes both location loss and class loss. By optimizing L... total The network can simultaneously learn how to accurately locate the target's position and determine the target's category (such as the wearing status of a safety helmet).
[0117] λ1 and λ2 are the weighting coefficients of the loss function, used to balance the effects of position loss and class loss. Typically, position loss and class loss have different impacts in actual training; therefore, it is necessary to adjust λ1 and λ2 to ensure a reasonable proportion of each in the total loss, preventing one loss from becoming too large and affecting the overall optimization.
[0118] L bbox It is the location regression loss, used to measure the difference between the model's predicted bounding box and the ground truth bounding box. The intersection-over-union ratio (IoU) is usually used to measure the degree of overlap between the predicted and ground truth boxes.
[0119] L class It is the category regression loss, used to measure the accuracy of the model's prediction of the target category (such as helmet wearing status), and is usually calculated using cross-entropy loss.
[0120] 5.2 Location Regression Loss
[0121] The goal of location regression loss is to regress the bounding box of the target object as accurately as possible, i.e., the overlap between the predicted and ground truth boxes. To calculate the location loss, the Intersection over Union (IoU) is typically used to measure the degree of overlap between the predicted and ground truth boxes. The IoU is defined as follows:
[0122]
[0123] Where IOU(predict, ground) truth The cross-union ratio (CUP) measures the degree of overlap between the predicted bounding box and the ground truth bounding box. `predict` refers to the predicted bounding box, i.e., the bounding box predicted by the model. `ground` is the ground truth bounding box. truth This represents the true bounding box, i.e., the actual labeled bounding box. Area_of Intersection Area_of is the area of the intersection between the predicted bounding box and the ground truth bounding box. Union This is the area of the union of the predicted bounding box and the ground truth bounding box.
[0124] Location regression loss L bbox The difference between the predicted bounding box and the ground truth bounding box is measured by calculating the difference in IoU, using the following formula:
[0125] L bbox =∑(1-IOU(predict,ground) truth ))
[0126] Among them, L bbox The optimization objective is to reduce the gap between the predicted and ground truth bounding boxes, making the IoU value as close to 1 as possible. This loss function represents the optimization objective of location regression: improving localization accuracy by reducing the IoU difference between the predicted and ground truth bounding boxes. The model minimizes this loss function using optimization methods such as gradient descent, thereby improving the target's location prediction.
[0127] 5.3 Class Regression Loss
[0128] Class regression loss measures the accuracy of a model's predictions for a target class (e.g., "wearing a helmet" or "not wearing a helmet"). In classification tasks, the most commonly used loss function is cross-entropy loss, whose formula is:
[0129] L class =-∑(y·log(p)+(1-y)·log(1-p))
[0130] Among them, L total L is the total regression loss function; bbox and L classλ1 and λ2 are the location regression loss function and the category regression loss function, respectively; λ1 and λ2 are the weight coefficients of the location regression loss function and the category regression loss function, respectively.
[0131] Where y is the true class label, usually a binary value (0 or 1), where 1 indicates the target belongs to a certain class (e.g., wearing a helmet), and 0 indicates it does not belong to that class (not wearing a helmet). p is the predicted probability of the target belonging to a certain class by the object detection model, usually the probability value output by the softmax or sigmoid function. class This is the category regression loss function, also known as cross-entropy loss, which measures the difference between the predicted probability and the true label.
[0132] The goal of cross-entropy loss is to maximize the consistency between the predicted probability and the true label. When the true label y is 1, L... class It tends to minimize log(p), while when y is 0, L class This tends to minimize log(1-p). By optimizing L class The network can learn the features of the target category better, thus improving classification accuracy.
[0133] 5.4 Loss Function Optimization
[0134] By simultaneously optimizing the location regression loss (L bbox ) and category regression loss (L class This allows the model to not only accurately locate the target's position but also effectively determine the target's category. The total loss function L... total By adjusting the weight coefficients of λ1 and λ2, the importance of position loss and class loss in the overall optimization is balanced. During training, the network continuously adjusts its parameters to minimize L. total This improves the accuracy of helmet wearing detection. In practical applications, optimizing the regression loss function is crucial. For example, in security monitoring, accurately detecting personnel wearing helmets is essential for ensuring construction site safety. By optimizing the regression loss function, the model can efficiently handle complex factors such as varying lighting and angles, improving the reliability and accuracy of the helmet wearing recognition system. Furthermore, the optimized loss function effectively reduces false positives and false negatives, improving the overall system performance. Through such regression loss function optimization, the model can not only accurately locate the target's bounding box but also accurately classify whether the target is wearing a helmet, making the system more adaptable and robust in practical applications.
[0135] Optimizing the regression loss function primarily involves adjusting the weights of the positional regression loss and class regression loss within the function to accurately regress the target's location and class. This is crucial for the accurate localization and classification of the helmet's wearing status. By optimizing the loss function, the model can better locate and classify targets in complex scenes, reducing false positives and false negatives. Regression loss function optimization is the final optimization step, relying on previous feature extraction and target augmentation mechanisms (PFPN, BGA, and multi-scale detection heads). By optimizing the regression loss function, the model can more accurately predict the helmet's location and wearing status, thereby improving the overall detection performance. Regression loss function optimization is closely related to the preceding steps, ultimately improving the network's detection performance and accuracy.
[0136] VI. Helmet Wearing Identification
[0137] The trained target detection model is used to identify whether a safety helmet is being worn, and the results of the safety helmet wearing identification are output.
[0138] This embodiment also provides a helmet wearing recognition system based on multi-scale feature fusion. The recognition system can implement the method described above. The recognition system includes...
[0139] (1) Multi-scale feature fusion module: The target detection model performs splicing and weighting operations on feature maps of different scales through a panoramic feature pyramid network to fuse feature maps of different scales;
[0140] (2) Dual-layer target enhancement module: The target detection model adopts a dual-layer target enhancement mechanism based on spatial attention mechanism and channel attention mechanism to perform weighted operation on the fused feature map in order to focus attention on the target region;
[0141] (3) Multi-scale detection head introduction module: Multi-scale detection heads are introduced into the target detection model. Multiple detection heads process targets of different sizes through anchor boxes and feature maps of different scales to optimize the accuracy of target detection.
[0142] (4) Regression loss function optimization module: The total regression loss function is constructed for the target detection model using the position regression loss function and the category regression loss function. During the training of the target detection model, the parameters are continuously adjusted using optimization methods to minimize the total regression loss function, thereby obtaining a well-trained target detection model.
[0143] In this embodiment, PFPN solves the problem of recognizing targets of different scales through multi-scale feature fusion. Compared with using features at a single level, PFPN significantly improves the network's ability to process targets of different sizes. BGA, through spatial and channel weighting operations, allows the network to focus on key regions, reduce background interference, and improve the model's target recognition accuracy. It not only enhances the focus on the target but also avoids excessive attention to irrelevant background, which greatly improves the helmet wearing status recognition effect in complex backgrounds. Introducing a multi-scale detection head further enhances the network's adaptability to targets of different sizes. It enables the network to not only handle helmets of different sizes but also optimize the scale of the anchor frame, making the detection more accurate. By optimizing the regression loss function, the target can be accurately located and its wearing status can be determined, giving the model higher accuracy in target localization and classification tasks.
[0144] The combination of these four core steps interacts to enhance the robustness and accuracy of the entire model, resulting in a recognition performance far exceeding the sum of individual features. For example, PFPN provides rich multi-scale features, while BGA and the multi-scale detection head further optimize feature representation and multi-scale adaptability, and the optimization of the regression loss function ensures the model's accuracy during the detection process.
[0145] This invention's method effectively adapts to scenes of varying sizes, angles, and complex backgrounds. The combination of PFPN and BGA enhances the model's ability to recognize helmet-wearing status in diverse environments. Through multi-scale feature fusion, target augmentation, and regression loss optimization, the model maintains high detection accuracy even in complex environments, while reducing background interference and localization errors at different angles. Optimization of the regression loss function not only accurately locates the target's bounding box but also correctly determines whether the target is wearing a helmet, improving accuracy and reliability in practical applications.
[0146] In summary, the various technical steps of the method of this invention support and complement each other, greatly improving the performance of the model in the helmet wearing recognition task, demonstrating excellent technical innovation and application prospects.
[0147] By adopting the above-disclosed technical solution of this invention, the following beneficial effects are obtained:
[0148] This invention provides a method and system for identifying helmet wearing status based on multi-scale feature fusion. By introducing a panoramic feature pyramid network (PFPN), a two-layer target enhancement mechanism (BGA), and optimizing the multi-scale detection head, this invention addresses the problems of low accuracy and poor robustness in helmet wearing status recognition under complex backgrounds and different angles in existing technologies, thereby improving the accuracy and stability of target detection. 2. Through the panoramic feature pyramid network of PFPN, this invention can better fuse features of different scales, reduce information loss, and significantly improve the ability to recognize targets of different sizes, thus improving the accuracy of helmet wearing status recognition, especially for targets with large size variations. The two-layer target enhancement mechanism (BGA), combined with spatial and channel attention, effectively improves the model's ability to focus on the target region, reduces background noise interference, and significantly improves detection accuracy in complex environments. By introducing a multi-scale detection head, the model can better adapt to targets of different scales, optimize the anchor frame scale, further improve the detection accuracy for helmets of different sizes, and reduce the incidence of missed and false detections. In dynamically changing working environments, this invention can stably handle various complex scenarios, including different shooting angles, background changes, and lighting conditions, thereby improving the robustness and applicability of the overall recognition system. This invention can significantly improve the accuracy and efficiency of helmet-wearing recognition in construction sites, industrial production, and other fields, reducing the need for human intervention, and further ensuring worker safety through high-precision recognition.
[0149] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A helmet-wearing recognition method based on multi-scale feature fusion, characterized in that: Includes the following steps, S1. Multi-scale feature fusion: The target detection model uses a panoramic feature pyramid network to stitch and weight feature maps of different scales in order to fuse feature maps of different scales. The panoramic feature pyramid network achieves multi-scale information fusion by stitching together and weighted summing feature maps at multiple scales. The calculation formula is as follows: PFPN i =concat(W i ·F i ,∑(a j ·F j )) Among them, PFPN i For multi-scale information fusion results; F i and F j These are the feature maps of the i-th and j-th layers, respectively; W i Let a be the weighting matrix of the feature maps of the i-th layer, used to perform weighting operations on the feature maps of the i-th layer; j The weighting coefficients of the feature map at layer j; ∑(a i ·F j For feature maps F at all scales j Perform a weighted summation; concat is an operation that concatenates multiple feature maps along the channel dimension; A loss function is constructed for the panoramic feature pyramid network. Based on this loss function, the panoramic feature pyramid network is trained through backpropagation, thereby continuously adjusting the weighting matrix W of the feature maps. i The weighting coefficient a of the feature map j ; S2, Dual-layer Target Enhancement: The target detection model employs a dual-layer target enhancement mechanism based on spatial attention and channel attention to perform weighted operations on the fused feature map, thereby focusing attention on the target region; step S2 specifically includes the following: S21. The spatial attention mechanism weights each spatial location in the feature map based on the importance of different locations in the image; the calculation formula is as follows: Attention spatial =σ(Conv(F)) Among them, Attention spatial σ represents the spatial weighting coefficients obtained through the spatial attention mechanism; F represents the input feature map; Conv(F) represents the spatial weighting coefficients extracted from the feature map through convolution operations; σ is the activation function used to map the spatial weighting coefficients extracted from the feature map through convolution operations to the [0,1] interval; S22. The channel attention mechanism emphasizes the importance of different channels in a specific task by weighting each channel of the feature map; the calculation formula is as follows: Attention channel =σ(FC(F)) Among them, Attention channel is the channel weighting coefficient obtained through the channel attention mechanism; FC(F) is the weighting coefficient of each channel extracted from the feature map through the fully connected layer; σ is the activation function used to map the weighting coefficient of each channel extracted from the feature map through the fully connected layer to the interval [0,1]. S23. Spatial attention and channel attention are weighted separately on the feature map, and the weighted results of the two are fused to enhance the network's ability to focus on the target region; the calculation formula is as follows: Attention fused =Attention spatial ·Attention channel ·F Among them, Attention fused This is the final fusion result; A loss function is constructed for the two-layer target augmentation mechanism. Based on this loss function, the two-layer target augmentation mechanism is trained through backpropagation, thereby continuously adjusting the weighting coefficients of the spatial Attention mechanism. spatial Attention and channel weighting coefficients channel ; S3. Introduction of multi-scale detection heads: Multi-scale detection heads are introduced into the target detection model. Multiple detection heads process targets of different sizes through anchor boxes and feature maps of different scales to optimize the accuracy of target detection. Multi-scale detection heads optimize target accuracy by adding anchor boxes of different scales to the network and processing them with different feature maps for each scale; the calculation formula is as follows: Detection output =∑(Anchor t ·Feature_map t ) Among them, Detection output The processing results of the multi-scale detection head; Anchor i The anchor box at the t-th scale; Feature_map t This is the feature map at the t-th scale; S4. Optimization of regression loss function: Construct a total regression loss function for the object detection model using the position regression loss function and the category regression loss function. During the training of the object detection model, continuously adjust the parameters using optimization methods to minimize the total regression loss function, thereby obtaining a well-trained object detection model. The total regression loss function is constructed by weighting the location regression loss function and the category regression loss function. The calculation formula is as follows: L total =λ1·L bbox +λ2·L class L bbox =∑(1-IOU(predict,ground truth )) L class =-∑(y·log(p)+(1-y)·log(1-p)) Among them, L total L is the total regression loss function; bbox and L class λ1 and λ2 are the location regression loss function and the class regression loss function, respectively; λ1 and λ2 are the weight coefficients of the location regression loss function and the class regression loss function, respectively; IOU is the intersection-union ratio used to measure the degree of overlap between the predicted box and the ground truth box; predict is the predicted box; ground truth For the true bounding box; Area_of Intersection Area_of is the area of the intersection of the predicted bounding box and the ground truth bounding box. Union y is the area of the union of the predicted bounding box and the ground truth bounding box; y is the ground truth class label, which is 1 when the target belongs to a certain class and 0 when the target does not belong to that class; p is the predicted probability of the target belonging to a certain class by the object detection model.
2. The helmet wearing recognition method based on multi-scale feature fusion according to claim 1, characterized in that: Step S4 is followed by, S5. Helmet Wearing Recognition: Uses a trained target detection model to identify helmet wearing status and outputs the helmet wearing recognition result.
3. The helmet wearing recognition method based on multi-scale feature fusion according to claim 1, characterized in that: Step S1 is preceded by, S0. Dataset preparation: Manually label the helmet wearing status in the collected images to construct a helmet wearing status dataset.
4. A helmet wearing recognition system based on multi-scale feature fusion, characterized in that: The identification system is capable of implementing the method described in any one of claims 1 to 3, and the identification system includes, Multi-scale feature fusion module: The target detection model uses a panoramic feature pyramid network to stitch and weight feature maps of different scales in order to fuse feature maps of different scales; Dual-layer target enhancement module: The target detection model uses a dual-layer target enhancement mechanism based on spatial attention and channel attention to perform weighted operations on the fused feature map in order to focus attention on the target region; Multi-scale detection head introduction module: A multi-scale detection head is introduced into the target detection model. Multiple detection heads process targets of different sizes through anchor boxes and feature maps of different scales to optimize the accuracy of target detection. The regression loss function optimization module constructs a total regression loss function for the object detection model using the location regression loss function and the category regression loss function. During the training process of the object detection model, the parameters are continuously adjusted using optimization methods to minimize the total regression loss function, thereby obtaining a well-trained object detection model.
Citation Information
Patent Citations
Safety helmet wearing detection system and method for small target
CN118942121A