Worker safety helmet real-time detection method, system, device and storage medium

CN116580357BActive Publication Date: 2026-08-07SHANDONG COMP SCI CENTNAT SUPERCOMP CENT IN JINAN +2
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHANDONG COMP SCI CENTNAT SUPERCOMP CENT IN JINAN
Filing Date
2023-05-11
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

然而,射频识别检测器的识别区域是有限的

Benefits of technology

[0023] 1. This invention uses YOLOv5 as the basic framework and adds a spatial-to-depth convolutional module (SPD-Conv) to improve the detection accuracy of low-resolution and small targets;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116580357B_ABST
    Figure CN116580357B_ABST
Patent Text Reader

Abstract

The application discloses a worker safety helmet real-time detection method, system, device and storage medium, the method comprises the steps of: acquiring an image to be processed; inputting the image to be processed into a trained helmet detection network, and outputting a helmet wearing detection result; wherein the helmet detection network comprises a backbone network, a neck network and a decoupling head connected in sequence; the backbone network is used for feature extraction on the input image; the neck network is used for feature enhancement processing on the extracted features; and the decoupling head classifies the enhanced features to obtain the detection result of whether the worker wears a helmet. The detection ability of the model for small targets is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision target detection technology, and in particular to a method, system, equipment and storage medium for real-time detection of worker safety helmets. Background Technology

[0002] The statements in this section merely refer to the background art related to this invention and do not necessarily constitute prior art.

[0003] A safety helmet is a type of protective equipment primarily designed to protect the head, effectively preventing injuries to construction workers in the event of an accident. Every year, deaths from construction site accidents account for a significant portion of non-natural deaths, indicating that the safety situation on construction sites remains extremely serious. Correctly wearing a safety helmet is directly related to reducing the number of injuries and fatalities on construction sites. However, due to weak safety awareness among construction workers, the importance of wearing safety helmets is often overlooked. Complex construction environments and unsafe behaviors by workers can easily lead to accidents, threatening the lives of construction workers. To monitor and correct unsafe behaviors and ensure the safety of construction workers, it is necessary to conduct real-time checks on whether construction workers are wearing safety helmets.

[0004] In 2013, Kelm et al. designed a mobile radio frequency identification (RFID) portal to check the compliance of construction workers wearing safety protective equipment. However, the recognition area of ​​the RFID detector is limited. Simply bringing the helmet close to the worker is insufficient to confirm whether the helmet is worn correctly. In 2019, Wang Rongxin et al. used YOLOv3 to detect heads without safety helmets in a given image, but some other detections were missed, such as some dense targets and small targets. In 2022, Wang Lijun et al., based on the YOLOv5 model, used a deformable convolutional network instead of traditional convolution in the backbone network; at the neck, a convolutional block attention module was introduced, and the original network's GIoU was replaced with DIoU. However, the model only targets safety helmet detection and does not consider the impact of wearing other headwear on detection.

[0005] Traditional safety helmet detection models suffer from low accuracy and are highly susceptible to environmental influences. In complex construction environments, safety helmets act as both small and densely packed targets, easily obscured and interfered with by other headwear. In practical applications, the original YOLOv5 model still has shortcomings in detecting these types of targets, posing a significant challenge. Previous studies primarily used privately collected datasets, lacking diversity, thus limiting the scope for comprehensive model performance analysis. However, the model's performance was not evaluated when interference from other headwear worn by construction workers was present. Summary of the Invention

[0006] To address the shortcomings of existing technologies, this invention provides a method, system, equipment, and storage medium for real-time detection of worker safety helmets; it also improves the model's ability to detect small targets.

[0007] In a first aspect, the present invention provides a method for real-time detection of worker safety helmets;

[0008] Real-time detection methods for worker safety helmets include:

[0009] Obtain the image to be processed;

[0010] The image to be processed is input into the trained helmet detection network, and the helmet wearing detection result is output.

[0011] The helmet detection network includes: a backbone network, a neck network, and a decoupling head connected in sequence; the backbone network is used to extract features from the input image; the neck network is used to perform feature enhancement processing on the extracted features; and the decoupling head classifies the enhanced features to obtain the detection result of whether the worker is wearing a helmet.

[0012] Secondly, the present invention provides a real-time detection system for worker safety helmets;

[0013] A real-time detection system for worker safety helmets includes:

[0014] The acquisition module is configured to acquire the image to be processed.

[0015] The processing module is configured to: input the image to be processed into the trained helmet detection network and output the helmet wearing detection result; wherein, the helmet detection network includes: a backbone network, a neck network and a decoupling head connected in sequence; the backbone network is used to extract features from the input image; the neck network is used to perform feature enhancement processing on the extracted features; and the decoupling head classifies the enhanced features to obtain the detection result of whether the worker is wearing a helmet.

[0016] Thirdly, the present invention also provides an electronic device, comprising:

[0017] Memory, used for non-transitory storage of computer-readable instructions; and

[0018] Processor, for executing the computer-readable instructions,

[0019] When the computer-readable instructions are executed by the processor, they perform the method described in the first aspect above.

[0020] Fourthly, the present invention also provides a storage medium for non-transitory storage of computer-readable instructions, wherein, when the non-transitory computer-readable instructions are executed by a computer, the instructions for executing the method described in the first aspect are executed.

[0021] Fifthly, the present invention also provides a computer program product, including a computer program that, when run on one or more processors, is used to implement the method described in the first aspect above.

[0022] Compared with the prior art, the beneficial effects of the present invention are:

[0023] 1. This invention uses YOLOv5 as the basic framework and adds a spatial-to-depth convolutional module (SPD-Conv) to improve the detection accuracy of low-resolution and small targets;

[0024] 2. Secondly, a global attention mechanism is added to the backbone network to reduce information loss, enhance the backbone network's ability to capture global information, and improve model performance;

[0025] 3. Finally, the YOLOv5 non-decoupled head is replaced with a decoupled head to separate the classification task from the regression task, so as to achieve better classification and regression of the predicted boxes and accelerate model convergence.

[0026] 4. Compared with existing target detection models, the model trained in this invention can effectively eliminate the influence of other interference conditions (such as wearing other headwear) on the detection of safety helmets, thus improving the model's robustness. In terms of performance, it enhances the model's ability to detect dense targets and small targets. Attached Figure Description

[0027] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.

[0028] Figure 1 This refers to the PAN+FPN structure of Example 1;

[0029] Figures 2(a)-2(d) This is the improved YOLOv5 network structure of Example 1;

[0030] Figure 3 This refers to the SPD-Conv module in Example 1;

[0031] Figure 4 This refers to the GAM module in Example 1;

[0032] Figure 5 This is the decoupled head structure of Example 1;

[0033] Figures 6(a)-6(c) Analysis of the dense target detection effect in Example 1;

[0034] Figures 6(d)-6(f) Analysis of the small target detection effect in Example 1;

[0035] Figures 6(g)-6(i) Analysis of interference detection effect of handheld safety helmet in Example 1;

[0036] Figure 7 The PR curve is obtained from the training in Example 1. Detailed Implementation

[0037] It should be noted that the following detailed descriptions are exemplary and intended to provide further illustration of the invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.

[0038] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments of the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. Furthermore, it should be understood that the terms “comprising” and “having”, and any variations thereof, are intended to cover non-exclusive inclusion, for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0039] Example 1

[0040] This embodiment provides a method for real-time detection of worker safety helmets;

[0041] Real-time detection methods for worker safety helmets include:

[0042] S101: Obtain the image to be processed;

[0043] S102: Input the image to be processed into the trained helmet detection network and output the helmet wearing detection result;

[0044] The helmet detection network includes: a backbone network, a neck network, and a decoupling head connected in sequence; the backbone network is used to extract features from the input image; the neck network is used to perform feature enhancement processing on the extracted features; and the decoupling head classifies the enhanced features to obtain the detection result of whether the worker is wearing a helmet.

[0045] Furthermore, the backbone network is the YOLOv5s Backbone network with the addition of the SPD-Conv module and the Global Attention Mechanism (GAM) module.

[0046] Further, as shown in Figure 2(a), the backbone network specifically includes:

[0047] The layers connected in sequence are: Focus layer, CBL1 layer, SPD-Conv1 layer, CSP1 layer, CBL2 layer, SPD-Conv2 layer, CSP2 layer, CBL3 layer, SPD-Conv3 layer, CSP3 layer, CBL4 layer, SPD-Conv4 layer, GAM layer, and SPPF layer.

[0048] Furthermore, the working principle of the backbone network includes: first, rescaling the input image to a uniform size, then passing it through the Focus layer, compressing and combining the information in the input feature map to extract a higher-level feature representation;

[0049] Then, local spatial information is extracted through convolution operations in the CBL1 layer, and the feature value distribution is normalized through the BN layer in the CBL1 layer. Finally, nonlinear transformation capability is introduced through the activation function in the CBL1 layer, thereby realizing the transformation and extraction of input features.

[0050] The feature map from the CBL1 layer is fed into the SPD-Conv1 layer to retain all discriminative feature information; the CSP1 layer passes the feature map from the SPD-Conv1 layer through the CSP1 layer's Bottleneck, increasing the network's depth and receptive field, and improving the feature extraction capability.

[0051] By using the GAM layer, the network focuses on global information about the object, thereby improving the performance of feature extraction.

[0052] Finally, through the SPPF layer, a convolution kernel is specified, and the output of each pooling is used as the input of the next pooling. This not only speeds up feature extraction but also enhances the feature map's feature representation capability.

[0053] It should be understood that the backbone network extracts features from the input image, transforming the original input image into multi-layer feature maps for subsequent object detection tasks. This minimizes computation and memory usage while maintaining high detection accuracy. The CBL1 layer, consistent with CBL2, CBL3, and CBL4 layers, primarily consists of convolutional layers, batch normalization (BN) layers, and activation functions. The SPD-Conv1 layer, consistent with SPD-Conv2, SPD-Conv3, and SPD-Conv4 layers, retains as much discriminative feature information as possible. The CSP1 layer, consistent with CSP2 and CSP3 layers, integrates feature maps of different scales obtained from the backbone network with the neck network, improving the model's multi-scale detection capabilities.

[0054] Furthermore, the working principle of the GAM layer includes:

[0055] In channel attention, for the input feature map, the first step is to perform a dimensionality transformation. The feature map after dimensionality transformation is input into the MLP, then converted back to its original dimension, and processed by the Sigmoid function for output.

[0056] In spatial attention, the number of channels is reduced by using a 7×7 convolution to decrease the computational load, and then another 7×7 convolution operation is used to increase the number of channels while maintaining consistency in the number of channels; finally, the output is processed by the Sigmoid function.

[0057] Furthermore, the GAM layer combines channel attention with spatial attention, preserving information to amplify the "global" cross-dimensional interaction, thereby improving the performance of deep neural networks by reducing information loss and enhancing the interaction of global features.

[0058] Furthermore, the working principle of the SPD-Conv1 layer includes:

[0059] The feature maps from the previous layer are downsampled according to a set scaling factor and merged along the channel dimension to avoid losing learnable feature information. Then, the channel dimension is reduced by convolution with a stride of 1 to reduce the amount of computation and retain all discriminative feature information.

[0060] It should be understood that pooling operations and strided convolutions can lead to the loss of fine-grained information and less efficient learning of feature representations, especially when dealing with more challenging tasks such as low-resolution images and small objects.

[0061] Furthermore, the internal structures of the SPD-Conv1 layer, SPD-Conv2 layer, SPD-Conv3 layer and SPD-Conv4 layer are consistent. The SPD-Conv1 layer includes: a Space-to-Depth layer and a non-staggered convolutional layer connected in sequence.

[0062] Further, as shown in Figure 2(b), the Focus layer includes:

[0063] The input terminal of the Focus layer is connected to the input terminals of four slice layers respectively. The output terminals of the four slice layers are connected to the input terminal of multiplier X1. The output terminal of multiplier X1 is connected to the input terminal of convolutional layer J1. The output terminal of convolutional layer J1 is connected to the input terminal of batch normalization layer BN1. The output terminal of batch normalization layer BN1 is connected to the input terminal of activation function layer SiLU1. The output terminal of activation function layer SiLU is connected to the output terminal of Focus layer.

[0064] Furthermore, the GAM layer combines channel attention mechanism with spatial attention to achieve attention to the detection target and the location of the detection target.

[0065] Further, as shown in Figure 2(c), the SPPF layer includes:

[0066] The convolutional layer J2, batch normalized layer BN2, activation function layer SiLU2, max pooling layer Z1, multiplier X2, convolutional layer J3, batch normalized layer BN3, and activation function layer SiLU3 are connected in sequence.

[0067] The output of max pooling layer Z1 is connected to the input of max pooling layer Z2, the output of max pooling layer Z2 is connected to the input of max pooling layer Z3, the output of max pooling layer Z2 is connected to the input of multiplier X2, and the output of max pooling layer Z3 is connected to the input of multiplier X2.

[0068] The output of the activation function layer SiLU2 is connected to the input of the multiplier X2.

[0069] Furthermore, such as Figure 1 As shown, the neck network adopts a dual-tower structure of a top-down Feature Pyramid (PAN) and a bottom-up Feature Pyramid (FPN).

[0070] Further, as shown in Figure 2(a), the neck network includes:

[0071] The *CSP1 layer, CBL5 layer, first upsampling layer, *CSP2 layer, CBL6 layer, second upsampling layer, *CSP3 layer, CBL7 layer, *CSP4 layer, CBL8 layer and *CSP5 layer are connected in sequence.

[0072] Furthermore, the working principle of the neck network includes: performing multi-scale feature fusion on the feature map and passing the fused features to the prediction layer.

[0073] Since the size and position of objects in an image are uncertain, a mechanism is needed to handle targets of different scales and sizes. This is achieved by fusing feature maps from different levels through upsampling and downsampling operations, generating a multi-scale feature pyramid.

[0074] The top-down approach achieves feature fusion at different levels by upsampling and fusing with coarser-grained feature maps, while the bottom-up approach fuses feature maps from different levels by using a convolutional layer.

[0075] The backbone network uses an FPN structure to obtain feature maps at different scales, while the neck network uses a PAN to combine feature maps from different levels to generate feature maps with multi-scale information, thereby improving the accuracy of object detection.

[0076] Furthermore, the decoupling head is implemented using a decoupled head.

[0077] Furthermore, the output of the SPD-Conv2 layer is connected to the input of the *CSP3 layer;

[0078] The output of the SPD-Conv3 layer is connected to the input of the *CSP2 layer;

[0079] The output of the SPPF layer is connected to the input of the *CSP1 layer;

[0080] The output of CBL5 layer is connected to the input of *CSP5 layer;

[0081] The output of CBL6 layer is connected to the input of *CSP4 layer;

[0082] The output of CSP3 layer is connected to the input of the decoupled head;

[0083] The output of CSP4 layer is connected to the input of the decoupled head.

[0084] Furthermore, as shown in Figure 2(c), the internal structures of CSP1, CSP2 and CSP3 are identical.

[0085] The CSP1 layer includes: a CBL9 layer, a Bottleneck layer, a convolutional layer J4, a multiplier X3, a batch normalization layer BN4, an activation function layer ReLU, and a CBL10 layer connected in sequence; the input of the CBL9 layer is connected to the input of the multiplier X3 through the convolutional layer J5.

[0086] Further, as shown in Figure 2(d), the Bottleneck layer includes: CBL11 layer and CBL12 layer connected in sequence.

[0087] The internal structures of CBL1, CBL2, CBL3, CBL4, CBL5, CBL6, CBL7, CBL8, CBL9, CBL10, CBL11, and CBL12 are consistent.

[0088] The CBL1 layer includes: a convolutional layer J5, a batch normalization layer BN5, and an activation function layer ReLU connected in sequence.

[0089] Furthermore, the internal structures of *CSP1, *CSP2, *CSP3, and *CSP4 are the same. The internal structure of *CSP1 is consistent with that of CSP1, except that CSP1 adds shortcuts connections in the Bottleneck module, while *CSP1 does not add shortcuts connections in the Bottleneck module.

[0090] Furthermore, such as Figure 5 As shown, the decoupled head has the following structure:

[0091] Convolutional layer J6, the input of which is the input of the decoupled head;

[0092] The output of the convolutional layer J6 is connected to the classification branch and the regression branch, respectively.

[0093] The classification branch includes convolutional layers J7, J8, and J9 connected in sequence;

[0094] The regression branch includes convolutional layers J10, J11, and J12 connected in sequence;

[0095] The output of convolutional layer J11 is also connected to the input of convolutional layer J13;

[0096] Convolutional layer J9 is used to output the classification result of whether a helmet is being worn;

[0097] Convolutional layers J12 and J13 output the bounding box of the helmet.

[0098] Furthermore, the decoupled head operates on the following principles:

[0099] In a decoupled head, classification and regression tasks are predicted separately, without sharing parameters from the previous layer, which speeds up model convergence and improves detection accuracy.

[0100] In a non-decoupled Coupled Head, the heads for classification and regression tasks share the parameters of the previous layer, so the two tasks are actually in conflict.

[0101] Furthermore, the training process of the trained helmet detection network includes:

[0102] Construct a training set and a test set, wherein the training set and the test set include images with known helmet-wearing classification labels;

[0103] Perform data augmentation on the training and test sets;

[0104] The training set is input into the helmet detection network and trained. When the loss function value of the network no longer decreases, training is stopped to obtain the initial helmet detection network.

[0105] The test set is input into the preliminary helmet detection network for testing. When all test metrics meet the set requirements, the testing is stopped, and the preliminary helmet detection network becomes the final helmet detection network. When all test metrics fail to meet the set requirements, the training set is changed, and training continues.

[0106] The test metrics include: precision (P), recall (R), and frames per second (FPS).

[0107] It should be understood that data augmentation processing is performed on the training and test sets, and existing public datasets are also augmented to enhance the diversity of data in the datasets.

[0108] The YOLOv5 algorithm has four network structures: YOLOv5s, YOLOv5m, YOLOv5l, and YOLOv5x. These four network structures differ in width and depth, but are fundamentally the same. The fastest and smallest model is YOLOv5s, with 7.0M parameters and 13.7M weight. This invention focuses on improving upon YOLOv5s, primarily because it has fewer parameters and faster speed, facilitating industrial deployment and real-time camera detection. The YOLOv5s network structure mainly consists of four parts: Input, Backbone, Neck, and Prediction.

[0109] In terms of data preprocessing, YOLOv5 adopts the online mosaic image enhancement method proposed by YOLOv4, with the aim of increasing the number of small targets in a single batch and improving the network's ability to recognize small targets.

[0110] The backbone network architecture employs Focus, SPPF, and CSPNet structures. Focus is a slicing operation; taking YOLOv5 as an example, the original 640×640×3 image input to the Focus structure is sliced ​​into a 320×320×12 feature map, quadrupling the number of channels. After a convolution operation, it finally becomes a 320×320×32 feature map. SPPF, based on SPP, is faster than SPP. It specifies a convolution kernel, and the output of each pooling operation becomes the input of the next pooling operation. YOLOv5 uses the CSPNet residual structure in both the backbone and neckline models, dividing the feature maps of the base layers into two parts and then combining them into a cross-stage hierarchical structure, reducing computational workload while ensuring the integrity of feature information.

[0111] The Neck structure employs a top-down PAN and a bottom-up FPN dual-tower structure, such as... Figure 1 As shown, shallow feature maps contain more location information and less semantic information. However, as the number of neural network layers increases, deeper feature maps contain more semantic information, but some location information is lost. FPN (Fixed-Phase Network) is top-down, upsampling strong semantic features from the top feature map to the bottom feature map. Simultaneously, PAN (Positioning-Based Network) downsampling transmits shallow localization information to deeper layers, enhancing localization capabilities at multiple scales. These two structures together enhance the feature fusion capability of the neck network model.

[0112] During target detection, the varying distances of the shooting scene and the complex construction environment generate a large number of small and low-resolution targets, occluded targets, dense targets, and interfering targets. However, in practical applications, the original YOLOv5 model still has certain shortcomings in detecting these types of targets. This invention improves the YOLOv5 model. The improved network structure is shown in Figure 2(a). First, because convolutional neural networks (CNNs) use strided convolution or pooling operations, some feature loss occurs, especially when extracting image features for low-resolution and small target objects. To address the issues of how to preserve the feature information of the target to be detected as much as possible and how to improve the ability of the YOLOv5 backbone network to capture global information, this invention embeds the SPD-Conv module and the GAM module into the YOLOv5 backbone network. Then, since the classification and localization tasks in target detection are of different interests... To alleviate the spatial misalignment problem caused by the inconsistency between the content of classification and localization in the YOLOv5 head, this invention replaces the non-coupled head of YOLOv5 with a decoupled head.

[0113] To improve the robustness of the detection model in complex environments, this invention adds four SPD-Conv modules after the CBL module in the YOLOv5s Backbone network, as follows: Figure 3 As shown.

[0114] SPD-Conv consists of space-to-depth layers and non-staggered convolutional layers. The extracted S×S×C1 intermediate feature map is first segmented according to a certain scale:

[0115] f 0,0 =X[0:S:scale,0:S:scale],f 1,0 =X[1:S:scale,0:S:scale],…,f scale-1,0

[0116] =X[sacale-1:S:scale,0:S:scale];

[0117] f 0,1 =X[0:S:scale,1:S:scale],f 1,1 =X[1:S:scale,1:S:scale],…,f scale-1,1

[0118] =X[scale-1:S:scale,1:S:scale];

[0119]

[0120] f 0,scale-1 =X[0:S:scale,0:S:scale-1],f 1,scale-1

[0121] =X[1:S:scale,scale-1:S:scale],…,

[0122] f scale-1,scale-1 =X[scale-1:S:scale,scale-1:S:scale]

[0123] Given any feature map X, the submap f x,y The feature map X(i,j) is composed of all feature maps, where i+x and j+y are divisible by a scaling factor. Therefore, each submap is downsampled by a scaling factor X. When scale = 2, it will be divided into f submaps. 0,0 ,f 1,0 ,f 0,1 ,f 1,1 There are 4 subgraphs, each with a size of 1. Then, connections are made along the channel dimension, and the feature map size becomes... Finally, through a non-stepping convolutional layer, a result of size [size missing] is obtained. Feature map, where C2<2 2 C1.

[0124] Unlike traditional strided convolution and pooling operations, the SPD-Conv module preserves all feature information of X, only changing the channel dimension. By utilizing the SPD-Conv module, it demonstrates better detection capabilities for low-resolution and small targets, making the model more adaptable to complex detection environments.

[0125] Designing a backbone network with powerful feature extraction capabilities while avoiding high computational costs and information loss is crucial. With the continuous development of deep learning, attention mechanisms have become an indispensable technology in the field of computer vision. This invention adds a GAM module before the SPPF module in the YOLOv5s backbone network to reduce feature information loss and enhance the network's ability to capture global information.

[0126] GAM combines channel attention and spatial attention mechanisms. Channel attention considers the target of attention, while spatial attention considers the location of attention.

[0127] The entire GAM module structure is as follows: Figure 4 As shown. The input feature map F1 is first processed by a channel attention mechanism to obtain F2, where Mc(F1) represents F1 after processing by the channel attention module; the resulting F2 is then element-wise multiplied with F1. The element-wise multiplication is used as the input to the spatial attention module, and Ms(F2) represents the result after processing by the spatial attention module. Finally, F2 and Ms(F2) are multiplied element-wise to obtain the final output F3.

[0128] In the channel attention module, the extracted feature maps are first arranged in three dimensions to preserve three-dimensional information, and then a two-layer multilayer perceptron (MLP) is used to amplify spatial correlation. In the spatial attention module, two 7×7 convolutions are used to fuse spatial information, while max pooling is removed to fully preserve feature information.

[0129] The classification and localization tasks are of different interests. In traditional non-decoupled detection heads, classification and regression tasks share parameters from the previous layer, leading to a conflict between the classification and localization tasks in the YOLOv5 head. In a decoupled head, classification and localization tasks no longer share parameters from the previous layer, such as... Figure 5As shown, to avoid increasing computational complexity, a 1×1 convolutional layer is first used to reduce the number of channels to 256; then two parallel branches are used, each containing two 3×3 convolutional layers for localization and classification respectively; and an IoU branch is added to the regression branch. The shapes of the outputs of the three branches Cls, Reg and IoU are [H,W,C], [H,W,4] and [H,W,1] respectively.

[0130] This invention transforms the YOLOv5s head into a decoupled head, allowing classification and localization tasks to be performed on two separate branches. This alleviates the conflict between the two tasks, accelerates model training convergence, and improves the performance of the detection model.

[0131] This invention expands the SHWD dataset, increasing the number of images from 7581 to 12000. The invention addresses the lack of dense safety helmet targets, small targets, and interfering targets wearing other headwear in the original dataset. This is achieved through dataset merging, online crawling, and manual downloading, followed by labeling using the Labelimg annotation tool. The dataset is divided into a training set and a test set at an 8:2 ratio. The expanded data is better adapted to complex safety helmet detection environments, resulting in a more robust model.

[0132] There are several metrics for measuring the performance of object detection models, such as precision (P), recall (R), and frames per second (FPS). Mean Average Precision (mAP) is the most commonly used evaluation method. Precision P is the probability that a predicted positive sample is actually a positive sample, and recall R is the probability that a sample actually being a positive sample is predicted to be a positive sample.

[0133] The method for calculating P:

[0134]

[0135] How to calculate R:

[0136]

[0137] TP stands for True Positive, meaning the sample is correctly identified as positive by the classifier; FP stands for False Positive, meaning the sample is correctly identified as positive by the classifier but is actually negative; FN stands for False Negative, meaning the sample is correctly identified as negative by the classifier but is actually positive. Mean average precision (mAP) refers to the average precision (AP) across all classes.

[0138] AP calculation method:

[0139]

[0140] How mAP is calculated:

[0141]

[0142] Where C represents the number of categories.

[0143] The model of this invention was evaluated using mAP@0.5, mAP@0.5:0.95, recall (R), and detection speed, depending on the IoU threshold. Detection speed here includes image preprocessing time, model inference speed, and post-processing time.

[0144] The operating system used in the experiments of this invention was CentOS Linux 8, and the GPU model was NVIDIA A100-SXM4-40GB. The PyTorch 1.11 deep learning framework and CUDA 11.3 were used in combination, with Python 3.8 as the programming language for the algorithms.

[0145] This invention does not use any pre-trained model. The model parameter batchsize is set to 64, and 64 training samples are taken from the training set for each training iteration. The image pixel size of both the training and test sets is set to 640×640. The SGD optimizer is used, with a momentum of 0.937, a weight decay coefficient of 0.0005, and both the initial and final learning rates set to 0.01. After 200 rounds of training, the final ideal weight file is generated.

[0146] This invention proposes an improved YOLOv5-based safety helmet detection model, which exhibits stronger robustness and is better adapted to complex construction environments. By combining the SPD convolutional module, GAM module, and decoupled head, the model's feature extraction capability is enhanced. While maintaining a lightweight design and meeting real-time performance requirements, the detection accuracy surpasses that of most currently popular lightweight models. The model's ability to detect small and densely packed targets is also improved.

[0147] This invention compares four lightweight object detection models: YOLOv3-tiny, PPYOLOE, YOLOv7-tiny, and YOLOv4-tiny. As shown in Table 1, the improved model outperforms all other models. The mAP@0.5 improved from 95.19% to 95.73% compared to the original YOLOv5s model. The mAP@0.5:0:95 ratio reached 61.28%, exceeding the original model by 1.43%. The recall rate improved from 92.05% to 92.90%.

[0148] Table 1 shows the experimental results of the improved YOLOv5s on the expanded SHWD.

[0149]

[0150]

[0151] Figures 6(a)-6(c) , Figures 6(d)-6(f) The images show the detection results for dense targets and small targets, respectively. It is clear that... Figures 6(a)-6(c) The original model for dense target detection suffers from incomplete detection, and the person in the upper right corner of the image who is not wearing a safety helmet is not detected. The model of this invention can successfully detect the person who is not wearing a safety helmet, and the phenomenon of missed detection is also improved. Figures 6(g)-6(i) The original model makes incorrect judgments for people holding safety helmets, and it also makes incorrect judgments for people wearing other headwear. However, the improved model of this invention is more robust and can correctly detect the problem of wearing a safety helmet.

[0152] like Figure 7 As shown, the obtained PR curves show that mAP@0.5 can reach 96.70% for the single-class "helmet" detection and 94.80% for the "person" detection.

[0153] Example 2

[0154] This embodiment provides a real-time detection system for worker safety helmets;

[0155] A real-time detection system for worker safety helmets includes:

[0156] The acquisition module is configured to acquire the image to be processed.

[0157] The processing module is configured to: input the image to be processed into the trained helmet detection network and output the helmet wearing detection result; wherein, the helmet detection network includes: a backbone network, a neck network and a decoupling head connected in sequence; the backbone network is used to extract features from the input image; the neck network is used to perform feature enhancement processing on the extracted features; and the decoupling head classifies the enhanced features to obtain the detection result of whether the worker is wearing a helmet.

[0158] It should be noted that the acquisition module and processing module described above correspond to steps S101 to S102 in Embodiment 1. The examples and application scenarios implemented by the modules and corresponding steps are the same, but are not limited to the content disclosed in Embodiment 1. It should also be noted that the modules described above, as part of the system, can be executed in a computer system such as a set of computer-executable instructions.

[0159] The descriptions of each embodiment in the above embodiments have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.

[0160] The proposed system can be implemented in other ways. For example, the system embodiments described above are merely illustrative, and the division of modules described above is only a logical functional division. In actual implementation, there may be other division methods. For example, multiple modules may be combined or integrated into another system, or some features may be ignored or not executed.

[0161] Example 3

[0162] This embodiment also provides an electronic device, including: one or more processors, one or more memories, and one or more computer programs; wherein, the processor is connected to the memory, and the one or more computer programs are stored in the memory. When the electronic device is running, the processor executes the one or more computer programs stored in the memory to cause the electronic device to perform the method described in Embodiment 1.

[0163] It should be understood that in this embodiment, the processor can be a central processing unit (CPU), or it can be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc.

[0164] Memory may include read-only memory and random access memory, and provides instructions and data to the processor. A portion of memory may also include non-volatile random access memory. For example, memory may also store information about the device type.

[0165] In the implementation process, each step of the above method can be completed by the integrated logic circuits in the processor hardware or by software instructions.

[0166] The method in Embodiment 1 can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor. The software modules can reside in readily available storage media in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory; the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method. To avoid repetition, a detailed description is not provided here.

[0167] Those skilled in the art will recognize that the units and algorithm steps described in connection with the various examples of this embodiment can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this invention.

[0168] Example 4

[0169] This embodiment also provides a computer-readable storage medium for storing computer instructions, which, when executed by a processor, complete the method described in Embodiment 1.

[0170] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A real-time detection method for worker safety helmets, characterized by: include: Obtain the image to be processed; The image to be processed is input into the trained helmet detection network, which outputs the helmet wearing detection result. The helmet detection network includes a backbone network, a neck network, and a decoupling head connected in sequence. The backbone network is used to extract features from the input image. The neck network is used to perform feature enhancement processing on the extracted features. The decoupling head classifies the enhanced features to obtain the detection result of whether the worker is wearing a helmet. The backbone network specifically includes: the Focus layer, CBL1 layer, SPD-Conv1 layer, CSP1 layer, CBL2 layer, SPD-Conv2 layer, CSP2 layer, CBL3 layer, SPD-Conv3 layer, CSP3 layer, CBL4 layer, SPD-Conv4 layer, GAM layer and SPPF layer connected in sequence. The backbone network operates as follows: First, the input image is rescaled to a uniform size. Then, through a Focus layer, the information in the input feature map is compressed and combined to extract a higher-level feature representation. Next, convolutional operations in the CBL1 layer extract local spatial information, and a BN layer normalizes the feature value distribution. Finally, an activation function in the CBL1 layer introduces non-linear transformation capabilities, thereby achieving feature transformation and extraction. The feature map from the CBL1 layer is fed into the SPD-Conv1 layer to retain all discriminative feature information. The CSP1 layer passes the feature map from the SPD-Conv1 layer through the Bottleneck, increasing the network's depth and receptive field, thus improving feature extraction capabilities. The GAM layer focuses the network on global object information, further enhancing feature extraction. Finally, the SPPF layer specifies a convolutional kernel, using the output of each pooling step as the input for the next pooling step, accelerating feature extraction and enhancing the feature map's expressive power. The neck network employs a dual-pyramid structure of a top-down Feature Pyramid (PAN) and a bottom-up Feature Pyramid (FPN), comprising: a *CSP1 layer, a CBL5 layer, a first upsampling layer, a *CSP2 layer, a CBL6 layer, a second upsampling layer, a *CSP3 layer, a CBL7 layer, a *CSP4 layer, a CBL8 layer, and a *CSP5 layer connected sequentially; the working principle of the neck network includes: performing multi-scale feature fusion on the feature maps and passing the fused features to the prediction layer; The decoupling head is implemented using a decoupled head. The output of the SPD-Conv2 layer is connected to the input of the *CSP3 layer; the output of the SPD-Conv3 layer is connected to the input of the *CSP2 layer; the output of the SPPF layer is connected to the input of the *CSP1 layer; the output of the CBL5 layer is connected to the input of the *CSP5 layer; the output of the CBL6 layer is connected to the input of the *CSP4 layer; the output of the *CSP3 layer is connected to the input of the decoupled head; the output of the *CSP4 layer is connected to the input of the decoupled head. The working principle of the GAM layer includes: In channel attention, for the input feature map, a dimensionality transformation is first performed. The feature map after dimensionality transformation is input into the MLP, then converted back to its original dimension, and processed by the Sigmoid function before output. In spatial attention, the number of channels is reduced by a 7×7 convolution to reduce computation, and then a 7×7 convolution operation is performed to increase the number of channels while maintaining a consistent number of channels. Finally, the output is processed by the Sigmoid function. In the YOLOv5s Backbone network, a GAM module is added before the SPPF module to reduce feature loss and enhance the network's ability to capture global information. GAM combines channel attention and spatial attention mechanisms. Channel attention considers the target of interest, while spatial attention considers the location of interest. The input feature map F1 is first processed by the channel attention mechanism to obtain F2, where Mc(F1) represents F1 after processing by the channel attention module. The resulting F2 is then element-wise multiplied with F1. The element-wise multiplication is used as the input to the spatial attention module, and Ms(F2) represents the result after processing by the spatial attention module. Finally, F2 and Ms(F2) are multiplied element-wise to obtain the final output F3. In the channel attention module, the extracted feature maps are first arranged in three dimensions to preserve three-dimensional information, and then a two-layer multilayer perceptron is used to amplify spatial correlation. In the spatial attention module, two 7×7 convolutions are used to fuse spatial information, while max pooling is removed to fully preserve feature information. The working principle of the SPD-Conv1 layer includes: downsampling the feature map output from the previous layer according to a set scaling factor, merging along the channel dimension to avoid losing learnable feature information; then, reducing the channel dimension and computational load by using convolution with a stride of 1, while retaining all discriminative feature information. SPD-Conv consists of Space-to-Depth layers and non-staggered convolutional layers, which extract... The intermediate feature map of the size is first divided into segments according to a certain scale: … Given any feature map sub-mapping A feature map is composed of all feature maps. , and It is divisible by a scaling factor; therefore, each subgraph is downsampled by a scaling factor. When scale=2, it will be divided into , , , There are 4 subgraphs, each with a size of 1. Then, connections are made along the channel dimension, and the feature map size becomes... Finally, through a non-stepping convolutional layer, a result of size [size missing] is obtained. The feature map, where Unlike the original strided convolution and pooling operations, the SPD-Conv module retains... All the feature information is just a change in the channel dimension; The decoupled head structure includes: a convolutional layer J6, the input of which is the input of the decoupled head; the output of the convolutional layer J6 is connected to a classification branch and a regression branch respectively; the classification branch includes convolutional layers J7, J8, and J9 connected in sequence; the regression branch includes convolutional layers J10, J11, and J12 connected in sequence; the output of convolutional layer J11 is also connected to the input of convolutional layer J13; convolutional layer J9 is used to output the classification result of whether a helmet is worn; convolutional layers J12 and J13 output the bounding box of the helmet; the working principle of the decoupled head includes: in the decoupled head, the classification and regression tasks are predicted separately, and the parameters of the previous layer are not shared, which speeds up the model convergence speed and improves the detection accuracy; First, a 1×1 convolutional layer is used to reduce the number of channels to 256; then, two parallel branches are used, each containing two 3×3 convolutional layers for localization and classification respectively; and an IoU branch is added to the regression branch; the shapes of the outputs of the three branches Cls, Reg and IoU are [H,W,C], [H,W,4] and [H,W,1] respectively.

2. A real-time detection system for worker safety helmets, characterized in that: The real-time detection method for worker safety helmets as described in claim 1 includes: The acquisition module is configured to acquire the image to be processed. The processing module is configured to: input the image to be processed into the trained helmet detection network and output the helmet wearing detection result; wherein, the helmet detection network includes: a backbone network, a neck network and a decoupling head connected in sequence; the backbone network is used to extract features from the input image; the neck network is used to perform feature enhancement processing on the extracted features; and the decoupling head classifies the enhanced features to obtain the detection result of whether the worker is wearing a helmet.

3. An electronic device, characterized in that it comprises: Memory is used to store computer-readable instructions in a non-transitory manner. as well as Processor, for executing the computer-readable instructions, When the computer-readable instructions are executed by the processor, they perform the method described in claim 1.

4. A storage medium, characterized in that, The computer-readable instructions are stored non-transitory, wherein when the non-transitory computer-readable instructions are executed by a computer, the instructions of the method of claim 1 are executed.

Citation Information

Patent Citations

  • Seedling rotating frame target detection method and system

    CN114493975A