Optimized YOLOv8n safety helmet detection model for electric power inspection scene
By adding a P2 detection layer, an LSCD detection head, a C2f-Faster module, and an SPPF-LSKA module to the YOLOv8n model, the problems of low detection accuracy and high computational complexity of small targets in power line inspection scenarios are solved, and efficient and accurate safety helmet detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-26
- Publication Date
- 2026-03-13
AI Technical Summary
Existing target detection algorithms have low accuracy in detecting small targets like safety helmets in power line inspection scenarios, require large amounts of computation, and are easily affected by background interference, making it difficult to deploy them in real time on resource-constrained edge devices.
The detection accuracy is improved and the computational complexity is reduced by adding a P2 small target detection layer, adopting a lightweight LSCD detection head, introducing a C2f-Faster module and integrating an SPPF-LSKA module, and improving the YOLOv8n model.
It significantly improves the detection accuracy and robustness of safety helmets for small targets, while reducing the number of model parameters and computational load, making it suitable for real-time deployment on edge devices.
Smart Images

Figure CN121661324A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of target detection technology, specifically to a YOLOv8n safety helmet detection model optimized for power line inspection scenarios. Background Technology
[0002] In the power industry, inspection and construction personnel often need to work in complex environments such as high voltage, high altitude, and outdoor conditions. Wearing safety helmets correctly is a crucial measure to ensure personnel safety. Therefore, utilizing technological means to automatically and accurately detect whether workers are wearing safety helmets is of great significance for safe power production.
[0003] Currently, deep learning-based object detection algorithms, such as the YOLO series, are widely used in safety helmet detection tasks. However, power line inspection scenarios have their own unique characteristics: First, inspection cameras are usually far from workers, causing safety helmets to appear as small targets in images with few pixels and indistinct features; second, the outdoor environment is complex, with issues such as weather, lighting changes, and interference from similar objects. These factors make general object detection models prone to false positives and false negatives when applied in power line inspection scenarios, and their detection accuracy and robustness are insufficient to meet the needs of practical applications.
[0004] While some existing research attempts to improve models like YOLO to enhance small target detection performance, most improvements significantly increase the number of model parameters and computational complexity, hindering real-time deployment on resource-constrained edge devices. Therefore, achieving lightweight models while maintaining high detection accuracy is a key challenge in current power line inspection safety helmet detection technology. Summary of the Invention
[0005] Based on the problems existing in the background technology, this invention proposes a YOLOv8n safety helmet detection model optimized for power line inspection scenarios. The purpose of this invention is to solve the problems of low detection accuracy, high computational load, and susceptibility to background interference in complex power line scenarios of existing detection algorithms, and to provide a solution that achieves a good balance between detection accuracy and model efficiency.
[0006] To achieve the above objectives, the present invention adopts the following technical solution:
[0007] Add a P2 small target detection layer: In addition to the existing P3, P4 and P5 detection layers, a high-resolution P2 detection layer with a resolution of 160×160 pixels is added to capture richer shallow detail features and improve the ability to perceive small safety helmets.
[0008] A lightweight LSCD detection head is adopted: the original YOLOv8n detection head is replaced with an LSCD detection head. This detection head uses group normalization instead of batch normalization and uses parameter-shared convolution to aggregate information from feature maps of different scales, which significantly reduces the number of parameters and computation while maintaining accuracy.
[0009] Introducing the C2f-Faster module: The Bottleneck module within the C2f module in the backbone and neck network is replaced with the FasterBlock module from FasterNet. FasterBlock employs partial convolution operations, extracting spatial features only from a subset of the input channels, effectively reducing the model's computational complexity.
[0010] Integrating the SPPF-LSKA module: The SPPF-LSKA separable large convolutional kernel attention mechanism is introduced into the SPPF layer to form the SPPF-LSKA module. This module utilizes depthwise convolution and depthwise dilated convolution to construct attention maps, enabling the model to focus on important features and suppress interference from complex background information.
[0011] The design process of the method includes four parts: data preprocessing, model building, model training and hyperparameter optimization, and model evaluation. First, the collected power line inspection image data is cleaned and labeled; then, the improved YOLOv8n model structure is constructed; the model is trained using the processed dataset, and the optimal parameter configuration is found using hyperparameter optimization; finally, the model's performance is evaluated on the test set.
[0012] Through the synergistic effect of the above four improvements, this invention significantly reduces the number of model parameters while effectively improving the detection accuracy and robustness of small target safety helmets in complex power line inspection scenarios. Attached Figure Description
[0013] Figure 1 The diagram shows the structure of the improved YOLOv8n network model of this invention.
[0014] Figure 2 A structural diagram of the LSCD detection head is shown.
[0015] Figure 3 The structural diagram of the C2f-Faster module is shown.
[0016] Figure 4 The structural diagrams of FasterBlock and PConv are shown.
[0017] Figure 5 The structural diagram of the LSKA and SPPF-LSKA modules is shown. Detailed Implementation
[0018] The present invention will be further described below with reference to the accompanying drawings:
[0019] Example 1: A YOLOv8n safety helmet detection model optimized for power line inspection scenarios is set up. This model includes: first, labeling and segmenting power line inspection images obtained from a specific dataset; then, constructing an improved YOLOv8n model based on the PyTorch framework. This model enhances small target perception by adding a P2 detection layer, replaces the LSCD detection head for parameter sharing and lightweighting, introduces a C2f-Faster module to reduce computation by utilizing partial convolutions, and integrates an SPPF-LSKA module to suppress background interference through a large convolutional kernel attention mechanism; next, training and optimizing the model using set hyperparameters under specified hardware conditions; finally, applying the trained model to power line inspection images or video streams to output the detection results of safety helmet wearing.
[0020] according to Figure 1 : Construct an improved YOLOv8n model. Specific improvements are as follows:
[0021] A P2 detection layer is added: The YOLOv8n model has three different scale detection heads: P5 (20×20), P4 (40×40), and P3 (80×80), which are used to detect large, medium, and small targets in the image, respectively. Workers wearing safety helmets occupy a relatively small proportion of the image, resulting in limited usable information. The 80×80 feature map corresponding to the P3 detection head is insufficient to extract comprehensive features of helmet wearing. Since shallow feature information has high resolution, a small receptive field, and strong spatial information, this invention adds a P2 detection head with a corresponding feature map size of 160×160 to capture more rich details in the shallow feature map. In the Neck part, feature information at four different scales (160×160, 80×80, 40×40, and 20×20) is fused to achieve complementary enhancement of shallow fine-grained information and deep semantic information. The enhanced four sets of multi-scale feature information are then passed to the detection head for target classification and localization prediction, thereby improving the detection accuracy of small targets.
[0022] according to Figure 2The YOLOv8 detection head is divided into two branches, each performing independent convolution operations. This results in redundant parameter calculations, impacting the model's feature extraction efficiency. Introducing the P2 detection head further increases the computational burden. Therefore, this invention introduces a lightweight LSCD detection head. By using shared convolution operations, it improves feature extraction efficiency, reduces computational costs, and enhances the stability of detection results. The LSCD detection head replaces the batch normalization (BN) layer in ordinary convolutional layers with group normalization (GN). It groups feature channels and calculates the mean and variance within each group for normalization, effectively avoiding the excessive batch dependency of BN layers and maintaining stable accuracy across batch sizes. Furthermore, LSCD extracts feature maps of different scales from the P2 to P5 detection heads, adjusts channels using four 1×1 shared convolutions (Conv_GN), and then aggregates information using two 3×3 parameter-shared convolutions (Conv_GN), reducing redundant information. Finally, the information extracted by the shared convolution is input into the classification and regression heads, and a scale layer is used to scale the features at different scales, addressing the issue of inconsistent target sizes across different detection heads. This design significantly reduces the computational cost of the model while improving feature extraction efficiency.
[0023] according to Figure 3 and Figure 4 In the power line inspection scenario, the task of detecting the wearing of safety helmets requires both high detection accuracy and a suitable model size. To further improve the computational efficiency of the model, the C2f module in YOLOv8 is improved by replacing Bottleneck in the C2f module with the FasterBlock module from Fasternet, forming the C2f-Faster module. The FasterBlock module consists of PConv layers and Conv layers. The partial convolution (Patial Convolution, PConv) only performs spatial feature extraction on a subset of channels, leaving the remaining channels unchanged. With the same number of input and output channels, compared to standard convolution, PConv has lower computational and memory requirements, effectively reducing the model's computational load and improving its computational efficiency.
[0024] according to Figure 5To address the interference of complex backgrounds on helmet detection in power line inspection scenarios, an SPPF-LSKA module with separable large convolutional kernels was introduced into the SPPF layer of YOLOv8n. The LSKA module utilizes standard depthwise convolution (DW-Conv) to help the model focus on important parts of the image, forming an initial attention map. Then, depthwise dilated convolution (DW-D-Conv) with adjustable dilation rate is used to weight and fuse information at different scales, effectively capturing the correlation between local details and global semantics. Finally, the attention map is fused and applied to obtain the final attention map. This attention map weights the original features, enhancing the network's focus on important features and suppressing useless background information, thereby improving the model's detection accuracy in complex backgrounds.
[0025] Example 2: A YOLOv8n safety helmet detection model optimized for power line inspection scenarios was established. This optimized model, validated through ablation experiments, uses the original YOLOv8 model as a baseline and sequentially adds a P2 detection layer, an LSCD detection head, a C2f-Faster module, and an SPPF-LSKA module. Experimental results show that, compared to the baseline model, the final model (Ours) improves accuracy by 1%, recall by 4.9%, and mean precision by 3.4%, while reducing the number of model parameters by 34.6%. This fully demonstrates the significant effectiveness of this invention in improving detection accuracy and achieving model lightweighting.
[0026] Example 3: An optimized YOLOv8n safety helmet detection model for power line inspection scenarios is set up. This optimized YOLOv8n safety helmet detection model for power line inspection scenarios includes comparative experiments between the method described in this invention and current mainstream target detection models, such as SSD, YOLOv5n, YOLOv6n, and YOLOv7-tiny. On the same power line inspection test set, the method described in this invention achieved an average accuracy of 82.2%, outperforming all compared models. Simultaneously, the parameter count of this method is only 1.97M, far lower than YOLOv5n's 4.2M and YOLOv7-tiny's 6.01M, demonstrating its superior overall performance.
Claims
1. A YOLOv8n safety helmet detection model optimized for power line inspection scenarios, characterized in that, Includes the following steps: S1: Obtain the image dataset of power inspection scene, clean and label the image data, classify it into "wearing a safety helmet" and "not wearing a safety helmet", and divide the dataset into training set, validation set and test set; S2: Construct an improved YOLOv8n object detection model, the improvement including: S2.1: Add a 160×160 pixel scale P2 small object detection layer after the neck network of the baseline YOLOv8n model; S2.2: Replace the detection head of the original YOLOv8n model with the LSCD lightweight detection head; S2.3: Replace the C2f modules in the backbone and neck network of the model with C2f-Faster modules; S2.4: Replace the SPPF module with the SPPF-LSKA module at the end of the backbone network; S3: Train the improved YOLOv8n model using the training set, and use the validation set to validate the model and fine-tune the hyperparameters; S4: Input the power line inspection image to be detected into the trained model, and output the detection results of the safety helmet wearing, including the target location and category confidence.
2. The YOLOv8n safety helmet detection model optimized for power line inspection scenarios as described in claim 1, characterized in that, The LSCD lightweight detection head in S2.2 is specifically implemented as follows: L1: extracting feature maps from the detection layers at four scales, P2, P3, P4, and P5; L2: adjusting the number of channels in each feature map using four 1×1 shared convolutional layers, followed by group normalization; L3: aggregating cross-scale information on the adjusted features using two 3×3 parameter-shared convolutional layers; L4: inputting the aggregated features into independent classification and regression branches, and scaling the features through a scale layer to adapt to the scale of different detection heads.
3. The YOLOv8n safety helmet detection model optimized for power line inspection scenarios as described in claim 1, characterized in that, The C2f-Faster module in S2.3 is implemented by replacing Bottleneck in the original C2f module with the FasterBlock module. The workflow of the FasterBlock module is as follows: F1: For the input feature map, first use partial convolution to extract spatial features from some input channels; F2: Then, use regular convolution to perform feature transformation on all channels; F3: The formula for calculating the floating-point computation cost of the partial convolution is as follows: Where h and w are the height and width of the feature map, k is the convolution kernel size, and c p Let r be the number of channels in the convolution operation, and satisfy r = c. p / c = 1 / 4, where c is the total number of channels.
4. A YOLOv8n safety helmet detection model optimized for power line inspection scenarios as described in claim 1, characterized in that, The SPPF-LSKA module in S2.4 introduces the LSKA separable large convolutional kernel attention mechanism after the SPPF structure. Its specific process includes: K1: Processing the input features using standard depthwise convolution to generate an initial attention map; K2: Using depthwise dilated convolution with adjustable dilation rate to weight and fuse contextual information at different scales; K3: Fusing and applying attention to generate the final attention map, weighting the original features to enhance important features and suppress background interference.