An Improved YOLOv5 Algorithm for Wood Defect Detection Based on Attention
Siyu Han, Xiangtao Jiang, Zhenyu Wu
Abstract
Wood defect detection is a research hotspot in the field of forestry at present. However, existing studies on wood defect detection mainly focus on detecting a single type of defect or common defects, such as knots, insect pests, and cracks, which cannot meet the processing needs of high-quality wood. Moreover, there are problems, such as low recognition rates of small-target defects and poor recognition integrity of dense defects. To address these issues, we construct a large-scale dataset containing multiple types of wood surface defects through data augmentation techniques. We also introduce the Coordinate Attention module, Transformer Encoder module, and Swin Transformer module in the YOLOv5 network structure. The backbone network CSP-Darknet53 is optimized, and BiFPN is introduced in the neck part to achieve multi-scale weighted bidirectional feature fusion. In addition, we implement three new heads: Shead, Mhead, and Lhead in the prediction part. Comparison experiments show that STC-YOLOV5 outperforms some object detection algorithms. Ablation experiments show that each module effectively improves the detection performance. Compared to YOLOv5, STC-YOLOv5 proposed in this paper improve the mAP by 3.1%. All types and scales of wood surface defects are detected better, with great potential for application in the forestry industry.