Safety helmet and reflective garment simultaneous detection method based on improved lightweight YOLOv8n
By improving the YOLOv8n network and combining it with RFAConv, LSCD, C2f_Faster_EMA and MLCA modules, efficient and real-time detection of safety helmets and reflective vests is achieved. This solves the problems of high detection algorithm complexity and limited application scenarios in high-risk industries, and improves detection accuracy and real-time performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JILIN INST OF CHEM TECH
- Filing Date
- 2026-01-08
- Publication Date
- 2026-04-17
AI Technical Summary
In high-risk industries, existing technologies for detecting safety helmets and reflective vests have high complexity and computational requirements. Moreover, most algorithms only target safety helmets and ignore reflective vests, which cannot meet the complex and diverse actual needs, resulting in low detection efficiency and limited application scenarios.
An improved YOLOv8n lightweight network is adopted, which dynamically optimizes the convolution kernel weights through the RFAConv module, uses the LSCD lightweight shared convolutional detection head, improves the efficiency of small target feature extraction through the C2f_Faster_EMA module, and incorporates the MLCA attention mechanism to enhance multi-scale feature fusion, so as to achieve simultaneous detection of safety helmets and reflective clothing.
It significantly reduces model parameters and computational load, improves detection accuracy and real-time performance, is suitable for resource-constrained environments, achieves millisecond-level identification of safety helmets and reflective vests, reduces the false negative rate, and is suitable for safety management in high-risk industries such as construction sites.
Smart Images

Figure CN121883984A_ABST
Abstract
Description
[0001] This invention belongs to the field of computer vision, specifically relating to a method for simultaneous detection of safety helmets and reflective vests based on an improved lightweight YOLOv8n. It is applicable to scenarios such as construction site safety management, underground operation safety assurance, highway maintenance and construction, power line inspection, and cargo loading, unloading, and transportation. The lightweight nature of this method enables it to meet real-time requirements, allowing for rapid processing and analysis of large amounts of image or video data in a short time, providing timely feedback on detection results. This facilitates the prompt detection of situations where safety helmets and reflective vests are not worn correctly and allows for appropriate corrective measures to be taken. Background Technology
[0002] In high-risk industries such as construction and transportation, the correct wearing of safety helmets and reflective vests is a crucial measure to protect workers' lives. Safety helmets effectively mitigate the impact of falling objects from heights, while reflective vests reduce direct injuries from accidents. However, due to the high turnover of personnel and management challenges at construction sites, the failure to wear safety helmets and vests as required frequently occurs, leading to frequent safety accidents. These problems seriously impact the sustainable development of the construction industry and social stability. Therefore, developing efficient and intelligent safety helmet and vest wearing detection technologies is of paramount importance.
[0003] Traditional safety equipment inspections primarily rely on manual inspections or sensor monitoring. While manual inspections are intuitive, they require significant manpower and are susceptible to subjective biases, leading to missed or false detections. Sensor-based technologies, such as RFID or IoT devices, can achieve a degree of automation, but their high installation and maintenance costs make them difficult to adapt to complex and changing construction site environments. These limitations have driven the rise of computer vision-based automated inspection technologies.
[0004] In recent years, with the rapid development of deep learning technology, object detection algorithms have been widely used in the industrial security field. The core of object detection is to extract effective features from images and locate the target. Deep learning, through end-to-end model training, overcomes the shortcomings of traditional manual feature design, significantly improving detection accuracy and robustness. However, although existing algorithms have made progress in the accuracy of safety helmet detection, they still fail to solve the technical challenges of high algorithm complexity, large computational requirements, and demanding hardware requirements. Furthermore, most current algorithms only target safety helmet detection, neglecting the recognition of reflective vests. This single detection mode limits the application scenarios of the algorithms and cannot meet more complex and diverse practical needs. Summary of the Invention
[0005] This invention proposes a lightweight safety helmet and reflective vest detection method based on an improved YOLOv8n to address the safety monitoring needs of high-risk work environments. This method enhances the model's ability to capture key features by introducing the RFAConv module to dynamically optimize convolutional kernel weights; it employs a lightweight shared convolutional detection head (LSCD) to reduce redundant computation while maintaining high detection accuracy; it combines the C2f_Faster_EMA module to improve the efficiency of small target feature extraction, significantly reducing model parameters and computational load; and it incorporates the MLCA attention mechanism to strengthen multi-scale feature fusion, ensuring accurate identification of occluded targets even in complex backgrounds. Experimental results show that the improved algorithm achieves significant weight reduction while maintaining detection accuracy, making it suitable for real-time deployment in resource-constrained environments and providing an efficient solution for safety management in high-risk industries.
[0006] To achieve the above objectives, the present invention provides the following technical solution:
[0007] A method for simultaneous detection of safety helmets and reflective vests based on the improved lightweight YOLOv8n includes the following steps:
[0008] Step 1: Construct an improved lightweight network model: The entire network consists of three main parts: a backbone network, a feature processing module, and a detection output module. The backbone network adopts an improved lightweight network architecture, using deformable convolutions in the convolutional layers to maintain the feature map resolution of the input size while enhancing the feature extraction capability for irregular targets. The feature processing module contains four core sub-modules: RFAConv, LSCD, C2f_Faster_EMA, and MLCA. The detection output module employs a multi-scale feature fusion mechanism.
[0009] Step 2: Obtain the image dataset of safety helmets and reflective vests;
[0010] Step 3: Input the safety helmet and reflective vest dataset prepared in Step 2 into the improved lightweight network model built in Step 1 for training, and obtain the trained safety helmet and reflective vest detection model.
[0011] The process of building the improved lightweight detection model includes:
[0012] Based on the initial feature map of the input image, the key feature map is extracted by dynamic weight allocation through the RFAConv module;
[0013] The key feature map is input into the LSCD module, and multi-scale features are extracted through lightweight shared convolution to obtain the optimized feature map;
[0014] Based on the optimized feature map, the spatial-channel dual attention mechanism of the C2f_Faster_EMA module is used to generate a small target enhanced feature map;
[0015] The enhanced feature map of the small target is input into the MLCA module, and a multi-scale fused feature map is obtained through the interaction and fusion of local and global features.
[0016] The multi-scale fused feature map is input into the detection head, and the final detection result is output through classification and regression branches.
[0017] The improved lightweight detection model also includes:
[0018] 1) The RFAConv module employs a dynamic weight allocation mechanism, comprising four cascaded stages and a weight sharing strategy. It aggregates global features through average pooling, processes them using 1×1 convolutions, and then combines normalization and ReLU activation functions to enhance non-linear characteristics. Finally, it generates an attention map using Softmax to achieve weighted feature fusion. This design effectively highlights key regions and suppresses redundant information by dynamically allocating feature weights within the receptive field.
[0019] 2) The LSCD module adopts a lightweight shared convolution design, which merges multi-channel convolution operations into a shared computation process and combines group normalization layers to optimize the stability of small-batch training; it adopts a multi-scale feature fusion strategy to weight and fuse feature maps of different resolutions, which significantly enhances the detection capability of multi-scale targets (especially small targets);
[0020] 3) The C2f_Faster_EMA module adopts a lightweight architecture and a multi-scale attention fusion design. Based on the lightweight architecture of FasterNet, it performs calculations only on effective pixel regions through partial convolution (PConv), which significantly reduces redundant computations. It integrates the EMA attention mechanism, which includes a 1×1 convolution branch to capture the global context and a 3×3 convolution branch to focus on local details. It also aggregates feature space relationships through global average pooling and optimizes the feature extraction efficiency of small targets by weighted fusion of multi-scale feature maps through dynamic weight allocation strategy.
[0021] 4) The MLCA module adopts a hybrid local channel attention mechanism. The input feature map is processed by local average pooling (LAP) to extract local region information, while global average pooling (GAP) captures the overall statistical context. The local and global feature maps are further compressed by one-dimensional convolution, and multi-scale feature fusion is achieved through multiplication and addition operations. Finally, the attention map generator dynamically allocates feature weights to highlight key regions and suppress redundant information.
[0022] Step 4: Select the minimum loss function and the optimal evaluation metric: Minimize the loss function until the number of training iterations reaches a set threshold or the value of the loss function reaches a set range. The model parameters are considered to have been pre-trained and saved. At the same time, select mAP@0.5:0.95, FPS, number of parameters (Params), and computational cost (GFLOPs) as evaluation metrics to measure the performance of the algorithm.
[0023] Step 5, fine-tune the model: Train and fine-tune the model using a dataset of images of safety helmets and reflective vests in specific scenarios to obtain stable and usable model parameters, thereby further improving the model's detection capabilities;
[0024] Step 6, Save the model: Solidify the finalized model parameters. When you need to detect safety helmets and reflective vests, you can directly input the image into the network to get the final detection result.
[0025] The backbone of the improved lightweight network model adopts an improved lightweight network architecture, using deformable convolutions in the convolutional layers to maintain the feature map resolution of the input size while enhancing the feature extraction capability for irregular targets.
[0026] The improved YOLOv8n detection model further includes: dynamic weight allocation and self-correction mechanism in the RFAConv module; lightweight shared convolution and multi-scale feature fusion strategy in the C2f_Faster_EMA module; spatial-channel dual attention network and repulsion loss compensation mechanism in the MLCA module; and a three-stage downsampling structure and local and global feature interaction fusion strategy in the LSCD module.
[0027] The beneficial effects of this invention are:
[0028] The beneficial effects of this invention lie in the significant improvement in the accuracy and real-time performance of helmet and reflective vest detection by introducing the RFAConv dynamic weight allocation mechanism, the LSCD lightweight shared convolutional detection head, the C2f_Faster_EMA multi-scale attention module, and the MLCA hybrid local channel attention mechanism. Specifically: the RFAConv module improves the small target detection accuracy by 0.3% by dynamically allocating convolutional kernel weights and focusing on key feature regions; the LSCD module uses shared convolutions and group normalization layers to achieve a computational efficiency of 6.7 GFLOPs while maintaining 2.38M parameters, reducing the model size to 5.0MB; the C2f_Faster_EMA module combines a lightweight architecture with a multi-scale attention mechanism to improve the small target mAP by 0.4% and the inference speed by 18%; and the MLCA module improves the small target recall rate by 25% in complex backgrounds through local-global feature interaction fusion. The improved YOLOv8n model has 43.6% fewer parameters than the original version (1.69M vs 3.00M), 37% less computation (5.1GFLOPs vs 8.1GFLOPs), and a 41.2% smaller size (3.7MB vs 6.3MB). It can achieve real-time detection at 35FPS on mobile devices. This algorithm performs exceptionally well in low-light, occluded, and densely populated scenes, reducing the false negative rate by 15% compared to traditional methods. It has been successfully applied to safety monitoring at construction sites, achieving millisecond-level recognition of helmet / reflective vest wearing status, providing an efficient solution for safety management in high-risk industries.
[0029] This invention has the following innovative features:
[0030] (1) RFAConv dynamic weight allocation module: After aggregating global features through average pooling, an attention map is generated, and the feature weights within the receptive field are dynamically allocated, effectively highlighting key regions and suppressing redundant information. After replacing the traditional convolution in the YOLOv8n backbone network, the accuracy of small target detection is improved by 0.3%, while keeping the number of parameters basically unchanged.
[0031] (2) LSCD lightweight shared convolutional detection head: adopts shared convolution to merge multi-channel calculation process, and combines group normalization layer to optimize training stability; through multi-scale feature fusion strategy to weighted fuse feature maps of different resolutions, while maintaining 2.38M parameters, it achieves 6.7GFLOPs computation efficiency and reduces the model size to 5.0MB.
[0032] (3) C2f_Faster_EMA multi-scale attention module: Based on the FasterNet lightweight architecture to reduce redundant computation, it integrates the EMA attention mechanism (1×1 convolutional branch captures global context + 3×3 convolutional branch focuses on local details), and optimizes the feature extraction efficiency of small targets through dynamic weight allocation, thereby improving the mAP of small targets in complex scenarios by 0.4% and the inference speed by 18%.
[0033] (4) MLCA Hybrid Local Channel Attention Module: The feature map is processed in parallel by Local Average Pooling (LAP) and Global Average Pooling (GAP). After one-dimensional convolution compression, multi-scale fusion is achieved through multiplication and addition. The recall rate of small targets in complex backgrounds is improved by 25%, which significantly enhances the feature representation ability of occluded scenes. Attached Figure Description
[0034] Figure 1 Flowchart of the detection method;
[0035] Figure 2 A schematic diagram of the improved lightweight YOLOv8n network structure of this invention;
[0036] Figure 3 The receptive field attention convolution (RFAConv) structure diagram of this invention;
[0037] Figure 4 A structural diagram of the lightweight shared convolutional detection head (LSCD) of the present invention;
[0038] Figure 5 The lightweight network architecture FasterNet of this invention is shown in the network structure diagram.
[0039] Figure 6 A schematic diagram illustrating the working principle of the EMA attention mechanism module of this invention;
[0040] Figure 7 Structure diagram of the Faster_EMA Block fusion module of the present invention;
[0041] Figure 8 The structural diagram of the C2f_Faster_EMA fusion module of the present invention;
[0042] Figure 9 A schematic diagram illustrating the working principle of the MLCA attention mechanism module of this invention;
[0043] Figure 10 Comparison of the simultaneous detection effects of the safety helmet and reflective vest of the present invention (showing the comparison of detection results in a construction site);
[0044] Table 1 Comparison of detection performance indicators of the present invention (comparison of key indicators such as FLOPs, Parameters, Model size, etc. with other methods). Figure 11 Comparison of detection performance indicators of the present invention (by comparing the performance of the model before and after the improvement in key performance indicators such as floating-point operations (GFLOPs), number of model parameters (Params), model size (Size), and average precision (mAP), the optimization effect of the model in terms of computational efficiency, storage requirements, and detection accuracy is shown). Detailed Implementation
[0045] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
[0046] like Figure 1 As shown, this invention provides a method for simultaneous detection of safety helmets and reflective vests based on the improved lightweight YOLOv8n, comprising the following steps:
[0047] Step 1: Data Acquisition and Preprocessing
[0048] This invention utilizes the HardHat-Vest Dataset from the open-source dataset website Kaggle, selecting a total of 6381 images showing the wearing status of safety helmets and reflective vests by construction workers. The dataset is divided into a training set (4466 images), a validation set (1276 images), and a test set (639 images) in a 7:2:1 ratio. In the preprocessing stage, YOLOv8n's mosaic data augmentation technique is introduced, expanding data diversity through random cropping, scaling, and stitching; adaptive grayscale padding is combined to process images of different sizes; and an anchor-free mechanism is employed to simplify the prediction task and improve training efficiency.
[0049] Step 2: Model Building
[0050] like Figure 2 , Figure 3 , Figure 4 , Figure 5 As shown, the model building phase consists of four core modules:
[0051] 1) RFAConv module: Replaces the last four convolutional layers in the backbone network, aggregates global features through average pooling, processes them through 1×1 groups of convolutions, combines normalization and ReLU activation functions to enhance non-linear characteristics, and then uses Softmax to generate attention maps, dynamically allocates feature weights within the receptive field, and highlights key regions.
[0052] 2) LSCD Lightweight Shared Convolutional Detection Head: Replaces the original detection head by merging multi-channel computation processes through shared convolution and combining group normalization (GN) layers to optimize the stability of small-batch training; adopts a multi-scale feature fusion strategy to weightedly fuse feature maps of different resolutions, thereby enhancing the detection capability of multi-scale targets.
[0053] 3) C2f_Faster_EMA module: Replaces the C2f module of YOLOv8n with a module that integrates the lightweight architecture of FasterNet and the EMA attention mechanism. FasterNet performs computation only in the effective pixel region through partial convolution (PConv), which significantly reduces redundant computation; EMA captures the global context through 1×1 convolution branches and focuses on local details through 3×3 convolution branches, and combines global average pooling to generate attention maps, thus optimizing the efficiency of small target feature extraction.
[0054] 4) MLCA Attention Mechanism Module: A hybrid local channel attention mechanism is introduced in the backbone layer. The feature map is processed in parallel by local average pooling (LAP) and global average pooling (GAP). After one-dimensional convolution compression, the local and global features are fused by multiplication and addition operations to highlight important information and suppress redundant features.
[0055] Step 3: Loss Function Design and Optimization
[0056] A decoupled head structure is used to separate the classification and regression tasks. Binary Cross-Entropy Loss is used for classification, while Distribution Focal Loss is used for regression to optimize bounding box regression accuracy. The optimizer is SGD with a momentum of 0.9 and a weight decay of 0.0005 to prevent overfitting. The initial learning rate is 0.01, and a cosine annealing scheduler is used for periodic adjustment. A warm-up strategy is employed to gradually increase the learning rate over the first 5 epochs to ensure training stability.
[0057] Step 4: Model Training and Optimization
[0058] The model was trained on an NVIDIA A16 GPU using the PyTorch framework, with a batch size of 16, input image size of 640×640, and 100 training epochs. Every 10 epochs, the mAP@0.5 metric was evaluated on the validation set, and the optimal model parameters were saved. For specific scenarios (such as low-light nighttime or densely occluded environments), the model was fine-tuned using scene-specific datasets to further improve detection robustness.
[0059] Step 5: Experimental Results and Analysis
[0060] As shown in Table 1, ablation experiments show that the RFAConv module improves mAP by 0.3%; the LSCD module reduces FLOPs from 8.3G to 6.7G while maintaining accuracy; the C2f_Faster_EMA module further reduces the number of parameters to 1.69M; and the MLCA module ultimately achieves an mAP of 0.811. Comparative experiments in Table 2 show that the improved YOLOv8n model has 43.6% fewer parameters than the original version (1.69M vs 3.00M), 37% less computation (5.1G vs 8.1G), and a 41.2% smaller model size (3.7MB vs 6.3MB). Its mAP@0.5 reaches 0.811, significantly outperforming mainstream lightweight models such as YOLOv5n (0.801) and YOLOv8n (0.810).
[0061] The foregoing has provided a detailed description of a method for simultaneous detection of safety helmets and reflective vests based on an improved lightweight YOLOv8n, as provided by this invention. The specific embodiments described are merely for the purpose of aiding understanding the method and its core principles. It should be noted that those skilled in the art can make various improvements and modifications to this invention without departing from its principles, and these improvements and modifications also fall within the scope of protection of the claims of this invention.
Claims
1. A method for simultaneous detection of safety helmets and reflective vests based on an improved lightweight YOLOv8n, characterized in that, Includes the following steps: S1. Collect image datasets of safety helmets and reflective vests: The dataset should include various construction sites, different lighting conditions and occlusion situations to ensure the generalization ability of the model. Each image needs to be labeled with a bounding box, and the label content includes the category and location information of the safety helmet and reflective vest. S2. Image preprocessing: Adaptive image enhancement technology is used to perform brightness correction and noise suppression on low-light images to avoid information loss. Random cropping, rotation, and flipping operations are used to enhance the diversity of training data. S3. Constructing an Improved Lightweight Model: A receptive field attention convolution (RFAConv) is introduced, dynamically allocating kernel weights to reflect the importance of image features within the receptive field. Combined with a lightweight shared convolutional detection head (LSCD), the detection capability is further enhanced through shared convolution and feature scaling at scale layers, significantly reducing the number of parameters and computational cost while maintaining high model performance. A C2f_Faster_EMA module is designed to encode global information and adjust the weights of each parallel branch, thereby highlighting the extraction of small target features. An MLCA attention mechanism is added to effectively capture multi-scale information by simultaneously processing local and global features. S4. Model Training: The SGD optimizer is used with momentum set to 0.9 and weight decay set to 0.0005 to prevent overfitting.
2. The method according to claim 1, characterized in that, The RFAConv (Receptive Field Attention Convolution) dynamically adjusts the weights of the convolution kernel, taking into account the importance of each feature in the receptive field, and combines the feature map with the attention map to ensure that the network can focus on processing the most critical information.
3. The method according to claim 1, characterized in that, The LSCD lightweight shared convolutional detection head maintains high detection accuracy while reducing redundant computation and parameter count through lightweight design and efficient feature fusion strategy.
4. The method according to claim 1, characterized in that, The C2f_Faster_EMA module effectively reduces model parameters and floating-point operations while encoding global information and adjusting the weights of each parallel branch, thereby highlighting the extraction of small target features.
5. The method according to claim 1, characterized in that, The MLCA attention mechanism module effectively captures multi-scale information by simultaneously processing local and global features, thereby improving the accuracy and robustness of the model in detecting complex backgrounds or small targets.