Safety helmet wearing detection method in complex environment
By constructing the MMAE-YOLO model, the problem of insufficient accuracy in safety helmet detection under complex environments was solved, achieving efficient and reliable safety monitoring, improving detection accuracy and reducing computational resource consumption.
Patent Information
- Application Number
- CN202511270560.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-08
- Publication Date
- 2025-11-21
AI Technical Summary
Existing algorithms are not accurate enough in detecting safety helmets that are small or partially occluded targets in complex environments, making it difficult to meet the regulatory requirements for high real-time performance and high precision.
The MMAE-YOLO model was constructed by replacing the C2f module and SPPF layer in the backbone network, introducing the scale sequence fusion and feature selection structure ASF-FS, and adopting the lightweight ECA detail enhancement detection head EELD to improve detection accuracy and reduce model complexity.
It significantly improves the detection accuracy of occlusion and small targets in complex scenes. The improved model's mAP@50 increased from 86.0% to 89.3%, and the recall rate increased from 79.3% to 81.6%, while reducing model complexity and computational cost.
Smart Images

Figure CN120997526A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of computer vision and artificial intelligence, more specifically, relates to a safety helmet wearing detection method in a complex environment. BACKGROUND
[0002] In high-risk operation scenarios such as industrial production, construction, and power operation, wearing a safety helmet is a basic protective measure to protect the personal safety of operating personnel. In particular, in environments such as power transmission line inspection and high-altitude operation, operating personnel often face risks such as high voltage and high-altitude falling, and the wearing of safety helmets directly affects the safety of operations. Therefore, accurately identifying whether operating personnel are correctly wearing safety helmets in real time has become a key link in intelligent supervision and safety control.
[0003] Existing detection of safety helmet wearing mainly relies on manual patrol and video playback review. Manual patrol requires assigning dedicated safety management personnel to conduct regular or irregular patrols in the operating area, checking the safety helmet wearing of operating personnel one by one, which has high labor intensity and low detection efficiency, and is limited by the number of personnel and the interval of patrols, making it difficult to achieve real-time and full-coverage monitoring of the entire operating area, resulting in many violations being unable to be discovered in time. Video playback review checks the safety helmet wearing by reviewing the monitoring video afterwards, which not only has obvious lag and cannot correct the violation at the first time, but also requires a large amount of manpower to review the video frame by frame, which is inefficient and cannot meet the urgent need for high real-time and high-precision supervision of modern complex construction sites.
[0004] With the rapid development of computer vision technology and deep learning algorithms, automatic recognition technology based on target detection algorithms provides an innovative solution for safety helmet detection. In the field of safety helmet detection, target detection algorithms are used to recognize and locate safety helmets in monitoring videos or images, enabling automatic and real-time monitoring of the safety helmet wearing of operating personnel. However, due to the complex construction site environment, safety helmets in images are usually small in size and severely occluded, and safety helmet detection is a small target detection problem. Existing algorithms may miss or misidentify in complex scenarios, and the detection accuracy and robustness still need to be improved. SUMMARY
[0005] The present application aims to solve the problem of insufficient detection accuracy of existing algorithms for small targets and partially occluded targets in complex environments, and provides a safety helmet wearing detection method in a complex environment. By constructing an MMAE-YOLO model, the detection accuracy of small targets and occluded targets is significantly improved compared to the traditional YOLOv8n model while ensuring real-time detection, and the model complexity is effectively reduced, making it suitable for efficient and reliable safety monitoring in construction sites.
[0006] To achieve the above object, the technical scheme adopted by the present application is as follows: The present application provides a safety helmet wearing detection method in a complex environment, comprising the following steps: Step 1, obtain a safety helmet detection dataset, and divide the dataset into a training set, a validation set and a test set; Step 2, build an MMAE-YOLO model, the MMAE-YOLO model takes YOLOv8n as a base model, replaces the C2f module in the backbone network with a C2f-MSEFA module, and replaces the SPPF layer with a MAConv module; use scale sequence fusion and feature selection structure ASF-FS to replace the neck network of the original YOLOv8n, and use EELD detection head as the detection head; Step 3, set the training parameters, use the training set to iteratively train the MMAE-YOLO model, optimize the model hyperparameters in combination with the validation set, and obtain a detection model with the best performance; Step S4, input the image to be tested into the detection model with the best performance in step 3 for inference, automatically identify and detect the target in the image to be tested, and output the detection result of whether the safety helmet is worn.
[0007] As a possible implementation manner of the present application, in step 2, the processing flow of the C2f-MSEFA module is: first, multi-scale adaptive average pooling is used, the pooling scale is [3, 6, 9, 12], then two convolution layers are used for processing to realize channel compression and local feature enhancement respectively; then an edge enhancement module is introduced to highlight edge information; finally, a feature fusion method is used to integrate and output the multi-scale information.
[0008] As a possible implementation manner of the present application, in step 2, the processing flow of the edge enhancement module is: first, the input feature map is smoothed, then difference extraction and convolution processing are performed on the input feature map, and the processing result is added to the input feature map again.
[0009] As a possible implementation manner of the present application, in step 2, the processing flow of the MAConv module is: the MAConv module first compresses the channel number through 3x3 convolution, then performs dilated convolution at multiple dilated rates using a shared convolution kernel, and concatenates them in the channel dimension, then introduces an ECA attention mechanism to enhance feature expression, and finally fuses channel information through 3x3 convolution to output a unified feature map.
[0010] As a possible implementation manner of the present application, in step 2, the scale sequence used in the neck network is fused with a feature selection structure ASF-FS, which is based on the ASF-YOLO structure and introduces a multi-scale edge information selection module C2f-MSEAFS and a P2 block layer in the structure.
[0011] As a possible implementation manner of the present application, the C2f-MSEAFS module introduces a double-domain selection mechanism DSM on the basis of the C2f-MSEFA module, that is, a DSM module is added between Concat and Conv in the C2f-MSEFA module.
[0012] As a possible implementation manner of the present application, the processing flow of the EELD detection head is as follows: Different outputs of the neck network are taken as inputs of the detection head, which are input into P2, P3, P4 and P5 detection layers, the input feature maps of each detection layer are first processed by a 1x1 convolution layer containing group normalization, then processed by an ECA attention mechanism, and finally input into a shared detail enhancement convolution module for processing, the shared detail enhancement convolution module includes two group normalization-based modules.
[0013] As a possible implementation manner of the present application, in the final stage of the detection head, independent convolution branches are respectively used for different tasks, for the bounding box regression task, the channel number of the feature map is mapped to 4 through Conv2d, corresponding to (x, y, w, h) of the predicted box, and then the intersection over union and geometric constraints between the predicted box and the real box are calculated by BBox.Loss to measure the difference of the target position and scale; for the target classification task, the channel number of the feature map is mapped to nc through Conv2d, and Cls.Loss is used to calculate the difference between the predicted class probability and the real label.
[0014] As a possible implementation manner of the present application, in step 2, the processing flow of the backbone network is as follows: The input is first processed by two Convs, then the feature is input into the C2f-MSEFA module for processing, the fine-grained edge and texture information are extracted at the P2 scale, and the processing continues to a deeper layer; After the feature is processed by Conv again, it is input into the C2f-MSEFA module for processing, to enhance the middle-level semantic features and edge information; Then, the deep layer features are extracted again through Conv and C2f-MSEFA; Finally, the highest layer semantic features are extracted through Conv and C2f-MSEFA, and then the multi-scale context information is fused through the MAConv module.
[0015] As a possible implementation manner of the present application, in step 2, the processing flow of the neck network is as follows: Firstly, the features of the 9th layer of the Backbone network and the features from the 4th layer of the Backbone network are respectively input into the Conv for processing, and then the two outputs are input into the TFE module together with the features from the 6th layer of the Backbone network to fuse and enhance the multi-layer features, and then the processing results are input into the C2f-MSEAFS module to extract the middle-level semantic and edge information, and are input into the Conv module for dimension reduction, and the output result is recorded as feature A1. The features from the 2nd layer of the Backbone network are input into the Conv for processing, and then the output results are input into the TFE module together with the features from the 4th layer of the Backbone network and the feature A1 for processing, to enhance the small target features, and then the processing results are input into the C2f-MSEAFS module to extract the low-level fine-grained information, and the output result is recorded as feature A2. The feature A2 is input into the Conv module for processing, and then the processed feature A2 is combined with the feature A1 through the Concat module, and then the combined result is input into the C2f-MSEAFS module again to extract the middle-scale features, and the output result is recorded as feature A3, and the feature A3 is input into the Conv module again for processing, and then the processed feature A3 is combined with the features from the 9th layer of the Backbone network after dimension reduction through the Concat module, and then the combined result is input into the C2f-MSEAFS module again for processing, and the output result is recorded as feature A4. In the neck network, the features from the 4th layer and the 8th layer of the Backbone network are also input into the SSFF module to realize cross-scale feature fusion, and the output result is connected with the feature A2 through the Add module to enhance the feature transmission stability, and the output result after processing is recorded as feature A5. The feature A5 is processed through the P2 block structure, and the output result after processing is recorded as feature A7.
[0016] Compared with the prior art, the present application has the following beneficial effects: (1) The safety helmet wearing detection method in a complex environment provided by the present application, in the face of the complex scene of safety helmet detection, the MMAE-YOLO model is designed specifically, which significantly improves the accuracy of occlusion and small target detection and the overall efficiency of the model in a complex scene. Firstly, in the Backbone backbone network, the C2f-MSEFA module is proposed, which extracts features from different spatial resolution regions through multi-scale adaptive average pooling, effectively enhances the detail information expression ability, and improves the adaptability of the model to complex background changes.
[0017] Secondly, a multi-scale attention conversion (MAConv) module is used in the 9th layer. The module fuses a multi-scale dilated convolution and an ECA channel attention mechanism, expands the receptive field while reducing the parameter quantity, and further improves the extraction ability of cross-scale context information.
[0018] Furthermore, in the neck feature fusion structure, a scale sequence fusion and feature selection structure (ASF-FS) based on the ASF-YOLO design is introduced. The structure integrates a multi-scale edge information screening module C2f-MSEAFS, which can efficiently extract and detect task highly related key information from multi-scale features, and additionally adds an optimized P2 block layer to enhance the detection sensitivity of small targets.
[0019] Finally, in the detection head (Head) part, a lightweight ECA detail enhancement detection head (EELD) is proposed. The module combines the ECA attention mechanism, deconvolution operation and independent batch normalization strategy, effectively reduces the model complexity and computational overhead while maintaining the detection accuracy.
[0020] Through the above structural improvement, the MMAE-YOLO model proposed in the application significantly improves the detection performance under the premise of maintaining real-time detection capability. Experimental results show that the mAP@50 of the improved model is improved from 86.0% to 89.3%, and the recall rate is improved from 79.3% to 81.6%, which verifies the effectiveness and practical value of the method in small target detection and complex background adaptation. BRIEF DESCRIPTION OF DRAWINGS
[0021] Figure 1 is the overall flowchart of the safety helmet wearing detection method of the application; Figure 2 is the SHEL5K dataset distribution used in the application; Figure 3 is the yaml structure diagram of the MMAE-YOLO network model of the application; Figure 4 is the structure diagram of the MMAE-YOLO network model of the application; Figure 5 is the structure diagram of the C2f-MSEFA module of the application; Figure 6 is the structure diagram of the MAConv module of the application; Figure 7 is the structure diagram of the ECA module in the MAConv module of the application; Figure 8 is the structure diagram of the C2f-MSEAFS module of the application; Figure 9 is the structure diagram of the DSM module of the application; Figure 10 Structure diagram of the TFE module of the present application; Figure 11 Structure diagram of the TFE module of the present application; Figure 12 Structure diagram of the EELD module of the present application; Figure 13 Results of safety helmet wearing detection in images in three different scenarios in the embodiment of the present application using YOLOv8n and MMAE-YOLO algorithms, respectively. DETAILED DESCRIPTION
[0022] To make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions of the present application will be described clearly and completely below in conjunction with the drawings and specific embodiments. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of protection of the present application.
[0023] To achieve the purpose of accurate detection of safety helmet wearing in complex environments, such as small target detection or detection of occluded targets, as shown in Figure 1 The present embodiment provides a safety helmet wearing detection method in a complex environment, which includes the following steps: Step 1, directly and completely import the SHEL5K public dataset, and use its pre-processed and basic annotations; Perform integrity check on the data to ensure that all categories of samples, including helmets, helmet-wearing, helmet-wearing people, heads, people without helmets, and faces, are included; Then, randomly divide the public dataset into a training set, a validation set and a test set in a ratio of 7:2:1, forming a complete and fine-checking safety helmet detection dataset for subsequent algorithm development and effect evaluation.
[0024] Dataset source address: https: / / universe.roboflow.com / database-sjrvw / shel5k-new. The category distribution of the dataset is shown in Figure 2 .
[0025] Step 2, construct the MMAE-YOLO model structure as shown in Figure 3 and Figure 4 The model is composed of Backbone, Neck and Head: MMAE-YOLO model yaml structure configuration explanation: In the YOLO configuration file, each line adopts the format of [from, repeats, module, args] to represent the definition of a network layer. from specifies the input source of the layer, -1 represents the last layer, [a, b] represents the features from the a-th and b-th layers, which will be spliced or fused during forward propagation; repeats represents the number of times the module is stacked, such as C2f-MSEFA, C2f-MSEAFS, etc. module represents the type of module used, such as Conv, C2f, etc., which is usually defined in the model code; args is the parameter list passed to the module, the specific content depends on the module. Take Figure 3 For example, the first layer [-1, 1, Conv, [64, 3, 2]] is explained as follows: perform a Conv operation on the output of the last layer, with a convolution kernel size of 3x3, a stride of 2, and an output channel number of 64, to realize downsampling and adjust the channel number of the feature map.
[0026] In combination with Figure 4 , the structure and processing flow of the backbone network are explained as follows: The backbone network of the MMAE-YOLO model constructed by the application is composed of a series of alternating down-sampling convolution layers and multi-scale edge information enhancement modules to realize feature extraction from high-resolution details to deep semantics. The specific process is as follows: The network starts from the input image, first passes through Conv (from the input of the last layer) processing, down-samples to P1 / 2 scale, and extracts initial low-level features; then it is processed by Conv (from the input of the last layer) again, down-samples to P2 / 4, providing a basis for subsequent multi-scale feature fusion. Then, the features are input into the C2f-MSEFA (from the input of the last layer, repeated 3 times) module for processing, which extracts fine-grained edge and texture information at the P2 scale, and continues to deeper layers. The features are processed by Conv (from the input of the last layer) to down-sample to P3 / 8, and then input into the C2f-MSEFA (repeated 6 times) module for processing to enhance the middle-level semantic features and edge information. Then, it is down-sampled to P4 / 16 again by Conv (from the input of the last layer), and then extracted by C2f-MSEFA (repeated 6 times) to extract deep features. Finally, the features are down-sampled to P5 / 32 by Conv (from the input of the last layer), and then input into the C2f-MSEFA (repeated 3 times) module for highest-level semantic extraction, and then fused by the MAConv (from the input of the last layer) module to fuse multi-scale context information, providing high-quality deep features for the Neck. This design not only preserves the fine-grained edge information of the shallow layer, but also fully extracts the semantic features of the deep layer, laying a solid foundation for multi-scale detection.
[0027] It should be noted that the C2f-MSEFA module designed in the backbone network has a structure as shown in Figure 5 and its processing flow is as follows: The module first performs a 3x3 Conv on the input feature map to obtain local features, and simultaneously performs adaptive average pooling (AdaptiveAvgPool) and two convolution (Conv) operations under multi-scale pooling ([3, 6, 9, 12]) to reduce the dimension and enhance the details of features of different scales. All scale feature maps are then restored to the original size by upsampling (Upsample) and input to the edge enhancement module (EdgeEnhancer module) for edge information extraction and enhancement.
[0028] In the EdgeEnhancer module, the module first performs smoothing processing on the input feature map, then performs differential extraction of edge details with the original image (i.e., the feature map input to the module at the beginning), and after convolution processing, adds the original image to obtain enhanced features.
[0029] Finally, all EdgeEnhancer modules splice the edge-enhanced features of each scale with the local features and fuse them through 3x3 convolution (Conv) to generate output feature maps containing multi-scale information and detail features.
[0030] In addition, a multi-scale attention conversion (MAConv) module is used in the 9th layer of the backbone network. The module fuses multi-scale dilated convolution and ECA channel attention mechanism, expands the receptive field while reducing the parameter amount, and further improves the extraction ability of cross-scale context information.
[0031] In combination with Figure 6 , the specific process of the MAConv module is as follows: the module first compresses the channel number through 3x3 convolution, then performs dilated convolution (DConv) under multiple dilation rates (1, 3, 5) using shared convolution kernels, adjusts the dilation rate (such as 1, 3, 5) to control the size of the receptive field, thereby capturing features of different scales in local details and global context, and splicing (Concat) them in the channel dimension. Next, the ECA attention mechanism is introduced to enhance feature expression, and finally the channel information is fused through 3x3 convolution (Conv) to output a unified feature map.
[0032] Furthermore, the structure diagram of the ECA module introduced in the MAConv module is as shown in Figure 7As shown, the ECA module is a lightweight attention mechanism designed to enhance informative channels and suppress irrelevant ones by adaptively assigning channel attention weights. ECA utilizes fast 1D convolutions with small kernel sizes to perform local cross-channel interactions. This approach eliminates the need for fully connected layers or complex transformations, enabling ECA to effectively capture channel dependencies with extremely low computational cost. Due to its efficiency and simplicity, ECA can be seamlessly integrated into various backbone architectures, improving performance without significantly increasing overhead.
[0033] In combination Figure 4 The structure and processing flow of the neck network Neck are described as follows: The Neck part adopts an ASF-FS structure using a scale sequence fusion and feature selection structure (ASF-FS), which is based on the ASF-YOLO structure and introduces a multi-scale edge information selection module C2f-MSEAFS, which aims to efficiently filter out key features highly relevant to the target task from multi-scale edge information. In addition, an optimized P2 layer (i.e., P2 block layer) is added to increase sensitivity to small targets. Specifically, the Neck part is based on the multi-scale feature maps processed by the Backbone, specifically including features from the 2nd, 4th, 6th, 8th, and 9th layers of the Backbone network, and the processing flow is as follows: First, the output processed by the Backbone network (i.e., the feature from the 9th layer of the Backbone network) and the feature from the 4th layer of the Backbone network are input into the Conv for processing, compressing the channels to reduce the computational load, and then the two outputs are input into the TFE module together with the feature from the 6th layer of the Backbone network to fuse and enhance the features of multiple layers, and then the processing results are input into the C2f-MSEAFS module to extract middle-level semantics and edge information, and input into the Conv module for dimension reduction, and the output result is denoted as feature A1.
[0034] The feature from the 2nd layer of the Backbone network is input into the Conv for processing, and then the output result is input into the TFE module together with the feature from the 4th layer of the Backbone network and the feature A1 for processing to enhance the small target features, and then the processing results are input into the C2f-MSEAFS module to extract low-level fine-grained information, and the output result is denoted as feature A2.
[0035] The feature A2 is input to the Conv module for processing, and after processing, the feature A2 is combined with the feature A1 through the Concat module, and then input to the C2f-MSEAFS module again to extract the medium-scale feature, and the output result is recorded as feature A3. The feature A3 is input to the Conv module again for processing, and after processing, the feature A3 is combined with the feature from the 9th layer of the Backbone network through the Concat module, and then input to the C2f-MSEAFS module again for processing, and the output result is recorded as feature A4.
[0036] In the neck network, the features from the 4th layer and the 8th layer of the Backbone network are also input to the SSFF module to realize cross-scale feature fusion, and the output result is connected in residual connection with the feature A2 through the Add module to enhance the stability of feature transmission, and the output result after processing is recorded as feature A5.
[0037] The feature A5 is processed by the P2 block structure, and the output result after processing is recorded as feature A7. Specifically, the processing flow of the P2 block structure includes: First, the feature A5 is upsampled through the Upsample, and is concatenated with the feature from the 2nd layer of the Backbone, and then input to the C2f-MSEAFS module to extract the small-scale target feature, and the output result is recorded as feature A6.
[0038] Then, the feature A6, the feature A5 and the feature from the 2nd layer of the Backbone are input to the SSFF module for processing, and the output result after processing is connected with the feature A6 through the Add module, and the output result is recorded as feature A7, which completes the multi-scale feature fusion and residual enhancement, and provides high-quality input for the detection head.
[0039] It should be noted that the C2f-MSEAFS module used in the neck network has a structure as shown in Figure 8 The module introduces an innovative method based on attention mechanism, i.e. dual-domain selection mechanism (DSM), on the basis of the C2f-MSEFA module. The DSM module is added between the Concat and the Conv to form the C2f-MSEAFS module. The DSM module focuses on the key areas in the image (such as complex edges and high-frequency signal areas), and adaptively selects the features more relevant to the task in the multi-scale features.
[0040] The structure of the DSM module in the C2f-MSEAFS module is as shown in Figure 9As shown, the DSM module consists of two components: a spatial selection module (SSM) and a frequency selection module (FSM). Given an input feature, the SSM and FSM are used sequentially. The spatial selection module (SSM) aims to help the network focus on key regions in the spatial domain, providing a significantly degraded initial position for the subsequent frequency selection module (FSM). Given an intermediate feature map F, the input feature F is first compressed along the channel dimension by both max-pooling and average-pooling operations, followed by a convolution layer to generate a general feature map. Since there are differences in the degradation patterns of different channels, the input feature F is converted by channel separation to generate a per-channel feature representation, and F' is used to modulate the generated feature. The frequency selection module (FSM) can directly assist the recovery process using Fs. First, apply a mean filter to Fs to extract low-frequency features, and then subtract the generated low-frequency signal from the input to obtain complementary high-frequency features. In combination Figure 10 The specific process of the SSFF module used in the present application is as follows: The SSFF module receives three feature maps (P3, P4, P5), projects them to a unified channel dimension by 1x1 convolution (re-project P3 if necessary), and up-samples P4 and P5 to match the spatial size of P3. Then, these feature maps are stacked along the scale axis to generate a tensor of shape [B, 3, C, H, W]. Next, a 1x1x1 3D convolution is used, combined with 3D batch normalization and a SiLU activation function, to unify the multi-scale representation. Finally, a 3x1x1 3D max-pooling operation is performed to select the most important responses, and the scale dimension is removed by a compression operation, generating a feature map of shape [B, C, H, W] for the detection head.
[0041] In combination Figure 11 The specific process of the TFE module is as follows: To solve the problem of dense small target detection, a triple feature enhancement (TFE) module is introduced. Unlike the traditional feature pyramid network (FPN), which up-samples low-resolution features at the expense of fine details in high-resolution maps, TFE explicitly divides features into large, medium, and small spatial scales. It systematically integrates cross-scale information and enhances discriminative details through convolution and pooling operations.
[0042] In combination Figure 4 The structure and processing flow of the detection head Head are as follows: The detection head adopts an EELD module. Feature A4 processed by the neck network is taken as the P5 layer of the detection head, feature A3 is taken as the P4 layer of the detection head, feature A5 is taken as the P3 layer of the detection head, and feature A7 is taken as the P2 layer of the detection head, which are respectively input into the EELD module for edge and semantic enhancement, and finally the detection result is output. This design fully integrates shallow fine-grained features and deep semantic information, ensures high precision and high efficiency in complex background and multi-size target scenes, and guarantees the robust recognition ability of multi-scale targets.
[0043] In combination Figure 12 , the specific process of the detection head EELD module is as follows: The input feature map of each detection layer (P2, P3, P4, P5) is first processed by a 1x1 convolution layer (Conv_GN) containing group normalization to adjust the channel number and realize preliminary feature compression.
[0044] Then, the ECA attention mechanism is used for processing. Subsequently, these features are sent to a shared detail enhancement convolution module (DEConv_GN) containing two group normalization (GN) based on group normalization. This shared convolution structure reduces parameter redundancy by sharing weights across feature layers, while effectively enhancing the expression ability of feature maps, thereby improving the robustness of small object detection and complex scenes.
[0045] In the final stage of the detection head, independent convolution branches are used for different tasks. For the bounding box regression task, the channel number of the feature map is mapped to 4 through Conv2d, corresponding to the (x, y, w, h) of the predicted box, and then the intersection over union and its geometric constraints between the predicted box and the real box are calculated using BBox.Loss (such as CIoU or SIoU) to measure the difference in target position and scale. For the target classification task, the channel number of the feature map is mapped to nc (number of classes) through Conv2d, and Cls.Loss (based on binary cross-entropy BCE) is used to calculate the difference between the predicted class probability and the real label.
[0046] Step 3, set the training parameters of the MMAE-YOLO model, perform multiple rounds of iterative training on the model based on the training set, and dynamically adjust and optimize the hyperparameters of the model during the training process, so as to improve the comprehensive performance of the network structure in terms of accuracy, recall rate and generalization ability.
[0047] Specifically, the following hyperparameters are set in step 3: the number of training epochs is set to 250, the optimizer is SGD, the batch size is 8, the initial learning rate is 0.01, and the momentum parameter is set to 0.937. Through iterative learning of the model on the training set and adjusting the hyperparameters based on the validation set, the optimal model parameter configuration is obtained.
[0048] Step 4: Based on the optimal model structure obtained through model training and parameter tuning, the MMAE-YOLO model is applied to the SHEL5K safety helmet dataset to automatically identify and detect targets in images and output detection results of whether a safety helmet is worn, achieving automated and intelligent safety supervision on construction sites and providing accurate and reliable identification support for actual application scenarios.
[0049] To evaluate the performance of the safety helmet wearing detection method of the proposed MMAE-YOLO model, some evaluation indicators are used to compare the parameters of the YOLOv8n model and the proposed MMAE-YOLO safety helmet wearing detection model. The comparison results are shown in Table 1. The evaluation indicators in Table 1 include the following: precision (P), recall (R), mean average precision (mAP), mean average precision at an intersection over union threshold of 0.5 (mAP50), parameter quantity (Params), and computational complexity (GFLOPs). The related function expressions are as follows:
[0050]
[0051]
[0052]
[0053] where TP is the number of correctly detected targets, FP is the number of incorrectly detected targets, FN is the number of missed targets, P represents precision, R represents recall, mAP represents average precision, and F1 score is a comprehensive performance indicator considering P and R; Table 1 Comparison results
[0054] According to the data comparison in Table 1, the MMAE-YOLO model is superior to the YOLOv8n model in terms of P, R, F1, mAP50, GFLOPs, and Params. Specifically, the improved model only requires 2.11M parameters to achieve an mAP50 of 89.3%, which is 3.3 percentage points higher than the original model; at the same time, the model computation (GFLOPs) is reduced by 29.7%. This improvement not only improves detection accuracy but also effectively reduces computational resource consumption.
[0055] The actual detection effect diagram is shown in the following figure Figure 13 As shown in the figure, the YOLOv8n model and the MMAE-YOLO model of the present application are used for detection in three different scenes, respectively. The comparison of the detection results shows that the original YOLOv8n algorithm is difficult to accurately detect the target, as shown by the red elliptical frame, which is the missed detection target of the original YOLOv8n algorithm. The blue square frame is the construction personnel wearing safety helmets detected and recognized by the two algorithms, and the magenta square frame is the construction personnel without safety helmets detected by the algorithm.
[0056] In the group (a) image, the increase of environmental complexity significantly improves the difficulty of recognition. In the group (b) image, the dense distribution of small targets in multi-scale objects makes the detection task more challenging. In the group (c) image, the object occlusion significantly increases the probability of missed detection. The detection method proposed by the present application successfully alleviates these detection limitations and demonstrates excellent robustness and adaptability.
[0057] The above describes the present application and its embodiments in a schematic manner, which is not restrictive, and the embodiments shown in the drawings are only one of the embodiments of the present application, and the actual structure is not limited thereto. Therefore, if a person skilled in the art is inspired thereby, without departing from the purpose of the present application, similar structural modes and embodiments can be designed without creativity, which shall belong to the protection scope of the present application.
Claims
1. A method for detecting helmet wearing in complex environments, characterized in that: Includes the following steps: Step 1: Obtain the safety helmet detection dataset and divide it into training, validation, and test sets; Step 2: Construct the MMAE-YOLO model. The MMAE-YOLO model is based on the YOLOv8n model. The C2f module in the backbone network is replaced with the C2f-MSEFA module, and the SPPF layer is replaced with the MAConv module. The original YOLOv8n neck network was replaced with the Scale Sequence Fusion and Feature Selection Structure ASF-FS, and the EELD detection head was adopted. Step 3: Set training parameters, use the training set to iteratively train the MMAE-YOLO model, and combine the validation set to optimize the model hyperparameters to obtain the detection model with the best performance; Step S4: Input the image to be tested into the detection model with the best performance in step 3 for inference, automatically identify and detect the target in the image to be tested, and output the detection result of whether a safety helmet is worn.
2. The method for detecting helmet wearing in complex environments according to claim 1, characterized in that, In step 2, the processing flow of the C2f-MSEFA module is as follows: First, multi-scale adaptive average pooling is used with pooling scales of [3, 6, 9, 12]. Then, channel compression and local feature enhancement are achieved through two convolutional layers. Next, an edge enhancement module is introduced to highlight edge information. Finally, feature fusion is used to integrate and output multi-scale information.
3. The method for detecting helmet wearing in complex environments according to claim 2, characterized in that, In step 2, the processing flow of the edge enhancement module is as follows: first, the input feature map is smoothed, then it is differentially extracted and convolved with the input feature map, and the processing result is added to the input feature map again.
4. The method for detecting helmet wearing in complex environments according to claim 1, characterized in that, In step 2, the processing flow of the MAConv module is as follows: The MAConv module first compresses the number of channels through 3×3 convolution, then performs dilated convolution at various dilation rates using shared convolution kernels, and concatenates them in the channel dimension. Next, it introduces the ECA attention mechanism to enhance feature expression, and finally fuses channel information through 3×3 convolution to output a unified feature map.
5. A method for detecting helmet wearing in complex environments according to any one of claims 2-4, characterized in that, In step 2, the scale sequence fusion and feature selection structure ASF-FS used in the neck network is based on the ASF-YOLO structure and introduces the multi-scale edge information selection module C2f-MSEAFS and the P2 block layer into the structure.
6. The method for detecting helmet wearing in complex environments according to claim 5, characterized in that, The C2f-MSEAFS module introduces a dual-domain selection mechanism (DSM) based on the C2f-MSEFA module. That is, a DSM module is added between Concat and Conv in the C2f-MSEFA module.
7. A method for detecting helmet wearing in complex environments according to any one of claims 2-4, characterized in that, The processing flow of the EELD detection head is as follows: The different outputs of the neck network are used as the inputs of the detection head, which are then fed into the P2, P3, P4, and P5 detection layers. The input feature maps of each detection layer are first processed by a 1×1 convolutional layer with group normalization, then processed by the ECA attention mechanism, and finally fed into the shared detail enhancement convolutional module for further processing.
8. The method for detecting helmet wearing in complex environments according to claim 7, characterized in that, In the final stage of the detection head, independent convolutional branches are used for different tasks. For the bounding box regression task, Conv2d is used to map the number of channels of the feature map to 4, corresponding to (x, y, w, h) of the predicted box. Then, BBox.Loss is used to calculate the intersection-union ratio and geometric constraints between the predicted box and the ground truth box to measure the difference in target location and scale. For the target classification task, Conv2d is used to map the number of channels of the feature map to nc, and Cls.Loss is used to calculate the difference between the predicted class probability and the ground truth label.
9. A method for detecting helmet wearing in complex environments according to any one of claims 2-4, characterized in that, In step 2, the processing flow of the backbone network is as follows: The input first goes through two Conv processes. Then, the features are input into the C2f-MSEFA module for processing, where fine-grained edge and texture information is extracted at the P2 scale and then processed to a deeper level. The features are processed again by Conv and then input into the C2f-MSEFA module for further processing to enhance mid-level semantic features and edge information. Subsequently, deep features were extracted again using Conv and C2f-MSEFA models; Finally, the features are extracted for the highest-level semantics using the Conv and C2f-MSEFA modules, and then multi-scale contextual information is fused using the MAConv module.
10. The method for detecting helmet wearing in complex environments according to claim 9, characterized in that, In step 2, the processing flow of the neck network is as follows: First, the features from layer 9 of the Backbone network and the features from layer 4 of the Backbone network are input into Conv for processing. Then, these two outputs, together with the features from layer 6 of the Backbone network, are input into the TFE module to fuse the features of multiple layers and enhance them. Next, the processing results are input into the C2f-MSEAFS module to extract the mid-level semantics and edge information, and then input into the Conv module for dimensionality reduction. The output result is denoted as feature A1. Features from layer 2 of the Backbone network are input into Conv for processing. The output, along with features from layer 4 of the Backbone network and feature A1, are input into the TFE module for processing to enhance small target features. The processing result is then input into the C2f-MSEAFS module to extract low-level fine-grained information. The output is denoted as feature A2. Feature A2 is input into the Conv module for processing. After processing, it is merged with feature A1 through the Concat module. After merging, it is input into the C2f-MSEAFS module to extract mesoscale features. The output result is denoted as feature A3. Feature A3 is input into the Conv module for processing again. After processing, it is merged with the feature from layer 9 of the Backbone network after dimensionality reduction by Conv through the Concat module. After merging, it is input into the C2f-MSEAFS module for processing. The output result is denoted as feature A4. In the neck network, features from layers 4 and 8 of the Backbone network are also input into the SSFF module to achieve cross-scale feature fusion. The output is residually connected to feature A2 through the Add module to enhance the stability of feature transfer. After processing, the output is denoted as feature A5. Feature A5 is processed using a P2 block structure, and the output result is denoted as feature A7.
Citation Information
Cited By
Text-fused multi-scale edge information multi-target detection method
CN121582546A