Computer Engineering and Applications ›› 2023, Vol. 59 ›› Issue (10): 244-252.DOI: 10.3778/j.issn.1002-8331.2209-0413

• Graphics and Image Processing • Previous Articles     Next Articles

Improved Fabric Defect Detection Algorithm of YOLOv5

MA Ahui, ZHU Shuangwu, LI Choudan, MA Xiaotong, WANG Shihao   

  1. College of Textile Science and Engineering, Xi’an Polytechnic University, Xi’an 710048, China
  • Online:2023-05-15 Published:2023-05-15

改进YOLOv5的织物疵点检测算法

马阿辉,祝双武,李丑旦,马晓彤,王世豪   

  1. 西安工程大学 纺织科学与工程学院,西安 710048

Abstract: Aiming at the problems of slow detection speed of two-stage algorithm and low detection accuracy of one-stage algorithm in the current network model applied to fabric defect detection, an improved YOLOv5 fabric defect detection algorithm is proposed. Firstly, for the different sizes of fabric defects, the clustering distance standard of the [K]-mean algorithm is modified, and the size of the priori frame is recalculated. Secondly, the standard convolution(SC) of the network Neck layer is improved, and the depth separation convolution(DSC) is combined with the standard convolution to reduce the amount of network layer parameters while maintaining the feature extraction capability of the network. The coordinate attention(CA) mechanism is introduced in the feature fusion stage, so that the network can capture the connection between each channel while retaining the precise positioning information of the target, thereby enhancing the feature extraction and positioning capabilities of the network. Finally, the weighted bidirectional feature pyramid network(BiFPN) is used, the feature pyramid module is modified to achieve simple and fast multi-scale feature fusion. After training on the data set, the results show that the mAP value of the improved YOLOv5 model can reach 97.4%, which is 2.8 percentage points higher than the original network accuracy, which meets the requirements of fabric defect detection.

Key words: fabric defect detection, YOLOv5, attention mechanism, feature fusion

摘要: 针对目前应用到织物疵点检测的网络模型中存在的两阶段算法检测速度慢、一阶段算法检测精度低的问题,提出了一种改进YOLOv5的织物疵点检测算法。针对织物疵点大小不一的问题,对[K]-mean算法的聚类距离标准进行修改,重新计算先验框大小;对网络Neck层标准卷积(standard convolution,SC)进行改进,将深度分离卷积(depth separation convolution,DSC)与标准卷积结合,减少网络层参数量,同时保持网络的特征提取能力;在特征融合阶段引入坐标注意力机制(coordinate attention,CA),使网络能够捕捉各通道之间联系的同时保留目标的精确定位信息,加强网络的特征提取和定位能力;使用加权双向特征金字塔网络(bidirectional feature pyramid network,BiFPN)中的方法,对特征金字塔模块进行修改,实现简单快速的多尺度特征融合。在数据集上进行训练,结果表明,改进的YOLOv5模型的mAP值可达到97.4%,相比于原网络精度提高了2.8个百分点,满足了织物疵点检测的要求。

关键词: 织物疵点检测, YOLOv5, 注意力机制, 特征融合