Workpiece recognition and detection algorithm based on improved YOLOv5s
-
摘要: 针对机器人在抓取目标工件的过程中由于光线强度变化、图像环境复杂和拍摄设备移动等造成的工件识别精度低的问题,文章提出一种改进YOLOv5s的工件识别检测算法。首先,通过数据增强扩充数据集并进行预处理;其次,使用改进的k-means聚类算法重新生成更有效的预设锚框,缩短收敛路径;然后,在特征融合网络中添加CBAM注意力机制,有效抑制背景信息干扰,提高特征提取速度;此外,将特征融合模块中原有的特征金字塔结构替换成加权双向特征金字塔Bi-FPN结构,实现高效的加权特征融合和双向跨尺度连接,提高网络对不同尺度特征的融合效率;最后,通过采用α-IoU作为边界框回归损失函数,提高模型的定位效果。结果表明,改进后的YOLOv5s算法对工件检测的mAP值提升了6.03%,检测速度提升了13.7 fps,验证了改进算法的有效性。Abstract: Aiming at the low accuracy of workpiece recognition caused by the change of light intensity, the complexity of image environment and the movement of shooting equipment, an improved YOLOv5s workpiece recognition and detection algorithm was proposed. Firstly, the data set is expanded by data enhancement and preprocessed. Secondly, the improved k-means clustering algorithm is used to re-generate a more effective pre-set anchor frame and shorten the convergence path. Then, CBAM attention mechanism is added to the feature fusion network to effectively suppress background information interference and improve feature extraction speed. In addition, the original feature pyramid structure of the feature fusion module is replaced by the weighted bidirectional feature pyramid Bi-FPN structure to achieve efficient weighted feature fusion and bidirectional cross-scale connection, and improve the fusion efficiency of different scale features. Finally, the positioning effect of the model is improved by using α-IoU as the bounding box regression loss function. The results show that the improved YOLOv5s algorithm improves the mAP value of workpiece detection by 6.03% and the detection speed by 13.7 fps, which verifies the effectiveness of the improved algorithm.
-
表 1 训练平台配置参数
参数 配置 操作系统 Windows 10 显存 24 G 内存 32 G GPU Nvidia RTX 3090 GPU加速环境 CUDA 10.1 训练框架 Pytorch 表 2 训练参数设置表
参数名称 设定值 动量(Momentum) 0.9 权重衰减系数(Weight Decay) 0.000 5 初始学习率(Origin Learning Rate) 0.01 遍历次数(Epoch) 300 批处理大小(Batchsize) 8 非极大值抑制阈值(NMS) 0.5 表 3 YOLOv5s改进前后算法的检测结果对比
检测算法 AP/(%) mAP/
(%)速度/fps 工件1 工件2 工件3 工件4 工件5 工件6 YOLOv5s 89.98 88.55 93.30 90.62 90.29 92.67 90.90 15.6 Improved
YOLOv5s96.56 94.67 97.13 98.04 97.55 97.64 96.93 29.3 表 4 不同算法的检测结果对比表
检测算法 mAP/(%) 速度/fps SSD 84.54 13.2 Faster R-CNN 86.63 9.6 YOLOv5s 90.90 15.6 Improved YOLOv5s 96.93 29.3 -
[1] Zhou H Y,Jiang F,Lu H T. SSDA-YOLO:Semi-supervised domain adaptive YOLO for cross-domain object detection[J]. Computer Vision and Image Understanding,2023,229:103649. doi: 10.1016/j.cviu.2023.103649 [2] 郑如新,孙青云,马素慧,等. 基于机器视觉的工件识别应用研究[J]. 机械设计与制造,2023(8):299-303. doi: 10.3969/j.issn.1001-3997.2023.08.060 [3] 姚卫杰,朱华炳,殷玉龙. 基于Hu矩模板匹配和目标跟踪的ROI实时自动提取[J]. 组合机床与自动化加工技术,2021(9):52-56. [4] 何文轩,王拯洲,魏际同,等. 基于BLOB区域和边缘特征分析的准直图像双光学目标识别方法[J/OL]. 光子学报:1-22[2023-08-25].http://kns.cnki.net/kcms/detail/61.1235.O4.20230816.1017.002.html. [5] 刘源,夏春蕾. 一种基于Sobel算子的带钢表面缺陷图像边缘检测算法[J]. 电子测量技术,2021,44(3):138-143. [6] 苏维成,梁宏斌,冯广. 基于Tiny-YOLOv3改进算法的工件识别[J]. 制造技术与机床,2021(10):78-83. [7] 张宇廷,王宗彦,李梦龙,等. 基于机器视觉与Faster-RCNN的Delta机器人工件识别检测[J]. 机床与液压,2023,51(5):35-40. doi: 10.3969/j.issn.1001-3881.2023.05.006 [8] 崔新霞,卢硕晨,孙敦凯. 基于视觉感知的机器人工件识别方法研究[J]. 包装工程,2023,44(7):186-195. [9] Li J J,Zhu Z F,Liu H X,et al. Strawberry R-CNN:Recognition and counting model of strawberry based on improved faster R-CNN[J]. Ecological Informatics,2023,77:102210. doi: 10.1016/j.ecoinf.2023.102210 [10] 邵延华,张铎,楚红雨,等. 基于深度学习的YOLO目标检测综述[J]. 电子与信息学报,2022,44(10):3697-3708. doi: 10.11999/JEIT210790 [11] 陈卫彪,贾小军,朱响斌,等. 基于DSM-YOLO v5的无人机航拍图像目标检测[J]. 计算机工程与应用, 2023,59(18):226-233. [12] Li J C,Zhang X Q,Zhang Y,et al. Investigation of the J-TEXT plasma events by k-means clustering algorithm[J]. Plasma Science and Technology,2023,25(8):085103. doi: 10.1088/2058-6272/acc3d1 [13] Yuan C C,Liu T H,Gao F Y,et al. YOLOv5s-CBAM-DMLHead:A lightweight identification algorithm for weedy rice (Oryza sativa f. spontanea) based on improved YOLOv5[J]. Crop Protection,2023,172:106342. doi: 10.1016/j.cropro.2023.106342 [14] Syazwany N S,Nam J H,Lee S C. MM-BiFPN:multi-modality fusion network with Bi-FPN for MRI brain tumor segmentation[J]. IEEE Access,2021,9:160708-160720. doi: 10.1109/ACCESS.2021.3132050 [15] 单慧琳,吕宗奎,付相为,等. 改进YOLOv5s的交通多目标检测方法[J]. 国外电子测量技术,2023,42(4):8-15.