Please wait a minute...
浙江大学学报(工学版)  2024, Vol. 58 Issue (12): 2438-2446    DOI: 10.3785/j.issn.1008-973X.2024.12.003
计算机技术     
基于改进YOLOv5s的烟梗物料目标检测算法
吕佳铭(),张峰*(),罗亚波
武汉理工大学 机电工程学院,湖北 武汉 430070
Improved YOLOv5s based target detection algorithm for tobacco stem material
Jiaming LV(),Feng ZHANG*(),Yabo LUO
School of Mechanical and Electronic Engineering, Wuhan University of Technology, Wuhan 430070, China
 全文: PDF(1394 KB)   HTML
摘要:

在烟草生产线中烟梗输送下落过程中,存在背景信息干扰、目标数量多且形状不一、目标堆叠、下落速度过快等问题,传统图像处理算法难以解决. 提出基于改进YOLOv5s的烟梗物料目标检测算法. 对YOLOv5s网络的骨干和头部进行优化改进,显著提高检测精度,大幅缩小模型大小;将骨干网络优化为RepViT-m1结构,以提高信息提取的效率;采用重参数化技术,以更好地捕捉目标的特征,提高检测的精确性;引入基于注意力机制的目标检测头Dynamic Head,使模型更专注于潜在的目标区域,进一步提高检测精度. 实验结果表明:在自建的烟梗数据集上,相较于原YOLOv5s模型,改进YOLOv5s模型的mAP@0.50为96.1%,提高了5.8个百分点;mAP@0.50∶0.95为94.7%,提高了5.7个百分点;模型大小为12.1 MB,减少了12.3%. 模型可以为实时监控系统提供可靠且精确的支持.

关键词: 目标检测YOLOv5s烟梗检测RepViT重参数化注意力机制    
Abstract:

There are problems such as background interference, multiple and irregularly shaped targets, target overlap, and rapid falling speeds during the transportation of tobacco stems in the tobacco production line. A tobacco stem material target detection algorithm based on improved YOLOv5s was proposed. The backbone and head of the YOLOv5s network were optimized, significantly improving the detection accuracy and substantially reducing the model size. Firstly, the network’s backbone was optimized into the RepViT-m1 structure, enhancing the information extraction efficiency. Secondly, reparameterization techniques were used to better capture the target features, thus improving the detection precision. Dynamic Head, a target detection head based on the attention mechanism, was introduced to make the model be focused on the potential target area to further improve the detection accuracy. Experimental results on self-constructed tobacco stem dataset demonstrated the effectiveness of the improved YOLOv5s model. Compared with the original YOLOv5s model, the improved model achieved an mAP@0.50 of 96.1%, which was improved by 5.8 percentage points; and achieved an mAP@0.50:0.95 of 94.7%, which was improved by 5.7 percentage points. Furthermore, the model size was 12.1 MB, which was decreased by 12.3%. The results provide reliable and accurate support for real-time monitoring systems.

Key words: target detection    YOLOv5s    tobacco stem detection    RepViT    reparameterization    attention mechanism
收稿日期: 2023-11-14 出版日期: 2024-11-25
CLC:  TP 391.4  
基金资助: 国家自然科学基金资助项目(51875430).
通讯作者: 张峰     E-mail: 345815526@qq.com;zhangfengie@whut.edu.cn
作者简介: 吕佳铭(2000—),男,硕士生,从事机器视觉研究. orcid.org/0009-0003-8868-7248. E-mail:345815526@qq.com
服务  
把本文推荐给朋友
加入引用管理器
E-mail Alert
作者相关文章  
吕佳铭
张峰
罗亚波

引用本文:

吕佳铭,张峰,罗亚波. 基于改进YOLOv5s的烟梗物料目标检测算法[J]. 浙江大学学报(工学版), 2024, 58(12): 2438-2446.

Jiaming LV,Feng ZHANG,Yabo LUO. Improved YOLOv5s based target detection algorithm for tobacco stem material. Journal of ZheJiang University (Engineering Science), 2024, 58(12): 2438-2446.

链接本文:

https://www.zjujournals.com/eng/CN/10.3785/j.issn.1008-973X.2024.12.003        https://www.zjujournals.com/eng/CN/Y2024/V58/I12/2438

图 1  YOLOv5s算法网络结构图
图 2  Dynamic Head引入示意
图 3  基于连通域的自动标签算法过程图
图 4  现场环境搭建示意图
图 5  实际应用场景图
模型P/%R/%mAP@0.50/%mAP@0.50∶0.95/%M/MBGFLOPsFPS/帧
①YOLOv5s77.893.390.389.013.816.6212.77
②YOLOv5s+RepViT-m181.985.389.886.226.224144.93
③YOLOv5s+重参数化的RepViT-m180.390.491.586.511.419.9192.31
④YOLOv5s+Dynamic Head79.793.692.190.613.717.8185.19
⑤YOLOv5s+RepViT-m1+Dynamic Head84.196.495.894.314.221.8133.33
⑥本研究算法86.294.196.194.712.121.3178.57
表 1  模块消融实验结果分析
dP/%R/%mAP@0.50/%mAP@0.50∶0.95/%
288.391.993.790.7
484.585.692.389.5
686.294.196.194.7
887.492.995.991.6
表 2  头部深度消融实验结果分析
模型P/%R/%mAP@0.50/%mAP@0.50∶0.95/%M/MBGFLOPsFPS/帧
Faster R-CNN78.683.387.582.0108.0150.813.14
YOLOv3-tiny75.885.184.380.816.613.0163.93
YOLOv378.287.187.983.8117.9155.327.80
YOLOv7-tiny85.288.789.886.411.713.2123.46
YOLOv775.387.786.384.871.3105.225.58
YOLOx-s76.592.989.184.034.326.8101.73
YOLOv8s80.393.589.586.721.428.8112.36
YOLOv5s77.893.390.389.013.816.6212.77
本研究算法86.294.196.194.712.121.3178.57
表 3  不同目标检测算法对比实验结果分析
图 6  训练和验证损失曲线图
图 7  烟梗长度识别混淆矩阵图
图 8  分类识别效果图
图 9  模型改进前后识别效果对比
1 高尊华, 鲍文华, 程红军, 等 梗丝结构对卷烟质量稳定性的影响[J]. 烟草科技, 2007, (2): 5- 7
GAO Zunhua, BAO Wenhua, CHENG Hongjun, et al Influence of cut stem structure on quality stability of cigarette[J]. Tobacco Science and Technology, 2007, (2): 5- 7
doi: 10.3969/j.issn.1002-0861.2007.02.001
2 崔云月, 管一弘, 孙娜, 等 BP神经网络在烟梗长短梗率检测中的应用[J]. 软件导刊, 2021, 20 (2): 63- 67
CUI Yunyue, GUAN Yihong, SUN Na, et al The application of BP neural network in the determination of the stalk length and stem rate[J]. Software Guide, 2021, 20 (2): 63- 67
doi: 10.11907/rjdk.202478
3 杨耀伟, 张月华, 崔廷, 等 基于机器视觉和深度学习的烟梗识别方法[J]. 计算机应用, 2022, 42 (Suppl.1): 118- 122
YANG Yaowei, ZHANG Yuehua, CUI Ting, et al Tobacco stem recognition method based on machine vision and deep learning[J]. Journal of Computer Applications, 2022, 42 (Suppl.1): 118- 122
4 肖雷雨, 王澍, 刘渊根, 等 基于深度学习技术的烟梗形态分类与识别[J]. 烟草科技, 2021, 54 (6): 65- 74
XIAO Leiyu, WANG Shu, LIU Yuangen, et al Classification and identification of tobacco stem morphology based on deep learning technology[J]. Tobacco Science and Technology, 2021, 54 (6): 65- 74
5 刘新宇, 郝同盟, 张红涛, 等 基于改进YOLOv3网络的烟梗识别定位方法[J]. 食品与机械, 2022, 38 (3): 103- 109
LIU Xinyu, HAO Tongmeng, ZHANG Hongtao, et al Cigarette stem identification and location method based on improved YOLOv3 network[J]. Food and Machinery, 2022, 38 (3): 103- 109
6 苗新法, 刘宝莲, 李晓琴, 等. 改进YOLOV5s的铁轨裂纹目标检测算法[EB/OL]. [2023-11-03]. http://kns.cnki.net/kcms/detail/11.2127.TP.20230825.1227.008.html.
7 崔丽群, 曹华维. 基于改进YOLOv5的遥感图像目标检测[EB/OL]. [2023-11-03]. https://doi.org/10.19678/j.issn.1000-3428.0067790.
8 金鑫, 庄建军, 徐子恒 轻量化YOLOv5s网络车底危险物识别算法[J]. 浙江大学学报: 工学版, 2023, 57 (8): 1516- 1526
JIN Xin, ZHUANG Jianjun, XU Ziheng Lightweight YOLOv5s network-based algorithm for identifying hazardous objects under vehicles[J]. Journal of Zhejiang University: Engineering Science, 2023, 57 (8): 1516- 1526
9 ZHANG Z H, ZUO Z Y, LI Z, et al Real-time wheat unsound kernel classification detection based on improved YOLOv5[J]. Journal of Advanced Computational Intelligence and Intelligent Informatics, 2023, 27 (3): 474- 480
doi: 10.20965/jaciii.2023.p0474
10 HONG W W, MA Z H, YE B L, et al Detection of green asparagus in complex environments based on the improved YOLOv5 algorithm[J]. Sensors, 2023, 23 (3): 1562
doi: 10.3390/s23031562
11 YUAN J X, ZHENG X Z, PENG L W, et al Identification method of typical defects in transmission lines based on YOLOv5 object detection algorithm[J]. Energy Reports, 2023, (9): 323- 332
12 ZHOU T, YANG J. An improved YOLOv5 algorithm for construction solid waste detection [C]// IEEE 3rd International Conference on Electronic Technology , Communication and Information . Changchun: IEEE, 2023: 473–477.
13 FU Z. Vision transformer: vit and its derivatives [EB/OL]. [2023-08-24]. https://arxiv.org/abs/2205.11239.
14 LI C H, ZHANG C N. CNN or vit? revisiting vision transformers through the lens of convolution [EB/OL]. [2023-11-03]. https://arxiv.org/abs/2309.05375.
15 WANG A, CHEN H, LIN Z J, et al. Repvit: revisiting mobile cnn from vit perspective [EB/OL]. [2023-11-03]. https://arxiv.org/abs/2307.09283.
16 DING X H, ZHANG X Y, MA N N, et al. Repvgg: making vgg-style convnets great again [C]// IEEE/CVF Conference on Computer Vision and Pattern Recognition . Nashville: IEEE, 2021: 13733–13742.
[1] 李灿林,王新玥,马利庄,邵志文,张文娇. 融合注意力机制和结构线提取的图像卡通化[J]. 浙江大学学报(工学版), 2024, 58(8): 1728-1737.
[2] 李忠良,陈麒,石琳,杨朝,邹先明. 时间感知组合的动态知识图谱补全[J]. 浙江大学学报(工学版), 2024, 58(8): 1738-1747.
[3] 吴书晗,王丹,陈远方,贾子钰,张越棋,许萌. 融合注意力的滤波器组双视图图卷积运动想象脑电分类[J]. 浙江大学学报(工学版), 2024, 58(7): 1326-1335.
[4] 马现伟,范朝辉,聂为之,李东,朱逸群. 对失效传感器具备鲁棒性的故障诊断方法[J]. 浙江大学学报(工学版), 2024, 58(7): 1488-1497.
[5] 杨军,张琛. 基于边界点估计与稀疏卷积神经网络的三维点云语义分割[J]. 浙江大学学报(工学版), 2024, 58(6): 1121-1132.
[6] 李运堂,李恒杰,张坤,王斌锐,关山越,陈源. 基于新型编码解码网络的复杂输电线识别[J]. 浙江大学学报(工学版), 2024, 58(6): 1133-1141.
[7] 宋娟,贺龙喜,龙会平. 基于深度学习的隧道衬砌多病害检测算法[J]. 浙江大学学报(工学版), 2024, 58(6): 1161-1173.
[8] 邢志伟,朱书杰,李彪. 基于改进图卷积神经网络的航空行李特征感知[J]. 浙江大学学报(工学版), 2024, 58(5): 941-950.
[9] 刘毅,陈一丹,高琳,洪姣. 基于多尺度特征融合的轻量化道路提取模型[J]. 浙江大学学报(工学版), 2024, 58(5): 951-959.
[10] 魏翠婷,赵唯坚,孙博超,刘芸怡. 基于改进Mask R-CNN与双目视觉的智能配筋检测[J]. 浙江大学学报(工学版), 2024, 58(5): 1009-1019.
[11] 宦海,盛宇,顾晨曦. 基于遥感图像道路提取的全局指导多特征融合网络[J]. 浙江大学学报(工学版), 2024, 58(4): 696-707.
[12] 邓天民,程鑫鑫,刘金凤,张曦月. 基于特征复用机制的航拍图像小目标检测算法[J]. 浙江大学学报(工学版), 2024, 58(3): 437-448.
[13] 张会娟,李坤鹏,姬淼鑫,刘振江,刘建娟,张弛. 基于空间相关性增强的无人机检测算法[J]. 浙江大学学报(工学版), 2024, 58(3): 468-479.
[14] 宋明俊,严文,邓益昭,张俊然,涂海燕. 轻量化机器人抓取位姿实时检测算法[J]. 浙江大学学报(工学版), 2024, 58(3): 599-610.
[15] 姚鑫骅,于涛,封森文,马梓健,栾丛丛,沈洪垚. 基于图神经网络的零件机加工特征识别方法[J]. 浙江大学学报(工学版), 2024, 58(2): 349-359.