计算机工程与应用 ›› 2024, Vol. 60 ›› Issue (7): 306-314.DOI: 10.3778/j.issn.1002-8331.2307-0275

• 工程与应用 • 上一篇    下一篇

钢材表面缺陷检测的YOLOv5s算法优化研究

徐洪俊,唐自强,张锦东,朱沛华   

  1. 1.国网江苏省电力工程咨询有限公司,南京 210000
    2.同济大学 土木工程学院,上海 200000
    3.石家庄铁道大学 安全工程与应急管理学院,石家庄 050043
  • 出版日期:2024-04-01 发布日期:2024-04-01

Research on Optimization of YOLOv5s Detection Algorithm for Steel Surface Defect

XU Hongjun, TANG Ziqiang, ZHANG Jindong, ZHU Peihua   

  1. 1.State Grid Jiangsu Electric Engineering Consulting Co., Ltd., Nanjing 210000, China
    2.College of Civil Engineering, Tongji University, Shanghai 200000, China
    3.College of Safety Engineering and Emergency Management, Shijiazhuang Tiedao Universtiy, Shijiazhuang 050043, China
  • Online:2024-04-01 Published:2024-04-01

摘要: 针对YOLOv5对钢材缺陷复杂特征提取能力不足且检测结果易受背景环境干扰等问题,提出一种基于YOLOv5s的钢材表面缺陷检测算法。该算法在Backbone的核心特征提取模块C3中引入CBAM注意力,提升Backbone层对于关键信息的关注度;利用CARAFE替换最近邻插值算法,降低了上采样操作对于特征信息造成的损失;提出用融合跨阶段局部网络的金字塔池化结构SPPCPSC替换YOLOv5中的SPPF,提升网络的表达能力和感知能力。实验结果表明,提出YOLOv5s改进模型在NEU-DET数据集上的mAP@0.5达到了76.6%,比YOLOv5s提升2.3个百分点,模型参数量与基线模型基本一致,而CARAFE是导致改进模型检测速度降低的主要原因。除此,实验结果还发现CARAFE与SPPCSPC_group组合使用,对于模型的检测准确度有良好的提升作用。

关键词: YOLOv5, 注意力机制, 跨阶段局部通道金字塔池化结构(SPPCSPC), 特征提取, 缺陷检测

Abstract: Aiming at the problems that YOLOv5 has insufficient ability to extract complex features of steel defects and the detect results are susceptible to background environment, a steel surface defect detection algorithm based on YOLOv5s is proposed. This algorithm introduces CBAM attention into C3 to enhance attention to key information. It utilizes the CARAFE to replace the nearest neighbor interpolation algorithm, reducing the loss of feature information caused by upsampling. It proposes to replace the SPPF in YOLOv5 with the SPPCPSC, which can improve the expressive ability of the network. The experimental results show that the mAP@0.5 of the proposed YOLOv5s improved model on the NEU-DET dataset reaches 76.6%, which is 2.3 percentage points higher than that of YOLOv5s. The model parameters are basically the same as YOLOv5s. The CARAFE module is the main reason for the slowdown of the improved model detection speed. In addition, the combination of the CARAFE and the SPPCSPC_group has a good effect on the detection accuracy of the model.

Key words: YOLOv5, attention mechanism, spatial pyramid pooling-cross stage partial channel (SPPCSPC), feature extraction, defect detection