A method for detecting helmet wearing in industrial areas based on YOLOv5

By incorporating the ECA attention mechanism into the YOLOv5 target detection algorithm, a safety helmet pattern recognition module was constructed, which solved the problems of high computational load and poor real-time performance of existing safety helmet detection methods. This enabled real-time and accurate safety helmet wearing detection on low-cost terminal devices, ensuring safety in the work area.

CN115937788BActive Publication Date: 2025-10-31SHENYANG INSTITUTE OF CHEMICAL TECHNOLOGY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310001087.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-03
Publication Date
2025-10-31
Estimated Expiration
2043-01-03

AI Technical Summary

Technical Problem

Existing safety helmet detection methods involve large computational loads and high time complexity on construction sites, making real-time monitoring difficult. Furthermore, traditional deep neural network algorithms consume significant resources on low-cost terminal devices, hindering their application.

Method used

A safety helmet pattern recognition module is constructed using a YOLOv5-based object detection algorithm combined with the ECA attention mechanism. Through image processing and video detection, it can monitor whether workers are wearing safety helmets in real time and achieve real-time detection on low-performance terminals.

Benefits of technology

It enables real-time and accurate detection of workers' helmet wearing status on low-cost terminal equipment, improving detection speed and accuracy, and can promptly remind workers who are not wearing helmets, thus ensuring the safety of the work area.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115937788B_ABST
    Figure CN115937788B_ABST
Patent Text Reader

Abstract

This invention discloses a method for detecting helmet wearing in industrial areas based on YOLOv5. The method employs the YOLOv5 object detection algorithm to detect whether workers in the factory area are correctly wearing helmets, obtaining real-time helmet wearing data. This data is then transmitted to the corresponding control module, and the system ultimately reminds workers who are not wearing helmets based on the helmet wearing data. Compared to traditional time series models, object detection technology offers higher efficiency, accuracy, and real-time performance, enabling the system to obtain currently valid helmet wearing data. This improves the timeliness of helmet wearing detection and allows for appropriate reminders to workers not wearing helmets correctly.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a method for detecting helmet wearing, and more particularly to a method for detecting helmet wearing in the YOLOv5 industrial zone. Background Technology

[0002] In recent years, with the development of artificial intelligence technology, the application of deep neural network algorithms has become increasingly widespread. Deep convolutional neural networks are key to many deep learning paradigms for visual tasks, including object recognition, detection, and segmentation. Deep neural networks (DNNS) automatically extract discriminative feature representations from data in an end-to-end manner and have outperformed other machine learning algorithms in many benchmark tests.

[0003] The main methods for detecting safety helmets on construction sites include detecting them by color features or detecting faces first and then classifying them by safety helmet features through a classifier. Although these methods meet the accuracy requirements, they involve a large amount of computation and have high time complexity, which is not conducive to real-time monitoring.

[0004] In recent years, deep neural networks have been widely used for object detection. However, they require large training sets and precise annotations, which poses significant challenges to practical applications. They also consume large amounts of computer memory and computational resources, making them unsuitable for low-cost terminal devices. Object detection algorithms include single-stage and two-stage algorithms. The latter requires object localization followed by classification of the localized image, a single-stage process. Represented by R-CNN, SPP-net, Fast-RCNN, Faster-RCNN, and Mask R-CNN, these algorithms offer high accuracy but are slow and unsuitable for real-time scenarios. The former, single-stage object detection based on regression algorithms, primarily represented by YOLO and SSD, directly regresses the bounding box, resulting in slightly lower accuracy but a significant speed advantage. Since helmet detection requires high real-time performance, the YOLOv5 single-stage object detection model is adopted, offering advantages in both speed and accuracy. Experimental results show that the method achieves high accuracy with low memory consumption, enabling real-time detection on low-performance terminals and allowing for expansion to other similar applications. Summary of the Invention

[0005] The purpose of this invention is to provide a method for detecting the wearing of safety helmets in industrial areas based on YOLOv5. This invention uses computer image processing and industrial control methods to process the acquired images, extract image features, and transmit the necessary information data from the images to a safety helmet pattern recognition module. This module can determine whether workers are wearing safety helmets based on the data and remind workers who are not wearing safety helmets, thereby ensuring the safety of personnel in the work area.

[0006] The objective of this invention is achieved through the following technical solution:

[0007] A method for detecting helmet wearing in industrial areas based on YOLOv5 is proposed. The method constructs an image detection network model for helmet pattern recognition. The helmet pattern recognition module extracts data from the image model and assigns traffic patterns based on real-time conditions. Specifically, the method includes the following steps:

[0008] 1) Create a safety helmet dataset for target detection in a safety helmet recognition system;

[0009] 2) Configure the network environment using the deep learning PyTorch framework, and complete the YOLOv5 model building within this environment;

[0010] 3) An ECA attention mechanism was added to the original YOLOv5 model framework to optimize the model;

[0011] 4) Use the preprocessed dataset as input to the network for training, load the YOLOv5s pre-trained weights, and use CIOU as the loss function;

[0012] 5) The network model was tested by filming workers entering the factory area and wearing safety helmets;

[0013] 6) The helmet pattern recognition module organizes the helmet conditions detected by the system and determines the appropriate helmet pattern based on the helmet data.

[0014] The aforementioned method for detecting the wearing of safety helmets in industrial areas based on YOLOv5 involves preprocessing the image dataset input to the model. For fire pattern recognition, the dataset uses images of workers not yet in the factory area or already inside. Video recordings from monitoring equipment are collected and processed frame by frame to obtain images of passengers under various conditions. Images of workers wearing safety helmets are collected, organized, and converted to JPG format. The image data is then labeled using the labelimg tool, and the labels are output in XML format. Since YOLOv5 uses TXT labels, the XML labels need to be converted to TXT format using code. During network training, the data needs to be divided into training and testing sets. Here, 80% of the dataset is used as the training set, and the remaining 20% ​​is used as the testing set.

[0015] The method for detecting helmet wearing in industrial areas based on YOLOv5 involves preprocessing the image dataset to build an image processing target detection model. The model architecture consists of four parts: input, backbone, Neck, and head. The input layer processes the input image, employing Mixup data augmentation, adaptive anchor box calculation, and adaptive image scaling to improve the training speed and network accuracy. The backbone uses Focus and ASP structures to build a neural network for image features. The Neck uses FPN+PAN structures to enhance the network's feature fusion capability. The head uses CIOU as the loss function to predict image features and generate bounding boxes and class confidence scores. The model loads YOLOv5 pre-trained weights with an initial learning rate of 0.01, momentum of 0.959, loss gain of 0.55, and CIOU as the loss function. The remaining parameters use default values.

[0016] The aforementioned method for detecting helmet wearing in industrial areas based on YOLOv5 involves building a target detection model. To further improve the model's accuracy, an ECA attention mechanism is employed to optimize the network model. This mechanism adds an attention mechanism to the completed YOLOv5 backbone network, embedding positional information into channel attention to obtain attention weights on the height and width of the feature map. Finally, by incorporating these attention weights into the original feature map, the network's detection accuracy is enhanced. The ECA attention mechanism formula is as follows:

[0017] (1)

[0018] Compared to the initial model, the model with the added ECA attention mechanism showed an increase in map size of about 0.7%, which is of great significance for the model to detect helmet wearing.

[0019] The method for detecting helmet wearing in industrial areas based on YOLOv5 involves optimizing the model by setting parameters such as the number of data frames input into the network at one time, the number of training rounds, and the number of worker threads, and then starting model training. After the model training is completed, the performance indicators of the model are checked to see if they are reasonable. A camera is then turned on to detect the input data, and the confidence of the predicted bounding boxes is checked.

[0020] The aforementioned method for detecting helmet wearing in industrial areas based on YOLOv5 involves training and testing a model. The helmet wearing detection system uses a target detection network to extract information on workers wearing helmets. The system records each worker entering with a correctly worn helmet, recording data such as correctly worn and incorrectly worn helmets at regular intervals. This data is then transmitted to an information management module for optimization of helmet detection. The helmet pattern recognition module receives the helmet data from the target detection and selects a suitable pattern based on real-time pedestrian flow data.

[0021] The advantages and effects of this invention are:

[0022] This invention employs the YOLOv5 object detection algorithm to detect whether factory workers are correctly wearing safety helmets, obtaining real-time helmet-wearing data. This data is then transmitted to the corresponding control module, and the system ultimately reminds workers who are not wearing helmets based on the helmet-wearing data. Compared to traditional time series models, object detection technology offers higher efficiency, accuracy, and real-time performance, enabling the system to obtain current and valid helmet-wearing data. This improves the timeliness of helmet-wearing detection and allows for appropriate reminders to workers not wearing helmets correctly.

[0023] This invention employs an object detection-based method, incorporating image recognition into a safety helmet detection system. By detecting workers wearing safety helmets in a factory area, it can obtain real-time information on helmet wearing status. Compared to traditional time-series prediction algorithms, it offers significantly higher realism and timeliness. By transmitting actual helmet-wearing data to a safety helmet pattern recognition module, it can determine the helmet-wearing status of workers. Furthermore, data on correctly and incorrectly worn helmets can be used to optimize the scheduling algorithm. An ECA attention mechanism has been added to the YOLOv5 object detection algorithm, optimizing the original algorithm and improving network accuracy, which is beneficial for safety helmet wearing detection. Attached Figure Description

[0024] Figure 1 This is a schematic diagram of the detection process of the present invention;

[0025] Figure 2 This is a structural diagram of the safety helmet detection system of the present invention;

[0026] Figure 3 This is a diagram of the YOLOv5 model architecture of the present invention;

[0027] Figure 4 This is a network structure diagram of the ECA attention mechanism of the present invention;

[0028] Figure 5 This is a flowchart of the model training process of the present invention;

[0029] Figure 6 This is the accuracy map of the present invention;

[0030] Figure 7 This is a graph of the loss function of the present invention. Detailed Implementation

[0031] The embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.

[0032] This invention applies the object detection method to the detection and recognition of a safety helmet system. Taking the correct wearing of a safety helmet as an example, the system is divided into two parts: an object detection algorithm network and a safety helmet pattern recognition.

[0033] Safety helmet testing process and structural diagram are as follows: Figure 1 , Figure 2 As shown.

[0034] Before building the network, the input image dataset needs to be preprocessed. First, the elevator passenger images are collected, organized, and converted to JPG format. Next, the image data is labeled using the labelimg tool, and the labels are output in XML format. Since YOLO uses TXT for labels, code is needed to convert the XML labels to TXT format. During network training, the data needs to be divided into training and testing sets. Here, 80% of the dataset is used as the training set, and the remaining 20% ​​is used as the testing set.

[0035] After preprocessing the dataset, it's necessary to build the YOLOv5 algorithm network model and configure the runtime environment. PyCharm is used as the project IDE. The downloaded PyTorch environment is imported into the project using conda. After configuring the environment, the parameters for YOLOv5 need to be set and the model built. The YOLOv5 model is as follows: Figure 3 As shown, the network mainly consists of an Input layer, a Backbone network, a Neck network layer, and a Head output layer. The Input layer processes the input image, employing techniques such as Mixup data augmentation, adaptive anchor box calculation, and adaptive image scaling to improve model training speed and network accuracy. The Backbone network uses a Focus structure and a CSP structure to build a neural network for image features. The Neck network uses an FPN+PAN structure to enhance the network's feature fusion capability. The Head layer uses CIOU as the loss function to predict image features, generating bounding boxes and class confidence scores.

[0036] After the initial YOLOv5 model was built, an ECA attention mechanism was added to its backbone network to optimize the network model. ECA is a novel attention mechanism for mobile networks that can improve network accuracy. The ECA attention mechanism module diagram is shown below. Figure 4 As shown, this invention incorporates ECA into the YOLOv5 model and modifies the original model framework. The first step is to write the ECA function into the common function to complete the ECA model structure. The second step is to modify the ECA model in YOLOv5. The third step is to rewrite the backbone network of the YOLOv5 model and add ECA into the backbone network model.

[0037] After model improvement, the preprocessed image dataset needs to be input into the network for training. Before training the model, YOLOv5 pre-trained weights are added to optimize training, shorten training time, and improve prediction accuracy. When changing model parameters, the path, type, and number of training datasets are set; the type and path of the pre-trained weights are loaded; hyperparameters and activation functions suitable for the dataset training type are selected; and the number of training threads, input images, and training epochs are set. After setting the model parameters, training begins to obtain model weights that conform to the system. The model training process is as follows: Figure 5 As shown.

[0038] After model training is complete, performance metrics such as Precision, ReECAll, F1 score, and map are used to check the quality of model training. The model's map accuracy is as follows: Figure 6 As shown, the loss function is as follows Figure 7 As shown, factory area video was used as input to the model to test the accuracy of the model in recognizing the predicted bounding box of the safety helmet.

[0039] The safety helmet detection system uses a target detection network to extract data from workers. The system records data on whether safety helmets are worn correctly or incorrectly. At regular intervals, it records the time workers spend wearing helmets and the time they remain in a particular location, transmitting this data to an information management module for optimization. By using target detection methods to identify safety helmets, the system can effectively and in real-time detect helmet wearing status. Example

[0040] This invention relates to the application of YOLOv5 in the detection of safety helmets in industrial plants, and employs the following steps:

[0041] 1. Create a dataset of personnel wearing safety helmets for target detection in a safety helmet detection system;

[0042] 2. Configure the network environment using the deep learning PyTorch framework, and complete the YOLOv5 model building within this environment;

[0043] 3. An ECA attention mechanism was added to the original YOLOv5 model framework to optimize the model;

[0044] 4. Use the preprocessed dataset as input to the network for training, load the YOLOv5s pre-trained weights, and use CIOU as the loss function;

[0045] 5. Use video footage of workers entering the factory area and wearing safety helmets to test the network model;

[0046] 6. The helmet pattern recognition module organizes the helmet conditions detected by the system and determines the appropriate helmet pattern based on the helmet data.

[0047] The specific implementation steps of step 1 are as follows:

[0048] Collect images of people wearing safety helmets correctly and label them using the labelimg tool.

[0049] Convert the labeled data into YOLO's txt format;

[0050] The dataset is divided into a training set and a test set.

[0051] The specific implementation steps of step 2 are as follows:

[0052] Import the necessary configuration environment for the project;

[0053] The YOLO model is constructed, consisting of an Input layer, a Backbone network, a Neck network layer, and a Head output layer.

[0054] The specific implementation steps of step 3 are as follows:

[0055] The ECA (Efficient Channel Attention Module) attention mechanism is introduced to enhance network optimization and improve network accuracy. ECA consists of two parts: global image pooling and one-dimensional convolution operation. The ECA module divides the input feature map into two directions, width and height, and performs global average pooling on each direction to obtain feature outputs in two directions.

[0056] Calculate cross-channel intervals However, in the experiments conducted by Wang, Wu, and others, because the dimensionality reduction operation of the dimensionality-reduced SENet affected the accuracy of the entire system, ECA used a method based on local cross-channel interaction to replace dimensionality reduction, while other operations remained largely unchanged.

[0057] The ECA module is designed to enable information exchange along local cross-paths, therefore the interaction channel must be configured. The approximate coverage area is determined based on the information interaction between channels (i.e., shared weight). ) and channel dimension The relationship is expressed by (1). and Potential relationships.

[0058] (1)

[0059] The linear function has certain limitations in some related characteristics, and the dimension of the channel is generally an exponent of 2. Therefore, an exponential function with a base of 2 is introduced in (2). In this paper, the values ​​of Y and b are set to 2 and 1, respectively, without any changes.

[0060] (2)

[0061] Therefore, given the channel dimension kernel size It can be calculated from (3):

[0062] (3)

[0063] Calculate the weight for each channel.

[0064] Based on the characteristics of ECA local cross-channel, this process can be summarized into a band matrix, as shown in (4). This matrix represents the bands starting from the current channel and... Connections between neighboring passages.

[0065] (4)

[0066] Therefore, each channel and its The relationship between neighboring channels can be summarized by (5). To better understand the meaning of this formula, this article will illustrate it with an example. Assume the current number of channels... , substitute into formula 3-1, and the solution is Substituting these values ​​into formula 3-3, we can calculate the weight of each channel. Indicates from The beginning A neighbor.

[0067] (5)

[0068] However, in order to further simplify the calculation and improve the network operating efficiency, the initial weight values ​​are all shared, resulting in (6).

[0069] (6)

[0070] The specific implementation steps of step 4 are as follows:

[0071] Loading pre-trained weights from YOLOv5s improves the speed and accuracy of network training;

[0072] The preprocessed dataset is divided into training and test sets and then fed into the network.

[0073] Set the bath size to 16, epochs to 100, input size to 640, and use the default hyperparameter settings;

[0074] Precision and Recall are selected as metrics to evaluate the model, and the formulas are as follows:

[0075] (7)

[0076] (8)

[0077] Where TP represents a positive sample correctly identified, FP represents a negative sample correctly identified as a positive sample, and FN represents a negative sample correctly identified. To address the divergence problem of IOU during training, CIOU is used as the loss function for the bounding box. CIOU considers the distance between the target and the anchor, the overlap rate, the scale, and the penalty factor, thereby enhancing the stability of the target box regression and accelerating the convergence speed of the regression between the predicted box and the ground truth box. The formula is as follows:

[0078] (9)

[0079] (10)

[0080] (11)

[0081] in, For the weight function, The aspect ratios of the predicted bounding box and the ground truth bounding box are: Let Euclidean distance be the center point of the predicted bounding box and the ground truth bounding box. To find the diagonal distance that simultaneously includes the minimum closure region of both the predicted and ground truth bounding boxes; finally, substitute it into... The loss function is obtained, and its formula is as follows:

[0082] (12)

[0083] The specific implementation steps of step 5 are as follows:

[0084] The performance metrics of the trained model, such as Precision, ReECAll, F1 score, map, and loss function, are tested; real-world passenger videos are input into the network to test the confidence level of the network's recognition.

[0085] The specific implementation steps of step 6 are as follows:

[0086] The system extracts data on workers wearing safety helmets before and after entering the factory, obtaining real-time worker flow data on helmet wearing, calculating helmet wearing time, and the time different people stay in a certain factory area. All this data is transmitted to the data management module, which organizes the data and transmits it to the corresponding data modules. The helmet pattern recognition system obtains the helmet wearing status and reminds workers in the factory area who are not wearing helmets in time based on those who are wearing helmets correctly.

Claims

1. A method for detecting helmet wearing in industrial areas based on YOLOv5, characterized in that, The method constructs an image detection network model for helmet pattern recognition. The helmet pattern recognition module extracts data from the image model and assigns traffic modes based on real-time conditions, specifically including the following steps: 1) Create a safety helmet dataset for target detection in a safety helmet recognition system; 2) Configure the network environment using the deep learning PyTorch framework, and build the YOLOv5 model within this environment; 3) An ECA attention mechanism was added to the original YOLOv5 model framework to optimize the model; 4) Use the preprocessed dataset as input to the network for training, load the YOLOv5s pre-trained weights, and use CIOU as the loss function; 5) Videos of workers entering the factory area wearing safety helmets were used to test the network model; 6) The helmet pattern recognition module organizes the helmet conditions detected by the system and determines the appropriate helmet pattern based on the helmet data; After the model training is completed and tested, the safety helmet wearing detection system uses a target detection network to extract the safety helmet wearing status of workers. The system records each worker who enters wearing a safety helmet correctly. At certain intervals, it records data on correctly worn and incorrectly worn safety helmets and transmits the data to the information management module for optimization of safety helmet detection. The safety helmet pattern recognition module obtains the safety helmet data from the target detection and selects a pattern suitable for the current situation based on the real-time detected pedestrian flow data.

2. The method for detecting helmet wearing in industrial areas based on YOLOv5 according to claim 1, characterized in that, The system preprocesses the image dataset of the input model; for fire pattern recognition, the dataset uses image data of workers in the unfinished factory area or workers who have already entered the factory area. The process involves collecting and processing video footage from surveillance equipment frame by frame to obtain images of passengers under various conditions. Images of workers wearing safety helmets are collected, organized, and converted to JPG format. The image data is then labeled using the labelimg tool, and the labels are output in XML format. Since YOLO uses TXT for labeling, code is needed to convert the XML labels to TXT format. During network training, the data needs to be divided into training and testing sets. Here, 80% of the dataset is used as the training set, and the remaining 20% ​​is used as the testing set.

3. The method for detecting helmet wearing in a YOLOv5 industrial zone according to claim 1, characterized in that, The image dataset was preprocessed to build an image processing object detection model. The model architecture consists of four parts: input, backbone, Neck, and head. The input layer processes the input images, using Mixup data augmentation, adaptive anchor box calculation, and adaptive image scaling to improve the training speed and network accuracy. The backbone uses Focus and ASP structures to build a neural network for image features. The Neck uses FPN+PAN structure to enhance the network's feature fusion capability. The head uses CIOU as the loss function to predict image features and generate bounding boxes and class confidence scores. The model loads YOLOv5 pre-trained weights with an initial learning rate of 0.01, momentum of 0.959, loss gain of 0.55, and CIOU as the loss function. The remaining parameters use default values.

4. The method for detecting helmet wearing in a YOLOv5 industrial zone according to claim 1, characterized in that, To further improve the accuracy of the object detection model, an ECA attention mechanism was used to optimize the network model. This mechanism was added to the completed YOLOv5 backbone network, embedding positional information into channel attention to obtain attention weights on the height and width of the feature map. Finally, by incorporating these attention weights into the original feature map, the network's detection accuracy was enhanced. The ECA attention mechanism formula is as follows: (1) Compared to the initial model, the model with the added ECA attention mechanism showed a 0.7% increase in map size, which is significant for the model's helmet-wearing detection.

5. The method for detecting helmet wearing in industrial areas based on YOLOv5 according to claim 1, characterized in that, To optimize the model, set parameters such as the number of data sheets input into the network at one time, the number of training rounds, and the number of worker threads, and start training the model. After the model training is completed, check whether the model's performance metrics are reasonable, turn on the camera to detect the input data, and check the confidence of the predicted bounding boxes.

Citation Information

Patent Citations

  • Safety helmet wearing detection method, system and device and storage medium

    CN112926405A

  • Lightweight YOLO v4 security protection detection method based on attention mechanism improvement

    CN113516076A