Safety helmet wearing automatic detection method and system based on lightweight network
By optimizing the YOLOv8 target detection model and introducing a lightweight network and a multi-scale attention mechanism, the problems of false positives and false negatives in helmet wearing detection were solved, achieving high-precision and low-computational-consumption automatic helmet wearing detection.
Patent Information
- Application Number
- CN202511649669.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-12
- Publication Date
- 2026-02-17
AI Technical Summary
Existing technologies for detecting the wearing of safety helmets are prone to misjudgment and omissions, especially when construction workers are not wearing their helmets correctly, making it impossible to detect them effectively and rendering the helmets ineffective in providing protection.
An automatic helmet-wearing detection method based on lightweight networks is adopted. By establishing and expanding the helmet-wearing standard dataset, the YOLOv8 target detection model is optimized. Variable convolution, multi-scale progressive channel attention, multi-head self-attention mechanism and lightweight network deployment are introduced to enhance the detection capability of small helmets and buckles. The loss function and training strategy are optimized to improve detection accuracy.
Significantly reduces algorithm computation while maintaining high detection performance and real-time capability, reduces false negative and false positive rates for small targets, and improves the accuracy and real-time performance of helmet wearing detection.
Smart Images

Figure CN121545181A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of detection methods, in particular to a safety helmet wearing automatic detection method and system based on a lightweight network. BACKGROUND
[0002] In recent years, the importance of safety has gradually increased at home and abroad, and the wearing of safety helmets is strictly checked in road traffic and construction sites. Related research at home and abroad is also rapidly developing.
[0003] At present, the mainstream safety helmet wearing detection at home and abroad mainly adopts a two-stage target detection method, which first separates construction personnel through a target detection network and then sends it to a safety helmet detection model for safety helmet wearing detection. Many researchers use the YOLO detection method, which has rapidly progressed from YOLO to YOLOv5, and has been improved on this basis to improve detection accuracy. For example, some people combine the YOLOv3 target detection network with the Facenet model, and use background difference method to improve safety helmet wearing detection accuracy.
[0004] Many researchers have continuously improved safety helmet wearing detection accuracy, but many people have only placed safety helmets on their heads to avoid inspection, without wearing them correctly, so safety helmets cannot play their due protective role in such cases. SUMMARY
[0005] The present application aims to solve the technical problems existing in the prior art and particularly innovatively proposes a safety helmet wearing automatic detection method and system based on a lightweight network to improve the accuracy of safety helmet wearing detection.
[0006] To achieve the above purpose, the present application provides a safety helmet wearing automatic detection method based on a lightweight network, comprising the following steps:
[0007] S1: establishing and expanding a safety helmet wearing specification dataset;
[0008] S2: establishing a target detection model based on YOLOv8;
[0009] S3: optimizing the model;
[0010] S4: training the improved model through the expanded safety helmet wearing specification dataset.
[0011] In the above scheme, step S1 further includes the following content:
[0012] S1-1: collecting safety helmet wearing images and expanding and preprocessing them using image algorithms;
[0013] S1-2: Label the safety helmet wearing image to obtain the cutting region and the cutting point in the region.
[0014] In the above scheme, step S3 further includes the following contents:
[0015] S3-1: Introduce variable convolution in the backbone of the YOLOv8 model, and replace part of the standard convolution layer;
[0016] S3-2: Introduce multi-scale progressive channel attention in the feature pyramid network to strengthen the output features of the variable convolution;
[0017] S3-3: Add the MPCA module to a specific position of the backbone and the neck part;
[0018] S3-4: Introduce a multi-head self-attention mechanism in the neck network to enhance the cross-scale feature fusion capability;
[0019] S3-5: Enhance the detection of small safety helmets and buckles;
[0020] S3-6: Lightweight network deployment;
[0021] S3-7: Optimize the loss function and training strategy.
[0022] In the above scheme, step S4 further includes the following contents:
[0023] S4-1: Input feature map;
[0024] S4-2: Global pooling in the height direction of the feature map;
[0025] S4-3: Global pooling in the width direction of the feature map;
[0026] S4-4: Double-path feature encoding;
[0027] S4-5: Spatial attention weight generation;
[0028] S4-6: Feature recalibration.
[0029] In the above scheme, step S3-2 further includes the following contents:
[0030] S3-2-1: The input feature map is subjected to a plurality of different scale pooling layers to obtain multi-scale features;
[0031] S3-2-2: The multi-scale features are fused, and then subjected to dimension reduction and feature integration through a convolution layer;
[0032] S3-2-3: The fused features are input into the coordinate attention mechanism to calculate the attention weights for the height and width, respectively;
[0033] S3-2-4: multiply the obtained attention weight with the input feature map.
[0034] In the above scheme, step S3-4 further includes the following contents:
[0035] S3-4-1: add position encoding to preserve spatial information;
[0036] S3-4-2: use multiple attention heads to capture different types of dependency;
[0037] S3-4-3: enhance feature representation through a Transformer encoder.
[0038] In the above scheme, step S3-5 further includes the following contents:
[0039] S3-5-1: add a P2 detection layer in the feature pyramid;
[0040] S3-5-2: upsample the deep features of the detection and fuse them with the shallow features;
[0041] S3-5-3: use a context module to enhance the ability to recognize small targets.
[0042] In the above scheme, step S3-6 further includes the following contents:
[0043] S3-6-1: reduce model complexity through parameter sharing;
[0044] S3-6-2: use depth separable convolution in some modules to reduce computation;
[0045] S3-6-3: prune and 8-bit quantize the trained model.
[0046] The application also provides a computer system, comprising:
[0047] a processor;
[0048] a memory for storing processor-executable instructions;
[0049] wherein the processor is configured to implement the application of claim 1-8 when the executable instructions are executed
[0050] In summary, the application has the following advantages: through the improved YOLO algorithm, the algorithm computation can be significantly reduced while maintaining high detection performance and real-time requirements; the attention mechanism is introduced to strengthen the multi-scale feature fusion capability, solve the information loss problem, and reduce the small target miss detection rate and false detection rate; with the help of deep learning technology, further development is carried out to reduce the misjudgment and omission. Attached Figure Description
[0051] Figure 1 This is a flowchart illustrating the present invention;
[0052] Figure 2 This is the dataset of safety helmet wearing guidelines for this invention;
[0053] Figure 3 This is a comparison chart of the data processed from the original YOLOv8 model and the improved model based on this technical solution. Detailed Implementation
[0054] The present invention will be further described below with reference to the embodiments and accompanying drawings:
[0055] like Figure 1 As shown, an automatic helmet-wearing detection method based on lightweight networks includes the following steps:
[0056] S1: Establish and expand the dataset of safety helmet wearing standards;
[0057] S1-1: Acquire images of helmet wearing and perform augmentation and preprocessing using image algorithms;
[0058] This embodiment selects an open-source, large-scale safety helmet wearing image dataset, which includes different scenes, lighting conditions, and personnel posture factors. It custom-constructs large-scale images and data annotations to provide personalized, high-quality training samples for model training. Figure 2 As shown.
[0059] S1-2: Annotate the images of helmet wearing to obtain the region to be cut and the cutting points within the region. Use the region cutting density to label the samples to avoid training bias.
[0060] The sample annotation includes: establishing a dynamic data augmentation index D. aug
[0061]
[0062] Based on the raw data of the helmet-wearing image, the height H orig and width W orig A width-to-height ratio is generated and adjusted using a weighted average α. This ratio is input into S1-2 for annotation and serves as the basis for calculating the cutting points within the region. θ is the category magnification factor, γ is the adjustment factor, and φ = 0.1π is used as the adjustment parameter for light sensitivity. T light Illuminance;
[0063] N cls As an important category count in the helmet wearing detection dataset,
[0064] In helmet-wearing detection scenarios, including:
[0065] Wear a safety helmet.
[0066] No helmet worn.
[0067] Improper helmet wearing
[0068] If the dataset is expanded to multiple scenarios (such as construction sites, factories, roads, etc.), N cls Includes scene categories, such as "construction site - daytime" and "road - nighttime", where N cls ≥3.
[0069] N cls via θ*N cls The term affects the input value of the logarithmic function, thereby regulating the intensity of data augmentation;
[0070] When N cls As it increases: the value of ln(θ*Ncls+γ) increases, driving D aug This boosts data augmentation, triggering more aggressive data augmentation to balance the distribution of samples across multiple classes and prevent the model from underfitting to a minority of classes.
[0071] When N cls When = 1, i.e., single-class detection: ln(θ*1+γ) takes the smaller value, D aug Dominated by the illumination term βsin(φ*Tlight), the focus is on optimizing illumination robustness.
[0072] N cls The value is also an important indicator of the density of area cutting.
[0073] This density control ensures the uniformity of the labeled sample distribution for each category, guaranteeing sufficient labeled samples even when wearing non-standard categories.
[0074] Through D aug Image annotation for driving helmet wearing, when D aug >2. Activate secondary annotation of edge regions.
[0075] S2: Establish a target detection model based on YOLOv8;
[0076] S3: Optimize the model;
[0077] S3-1: Introduce variable convolutions in the backbone of the YOLOv8 model to replace some standard convolutional layers;
[0078] The variable convolution includes: forming gradient field modulation through a variable convolution weight optimization function to achieve synergy between attention weights and convolution kernel deformation, thereby improving the efficiency of channel dimension feature selection;
[0079]
[0080] Where, Δx i and Δy i ω is obtained by using the coordinates of the cut points marked in the sample in S1-2. i ωi represents the learnable weight parameters of the variable convolution kernel on the spatial location channel c; the sparsity of ωi reduces the computational cost of the convolution kernel through L1 regularization constraints, adapting to the requirements of lightweight deployment. With D aug Linear correlation, with the superscript η being the dynamic adjustment index, preferably 1.2; λ being the activation threshold; and K being the kernel size of 3*3; the kernel deformation is guided by the coordinates of the cutting points to enhance the response intensity of the safety helmet edge features.
[0081] S3-2: Introduce multi-scale progressive channel attention into the feature pyramid network to enhance the output features of variable convolution;
[0082] S3-2-1: The input feature map is processed through multiple pooling layers of different scales to obtain multi-scale features;
[0083] S3-2-2: These multi-scale features are fused, and then dimensionality reduction and feature integration are performed through a convolutional layer;
[0084] S3-2-3: The fused features are fed into the coordinate attention mechanism to calculate the attention weights for height and width respectively;
[0085] S3-2-4: Multiply the obtained attention weights with the input feature map to enhance meaningful features and suppress background interference.
[0086] The attention weights include: progressive attention weights A prog ;
[0087]
[0088] The number of scales S is preferably 4; the scale weight μ s ={0.2,0.3,0.3,0.2}, where v is the spatial modulation coefficient; G spatial As a feature of the spatial gradient field, W dyn Get the parameters, v and D aug Negative correlation;
[0089] G spatial via tanh(G) spatialThe gradient field is mapped to the interval [-1, 1], then scaled by ν and added to a constant 1 to form the spatial gradient modulation factor (1 + ν * tanh(G)). spatial This factor, multiplied by the multi-scale channel attention weights, achieves two states: when G... spatial When the gradient is large, i.e., it is identified as the edge of a safety helmet, the high gradient region is enhanced, the modulation factor is >1, the attention weight of the region is increased, and the key feature response is strengthened; when the gradient is small, i.e. it is identified as a smooth background, the low gradient region is suppressed, the modulation factor is ≈1, and invalid feature interference is avoided.
[0090] G spatial W is directly taken from the output of S3-1 dyn The gradient field forms a cascade relationship from variable convolution weights to spatial gradients and then to attention modulation. dyn Focusing on the edge of the safety helmet through dynamic convolution kernel deformation; for W dyn Find the gradient to obtain G spatial Quantify the saliency of edge regions; G spatial Feedback to A prog This guides the attention mechanism to prioritize high-gradient regions.
[0091] S3-3: Add the MPCA module to a specific location on the backbone, as well as the neck section;
[0092] S3-4: Introduce a multi-head self-attention mechanism into the neck network to enhance the cross-scale feature fusion capability;
[0093] S3-4-1: Add location coding to preserve spatial information;
[0094] S3-4-2: Use multiple attention heads to capture different types of dependencies;
[0095] S3-4-3: Enhancing feature representation through a Transformer encoder;
[0096] The cross-scale feature fusion includes: setting a cross-scale attention fusion index I. attn
[0097]
[0098] Position encoding matrix P pos A output by S3-2 prog Spatial distribution generation, occlusion area mask M mask Taken from the area to be cut as marked in S1-2; d k P represents the attention dimension, δ is the residual fusion coefficient, used to adjust the contribution of convolutional residual connections in cross-scale feature fusion; posFollowing a Gaussian distribution N(0,0.1), P pos dot product QK with query-key T By combining the two, we can enhance the spatial location-sensitive attention weight calculation, avoid the loss of spatial information during feature fusion, and reduce the false detection rate of occluded scenes through the collaboration of location encoding and region masking, thereby improving the positioning accuracy of local features such as helmet edges and buckles.
[0099] M mask ∈{0,1} H×W M is a binary mask matrix; mask With attention weight matrix (QK) T +P pos ) Element-wise multiplication ⊙ achieves the suppression of the background region and the enhancement of the target region, that is, when M mask When (x,y)=1, retain the attention weight at that position; when M mask When (x,y)=0, the attention weight at that position is forcibly set to 0 to avoid background noise interference; Conv 3×3 (F neck ) is a 3×3 convolution operation on the neck feature map; local feature extraction and channel dimension adjustment are performed to enhance the spatial local correlation of features while reducing computational complexity;
[0100] δ*Conv3×3(F neck () is dynamic residual fusion, based on the principle of information complementarity, in I attn In the formula, δ*Conv3×3(F neck As a residual term, the self-attention mechanism captures the long-range global relationship between the helmet and the background, while the convolutional residual captures the local details of the helmet's edge texture. The two complement each other to improve the feature representation capability.
[0101] The multi-head self-attention mechanism can establish global dependencies, solve the problem of detecting helmets for small targets at a distance, and enhance the perception of minute features such as helmet buckles.
[0102] S3-5: Enhanced inspection of small safety helmets and buckles;
[0103] S3-5-1: Add a P2 detection layer to the feature pyramid; this detection layer has higher resolution and is used to detect small targets such as tiny helmets and buckles.
[0104] S3-5-2: Upsample the detected deep features and fuse them with the shallow features;
[0105] S3-5-3: Enhance the ability to identify small targets by utilizing the context module;
[0106] The context module includes: computing the context-aware feature enhancement function F.ctx ;
[0107]
[0108] Through dilated convolution Conv dilated The dual enhancement of (F) and edge features improves the recall rate for small target detection; by increasing the sampling interval of the convolution kernel, the receptive field is expanded without increasing computational cost, capturing a wider range of contextual information around the helmet; GAP(F) is global average pooling, which performs average pooling on the feature map F in the spatial dimension (H×W), outputting a vector of a specific number of channels, Conv 1×1 (F) Cross-channel information fusion and recombination are achieved by adjusting the number of channels through 1×1 convolution; F ctx The receptive field is expanded through dilated convolution, global average pooling aggregates global information, and 1×1 convolution adjusts the channel dimension. The element-wise multiplication operation with ⊙ enables dynamic modulation of the space-channel dimension, ultimately forming a closed-loop mechanism of context awareness and feature enhancement, thereby improving the accuracy of helmet wearing detection.
[0109] Edge(F) is taken from the output I of S3-4. attn Edge features, edge enhancement coefficient κ and D aug Positive correlation;
[0110] I attn Edge feature extraction (Sobel / Canny) Edge(F) is performed to quantify the outline clarity of key parts such as the edge, buckle, and brim of the safety helmet;
[0111] Edge(F) is fused with the main feature after being weighted by κ, so that when the edge of the safety helmet is blurred, Edge(F) provides clear edge contour information and improves positioning accuracy; through dynamic adjustment of κ, non-edge areas are not falsely enhanced, reducing false detections.
[0112] S3-6: Lightweight network deployment;
[0113] S3-6-1: Reduce model complexity through parameter sharing;
[0114] S3-6-2: Use depthwise separable convolution in some modules to reduce computational load;
[0115] S3-6-3: Prune and quantize the trained model to further improve inference speed;
[0116] The pruning includes: calculating the quantization pruning process using a mixed-precision quantization loss function;
[0117] L quant =CE(F full ,Fquant )+τ·MSE(W orig W pruned )+ξ·Entropy(A act );
[0118] Among them, W pruned It is an optimized W dyn A act For the output A prog Activation value distribution; τ is the pruning weight, ξ is the activation entropy constraint, Entropy(A act ) Measures feature diversity; by jointly optimizing quantized loss and pruning weights, the model size is compressed, improving inference speed; CE is the cross-entropy calculation, and MSE is the mean squared error calculation.
[0119] F full The output of the feature map for the full-precision model, such as a 32-bit floating-point number, represents the complete information representation of the original model; F quant The output of the quantized feature map, such as an 8-bit integer, is a lightweight model output after pruning and quantization compression; W orig W represents the original convolution weight matrix and an uncompressed dense parameter set. pruned The sparse weight matrix after pruning is obtained by reducing redundant parameters through operations such as channel pruning and kernel sparsification.
[0120] L quant By maintaining accuracy through CE, constraining weight differences through MSE, and enhancing generalization ability through Entropy, the three work together to achieve the quantization goals of high accuracy, low computational cost, and strong robustness.
[0121] S3-7: Optimize the loss function and training strategy;
[0122] The WIoU loss function is used to calculate the bounding box regression;
[0123] S4: Train the improved model using the expanded helmet-wearing guidelines dataset;
[0124] S4-1: Input feature map;
[0125] S4-2: Global pooling of the feature map along its height direction;
[0126] S4-3: Global pooling of the feature map along its width;
[0127] S4-4: Dual-path feature encoding;
[0128] S4-5: Spatial attention weight generation;
[0129] S4-6: Feature recalibration;
[0130] During feature recalibration, the dual-path feature encoding weight Γ is used. dual ,
[0131] Γ dual =Sigmoid(FC1(GAP(F h ))+FC2(GAP(F w )))·(1+ζ·cos(F h ,F w ))
[0132] Among them, FC1 is a fully connected layer 1, which is used for high-dimensional global pooling features GAP(F h A nonlinear transformation is performed to extract global context information in the vertical direction of the safety helmet, such as the longitudinal relative position of the worker's head and the safety helmet. FC2 is a fully connected layer 2: it performs a global pooling feature GAP(F) in the width dimension. w A nonlinear transformation is performed to extract the global context information of the helmet in the horizontal direction, such as the left-right symmetry of the helmet and the horizontal position of the buckle. GAP(F) h GAP(F) is a high-dimensional global average pooling method that averages the feature map F along its height dimension H, outputting a 1×W×C dimension that aggregates global semantics in the vertical direction, such as the contextual relationship between the helmet and the background. w ) is the width-dimensional global average pooling: the feature map F is averaged over the width dimension W, and the output dimension is H×1×C, which aggregates the global semantics in the horizontal direction, such as the correlation between the left and right edges of the safety helmet; ζ is the dual-path fusion coefficient, which is used to adjust the fusion ratio of the height and width paths with the spatial consistency term, and the value range is [0,1]; balancing local details and global structure.
[0133] cos(F h ,F w ) represents cosine similarity, used to calculate the high-dimensional feature GAP(F). h ) and width-dimensional features GAP(F) w The cosine similarity of FC1(GAP(F) is used to quantify the consistency of their spatial structures, such as the vertical-horizontal symmetry of the helmet edge. This is achieved through dual-path fusion of FC1(GAP(F)). h ))+FC2(GAP(F w The calculation involves using a fully connected layer to perform a non-linear transformation on the global pooled features in the height and width dimensions, extracting global contextual information of the helmet in the vertical and horizontal directions, such as the vertical extension of the helmet edge and the horizontal position of the buckle. A sigmoid activation function is used to map the fused features to the [0,1] interval, generating spatial attention weights to enhance the response of key areas of the helmet and suppress background noise. Then, spatial consistency modulation is used to calculate 1 + ζ × cos(F). h ,F w), through cosine similarity cos(F) h ,F w The spatial consistency of height and width features is quantified, such as the vertical-horizontal symmetry of the helmet edge, and its contribution is dynamically adjusted using ζ.
[0134] For example, the standard wearing scenario is when the edges of the helmet are symmetrical, cos(F) h ,F w )≈1, modulation term≈1+ζ, enhancing feature response; for example, in the scenario of improper wearing, when the edge of the safety helmet is asymmetrical, cos(F)≈1, modulation term≈1+ζ, enhancing feature response; h ,F w )≈0, modulation term≈1, to avoid excessive noise enhancement.
[0135] The beneficial effects of the above technical solution are as follows:
[0136] By employing multi-scale progressive channel attention and multi-head self-attention mechanisms, the model improves localization accuracy by 25% in key areas such as helmet edges and buckles, increases small target detection AP value by 12% for tiny helmets, and achieves mAP@0.5 of 94.5%, which is 3.5 percentage points higher than the traditional YOLOv8.
[0137] Context-aware feature enhancement module F ctx Combining dilated convolution with edge feature Edge(F) improves localization accuracy by 30% and reduces false detection rate by 10% in scenarios with blurred helmet edges; through κ and D aug Positive correlation dynamic adjustment avoids false enhancement in non-edge areas and reduces false detections.
[0138] Dual-path feature encoding weight Γ dual via FC1(GAP(F) h ))+FC2(GAP(F w )) Merge vertical and horizontal global contexts, combining ζ with cos(F) h ,F w Spatial consistency modulation improves the accuracy of safety helmet edge symmetry detection by 20% and reduces the false detection rate in improper wearing scenarios by 12%.
[0139] Dynamic D constructed from the dataset of S1 aug From sample labeling to variable convolution, attention mechanism, and lightweight model optimization in S3, and then to dual-path encoding and spatial attention training in S4, a complete technical loop of data preprocessing, feature extraction, model optimization, and deployment is formed to ensure feature consistency from Backbone to Neck.
[0140] Variable convolution weights W dyn With G spatial Cascaded modulation, I attn China Ppos With M mask synergy, F ctx The design, including dilated convolution and dual enhancement of edge features, achieves multi-dimensional optimization of spatial consistency from local details to global context, ultimately improving the overall performance of the system.
[0141] To demonstrate the effectiveness of the method of this invention, a comparative experiment was conducted between the improved model of this technical solution and the original YOLOv8 model. The data results are as follows: Figure 3 As shown.
Claims
1. An automatic helmet-wearing detection method based on lightweight networks, characterized in that: Includes the following steps: S1: Establish and expand the dataset of safety helmet wearing standards; S2: Establish a target detection model based on YOLOv8; S3: Optimize the model; S4: Train the improved model using the expanded helmet wearing guidelines dataset.
2. The automatic helmet wearing detection method based on lightweight networks according to claim 1, characterized in that: Step S1 also includes the following: S1-1: Acquire images of helmet wearing and perform augmentation and preprocessing using image algorithms; S1-2: Annotate the image of the helmet being worn to obtain the area to be cut and the cutting points within the area.
3. The automatic helmet wearing detection method based on lightweight networks according to claim 2, characterized in that: Step S3 also Includes the following: S3-1: Introduce variable convolutions in the backbone of the YOLOv8 model to replace some standard convolutional layers; S3-2: Introduce multi-scale progressive channel attention into the feature pyramid network to enhance the output features of variable convolution; S3-3: Add the MPCA module to a specific location on the backbone, as well as the neck section; S3-4: Introduce a multi-head self-attention mechanism into the neck network to enhance the cross-scale feature fusion capability; S3-5: Enhanced inspection of small safety helmets and buckles; S3-6: Lightweight network deployment; S3-7: Optimize the loss function and training strategy.
4. The automatic helmet wearing detection method based on lightweight networks according to claim 2, characterized in that: Step S4 also includes the following: S4-1: Input feature map; S4-2: Global pooling of the feature map along its height direction; S4-3: Global pooling of the feature map along its width; S4-4: Dual-path feature encoding; S4-5: Spatial attention weight generation; S4-6: Feature recalibration.
5. The automatic helmet wearing detection method based on lightweight networks according to claim 3, characterized in that: Step S3-2 also includes the following: S3-2-1: The input feature map is processed through multiple pooling layers of different scales to obtain multi-scale features; S3-2-2: These multi-scale features are fused, and then dimensionality reduction and feature integration are performed through a convolutional layer; S3-2-3: The fused features are fed into the coordinate attention mechanism to calculate the attention weights for height and width respectively; S3-2-4: Multiply the obtained attention weights by the input feature map.
6. The automatic helmet wearing detection method based on lightweight networks according to claim 3, characterized in that: Step S3-4 also includes the following: S3-4-1: Add location coding to preserve spatial information; S3-4-2: Use multiple attention heads to capture different types of dependencies; S3-4-3: Enhance feature representation through Transformer encoder.
7. The automatic helmet wearing detection method based on lightweight networks according to claim 3, characterized in that: Step S3-5 also includes the following: S3-5-1: Add a P2 detection layer to the feature pyramid; S3-5-2: Upsample the detected deep features and fuse them with the shallow features; S3-5-3: Enhance the ability to identify small targets by utilizing the context module.
8. The automatic helmet wearing detection method based on lightweight networks according to claim 3, characterized in that: Steps S3-6 also include the following: S3-6-1: Reduce model complexity through parameter sharing; S3-6-2: Use depthwise separable convolution in some modules to reduce computational load; S3-6-3: Prune and quantize the trained model to 8 bits.
9. A computer system, characterized in that, include: processor; Memory used to store processor-executable instructions; The processor is configured to implement the automatic helmet wearing detection method based on lightweight networks as described in any one of claims 1 to 8 when executing the executable instructions.