Abstract
As the performance requirements for printed circuit boards (PCBs) in electronic devices continue to increase, reliable defect detection during PCB manufacturing is vital. However, due to the small size, complex categories, and subtle differences in defect features, traditional detection methods are limited in accuracy and robustness. To overcome these challenges, this paper proposes MAS-YOLO, a lightweight detection algorithm for PCB defect detection based on improved YOLOv12 architecture. In the Backbone, a Median-enhanced Channel and Spatial Attention Block (MECS) expands the receptive field through median enhancement and depthwise convolution to generate attention maps that effectively capture subtle defect features. In the Neck, an Adaptive Hierarchical Feature Integration Network (AHFIN) adaptively fuses multi-scale features through weighted integration, enhancing feature utilization and focus on defect regions. Moreover, the original YOLOv12 loss function is replaced with the Slide Alignment Loss (SAL) to improve bounding box localization and detect complex defect types. Experimental results demonstrate that MAS-YOLO significantly improves mean average precision (mAP) and frames per second (FPS) compared to the original YOLOv12, fulfilling real-time industrial detection requirements.