-
摘要:
针对现有安全帽检测算法难以检测小目标、密集目标等缺点,提出一种基于YOLOv5s的安全帽检测改进算法。采用DenseBlock模块来代替主干网络中的切片结构,提升网络的特征提取能力;在网络颈部检测层加入SE-Net通道注意力模块,引导模型更加关注小目标信息的通道特征,以提升对小目标的检测性能;对数据增强方式进行改进,丰富小尺度样本数据集;增加一个检测层以便能更好地学习密集目标的多级特征,从而提高模型应对复杂密集场景的能力。此外,构建一个面向密集目标及远距离小目标的安全帽检测数据集。实验结果表明:所提改进算法比原始YOLOv5s算法平均精确率(mAP@0.5)提升6.57%,比最新的YOLOX-L及PP-YOLOv2算法平均精确率分别提升1.05%与1.21%,在密集场景及小目标场景下具有较强的泛化能力。
-
关键词:
- 安全帽检测 /
- YOLOv5s算法 /
- 数据增强 /
- DenseBlock模块 /
- SE-Net注意力模块
Abstract:A YOLOv5s-based helmet detection improvement method is developed in an effort to address the drawbacks of existing safety helmet recognition algorithms, which include difficulty detecting small targets and dense targets. The DenseBlock module is used to replace the slice structure in the backbone network, which improves the feature extraction capability of the network; the SE-Net channel attention module is added to the network neck detection layer, which leads the model to pay more attention to the channel characteristics of small target information, thus improving the performance effect of small objects; the data enhancement method is improved to enrich the small-scale sample data set. A detection layer is added to the model to help it learn multi-level aspects of crowded objects and be better able to handle complicated and dense scenarios. In addition, a helmet detection dataset is constructed for dense targets as well as long-distance small targets. The experimental results show that the improved algorithm improves the average accuracy (mAP@0.5) by 6.57% over the original YOLOv5s algorithm, and it is also increased by 1.05% and 1.21% respectively compared with the latest YOLOX-L and PP-YOLOv2 algorithms and has a strong generalization ability in dense scenes and small target scenes.
-
表 1 改进DenseBlock模块前后模型性能对比
Table 1. Comparison of model performance before and after improving DenseBlock module
算法 P/% R/% mAP@0.5/% 参数量 原始YOLOv5s算法 90.71 82.85 81.37 7066239 改进算法(DenseBlock) 91.36 85.78 84.34 7066741 表 2 加入SE-Net模块前后算法性能对比
Table 2. Comparison of algorithm performance before and after adding SE-Net module
% 算法 P R mAP@0.5 原始YOLOv5s算法 90.71 82.85 81.37 改进算法(Backbone+SE-Net) 91.42 85.14 84.23 改进算法(Neck+SE-Net) 91.29 85.32 84.48 表 3 改进数据增强方式前后算法性能对比
Table 3. Comparison of algorithm performance before and after improving data enhancement method
% 算法 P R mAP@0.5 原始YOLOv5s算法 90.71 82.85 81.37 改进算法(Mosaic) 90.79 84.79 83.56 表 4 原始算法颈部增加检测层前后算法性能对比
Table 4. Comparison of algorithm performance before and after adding detection layer in original algorithn
% 算法 P R mAP@0.5 原始YOLOv5s算法 90.71 82.85 81.37 改进算法(Adding layer) 91.47 85.33 83.78 表 5 实验参数值
Table 5. Experimental parameter values
初始
学习率终止
学习率学习率
调整轮数一次传入
图片数训练
轮数0.01 0.2 5 8 250 表 6 消融实验对比
Table 6. Comparison of ablation experiments
% 算法 P R mAP@0.5 原始YOLOv5s算法 90.71 82.85 81.37 改进算法(DenseBlock+SE-Net) 91.67 86.65 86.49 改进算法(DenseBlock+Mosaic) 90.96 86.43 85.93 改进算法(DenseBlock+Adding layer) 91.43 86.97 85.91 改进算法(SE-Net+Mosaic) 91.04 87.18 86.24 改进算法(SE-Net+Adding layer) 92.28 86.52 86.15 改进算法(Mosaic+Adding layer) 91.62 87.23 86.96 改进算法(DenseBlock+SE-Net+Mosaic) 91.66 87.73 86.85 改进算法(DenseBlock+SE-Net+Adding layer) 91.47 88.18 87.07 改进算法(DenseBlock+Mosaic+Adding layer) 91.92 88.33 86.61 改进算法(SE-Net+Mosaic+Adding layer) 90.13 87.14 86.48 改进算法(DenseBlock+SE-Net+
Mosaic+Adding layer)91.21 89.09 87.94 表 7 改进算法与现有目标检测算法性能对比
Table 7. Performance comparison between the proposed improved algorithm and existing object detection algorithms
算法 mAP@0.5/% mAP/% NFPS/(帧·s−1) YOLOv3 74.39 44.67 17.36 YOLOv3-tiny 72.87 43.12 21.48 YOLOv3-spp 75.78 47.15 16.58 YOLOv4 84.16 53.92 16.03 YOLOv5s 81.37 52.26 24.01 YOLOv5m 84.93 54.42 19.94 YOLOv5l 86.58 56.31 17.87 YOLOv5x 87.12 56.96 16.07 YOLOX-L 86.89 57.17 17.23 PP-YOLOv2 86.73 57.03 17.12 改进算法 87.94 58.14 20.45 表 8 改进算法与现有安全帽检测算法性能对比
Table 8. Performance comparison between proposed improved algorithm and existing safety helmet detection algorithms
% 算法 mAP@0.5 mAP 其他改进算法(改进锚框) 83.56 54.14 其他改进算法(增加自注意力机层) 84.32 53.95 其他改进算法((增加自注意力层+改进锚框) 84.87 55.63 其他改进算法(K-means聚类) 82.46 52.74 其他改进算法(增加特征图) 84.43 54.32 其他改进算法(增加特征图+K-means聚类) 85.78 55.31 其他改进算法(深度可分离卷积) 82.76 52.96 其他改进算法(改进SPP) 82.73 52.97 其他改进算法(深度可分离卷积+改进SPP) 84.21 55.13 其他改进算法(K-means++算法) 83.38 53.98 其他改进算法(多光谱注意力模块) 85.98 56.03 其他改进算法(K-means++算法+多光谱注意力模块) 86.09 56.76 本文改进算法 87.94 58.14 -
[1] YAN G B, SUN Q, HUANG J Y, et al. Helmet detection based on deep learning and random forest on UAV for power construction safety[J]. Journal of Advanced Computational Intelligence and Intelligent Informatics, 2021, 25(1): 40-49. doi: 10.20965/jaciii.2021.p0040 [2] 孙国栋, 李超, 张航. 融合自注意力机制的安全帽佩戴检测方法[J]. 计算机工程与应用, 2022, 58(20): 300-304. doi: 10.3778/j.issn.1002-8331.2103-0372SUN G D, LI C, ZHANG H. Safety helmet wearing detection method fused with self-attention mechanism[J]. Computer Engineering and Applications, 2022, 58(20): 300-304(in Chinese). doi: 10.3778/j.issn.1002-8331.2103-0372 [3] 许凯, 邓超. 基于改进YOLOv3的安全帽佩戴识别算法[J]. 激光与光电子学进展, 2021, 58(6): 0615002.XU K, DENG C. Research on helmet wear identification based on improved YOLOv3[J]. Laser & Optoelectronics Progress, 2021, 58(6): 0615002(in Chinese). [4] CHENG R, HE X W, ZHENG Z L, et al. Multi-scale safety helmet detection based on SAS-YOLOv3-Tiny[J]. Applied Sciences, 2021, 11(8): 3652. doi: 10.3390/app11083652 [5] 赵红成, 田秀霞, 杨泽森, 等. YOLO-S: 一种新型轻量的安全帽佩戴检测模型[J]. 华东师范大学学报(自然科学版), 2021(5): 134-145.ZHAO H C, TIAN X X, YANG Z S, et al. YOLO-S: A new lightweight helmet wearing detection model[J]. Journal of East China Normal University (Natural Science), 2021(5): 134-145(in Chinese). [6] 张锦, 屈佩琪, 孙程, 等. 基于改进YOLOv5的安全帽佩戴检测算法[J]. 计算机应用, 2022, 42(4): 1292-1300.ZHANG J, QU P Q, SUN C, et al. Safety helmet wearing detection algorithm based on improved YOLOv5[J]. Journal of Computer Applications, 2022, 42(4): 1292-1300(in Chinese). [7] 徐传运, 袁含香, 李刚, 等. 使用场景增强的安全帽佩戴检测方法研究[J]. 计算机工程与应用, 2022, 58(19): 326-332. doi: 10.3778/j.issn.1002-8331.2103-0030XU C Y, YUAN H X, LI G, et al. Research on safety helmet wearing detection method based on scene augment[J]. Computer Engineering and Applications, 2022, 58(19): 326-332(in Chinese). doi: 10.3778/j.issn.1002-8331.2103-0030 [8] 高明华, 杨璨. 基于改进卷积神经网络的交通目标检测方法[J]. 吉林大学学报(工学版), 2022, 52(6): 1353-1361. doi: 10.13229/j.cnki.jdxbgxb20210380GAO M H, YANG C. Traffic target detection method based on improved convolution neural network[J]. Journal of Jilin University (Engineering and Technology Edition), 2022, 52(6): 1353-1361(in Chinese). doi: 10.13229/j.cnki.jdxbgxb20210380 [9] ZHU L L, GENG X, LI Z, et al. Improving YOLOv5 with attention mechanism for detecting boulders from planetary images[J]. Remote Sensing, 2021, 13(18): 152-161. [10] 高云鹏. 基于深度神经网络的大田小麦麦穗检测方法研究[D]. 北京: 北京林业大学, 2019: 1-68.GAO Y P. Study on detection method of wheat ear in field based on deep neural network[D]. Beijing: Beijing Forestry University. 2019: 1-68(in Chinese). [11] 马永康, 刘华, 凌成星, 等. 基于改进YOLOv5的红树林单木目标检测研究[J]. 激光与光电子学进展, 2022, 59(18): 426-436.MA Y K, LIU H, LING C X, et al. Object detection of individual mangrove based on improved YOLOv5[J]. Laser & Optoelectronics Progress, 2022, 59(18): 426-436(in Chinese). [12] MAGALHÃES S A, CASTRO L, MOREIRA G, et al. Evaluating the single-shot MultiBox detector and YOLO deep learning models for the detection of tomatoes in a greenhouse[J]. Sensors, 2021, 21(10): 3569. doi: 10.3390/s21103569 [13] 舒朗, 张智杰, 雷波. 一种针对红外目标检测的Dense-Yolov5算法研究[J]. 光学与光电技术, 2021, 19(1): 69-75. doi: 10.19519/j.cnki.1672-3392.2021.01.010SHU L, ZHANG Z J, LEI B. Research on dense-Yolov5 algorithm for infrared target detection[J]. Optics & Optoelectronic Technology, 2021, 19(1): 69-75(in Chinese). doi: 10.19519/j.cnki.1672-3392.2021.01.010 [14] CHEN B L, ZHAO T S, LIU J H, et al. Multipath feature recalibration DenseNet for image classification[J]. International Journal of Machine Learning and Cybernetics, 2021, 12(3): 651-660. doi: 10.1007/s13042-020-01194-4 [15] LI G Q, ZHANG M, LI J J, et al. Efficient densely connected convolutional neural networks[J]. Pattern Recognition, 2021, 109: 107610. doi: 10.1016/j.patcog.2020.107610 [16] ALBAHLI S, AYUB N, SHIRAZ M. Coronavirus disease (COVID-19) detection using X-ray images and enhanced DenseNet[J]. Applied Soft Computing, 2021, 110: 107645. doi: 10.1016/j.asoc.2021.107645 [17] WANG Y, HAO Z Y, ZUO F, et al. A fabric defect detection system based improved YOLOv5 detector[J]. Journal of Physics:Conference Series, 2021, 2010(1): 012191. doi: 10.1088/1742-6596/2010/1/012191 [18] HUANG G, LIU Z, VAN DER MAATEN L, et al. Densely connected convolutional networks[C]//2017 IEEE Conference on Computer Vision and Pattern Recognition. Piscataway: IEEE Press, 2017: 2261-2269. [19] JUNG E, CHIKONTWE P, ZONG X P, et al. Enhancement of perivascular spaces using densely connected deep convolutional neural network[J]. IEEE Access:Practical Innovations, Open Solutions, 2019, 7: 18382-18391. [20] TANG X L, ZHONG B, PENG J P, et al. Multi-scale channel importance sorting and spatial attention mechanism for retinal vessels segmentation[J]. Applied Soft Computing, 2020, 93: 106353. doi: 10.1016/j.asoc.2020.106353 [21] ZHANG G Q, YANG J C, ZHENG Y H, et al. Hybrid-attention guided network with multiple resolution features for person re-identification[J]. Information Sciences, 2021, 578: 525-538. doi: 10.1016/j.ins.2021.07.058 [22] 陈文豪, 何敬, 刘刚. 引入注意力机制的卷积神经网络高光谱图像分类[J]. 激光与光电子学进展, 2022, 59(18): 162-169.CHEN W H, HE J, LIU G. Hyperspectral image classification based on convolution neural network with attention mechanism[J]. Laser & Optoelectronics Progress, 2022, 59(18): 162-169(in Chinese). [23] 邹梓吟, 盖绍彦, 达飞鹏, 等. 基于注意力机制的遮挡行人检测算法[J]. 光学学报, 2021, 41(15): 1515001. doi: 10.3788/AOS202141.1515001ZOU Z Y, GAI S Y, DA F P, et al. Occluded pedestrian detection algorithm based on attention mechanism[J]. Acta Optica Sinica, 2021, 41(15): 1515001(in Chinese). doi: 10.3788/AOS202141.1515001 [24] HU J, SHEN L, SUN G. Squeeze-and-excitation networks[C]// 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition. Piscataway: IEEE Press, 2018: 7132-7141. [25] 林贤早, 刘俊, 田胜, 等. 基于多空间混合注意力的图像描述生成方法[J]. 计算机应用, 2020, 40(4): 985-989.LIN X Z, LIU J, TIAN S, et al. Image description generation method based on multi-spatial mixed attention[J]. Journal of Computer Applications, 2020, 40(4): 985-989(in Chinese). [26] 程鸣洋, 盖绍彦, 达飞鹏. 基于注意力机制的立体匹配网络研究[J]. 光学学报, 2020, 40(14): 1415001. doi: 10.3788/AOS202040.1415001CHENG M Y, GAI S Y, DA F P. A stereo-matching neural network based on attention mechanism[J]. Acta Optica Sinica, 2020, 40(14): 1415001(in Chinese). doi: 10.3788/AOS202040.1415001 [27] CAO Z H, SHAO M F, XU L, et al. MaskHunter: Real-time object detection of face masks during the COVID-19 pandemic[J]. IET Image Processing, 2020, 14(16): 4359-4367. doi: 10.1049/iet-ipr.2020.1119 [28] 李成跃, 姚剑敏, 林志贤, 等. 基于改进YOLO轻量化网络的目标检测方法[J]. 激光与光电子学进展, 2020, 57(14): 141003.LI C Y, YAO J M, LIN Z X, et al. Object detection method based on improved YOLO lightweight network[J]. Laser & Optoelectronics Progress, 2020, 57(14): 141003(in Chinese). [29] J IANG X B, GAO T H, ZHU Z C, et al. Real-time face mask detection method based on YOLOv3[J]. Electronics, 2021, 10(7): 327-336. [30] ZHANG K, WU Y L, WANG J Y, et al. Semantic context-aware network for multiscale object detection in remote sensing images[J]. IEEE Geoscience and Remote Sensing Letters, 2022, 19: 1-5. [31] LI S S, LI Y J, LI Y, et al. YOLO-FIRI: Improved YOLOv5 for infrared image object detection[J]. IEEE Access, 2021, 9: 141861-141875. doi: 10.1109/ACCESS.2021.3120870 [32] CAO S, ZHANG X W, MA J W. Trans-scale feature aggregation network for multiscale pedestrian detection[J]. Journal of Beijing University of Aeronautics and Astronautics, 2020, 46(9): 1786-1796. [33] LI X G, FU C P, LI X L, et al. Improved faster R-CNN for multi-scale object detection[J]. Journal of Computer-Aided Design & Computer Graphics, 2019, 31(7): 1095-1101. [34] HSU W Y, LIN W Y. Adaptive fusion of multi-scale YOLO for pedestrian detection[J]. IEEE Access, 2021, 9: 110063-110073. doi: 10.1109/ACCESS.2021.3102600 [35] 管军霖, 智鑫. 基于YOLOv4卷积神经网络的口罩佩戴检测方法[J]. 现代信息科技, 2020, 4(11): 9-12. doi: 10.19850/j.cnki.2096-4706.2020.11.002GUAN J L, ZHI X. Mask wearing detection method based on YOLOv4 convolutional neural network[J]. Modern Information Technology, 2020, 4(11): 9-12(in Chinese). doi: 10.19850/j.cnki.2096-4706.2020.11.002 [36] 程可欣, 王玉德. 基于改进YOLOv3的自然场景人员口罩佩戴检测算法[J]. 计算机系统应用, 2021, 30(2): 231-236. doi: 10.15888/j.cnki.csa.007788CHENG K X, WANG Y D. Algorithm of mask wearing detection in natural scenes based on improved YOLOv3[J]. Computer Systems & Applications, 2021, 30(2): 231-236(in Chinese). doi: 10.15888/j.cnki.csa.007788 [37] LIU Y F, LIU H B, PENG J X, et al. Research on the Use of YOLOv5 object detection algorithm in mask wearingrecognition[J]. World Scientific Research Journal, 2020, 6(11): 230-238.