Computer Engineering and Applications ›› 2024, Vol. 60 ›› Issue (7): 175-182.DOI: 10.3778/j.issn.1002-8331.2309-0185

• Graphics and Image Processing • Previous Articles     Next Articles

Improved YOLOv7 Algorithm for Wood Surface Defect Detection

JIANG Xingwang, ZHAO Xingqiang   

  1. School of Automation, Nanjing University of Information Science & Technology, Nanjing 210044, China
  • Online:2024-04-01 Published:2024-04-01

改进YOLOv7的木材表面缺陷检测算法

江兴旺,赵兴强   

  1. 南京信息工程大学 自动化学院,南京 210044

Abstract: High quality wood is deeply loved by people, but it has various defects that lead to low yield and low utilization rate of high-quality wood. The use of deep learning object detection algorithms can achieve rapid and stable detection of wood surface defects, thereby improving the quality and utilization of wood. A wood surface defect detection model YOLOv7-ESS based on improved YOLOv7 is proposed to address the problem of poor detection accuracy caused by the small, dense, and complex target size of wood surface defects. Firstly, in response to the issue of extreme aspect ratio affecting the detection effect of wood crack defects, an attention module ECBAM is embedded to enhance the model’s feature extraction ability by enhancing attention to extreme aspect ratio defects. Secondly, in response to the problem of severe loss of feature information for small defects on the wood surface during feature extraction, a shallow weighted feature fusion network SFPN is introduced, which uses deep feature maps as output and effectively utilizes shallow feature information to improve the recognition accuracy of small defects. Finally, the SIoU loss function is introduced to improve the convergence speed and accuracy of the model. The results show that the average detection accuracy of the YOLOv7-ESS model is 94.7%, which is 11.2 percentage points higher than YOLOv7 and meets the defect detection requirements for wood production and processing.

Key words: wood surface, defect detection, YOLOv7, feature fusion, attention mechanism, loss function

摘要: 优质木材深受人们喜爱,但木材存在多种缺陷导致优质木材产量少,木材利用率低。运用深度学习的目标检测算法可以实现木材表面缺陷的快速稳定检测,以此提高木材的优质化和利用率。针对目前木材表面缺陷目标小、密集和复杂等特点导致检测精度较差的问题,提出了一种基于改进YOLOv7的木材表面缺陷检测模型YOLOv7-ESS。针对木材的裂缝缺陷存在极端长宽比例而影响检测效果的问题,嵌入注意力模块ECBAM,通过加强对极端长宽比例缺陷的注意力,提高模型的特征提取能力。针对在提取特征时木材表面小缺陷特征信息丢失严重的问题,引入浅层加权特征融合网络SFPN,以深层特征图作为输出,同时有效利用浅层特征信息,提高小缺陷的识别准确率。引入SIoU损失函数,提升模型收敛速度及模型精度。结果表明,YOLOv7-ESS模型平均检测精度为94.7%,较YOLOv7检测精度提高了11.2个百分点,满足木材生产加工时的缺陷检测要求。

关键词: 木材表面, 缺陷检测, YOLOv7, 特征融合, 注意力机制, 损失函数