A safety helmet wearing detection system and method for small targets
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHONGQING UNIV OF POSTS & TELECOMM
- Filing Date
- 2024-08-15
- Publication Date
- 2026-08-07
AI Technical Summary
主要分为两阶段检测方法和一阶段检测方法:两阶段检测的主要方法包括区域卷积神经网络(Regionswith Convolutional Neural Networks,RCNN)、(Spatial Pyramid Pooling Network,SPP-net)、以及与RCNN有关的改进网络如Fast R-CNN、Faster R-CNN、Mask R-CNN等,能够取得较好的检测精度,但其实时性较差,不适用建筑工地安全帽佩戴检测的场景;一阶段检测采用YOLO系列方法和SSD等方法,通过端到端的方法加快了检测速度,但其准确性较低
[0017]本发明提出了一种针对小目标的安全帽佩戴检测系统及方法,专注于提高安全帽佩戴检测中小目标的检测精度。首先,通过引入二维离散小波变换构建了一种新的下采样方式,该方法能够捕获多频域特征信息,有效减少特征损失,进一步提升对尺寸较小目标的检测精度;其次,针对小目标像素信息较少的问题,设计了多感受野分支与注意力机制相结合的ASPP_CBAM多尺度特征融合结构,此结构利用空洞卷积构造不同感受野的特征,从而丰富特征表达,在不增加计算资源的情况下,显著减少采样过程中造成的特征损失,利用CBAM注意力机制完善对重点的通道和重点的区域的关注,从而提高检测精度;使用新的WIoU v3损失函数,以提高模型的检测性能。该方法对小目标的检测效果尤为显著,有效提升了安全帽佩戴检测的精度。
Smart Images

Figure CN118942121B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer vision technology and relates to a helmet-wearing detection system and method for small targets. Background Technology
[0002] The implementation of automatic helmet-wearing detection systems on construction sites is based on multiple considerations. These systems can automatically monitor workers' helmet-wearing status in real time, reducing the pressure and workload of manual monitoring and improving efficiency. The detection results can promptly identify workers not wearing helmets and immediately issue alarms or notify management, reducing safety accidents and economic losses.
[0003] Current research methods for safety helmet wearing detection mainly employ deep learning-based approaches. These are primarily divided into two-stage and one-stage detection methods. Two-stage detection methods include RegionswithConvolutional Neural Networks (RCNN), Spatial Pyramid Pooling Network (SPP-net), and improved RCNN networks such as Fast R-CNN, Faster R-CNN, and Mask R-CNN. These methods achieve good detection accuracy but have poor real-time performance, making them unsuitable for construction site safety helmet wearing detection scenarios. One-stage detection methods employ YOLO series methods and SSD, which accelerate detection speed through end-to-end approaches, but their accuracy is lower.
[0004] The low detection accuracy of the target detection task in the above scenario is mainly due to three aspects: First, the target object, such as a safety helmet, may be obstructed in the specific scenario, resulting in information loss; second, there is less feature information that can be extracted from small-sized targets during feature extraction; and finally, the positioning accuracy requirements for small-sized targets are high, and the error caused by a slight deviation in the prediction box is much greater than that caused by larger-sized targets. Summary of the Invention
[0005] To address the problem of detecting small-sized targets, this invention introduces an attention mechanism and a multi-scale feature fusion scheme to reduce feature loss during feature extraction and fusion, thereby improving target detection accuracy.
[0006] To achieve the above objectives, the present invention provides a helmet-wearing detection system and method for small targets, comprising the following technical solutions:
[0007] In a first aspect, the present invention provides a method for detecting the wearing of safety helmets at small-target construction sites, comprising the following steps:
[0008] S1: Collect on-site images of construction sites and label the data, construct training and test datasets and perform preprocessing;
[0009] S2: Construct a helmet-wearing detection network for small targets based on a preset YOLOX model. The helmet-wearing detection network is used for helmet-wearing detection.
[0010] S3: Input the training set images and test set images into the helmet wearing detection network for training, and use WIoU v3 as the bounding box regression loss function to adjust the parameters of the helmet wearing detection network;
[0011] S4: Input the on-site image of the construction site to be tested into the trained safety helmet detection network, and output the real-time detection result of the on-site image of the construction site to be tested.
[0012] In a second aspect, the present invention also provides a safety helmet wearing detection system for small-target construction sites, used to implement the safety helmet wearing detection method for small-target construction sites as described in the first aspect of the present invention, the system comprising:
[0013] Image input module: used to acquire on-site images of construction sites, perform data annotation, build training and test datasets, and perform preprocessing;
[0014] Feature extraction module: Construct a helmet wearing detection network for small targets based on a preset YOLOX model. The helmet wearing detection network is used for helmet wearing detection. Input training set images and test set images into the helmet wearing detection network for training, and use WIoU v3 as the bounding box regression loss function to adjust the parameters of the helmet wearing detection network.
[0015] The detection and classification module is used to input the on-site image of the construction site to be tested into the trained safety helmet wearing detection network, and output the real-time detection result of the on-site image of the construction site to be tested.
[0016] Beneficial effects of this invention:
[0017] This invention proposes a helmet-wearing detection system and method for small targets, focusing on improving the detection accuracy of small targets in helmet-wearing detection. First, a novel downsampling method is constructed by introducing two-dimensional discrete wavelet transform. This method can capture multi-frequency domain feature information, effectively reducing feature loss and further improving the detection accuracy for small targets. Second, to address the issue of limited pixel information for small targets, an ASPP_CBAM multi-scale feature fusion structure combining multiple receptive field branches and an attention mechanism is designed. This structure utilizes dilated convolution to construct features from different receptive fields, thereby enriching feature representation and significantly reducing feature loss during sampling without increasing computational resources. The CBAM attention mechanism further enhances the focus on key channels and regions, thus improving detection accuracy. Finally, a novel WIoU v3 loss function is used to improve the model's detection performance. This method is particularly effective for detecting small targets, significantly improving the accuracy of helmet-wearing detection. Attached Figure Description
[0018] To make the objectives, technical solutions, and advantages of the present invention clearer, the preferred embodiments of the present invention will be described in detail below with reference to the accompanying drawings, wherein:
[0019] Figure 1 This is an architectural diagram of a construction site safety helmet wearing system and method for targeting small targets, according to an embodiment of the present invention.
[0020] Figure 2 This is a diagram showing the overall structure of the improved YOLOX network according to an embodiment of the present invention.
[0021] Figure 3 This is a structural diagram of the ASPP_CBAM module of the Backbone network in the improved YOLOX network according to an embodiment of the present invention;
[0022] Figure 4 A comparison chart showing the detection performance of traditional YOLOX and the improved YOLOX network of this invention on safety helmets of construction workers. Detailed Implementation
[0023] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0024] In view of the background art, the present invention aims to improve the accuracy of helmet wearing detection, such as... Figure 1 As shown, the present invention provides a method for detecting the wearing of safety helmets at small-target construction sites, comprising the following steps:
[0025] S1: Collect on-site images of construction sites and label the data, construct training and test datasets and perform preprocessing;
[0026] S2: Construct a helmet-wearing detection network for small targets based on a preset YOLOX model. The helmet-wearing detection network is used for helmet-wearing detection.
[0027] S3: Input the training set images and test set images into the helmet wearing detection network for training, and use WIoU v3 as the bounding box regression loss function to adjust the parameters of the helmet wearing detection network;
[0028] S4: Input the on-site image of the construction site to be tested into the trained safety helmet detection network, and output the real-time detection result of the on-site image of the construction site to be tested.
[0029] In this embodiment of the invention, in step S1, firstly, a digital camera is used to capture high-definition images of workers constructing actual construction sites; then, 860 sub-images are randomly selected from the captured high-resolution images, and the resolution is adjusted to 640×640 pixels to form an image dataset; the image data is manually labeled using the labelimg tool, with "hat" representing all personnel wearing safety helmets and "person" representing personnel not wearing safety helmets; then, the labels are output in XML format. Since YOLO's label format is TXT, Python code is needed to convert the XML labels to TXT format; finally, the dataset is divided into a training dataset and a test dataset in a 4:1 ratio for model training and testing.
[0030] In this embodiment of the invention, in step S2, the helmet wearing detection network is designed as follows: Figure 2 As shown, the specific steps include the following:
[0031] S21: In the backbone network part of the preset YOLOX model, add an attention mechanism unit after the Focus module;
[0032] S22: In the backbone network of the preset YOLOX model, the downsampling module in each stage of the CSPDarknet53 structure is improved by using two-dimensional discrete wavelet transform.
[0033] S23: In the Neck network part of the preset YOLOX model, dilated convolution is used to construct a multi-scale feature fusion structure instead of the FPN structure by using different dilation coefficients;
[0034] S24: In the Head network part of the preset YOLOX model, classify and detect the feature maps output by the Neck network part.
[0035] It's important to note that the YOLOX model is a deep learning model for object detection, an improved version of the YOLO (You Only Look Once) series. YOLOX offers significant performance and speed improvements over previous YOLO versions, primarily due to its innovative design and optimization strategies. The YOLOX architecture mainly consists of the following components: Backbone: Used for extracting image features. YOLOX typically uses CSPDarknet53 as its backbone, an improved version of Darknet-53 with better feature extraction capabilities and computational efficiency. Neck: Used to fuse features from different levels to better capture object details. YOLOX uses a combination of FPN (Feature Pyramid Network) and PANet (Path Aggregation Network). Head: Responsible for generating the final detection results, including classification probabilities and bounding box coordinates. YOLOX employs a multi-scale detection head similar to YOLOv3, enabling object detection at multiple scales. This invention makes some adjustments to the traditional YOLOX model to make it better applicable to helmet wearing detection and improve the accuracy of helmet wearing detection.
[0036] In step S21, this embodiment adds an attention mechanism unit after the Focus module in the traditional preset YOLOX model, thereby reducing the impact of pixel separation caused by the "Focus" layer in YOLOX on the detection of small targets by strengthening feature connections.
[0037] In some embodiments of the present invention, step S21 may include the following steps:
[0038] S211: The original feature map obtained from the Backbone network of the preset YOLOX model is entered into the Focus module. Four sub-feature maps are obtained from the original feature map at intervals of one pixel. These four sub-feature maps are concatenated in the channel dimension to form a new feature map.
[0039] S212: After the new feature map enters the attention mechanism unit, it first performs a 3×3 convolution on the input feature map to extract local information, then performs a concat fusion with the input feature map, and then generates an attention matrix through two consecutive convolutions; at the same time, it encodes the input feature map and multiplies it with the attention matrix to obtain global information; finally, it fuses the local information and global information.
[0040] In embodiments of the present invention, such as Figure 3 As shown, the system enters the Contextual Transformer module, which is referred to as the COT module in this invention. First, the input features are subjected to a 3×3 convolution to extract local information (key). Then, the local information is fused with the input features (query) using a concat operation. Next, an attention matrix is generated through two consecutive 1×1 convolutions. At the same time, the input features are encoded using a 1×1 convolution operation (value) and multiplied with the attention matrix to obtain global information. Finally, the local information and global information are fused.
[0041] The convolutional layer for the key consists of a grouped convolution, BatchNorm, and ReLU activation; the convolutional layer for the value consists of a 1×1 convolution and BatchNorm; and the attention embedding layer consists of two convolutional layers, a BatchNorm layer, and ReLU activation.
[0042] In other embodiments of the present invention, step S21 may further include:
[0043] A1: Image partitioning: Take a value for every pixel in an image, similar to neighbor downsampling, to obtain four images that are complementary; Stitching: Stitch these four sub-images along the channel dimension to form a new tensor of size (4,12,320,320).
[0044] A2: Enter the COT module: The output of Focus is used as the input of the COT module.
[0045] Furthermore, the specific steps for entering the COT module in A2 are as follows:
[0046] A21: Use 3×3 convolution operation, batch normalization and ReLU activation function to obtain local information (key) of the image from the input features;
[0047] A22: The local information and the input features (query) are fused using the Concat operation, and then concatenated along the channel dimension;
[0048] A23: The fused features are used to obtain the attention matrix through two consecutive convolutions. The kernel size of each convolution layer is set to 1×1, resulting in an attention matrix of size (4, 12, 3*3, 320, 320).
[0049] A24: Perform average pooling along the third dimension (the dimension where dim=2) of the attention matrix to restore the size of (4,12,320,320);
[0050] A25: Encode the input features using 1×1 convolution operations and batch normalization to obtain the Value matrix;
[0051] A26: Perform matrix multiplication on the encoded Value matrix and the attention matrix, that is, multiply them element by element to obtain the weighted global features;
[0052] A27: Use the Concat operation to fuse local and global information, performing matrix addition.
[0053] In step S22, this embodiment improves the downsampling module in the CSPDarknet53 structure using two-dimensional discrete wavelet transform, reducing feature loss through an efficient downsampling method. This embodiment refers to the improved downsampling module as DWT_Down downsampling. First, the original image is decomposed in the row direction using a Haar wavelet high-pass filter and a low-pass filter, dividing the original image into low-frequency and high-frequency components. Then, it is decomposed again in the column direction using Haar wavelet filters, resulting in four sub-bands representing features in different frequency domains, thus reducing the loss of discriminative features during conventional downsampling. In some embodiments of this invention, step S22 may include the following steps:
[0054] S221: Perform 2D-DWT (Two-Dimensional Discrete Wavelet Transform) on each channel feature of the image: Using a Haar wavelet filter, apply low-pass and high-pass filtering to the row direction of the features to generate low-frequency and high-frequency components. Apply low-pass and high-pass filtering to the column direction of the obtained low-frequency and high-frequency components to generate low-frequency and high-frequency components respectively. Each channel ultimately yields four sub-bands, each with a width and height equal to half of the input feature map. The four sub-bands are: low-frequency information (LL), horizontal high-frequency information (LH), vertical high-frequency information (HL), and diagonal high-frequency information (HH).
[0055] S222: Stitch together the four sub-band images obtained from each channel along the channel dimension;
[0056] S223: Channel number adjustment: Since the number of channels in the spliced feature map has increased fourfold, a 1x1 convolution operation is used to adjust the number of channels from 4*C back to C for subsequent network layer processing.
[0057] In step S23, this embodiment utilizes dilated convolution with different dilation coefficients to construct a multi-scale feature fusion structure instead of the FPN structure, thereby expanding the receptive field while reducing the number of parameters and computational cost of traditional downsampling. The Neck network contains two parallel ASPP_CBAM modules, with inputs F... Dark2 F Dark3 The features are divided into two levels, and then a fusion structure is used to obtain feature maps with different receptive fields. To reduce information loss caused by zero computation during dilated convolution and to mitigate interference from background information after feature fusion, a CBAM attention mechanism is used to reweight important information. The fused feature map is then processed through an attention mechanism to obtain channel attention and spatial attention, and then convolution is used to reduce the dimensionality of the features.
[0058] In some embodiments of the present invention, step S23 may include the following steps:
[0059] S231: Extract the output feature maps F from the second and third stages of the CSPDarknet53 structure. Dark2 F Dark3 These are respectively used as inputs to the parallel ASPP_CBAM module;
[0060] Here, the output feature maps of the second and third stages actually correspond to the output feature maps FDark2 and FDark3 of the second and third Resblock_body, respectively. These two output feature maps are used as inputs to the parallel ASPP_CBAM module. For example, when the input is (640,640,3), the shapes of the two feature layers are feat1=(80,80,256) and feat2=(40,40,512).
[0061] S232: For each ASPP_CBAM module, the input feature map is first dilated and convolved, and holes are inserted between the convolution kernel elements to expand the receptive field; feature maps with different receptive fields are obtained by adjusting different dilation coefficients; and then concatenated with the original feature map along the channel dimension.
[0062] S233: Name the concatenated output features as F 2_Dark2 F 2_Dark3 The system obtains the channel attention map through an attention mechanism, and then continues to calculate the spatial attention map; then the dimensionality of the obtained feature map is reduced through convolution operation; finally, the output of the parallel ASPP_CBAM module is obtained, which is used for subsequent detection by the Head network.
[0063] Furthermore, to input F 2_Dark2For example, the ASPP_CBAM module in S232 contains four parallel dilated convolutional layers to obtain a larger receptive field and extract more contextual information. The specific steps are as follows:
[0064] F 2_1 =AtrousConv(F Dark2 ,AX AtrousRate_1 (1)
[0065] F 2_2 =AtrousConv(F Dark2 ,AX AtrousRate_2 (2)
[0066] F 2_3 =AtrousConv(F Dark2 ,AX AtrousRate_3 (3)
[0067] F 2_4 =AtrousConv(F Dark2 ,AX AtrousRate_4 (4)
[0068] F 2_Dark2 =Concat(F 2_1 ,F 2_2 ,F 2_3 ,F 2_4 ,F Dark2 (5)
[0069] Where AtrousConv represents the input feature map F 2_Dark2 Perform dilated convolution operations, with the convolution operation parameter uniformly set to kernel_size=3. After dilated convolution, perform batch normalization and ReLU activation function, AX AtrousRate_1 AX AtrousRate_2 AX AtrousRate_3 and AX AtrousRate_4 These represent different hole coefficients, such as 6, 12, 18, and 24; Concat represents a channel-wise concatenation operation, resulting in the output feature map F. 2_Dark2 F after splicing dilated convolution 2_1 ,F 2_2 ,F 2_3 ,F 2_4 and the input feature map F Dark2 Its number of channels is F Dark2 Five times.
[0070] In other embodiments of the present invention, step S23 may further include:
[0071] The attention mechanism operation in S233 is as follows:
[0072] B1: Inferring a one-dimensional channel attention map M based on CBAM c_Dark2 ∈R 5C×1×1 Max pooling and average pooling are used to aggregate the spatial information of the feature map to generate max pooling features. and average pooling characteristics The output results are fed into a shared fully connected layer; the two results are added together and then normalized using the Sigmoid function to obtain the channel weight matrix M. c_Dark2 The calculation formula is as follows:
[0073]
[0074] Where σ represents the Sigmoid function, MLP is an important component of the shared network, the multilayer perceptron, W1 and W0 represent the weights of the MLP, and Avg and Max represent average pooling and max pooling, respectively.
[0075] B2: Perform a multiplication operation between the weight matrices of the input features and the channel features to obtain the result.
[0076] B3: Calculate the 2D spatial attention map M s_Dark2 ∈R 1×H×W Unlike channel-based mechanisms, this approach first applies max pooling and average pooling to the feature maps along the channel axes; then concatenates the two results; next, a 3×3 convolutional layer is used to learn spatial correlations to obtain a single-channel weight; finally, the weights are normalized using the sigmoid function to obtain the spatial weight matrix M. s_Dark2 The calculation formula is as follows:
[0077]
[0078] B4: Combine the result F′2 obtained from B2 with the spatial output weights M. s_Dark2 Multiply to get the result
[0079] B5: The result obtained from B4, F″2∈R 5C×H×W Perform a 1×1 convolution operation to compress the number of channels from 5C to C, thereby reducing the computational cost.
[0080] In this embodiment of the invention, step S3 may specifically include the following steps:
[0081] The training set is input into the network, and precision and recall are used as model metrics. The training weight file with the highest precision is selected as the optimal weight file. The test set and the optimal weight file are input into the trained network to obtain the helmet wearing status in the image to be detected.
[0082] Further, the following parameters were set for model training: input image size: train_img_size = 640, training batch size: batch_size = 4, number of iterations: epochs = 50, learning rate: learning-rate = 0.01, SGD momentum parameter: momentum = 0.9, weight decay rate: weight_decay = 0.0005, NMS threshold (used to remove duplicate detection boxes in the detection stage): nms_thres = 0.5, confidence threshold (used to filter low-confidence prediction boxes in the detection stage): conf_thres = 0.005, number of workers: num-workers = 4, and the remaining parameters used their default values. After training, the best-performing model weights were saved as the file best.pt for use in subsequent helmet-wearing detection tasks.
[0083] In this embodiment of the invention, in step S3, in order to solve the problem that the gradient of the traditional IoU is small when the overlapping region is small, which makes it difficult for the model to be effectively optimized, the WIoU v3 loss function is adopted. The gradient is enhanced by a weighting mechanism to improve the performance of the model when dealing with small overlapping regions and targets of different sizes, and avoids the performance degradation when detecting small targets. The calculation is shown in formulas (8)-(11):
[0084] L WIoUv3 =r×L WIoUv1 (8)
[0085]
[0086]
[0087]
[0088] Among them, L WIoUv3 The loss function for WIoU v3; (x, y) and (x gt y gt () represents the coordinates of the center points of the predicted bounding box and the ground truth bounding box. Indicates W g and H g Separating from the computational graph, R WIoUδ represents the normalized distance between the center points of the ground truth bounding box and the predicted bounding box; r is the non-monotonic focusing factor; α and β are hyperparameters that can be adjusted to suit different models, and δ is a positive number; These are the coefficients of the constructed monotonic focusing factor; It is the moving average of momentum m. β is used to describe the outlier degree of the bounding box quality. A small outlier degree means a high-quality anchor box. Based on the gradient gain allocation strategy of the WIoU v3 loss function, assigning a small gradient gain can make the bounding box regression focus on anchor boxes of average quality; assigning a small gradient gain to anchor boxes with large outliers will effectively prevent low-quality examples from generating large harmful gradients. Because The process is dynamic, and the quality gradation criteria for the anchor frames are also dynamic, making the gradient gain allocation strategy of WIoU v3 the optimal adjustment strategy at present. In some embodiments, the hyperparameters α and β are set to 1.9 and 3, respectively.
[0089] In some embodiments of the present invention, step S4 specifically includes taking periodic photos of the safety monitoring target area or extracting keyframes from surveillance video to capture real-time images of the construction site corresponding to the actual construction location; transmitting the acquired images of the construction site to a terminal computer; and using a trained helmet-wearing detection network to identify and detect the incoming images of the construction site, obtaining helmet-wearing detection results in the images. To acquire images of the construction site, helmet-wearing detection equipment and devices, such as multiple smart cameras, can be installed at the construction site to achieve the purpose of periodic monitoring.
[0090] In other embodiments of the present invention, step S4 may further include:
[0091] S41: Install safety helmet wearing detection equipment and devices at construction sites, including multiple smart cameras, to take photos of the safety monitoring target area at regular intervals, or extract key frames from the surveillance video to capture images of the target area corresponding to the actual construction site in real time, or directly upload the image files that need to be detected.
[0092] S42: Transmit the collected images of the construction site to the terminal computer;
[0093] S43: The terminal computer uses the improved YOLOX network model to identify and detect the incoming image, and uses the pre-trained best weight file best.pt for analysis to obtain the helmet wearing detection result in the target area image;
[0094] S44: The detection results can be displayed on the terminal computer via a graphical interface, showing the predicted boxes for detected safety helmets and their corresponding confidence levels, or a report file can be generated for management personnel to view. To improve management efficiency, the system can be configured with an alarm mechanism to immediately issue an alarm when a situation of not wearing a safety helmet is detected.
[0095] In some embodiments of the present invention, a safety helmet wearing detection system for small-target construction sites is also provided, for implementing the safety helmet wearing detection method for small-target construction sites as described in the first aspect of the present invention, and similarly referring to... Figure 1 As shown, the system includes:
[0096] Image input module: used to acquire on-site images of construction sites, perform data annotation, build training and test datasets, and perform preprocessing;
[0097] Feature extraction module: Construct a helmet wearing detection network for small targets based on a preset YOLOX model. The helmet wearing detection network is used for helmet wearing detection. Input training set images and test set images into the helmet wearing detection network for training, and use WIoU v3 as the bounding box regression loss function to adjust the parameters of the helmet wearing detection network.
[0098] The detection and classification module is used to input the on-site image of the construction site to be tested into the trained safety helmet wearing detection network, and output the real-time detection result of the on-site image of the construction site to be tested.
[0099] Understandably, this invention utilizes a two-dimensional discrete wavelet transform to construct a downsampling module method, capturing discriminative features through multi-frequency domain information. In the feature fusion part, the feature fusion network is improved by leveraging the ability of dilated convolution to acquire different receptive fields. By reducing feature loss, the detection accuracy of smaller targets in helmet wearing detection is improved, further enhancing the overall accuracy of helmet wearing detection. Compared to the original YOLOX method, this approach not only reduces the number of parameters but also further improves the accuracy of helmet wearing detection. Figure 4 As shown, Figure 4 The image shows a comparison of the detection performance of traditional YOLOX and the improved YOLOX network (corresponding to CDA-YOLOX) in this embodiment of the invention on the safety helmets of construction workers. The invention has a lower false negative rate.
[0100] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include ROM, RAM, disk, or optical disk, etc.
[0101] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A method for detecting the wearing of safety helmets on construction sites targeting small targets, characterized in that: Includes the following steps: S1: Collect on-site images of construction sites and label the data, construct training and test datasets and perform preprocessing; S2: Construct a helmet-wearing detection network for small targets based on a preset YOLOX model. The helmet-wearing detection network is used for helmet-wearing detection. Specifically, the following steps are included: S21: In the backbone network of the pre-defined YOLOX model, add an attention mechanism unit after the Focus module; constructing the Focus module with the integrated attention mechanism unit includes the following steps: S211: The original feature map obtained from the Backbone network of the preset YOLOX model is entered into the Focus module. Four sub-feature maps are obtained from the original feature map at intervals of one pixel. These four sub-feature maps are concatenated in the channel dimension to form a new feature map. S212: After the new feature map enters the attention mechanism unit, it first performs a 3×3 convolution on the input feature map to extract local information, then performs a concat fusion with the input feature map, and then generates an attention matrix through two consecutive convolutions; at the same time, it encodes the input feature map and multiplies it with the attention matrix to obtain global information; finally, it fuses the local information and global information. S22: In the backbone network of the preset YOLOX model, the downsampling module in each stage of the CSPDarknet53 structure is improved by using two-dimensional discrete wavelet transform. S23: In the Neck network part of the preset YOLOX model, dilated convolution is used with different dilation coefficients to construct a multi-scale feature fusion structure to replace the FPN structure; the Neck network includes two parallel ASPP_CBAM modules, whose inputs are the second and third stages of the CSPDarknet53 structure, i.e., F... Dark2 F Dark3, The features are divided into two levels, and then feature maps with different receptive fields are obtained through a fusion structure. The fused feature maps are then used to obtain channel attention and spatial attention through an attention mechanism, and then convolution is used to reduce the dimensionality of the features. The ASPP_CBAM module includes four parallel dilated convolutional layers. S24: In the Head network part of the preset YOLOX model, classify and detect the feature maps output by the Neck network part; S3: Input the training set images and test set images into the helmet wearing detection network for training, and use WIoU v3 as the bounding box regression loss function to adjust the parameters of the helmet wearing detection network; S4: Input the on-site image of the construction site to be tested into the trained safety helmet detection network, and output the real-time detection result of the on-site image of the construction site to be tested.
2. The method for detecting the wearing of safety helmets on construction sites for small targets according to claim 1, characterized in that: In step S22, the downsampling module in each stage of the improved CSPDarknet53 structure using two-dimensional discrete wavelet transform includes: first, selecting a Haar wavelet filter; applying low-pass filtering and high-pass filtering sequentially in the row and column directions for each channel of the original image to obtain four sub-bands with different frequency and spatial domains; concatenating the four sub-bands of each channel along the channel direction; and finally adjusting the number of channels through convolution operations, where the four sub-bands are low-frequency information, horizontal high-frequency information, vertical high-frequency information, and diagonal high-frequency information.
3. The method for detecting the wearing of safety helmets on construction sites for small targets according to claim 1, characterized in that: The specific implementation process of step S23 is as follows: S231: Extract the output feature maps of the second and third stages in the CSPDarknet53 structure. , These are respectively used as inputs to the parallel ASPP_CBAM module; S232: For each ASPP_CBAM module, first, dilated convolution is performed on the input feature map, and holes are inserted between the convolution kernel elements to expand the receptive field; feature maps with different receptive fields are obtained by adjusting different dilation coefficients; then, they are concatenated with the original feature map along the channel dimension. S233: Name the concatenated output features respectively. , The system obtains the channel attention map through an attention mechanism, and then continues to calculate the spatial attention map; then the dimensionality of the obtained feature map is reduced through convolution operation; finally, the output of the parallel ASPP_CBAM module is obtained, which is used for subsequent detection by the Head network.
4. The method for detecting the wearing of safety helmets on construction sites for small targets according to claim 1, characterized in that: Step S3 includes the following steps: inputting the training set images into the helmet wearing detection network, using precision and recall as model metrics, and selecting the training weight file with the highest precision as the optimal weight file; inputting the test set images and the optimal weight file into the trained helmet wearing detection network for verification.
5. The method for detecting the wearing of safety helmets on construction sites for small targets according to claim 1, characterized in that: Step S4 specifically includes taking photos of the safety monitoring target area at regular intervals, or extracting key frames from the monitoring video, to capture real-time images of the construction site to be tested corresponding to the actual construction site; transmitting the collected images of the construction site to be tested to the terminal computer; the terminal computer uses a trained safety helmet wearing detection network to identify and detect the incoming images of the construction site to be tested, and obtains the safety helmet wearing detection results in the images of the construction site to be tested.
6. A construction site safety helmet wearing detection system for small targets, used to implement the construction site safety helmet wearing detection method for small targets as described in any one of claims 1 to 5, characterized in that, The system includes: Image input module: used to acquire on-site images of construction sites, perform data annotation, build training and test datasets, and perform preprocessing; Feature extraction module: Construct a helmet wearing detection network for small targets based on a preset YOLOX model. The helmet wearing detection network is used for helmet wearing detection. Input training set images and test set images into the helmet wearing detection network for training, and use WIoU v3 as the bounding box regression loss function to adjust the parameters of the helmet wearing detection network. The detection and classification module is used to input the on-site image of the construction site to be tested into the trained safety helmet wearing detection network, and output the real-time detection result of the on-site image of the construction site to be tested.
Citation Information
Patent Citations
Safety helmet wearing detection method and device based on improved YOLOX
CN116503707A
Metal surface defect detection method and device based on improved YOLO model
CN116977294A