Abstract:To address the challenges of confusion among defect categories and the difficulty in detecting small defect targets in printed circuit board defect detection, an improved YOLOv5 detection model was proposed. The Swin-Transformer is incorporated into the backbone network to extract multi-scale features, capturing both local and global information. A prediction feature layer is added specifically for small targets, and the new multi-scale feature fusion and detection structure enable the model to learn more comprehensive feature information. The ECIoU_Loss is employed as the loss function, facilitating collaborative optimization between detection speed and accuracy in circuit board defect detection. Experimental results demonstrate that the improved YOLOv5 model achieves a mean average precision of 98.7% on the PCB Defect dataset, with a precision of 99.7% and a recall of 97.4%. These performance metrics outperform current mainstream detection models, showcasing the improved YOLOv5 model's effectiveness in classifying and localizing circuit board defects.