SNF-YOLOv8: A Lightweight PCB Defect Detection Algorithm base on Multiscale Feature Fusion and Attention Scale Sequence Fusion
摘要
The detection of subtle Printed Circuit Board (PCBs) defects, particularly Spur (spurious copper) and Mouse bite (micron-scale notches), remains challenging due to their minimal dimensions and interference from complex textures.Existing methods suffer from low sensitivity to micro-defects and degraded robustness under data variations like random noise injection, color shifts,and scaling.To address these issues, this paper proposes SNF-YOLOv8(Scale-aware Neural Fusion You Only Look Once Version8),an enhanced framework built upon YOLOv8n,integrating a lightweight Scale-aware Multi-level Feature Fusion (SMFF) strategy and an Attention-based Scale Sequence Fusion (ASF) mechanism.The SMFF optimizes bidirectional cross-layer connections and hierarchical feature pyramids to retain fine-grained details of micro-defects,while the ASF employs LSTM networks and dynamic channel-spatial attention to adaptively refine multi-scale feature weights.Experiments on a high-quality PCB defect dataset (2,772 images) demonstrate that SNF-YOLOv8 achieves a 90.0% mAP50,surpassing YOLOv8n by 3.1%,with a 17% reduction in parameters (2.49M) and real-time inference at 250 FPS. Cross-dataset validation on DeepPCB further confirms its robustness,achieving 98.4% mAP.The framework significantly improves detection accuracy for micron-scale defects like mouse bites (7.2% AP gain) and suppresses false alarms in complex backgrounds.This work provides a computationally efficient and reliable solution for industrial PCB inspection, advancing lightweight deep learning applications in automated quality control.