Abstract:A lightweight detection algorithm based on improving YOLOv8 is proposed to address the issues of high complexity, false alarms, and missed detections in current PCB surface defect detection methods. Due to some redundancy in the feature maps of the YOLOv8 backbone network after downsampling, a lightweight multi-scale mixed convolution (MSMC) is designed. This is combined with the C2f module to enhance the capability of extracting features at different scales. Additionally, an improved Bidirectional Feature Pyramid Network (BiFPN) structure is designed in the neck network, using two cross-layer connections to obtain richer semantic information. The C2f-Faster module is employed to reduce computational complexity during the feature fusion process. Moreover, the introduction of the CA attention mechanism and the WIoUv2 loss function strengthens the ability to locate small defects on PCBs. The experimental results show that the improved algorithm compared to YOLOv8n improves the detection accuracy by 2.2% on the PCB dataset, while the number of model parameters and the computation volume are reduced by 36.7% and 18.5% to 1.9 M and 6.6 G. The final model size is only 3.8 MB, providing a new approach for mobile terminal device deployment.