Improved YOLO model with attention mechanism and soft non-maximum suppression algorithm for applications in intelligent safety supervision
W. G. Li, Minhui Lin, Chi Zhan · 2025
To address the issues of low detection accuracy and the impact of cumulative errors in existing construction site safety detection studies, we propose an improved YOLOv5-based intelligent detection algorithm for construction site safety. First, to enhance the sensitivity of existing algorithms to important image features, we integrated a Spatial Transformer Network (STN) into the backbone network of YOLOv5, aiming to improve the feature extraction capabilities of the backbone. Second, we modified the convolutional layer (Conv) in the CBL module to a Spatial Attention Convolution (SAConv), making the Neck section more sensitive to spatial features. Finally, we employed an improved non-maximum suppression algorithm, Soft-NMS, to enhance the performance of the YOLOv5 model. Unlike the traditional NMS algorithm, which directly removes highly overlapping detection boxes, Soft-NMS reduces the confidence of overlapping boxes to retain more detection results, thereby improving detection recall and accuracy. The experimental results are as follows: on our self-constructed helmet-wearing detection dataset, we achieved an average accuracy of 95.9%, with a helmet detection average accuracy of 96.5% and a worker head detection average accuracy of 95.2%. Compared to the YOLOv5 algorithm, our model demonstrates a 3% improvement in average precision for helmet detection, meeting the precision requirements for helmet-wearing detection in complex construction scenarios.