SGR-YOLO model-based safety equipment detection method and system

By introducing the SGR-YOLO model on the Yolov5 model, using MobileNetV3 and Bi-FPN for feature extraction and fusion, and introducing the CBAM attention mechanism, the problem of Yolov5's accuracy and speed reduction in complex construction environments is solved, achieving more efficient Safety equipment inspection.

CN119495112APending Publication Date: 2025-02-21LIAOCHENG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411486134.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-23
Publication Date
2025-02-21

AI Technical Summary

Technical Problem

In complex construction environments, when the Yolov5 algorithm is deployed in embedded devices, there are problems of missed and missed targets, and the accuracy and speed are deteriorated.

Method used

Using the security equipment detection method based on the SGR-YOLO model, by using the MobileNetV3 network as the backbone network for feature extraction, the bidirectional feature pyramid network Bi-FPN is used for multi-scale feature fusion, and the CBAM attention mechanism module is introduced to optimize the prediction box and regression. Loss function.

Benefits of technology

It improves the detection accuracy and speed of safety equipment in complex environments, reduces the missed detection rate, and adapts to the lightweight needs of embedded equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119495112A_ABST
    Figure CN119495112A_ABST
Patent Text Reader

Abstract

The invention provides a security equipment detection method and system based on an SGR-YOLO model, and belongs to the technical field of security equipment detection.The method comprises the steps that a security equipment image is obtained, the security equipment image is preprocessed, and the preprocessed security equipment image is divided into a training set, a test set and a verification set; training the SGR-YOLO model by using the training set and the verification set to obtain the weight of the trained SGR-YOLO model; and evaluating the trained SGR-YOLO model by using the evaluation index, and inputting the test set into the trained SGR-YOLO model to obtain a detection result of whether the constructor wears the safety equipment or not. According to the invention, the problems of poor lightweighting and low detection precision of the yolov5 algorithm during landing deployment in the embedded equipment are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of safety equipment detection, and in particular relates to a safety equipment detection method and system based on an SGR-YOLO model. Background Art

[0002] Due to the complex construction environment, large flow of personnel and simultaneous operation of different machines at construction sites, workers often face potential safety risks during their work. If effective safety protection measures are not taken, various safety accidents may occur, resulting in casualties and property losses. Workers must wear safety helmets and safety vests during construction. However, in actual work, due to a lack of safety awareness, construction workers often fail to wear safety equipment, which leads to serious safety accidents and causes loss of life and property.

[0003] At present, construction companies usually adopt two aspects of safety supervision: manual supervision and monitoring supervision. Manual supervision of safety production is prone to problems such as failure to implement safety production responsibilities and waste of human resources. Supervision through monitoring may cause problems such as blind spots in the monitoring screen that cannot be supervised, low detection accuracy and poor real-time performance.

[0004] In recent years, with the continuous development of target detection technology, certain results have been achieved in the research of safety equipment detection. After actual deployment and testing in a large number of industries and scenarios, the Yolov5 algorithm stands out. Its fast detection speed and high accuracy have attracted the attention of experts and scholars. However, when the Yolov5 model is deployed in embedded devices, it cannot effectively detect targets in complex construction environments, and it is prone to small target missed detection and false detection problems, and the accuracy and speed are seriously deteriorated. Therefore, how to avoid the problem of small target missed detection and false detection when detecting safety equipment in complex environments, while ensuring its lightweight, is a problem that technical personnel in this field urgently need to solve. Summary of the invention

[0005] In view of the above-mentioned deficiencies in the prior art, the present invention provides a safety equipment detection method and system based on the SGR-YOLO model, which solves the problem of reduced accuracy and speed of the Yolov5 algorithm when deployed in embedded devices.

[0006] In order to achieve the above objectives, the technical solution adopted by the present invention is: a safety equipment detection method based on the SGR-YOLO model, comprising the following steps:

[0007] S1. Acquire safety equipment images, preprocess the safety equipment images, and divide the preprocessed safety equipment images into a training set, a test set, and a verification set;

[0008] S2. Use the training set and the validation set to train the SGR-YOLO model to obtain the trained SGR-YOLO model weights;

[0009] S3. Use the evaluation indicators to evaluate the trained SGR-YOLO model, and based on the evaluation results, input the test set into the trained SGR-YOLO model to obtain the detection results of whether the construction workers are wearing safety equipment.

[0010] The beneficial effects of the present invention are as follows: the present invention selects dimly lit images of construction scenes from safety equipment images to perform adaptive transformation processing Gamma image enhancement; uses annotation software to annotate targets in the images and divides them into training sets, test sets and verification sets; uses MobileNetV3 network as a backbone network in an improved Yolov5 network to extract features and reduce the number of network parameters; applies a bidirectional feature pyramid network Bi-FPN in a Neck part to fuse multi-scale features and adapt to target scale changes caused by photographic distance; introduces a CBAM attention mechanism module to combine channel and spatial attention to adapt to feature representation requirements of small targets; optimizes prediction boxes and regression loss functions to improve the convergence speed in network training and reduce the missed detection rate; uses an evaluation index to evaluate an SGR-YOLO model; and inputs a test set into the trained SGR-YOLO model to obtain a detection result of whether construction personnel are wearing safety equipment; and solves the problem of reduced accuracy and speed of the Yolov5 algorithm when deployed in embedded devices.

[0011] Furthermore, the step S1 includes the following steps:

[0012] S101, obtaining a safety equipment image;

[0013] S102, selecting an image of a construction scene with dim light from the acquired safety equipment images, and performing image enhancement processing to obtain an enhanced safety equipment image;

[0014] S103: annotate the objects in the data set of the safety equipment images after image enhancement, and divide the data set into a training set, a test set, and a validation set.

[0015] The beneficial effect of the above further solution is that by enhancing the safety equipment image, the quality and information content of the image can be effectively improved, thereby improving the accuracy of the target detection model.

[0016] Furthermore, the SGR-YOLO model is specifically:

[0017] Based on the basic framework of YOLOv5, the MobileNetV3 network is used as the backbone network for feature extraction of safety equipment images. The bidirectional feature pyramid network Bi-FPN is applied to the Neck part to adopt a weighted fusion method of normalized fusion to balance the weight mechanism between different feature levels to fuse multi-scale features. The attention mechanism module CBAM is introduced to combine channel and spatial attention and optimize the prediction box and regression loss function.

[0018] The beneficial effects of the above further scheme are: by using MobileNetV3 as the backbone network for feature extraction, the network parameters and computing memory are greatly reduced, and the network operation performance is improved. The application of the bidirectional feature pyramid network Bi-FPN in the Neck part can achieve simple and fast multi-scale feature fusion, meeting the real-time requirements of more efficient and miniaturized embedded target detection. Introducing the attention mechanism module CBAM in the feature extraction part enables the network to effectively extract key features, thereby further improving the accuracy of target detection, and can cope with various complex weather conditions in outdoor construction application scenarios.

[0019] Furthermore, the MobileNetV3 network includes a depth-separable convolution and an h-swish activation function;

[0020] The depthwise separable convolution is used to split the received multiple feature maps into feature maps of a single channel, perform a single-channel convolution operation on the split feature maps, stack the results of the convolution operation, and perform a point-by-point convolution operation on the stacked feature maps;

[0021] The expression of the h-swish activation function is as follows:

[0022]

[0023] ReLU6(x)=min(max(x,0),6)

[0024] Among them, h-swish(x) represents the h-swish activation function, ReLU6(x) represents the ReLU6 function, which is a variant of the rectified linear unit function ReLU, and x represents the input variable.

[0025] The beneficial effects of the above further scheme are: MobileNetV3 network architecture is lightweight, requires less computation, and is suitable for real-time detection. It captures key information, suppresses redundant information, has strong feature extraction capabilities, and can improve detection accuracy.

[0026] Furthermore, the bidirectional feature pyramid network Bi-FPN is specifically:

[0027] Based on the feature pyramid network FPN structure, the intermediate nodes at the highest dimensional feature layer and the lowest dimensional feature layer are deleted, and the residual edges connecting the input feature map and the output feature map are added to each feature layer at the intermediate position.

[0028] The beneficial effect of the above further scheme is: on the basis of the feature pyramid network FPN structure, the intermediate nodes located at the highest dimensional feature layer and the lowest dimensional feature layer are deleted, and the residual edges connecting the input feature map and the output feature map are added to each feature layer located in the middle position, which can improve the feature extraction efficiency, enhance the feature fusion capability and improve the model robustness, so that the model can better perform safety equipment detection.

[0029] Furthermore, the weight mechanism is expressed as follows:

[0030]

[0031] Among them, i, j both represent the number of feature maps input at the node of feature fusion, i = j, ω i and ω j They all represent the weights of each input feature map, and the initial range of the weights is 0<ω i <1,0<ω j <1, after each weight training, the ReLU activation function will be used to ensure ω i The value is always greater than 0, ε represents a constant, I i Represents the feature map matrix.

[0032] The beneficial effect of the above further scheme is that the fast normalized fusion weighted fusion method of Bi-FPN is an effective and efficient feature fusion method, which can improve the effectiveness of feature fusion, enhance the robustness of the model and reduce the computational complexity of the model, so that the model can better perform safety equipment detection.

[0033] Furthermore, the expression of the attention mechanism module CBAM is as follows:

[0034] F'=M s (M c (F)·F)·(M c (F)·F)

[0035] M s (F) = σ(f 5×5 [Avg(F);Max(F)])

[0036] M c (F)=σ{MLP[Avg(F)]+MLP[Max(F)]}

[0037] Among them, F' represents the feature map of the final output, Mc (F) represents the channel attention obtained by the CAM submodule, F represents the input feature map, M s (F) represents the channel attention obtained by the SAM submodule, σ represents the Sigmoid activation function, and f 5×5 represents a convolution kernel with a side length of 5, Avg represents average pooling, Max represents global maximum pooling, and MLP represents a fully connected hidden layer and a fully connected output layer.

[0038] The beneficial effects of the above further scheme are: the attention mechanism module CBAM is an effective and efficient attention mechanism, which can significantly improve the feature extraction ability of the model, and has multiple beneficial effects such as improving accuracy, enhancing robustness, improving generalization ability and reducing computational complexity.

[0039] Furthermore, the expressions of the optimized prediction box and regression loss function are as follows:

[0040] L CIoU =1-CIoU

[0041] CIoU=IoU-p 2 (b,b gt ) / c 2 -av

[0042]

[0043] a=v / ((1-IoU)+v)

[0044]

[0045] Among them, S i represents the score of the nth bounding box, IoU represents the measure of overlap between two bounding boxes, B M represents the prediction box with the highest score, B i Represents the predicted box of the current score, when B i and B M The intersection over union (IoU) is greater than or equal to N t Abandon B i , less than N t If B i , N t represents the overlap threshold, σ represents the scaling factor, a represents the measure of aspect ratio and overlap similarity, v represents the quantification of the aspect ratio difference between the true bounding box and the predicted bounding box, and w gt Indicates the width of the ground truth bounding box, h gt represents the height of the true bounding box, w represents the width of the predicted bounding box, h represents the height of the predicted bounding box, CIoU represents the regression loss function, and represents the difference between the predicted bounding box and the true bounding box.2 () represents the Euclidean distance, b and b gt They represent the center points of the real box and the predicted box respectively, c represents the shortest diagonal distance corresponding to the minimum encirclement of the real box and the predicted box, a represents the positive balance parameter of the aspect ratio of the two boxes, and L CIoU It is used to measure the similarity between the predicted bounding box and the true bounding box.

[0046] The beneficial effect of the above further scheme is: by optimizing the prediction box and the regression loss function, the convergence speed in the network training can be improved, and a higher regression box positioning accuracy can be obtained, which can reduce the probability of missed detection due to occlusion.

[0047] The present invention provides a safety equipment detection system based on the SGR-YOLO model, comprising:

[0048] The first processing module is used to obtain safety equipment images, pre-process the safety equipment images, and divide the pre-processed safety equipment images into a training set, a test set, and a verification set;

[0049] The second processing module is used to train the SGR-YOLO model using the training set and the validation set to obtain the trained SGR-YOLO model weight;

[0050] The third processing module is used to evaluate the trained SGR-YOLO model using the evaluation index, and input the test set into the trained SGR-YOLO model to obtain the detection result of whether the construction workers are wearing safety equipment.

[0051] The beneficial effects of the present invention are as follows: the present invention selects dimly lit images of construction scenes from safety equipment images to perform adaptive transformation processing Gamma image enhancement; uses annotation software to annotate targets in the images and divides them into training sets, test sets and verification sets; uses MobileNetV3 network as a backbone network in an improved yolov5 network to extract features and reduce the number of network parameters; applies a bidirectional feature pyramid network Bi-FPN in a Neck part to fuse multi-scale features and adapt to target scale changes caused by photographic distance; introduces a CBAM attention mechanism module to combine channel and spatial attention to adapt to feature representation requirements of small targets; optimizes prediction boxes and regression loss functions to improve convergence speed in network training and reduce missed detection rate; uses an evaluation index to evaluate an SGR-YOLO model; and inputs a test set into the trained SGR-YOLO model to obtain a detection result of whether construction workers wear safety equipment; and solves the problem of reduced accuracy and speed of the Yolov5 algorithm when deployed in embedded devices. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1The present invention is a flow chart of the method.

[0053] Figure 2 This is a structural diagram of the MobileNetV3-YOLOv5 network provided in this embodiment.

[0054] Figure 3 Schematic diagram of the structure of the original FPN module and the Bi-FPN module provided in this embodiment.

[0055] Figure 4 Schematic diagram of the structure of the attention mechanism module CBAM provided in this embodiment.

[0056] Figure 5 Box loss, target loss, classification loss, precision, recall, average precision, and mean average precision curves during training and validation set training in the SGR-YOLO model provided in this embodiment.

[0057] Figure 6 A comparison chart of the effects of the Yolov5s model and the SGR-YOLO model provided in this embodiment on test set detection.

[0058] Figure 7 It is a schematic diagram of the system structure of the present invention. DETAILED DESCRIPTION

[0059] The specific implementation modes of the present invention are described below so that those skilled in the art can understand the present invention. However, it should be clear that the present invention is not limited to the scope of the specific implementation modes. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations utilizing the concept of the present invention are protected.

[0060] Before describing the present invention, the following terms are explained:

[0061] SGR-YOLO model: The SGR-YOLO model is an improved model based on the yolov5s network, which can detect safety equipment images.

[0062] MobileNetV3 network: MobileNetV3 is a lightweight neural network architecture designed to provide high efficiency and high performance when running on mobile and embedded devices.

[0063] Neck part: In the model architecture of target detection, Neck usually refers to the middle part of the network, located between the backbone feature extraction network (backbone) and the final detection head (head).

[0064] LabelImg software: LabelImg software is an open source image annotation tool for creating and editing annotations for image datasets.

[0065] Gamma parameter: Gamma parameter usually refers to an important parameter in gamma correction. It can adjust the brightness and contrast of the image to make the display effect more natural and accurate.

[0066] CAM Submodule: The CAM channel attention submodule is mainly used to understand the spatial localization of the model's decision-making process in classification tasks. Specifically, it can help determine the areas that the model focuses on in the image and associate these areas with the final classification results.

[0067] SAM submodule: The SAM spatial attention submodule mainly enhances the model's perception ability in specific areas by learning and applying the spatial attention mechanism, thereby improving the performance and effect of the model in visual tasks.

[0068] NMS algorithm: NMS non-maximum suppression algorithm is a commonly used technology in target detection, which is mainly used to screen and eliminate redundant detection boxes, thereby improving the accuracy and stability of detection results.

[0069] Soft-NMS algorithm: The main idea of ​​the Soft-NMS soft non-maximum suppression algorithm is not to completely remove the box when suppressing overlapping boxes, but to gradually reduce its confidence, thereby retaining some information of low-confidence boxes to a certain extent.

[0070] Example 1

[0071] like Figure 1 As shown, the present invention provides a safety equipment detection method based on the SGR-YOLO model, and its implementation method is as follows:

[0072] S1. Obtain safety equipment images, preprocess the safety equipment images, and divide the preprocessed safety equipment images into a training set, a test set, and a verification set. The implementation method is as follows:

[0073] S101, obtaining a safety equipment image;

[0074] S102, selecting an image of a construction scene with dim light from the acquired safety equipment images, and performing image enhancement processing to obtain an enhanced safety equipment image;

[0075] S103: annotate the objects in the data set of the safety equipment images after image enhancement, and divide the data set into a training set, a test set, and a validation set.

[0076] In this embodiment, an image of safety equipment is obtained from the Internet, an image of a construction scene with dim light is selected from the image of safety equipment, and an image enhancement method using adaptive transformation processing Gamma is used to obtain an enhanced image of safety equipment; adaptive transformation processing Gamma specifically involves exponential transformation of image pixels, correcting Gamma parameters according to the mean brightness of the image, and adjusting images of different light intensities. LabelImg software is used to manually label various types of target detection objects in the enhanced safety equipment image, and the five categories are helmet, no-helmet, vest, no-vest, and person, and a txt file of annotation information is generated, including the number of target objects, coordinates, and other information, which is divided into training set, test set, and verification set in a ratio of 7:2:1 through a python script.

[0077] S2. Use the training set and the validation set to train the SGR-YOLO model to obtain the trained SGR-YOLO model weights, which are specifically:

[0078] Based on the basic framework of YOLOv5, the MobileNetV3 network is used as the backbone network for feature extraction of safety equipment images. The bidirectional feature pyramid network Bi-FPN is applied to the Neck part to adopt a weighted fusion method of normalized fusion to balance the weight mechanism between different feature levels to fuse multi-scale features. The attention mechanism module CBAM is introduced to combine channel and spatial attention and optimize the prediction box and regression loss function.

[0079] In this embodiment, the SGR-YOLO model is trained by a python program.

[0080] In this embodiment, the MobileNetV3 network is used as the backbone network for feature extraction. The structure of the MobileNetV3-YOLOv5 network is as follows: Figure 2 As shown in the figure, the MobileNetV3 network structure includes a deep separable convolution and an h-swish activation function, wherein the deep separable convolution is used to split the received multiple feature maps into feature maps of a single channel, and perform a single-channel convolution operation on the split feature maps, and stack the results of the convolution operation, and perform a point-by-point convolution operation on the stacked feature maps;

[0081] In this embodiment, depthwise separable convolution is used. For the multi-channel feature maps from the previous layer, they are first split into feature maps of a single channel, and single-channel convolution is performed on them respectively. Then, they are stacked together again, and only the size of the feature map of the previous layer is adjusted without changing the number of channels. Then, the feature map obtained previously is convolved point by point, and the size of the convolution kernel is 1×1. The filter contains the convolution kernel with the same number of channels as the previous layer, and each filter outputs 1 feature map.

[0082] In this embodiment, the h-swish activation function uses ReLU6 instead of the sigmoid function to improve the swish function. The expression of the h-swish activation function is as follows:

[0083]

[0084] ReLU6(x)=min(max(x,0),6)

[0085] Among them, h-swish(x) represents the h-swish activation function, ReLU6(x) represents the ReLU6 function, which is a variant of the rectified linear unit function ReLU, and x represents the input variable.

[0086] In this embodiment, the bidirectional feature pyramid network Bi-FPN is specifically as follows: based on the FPN structure, the intermediate nodes located at the highest dimensional feature layer and the lowest dimensional feature layer are deleted, and a residual edge connecting the input feature map and the output feature map is added to each feature layer located at the intermediate position.

[0087] In this embodiment, a bidirectional feature pyramid network Bi-FPN is applied in the Neck part to fuse multi-scale features. The bidirectional feature pyramid network Bi-FPN is a weighted bidirectional feature fusion structure that can achieve simple and fast multi-scale feature fusion. The structure of the bidirectional feature pyramid network Bi-FPN is as follows: Figure 3 As shown in the figure, it is improved on the basis of the traditional FPN structure. On the one hand, the intermediate nodes at the highest dimensional feature layer and the lowest dimensional feature layer are deleted respectively. On the other hand, the residual edge connecting the input feature map and the output feature map is added to each feature layer at the intermediate position. The bidirectional feature pyramid network Bi-FPN adopts a weighted fusion method of fast normalized fusion, which is used to balance the weight mechanism of importance between different feature levels. The principle of the weight mechanism is:

[0088]

[0089] Among them, i, j both represent the number of feature maps input at the node of feature fusion, i = j, ω i and ω j They all represent the weights of each input feature map, and the initial range of the weights is 0<ωi <1,0<ω j <1, after each weight training, the ReLU activation function will be used to ensure ω i The value is always greater than 0, ε represents a constant, I i Represents the feature map matrix.

[0090] In this embodiment, a CBAM attention mechanism module is introduced to combine channel and spatial attention.

[0091] In this embodiment, in the CNN network, the attention mechanism acts on the feature map to obtain more important feature information under limited computing power, solve the problem of information overload, and improve the efficiency and accuracy of network processing; the CBAM attention mechanism module is divided into two sub-block modules: the CAM channel attention module and the SAM spatial attention module. The feature map in the middle of the network is reconstructed through the two modules to highlight important features and suppress general features to improve the final detection effect. The structure of the attention mechanism module CBAM is as follows: Figure 4 shown.

[0092] In this embodiment, the CAM submodule considers the relationship between feature map channels and determines the importance of pixels. The input feature map uses global maximum pooling and average pooling on each channel, and then enters the multi-layer perceptron for dimensionality reduction and dimensionality increase operations, and then performs addition operations and Sigmoid activation, and finally obtains channel attention MC (F). The principle of the CAM submodule is:

[0093] M c (F)=σ{MLP[Avg(F)]+MLP[Max(F)]}

[0094] In this embodiment, the SAM submodule uses maximum pooling and average pooling to compress the channel, and then uses convolution to make the number of channels of the final feature map 1. After activation by the Sigmoid function, the network model pays more attention to the more important pixel areas in the target detection task and ignores the less important areas. The principle of the SAM submodule is:

[0095] M s (F) = σ(f 5×5 [Avg(F);Max(F)])

[0096] In summary, the principle of the attention mechanism module CBAM is:

[0097] F'=M s (M c (F)·F)·(M c (F)·F)

[0098] Among them, F' represents the feature map of the final output, Mc (F) represents the channel attention obtained by the CAM submodule, F represents the input feature map, M s (F) represents the channel attention obtained by the SAM submodule, σ represents the Sigmoid activation function, and f 5×5 represents a convolution kernel with a side length of 5, Avg represents average pooling, Max represents global maximum pooling, and MLP represents a fully connected hidden layer and a fully connected output layer.

[0099] In this embodiment, optimizing the prediction box and the regression loss function includes optimizing the loss function and improving the NMS algorithm.

[0100] In this embodiment, the YOLOv5 algorithm uses GIoU as the regression box loss function; GIoULoss introduces the minimum bounding rectangle of the predicted box and the true box based on the original function; assuming that A is the predicted box, B is the true box, and C is the minimum convex closed box containing A and B; its calculation formula is as follows:

[0101] GIoU = IoU - |C / (A∪B)| / |C|

[0102] LGIoU=1-GIoU

[0103] Among them, GIoU represents the regression box loss function, IoU represents the measure of overlap between two bounding boxes, calculated as the overlapping area divided by the merged area. A is the predicted box, B is the true box, and C is the minimum convex closed box containing A and B.

[0104] In this embodiment, the GIoULoss loss function value cannot measure the relative position relationship between the predicted box and the real box well. At the same time, it is difficult to optimize the predicted box in the horizontal or vertical direction, resulting in slow convergence. The CIoULoss comprehensively considers the three points of center point distance, coverage area and aspect ratio to solve the problems faced by GIoULoss. The calculation formula is as follows:

[0105] CIoU=IoU-p 2 (b,b gt ) / c 2 -av

[0106] L CIoU =1-CIoU

[0107] α and v are defined as follows:

[0108]

[0109] a=v / ((1-IoU)+v)

[0110] In this embodiment, the improved NMS algorithm is to introduce the Soft-NMS algorithm to replace NMS to process the prediction stage of target detection. The specific principle of the Soft-NMS algorithm is:

[0111]

[0112] Among them, S i represents the score of the nth bounding box, IoU represents the measure of overlap between two bounding boxes, B M represents the prediction box with the highest score, B i Represents the predicted box of the current score, when B i and B M The intersection over union (IoU) is greater than or equal to N t Abandon B i , less than N t If B i , N t represents the overlap threshold, σ represents the scaling factor, a represents the measure of aspect ratio and overlap similarity, v represents the quantification of the aspect ratio difference between the true bounding box and the predicted bounding box, and w gt Indicates the width of the ground truth bounding box, h gt represents the height of the true bounding box, w represents the width of the predicted bounding box, h represents the height of the predicted bounding box, CIoU represents the regression loss function, and represents the difference between the predicted bounding box and the true bounding box. 2 () represents the Euclidean distance, b and b gt They represent the center points of the real box and the predicted box respectively, c represents the shortest diagonal distance corresponding to the minimum encirclement of the real box and the predicted box, a represents the positive balance parameter of the aspect ratio of the two boxes, and L CIoU It is used to measure the similarity between the predicted bounding box and the true bounding box. is a Gaussian weighting function, and σ is a hyperparameter selected according to the actual situation; using the Soft-NMS algorithm, M The scores of prediction boxes with a larger degree of overlap are reduced, while the impact on boxes with a smaller degree of overlap is small, which reduces the missed detection rate and improves the accuracy of the algorithm.

[0113] In this embodiment, the training set is input into the SGR-YOLO model for training. The experimental hardware configuration is NVIDIA GeForce GTX 2080Ti, Intel Core i7-7800X@3.5GHz processor, memory 16G, operating system Ubuntu 18.04, deep learning framework Pytorch, CUDA version 11.6, Python version 3.8. The resolution of the input image is set to 640×640, the training batch is 16, the initial learning rate is 0.001, the IoU threshold is set to 0.6, and 100 epochs are trained to obtain the weight of the trained SGR-YOLO model.

[0114] In this embodiment, the training results are as follows: Figure 6 As shown in Table 1, after 100 iterations, the experimental results are shown in Table 1. The box value gradually decreases from 1.4833 at the beginning through the increase and decrease of the number of training times, and finally stabilizes at about 0.44381. The value is small and the training loss is low, indicating that the error between the model prediction frame and the actual frame is small, and the generated training result is relatively accurate; the value of cls is about 0.24866, and the model classification effect is good; precision indicates the accuracy of target recognition, and the accuracy rate can reach about 93.5%, and the accuracy of detecting the target object is relatively high. The recall rate is about 89.7%, indicating that the detection accuracy of the positive sample is good; mAP can finally stabilize at 93%, proving that the model detection accuracy is high. Table 1 is the SGR-YOLO training experiment results table.

[0115] Table 1

[0116]

[0117]

[0118] S3. Use the evaluation index to evaluate the trained SGR-YOLO model, and input the test set into the trained SGR-YOLO model to obtain the detection results of whether the construction workers are wearing safety equipment.

[0119] In this example, the images in the test set are input into the model through a Python program, and the output will show whether safety equipment is worn. The output is as follows Figure 6 shown.

[0120] In this embodiment, Figure 5As shown in the figure, the upper part is the experimental result curve of the SGR-YOLO model on the training set. The lower part is the experimental result curve of the SGR-YOLO model on the validation set. box_loss (bounding box loss): reflects the accuracy of the model's prediction of the target box position. The lower the box_loss, the more accurate the target box position predicted by the model. cls_loss (classification loss): reflects the accuracy of the model's prediction of the target box category. The lower the cls_loss (classification loss), the more accurate the target box category predicted by the model. dfl_loss (size-aware focal loss): reflects the accuracy of the model's prediction of the target box size. The lower the dfl_loss (size-aware focal loss), the more accurate the target box size predicted by the model. Precision: reflects the proportion of the correct target box predicted by the model. The higher the precision, the higher the proportion of the correct target box predicted by the model. Recall: reflects the proportion of the correct target box among all the target boxes predicted by the model. The higher the recall, the higher the proportion of the correct target box predicted by the model. mAP stands for mean average precision. mAP50: reflects the average precision of the model in detecting the target box when the IoU threshold is 0.5. The higher the mAP50, the higher the average precision of the model in detecting the target box when the IoU threshold is 0.5. mAP50-95: reflects the average precision of the model in detecting the target box when the IoU threshold is between 0.5 and 0.95. The higher the mAP50-95, the higher the average precision of the model in detecting the target box when the IoU threshold is between 0.5 and 0.95.

[0121] In this embodiment, in order to evaluate the detection accuracy and speed of the SGR-YOLO model, the model is evaluated using accuracy (Precision), recall (Recall), average precision (AP), mean average precision (mAP) and FPS.

[0122] In this embodiment, the calculation formulas for the detection accuracy evaluation indicators: recall rate Recall and precision Precision are as follows:

[0123]

[0124] Among them, TP is a true positive event, that is, the result given by the model is consistent with the result of the sample and both are positive; FP is a false positive event, that is, the result given by the model is positive, but the result of the sample is negative; FN is a false negative event, the result given by the model is negative, but the sample result is positive.

[0125] In this embodiment, the average precision AP can be obtained according to the values ​​of recall rate and precision. Its original definition is the area enclosed by the Precision-Recall curve and the two coordinate axes. The formula is as follows:

[0126]

[0127] Among them, P(R) represents precision as a function of recall R, and dR represents the differential operation symbol.

[0128] The AP value is used to evaluate the quality of the target detection results of the model in a certain category. The higher the AP value, the more accurate the model is in detecting this category.

[0129] The average AP value of all categories is averaged to get the mean average precision mAP, which is used to measure the overall detection effect of the model. The formula of the mAP value is as follows:

[0130]

[0131] In this embodiment, the detection speed evaluation index is:

[0132] The frame rate FPS is used to evaluate the detection speed of the algorithm model, that is, the number of images that can be processed per second. When comparing FPS, it needs to be performed on the same hardware. This example evaluates FPS on the Ascend Atlas 200IDK A2 device. The higher the FPS value, the faster the detection speed.

[0133] In this embodiment, the original YOLOv5s model and the SGR-YOLO model are trained for 100 rounds under the same configuration, and the evaluation comparison of the two models is shown in Table 2. In terms of model size, the SGR-YOLO model weight file is smaller and more lightweight; in terms of detection accuracy, the mAP of the SGR-YOLO model is only slightly improved compared to yolov5s. Considering that the SGR-YOLO model has a smaller number of parameters, it is reasonable that the mAP is less improved; in terms of deploying reasoning on embedded devices, SGR-YOLO has a higher FPS and a faster detection speed. The optimized model is significantly better than the original model. Compared with the original model, the optimized model ensures detection accuracy while improving lightweight, verifying the feasibility of the improved strategy. Table 2 is a performance comparison table of SGR-YOLO and Yolov5s.

[0134] Table 2

[0135]

[0136] In this embodiment, the test set is input into the trained SGR-YOLO model to obtain the detection result of whether the construction workers are wearing safety equipment; Figure 6 The comparison of the test set detection effects of the Yolov5s and SGR-YOLO models is shown in Figure (a). The left figure is the test effect of the Yolov5s model, and the right figure is the test effect of the SGR-YOLO model. It can be seen from the figure that when detecting whether a helmet is worn, the Yolov5s model does not detect the helmet target, while the improved SGR-YOLO model can detect the small target, and the small target detection effect is significantly better. In Figure (b), the left figure is the test effect of the Yolov5s model, and the right figure is the test effect of the SGR-YOLO model. It can be seen from the figure that when detecting whether a vest is not worn, the Yolov5s model does not detect the target without a vest, while the improved SGR-YOLO model can detect the target without a vest, and the detection effect is significantly better.

[0137] Example 2

[0138] like Figure 7 As shown, the present invention provides a safety equipment detection system based on the SGR-YOLO model described in Example 1, including:

[0139] The first processing module is used to obtain safety equipment images, pre-process the safety equipment images, and divide the pre-processed safety equipment images into a training set, a test set, and a verification set;

[0140] The second processing module is used to train the SGR-YOLO model using the training set and the validation set to obtain the trained SGR-YOLO model weight;

[0141] The third processing module is used to evaluate the trained SGR-YOLO model using the evaluation index, and input the test set into the trained SGR-YOLO model to obtain the detection result of whether the construction workers are wearing safety equipment.

[0142] In this embodiment, Figure 7 The safety equipment detection system shown can execute the technical solution shown in the non-safety equipment detection method of the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.

[0143] In this embodiment, the present application can divide the functional units according to the safety equipment detection method. For example, each function can be divided into each functional unit, or two or more functions can be integrated into one processing unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. It should be noted that the division of units in the present invention is schematic and is only a logical division. There may be other division methods in actual implementation.

[0144] In this embodiment, in order to realize the principle and beneficial effect of the safety equipment detection method, the safety equipment detection system includes hardware structures and / or software modules corresponding to the execution of each function. It should be easily appreciated by those skilled in the art that, in combination with the schematic units and algorithm steps described in the embodiments disclosed in the present invention, the present invention can be implemented in the form of hardware and / or a combination of hardware and computer software, and whether a function is executed in a hardware or computer software driven manner depends on the specific application and design constraints of the technical solution. Different methods can be used for each specific application to implement the described function, but such implementation should not be considered to exceed the scope of this application.

Claims

1. A safety equipment detection method based on the SGR-YOLO model, characterized in that: The following steps are involved: S1. Acquire safety equipment images, preprocess the safety equipment images, and divide the preprocessed safety equipment images into a training set, a test set, and a verification set; S2. Use the training set and the validation set to train the SGR-YOLO model to obtain the trained SGR-YOLO model weights; S3. Use the evaluation indicators to evaluate the trained SGR-YOLO model, and based on the evaluation results, input the test set into the trained SGR-YOLO model to obtain the detection results of whether the construction workers are wearing safety equipment.

2. The safety equipment detection method based on the SGR-YOLO model according to claim 1, characterized in that: The step S1 comprises the following steps: S101, obtaining a safety equipment image; S102, selecting an image of a construction scene with dim light from the acquired safety equipment images, and performing image enhancement processing to obtain an enhanced safety equipment image; S103: annotate the objects in the data set of the safety equipment images after image enhancement, and divide the data set into a training set, a test set, and a validation set.

3. The safety equipment detection method based on the SGR-YOLO model according to claim 1, characterized in that: The SGR-YOLO model is specifically: Based on the basic framework of YOLOv5, the MobileNetV3 network is used as the backbone network to extract the features of security equipment images. The bidirectional feature pyramid network Bi-FPN is applied to the Neck part to use the weighted fusion method of normalized fusion to balance the weight mechanism between different feature levels to fuse multi-scale features. The attention mechanism module CBAM is introduced to combine channel and spatial attention and optimize the prediction box and regression loss functions.

4. The safety equipment detection method based on the SGR-YOLO model according to claim 3 is characterized in that: The MobileNetV3 network includes a deep separable convolution and an h-swish activation function; The depthwise separable convolution is used to split the received multiple feature maps into feature maps of a single channel, perform a single-channel convolution operation on the split feature maps, stack the results of the convolution operation, and perform a point-by-point convolution operation on the stacked feature maps; The expression of the h-swish activation function is as follows: ReLU6(x)=min(max(x,0),6) Among them, h-swish(x) represents the h-swish activation function, ReLU6(x) represents the ReLU6 function, which is a variant of the rectified linear unit function ReLU, and x represents the input variable.

5. The safety equipment detection method based on the SGR-YOLO model according to claim 3 is characterized in that: The bidirectional feature pyramid network Bi-FPN is specifically: Based on the feature pyramid network FPN structure, the intermediate nodes at the highest dimensional feature layer and the lowest dimensional feature layer are deleted, and the residual edges connecting the input feature map and the output feature map are added to each feature layer at the intermediate position.

6. The safety equipment detection method based on the SGR-YOLO model according to claim 5, characterized in that: The expression of the weight mechanism is as follows: Among them, i, j both represent the number of feature maps input at the node of feature fusion, i = j, ω i and ω j They all represent the weights of each input feature map, and the initial range of the weights is 0<ω i <1,0<ω j <1, after each weight training, the ReLU activation function will be used to ensure ω i The value is always greater than 0, ε represents a constant, I i Represents the feature map matrix.

7. The safety equipment detection method based on the SGR-YOLO model according to claim 3 is characterized in that: The expression of the attention mechanism module CBAM is as follows: F'=M s (M c (F)·F)·(M c (F)·F) M s (F)=σ(f 5×5 [Avg(F);Max(F)]) M c (F)=σ{MLP[Avg(F)]+MLP[Max(F)]} Among them, F' represents the feature map of the final output, M c (F) represents the channel attention obtained by the CAM submodule, F represents the input feature map, M s (F) represents the channel attention obtained by the SAM submodule, σ represents the Sigmoid activation function, and f 5×5 represents a convolution kernel with a side length of 5, Avg represents average pooling, Max represents global maximum pooling, and MLP represents a fully connected hidden layer and a fully connected output layer.

8. The safety equipment detection method based on the SGR-YOLO model according to claim 3 is characterized in that: The expressions of the optimized prediction box and regression loss function are as follows: L CIoU =1-CIoU CIoU=IoU-p 2 (b,b gt ) / w 2 -av a=v / ((1-IoU)+v) Among them, S i represents the score of the nth bounding box, IoU represents the measure of overlap between two bounding boxes, B M represents the prediction box with the highest score, B i Represents the predicted box of the current score, when B i and B M The intersection over union (IoU) is greater than or equal to N t Abandon B i , less than N t If B i , N t represents the overlap threshold, σ represents the scaling factor, a represents the measure of aspect ratio and overlap similarity, v represents the quantification of the aspect ratio difference between the true bounding box and the predicted bounding box, and w gt Indicates the width of the ground truth bounding box, h gt represents the height of the true bounding box, w represents the width of the predicted bounding box, h represents the height of the predicted bounding box, CIoU represents the regression loss function, and represents the difference between the predicted bounding box and the true bounding box. 2 () represents the Euclidean distance, b and b gt They represent the center points of the real box and the predicted box respectively, c represents the shortest diagonal distance corresponding to the minimum encirclement of the real box and the predicted box, a represents the positive balance parameter of the aspect ratio of the two boxes, and L CIoU It is used to measure the similarity between the predicted bounding box and the true bounding box.

9. The safety equipment detection system according to any one of claims 1 to 8, characterized in that: include: The first processing module is used to obtain safety equipment images, pre-process the safety equipment images, and divide the pre-processed safety equipment images into a training set, a test set, and a verification set; The second processing module is used to train the SGR-YOLO model using the training set and the validation set to obtain the trained SGR-YOLO model weight; The third processing module is used to evaluate the trained SGR-YOLO model using the evaluation index, and input the test set into the trained SGR-YOLO model to obtain the detection result of whether the construction workers are wearing safety equipment.