Abstract:
Objective In the production process of printed circuit boards (PCBs), common defects such as mouse_bite, open_circuit, short, spur and spurious_copper are frequently encountered. These defects are characterized by their small size, color similarity to the background, and similar features across different defect types, which make detection challenging and prone to false positives and missed detections. Traditional inspection methods, including manual visual checks and conventional automated optical inspection (AOI), suffer from high error rates, limited adaptability, and dependency on manually selected features. Although deep learning approaches, particularly YOLO-series models, have improved detection robustness, they still face three core limitations in PCB defect inspection: insufficient feature extraction for tiny objects, poor balance between model lightweight and accuracy, and inadequate loss function design for small targets. To address the issues of limited samples, low efficiency, large parameter size, and low accuracy in detecting tiny-defects on PCBs, this paper proposes a lightweight detection model named PCB-YOLO based on the YOLOv8n.
Methods First, the original high-resolution PCB images with diverse background colors are converted to grayscale to minimize color interference. To avoid losing tiny defects during resizing, a sliding-window slicing strategy is applied, generating 640×480 sub-images with 100 pixel overlaps. Only slices containing defects are retained, effectively increasing the usable dataset while preserving small-object details. Second, considering the significant proportion of small target defects in PCBs, a Conv_SWS (SimAM with slicing) module is designed by integrating the SimAM attention mechanism and merging slicing operations. The input feature map is divided into local patches, each enhanced by SimAM to emphasize small-defect regions, before being recombined. This module replaces standard convolution in downsampling stages, enhancing multi-scale feature extraction without adding parameters. Third, the original C2f module in YOLOv8 is modified by introducing partial convolution (PConv) to comprehensively compute key feature channels, resulting in the design of the FBC2f module. This enhancement improves feature extraction capability while reducing the number of model parameters. Finally, the standard IoU loss is sensitive to minor localization errors and fails when boxes do not overlap. Thus, a combined loss using normalized Wasserstein distance (NWD) and IoU is proposed. NWD models bounding boxes as 2D Gaussian distributions and measures similarity via Wasserstein distance, providing stable gradients even for non-overlapping tiny objects. The final loss is a weighted sum of NWD and IoU, optimized with a balancing factor α=0.5. The model is trained and evaluated on an augmented PCB defect dataset containing 5172 images with 6282 defect instances. Performance is measured using mAP50, mAP50-95, parameters, FLOPs, and frame per second (FPS). Comparative experiments include ablation studies, attention mechanism comparisons, loss function analysis, and benchmarking against state-of-the-art detectors.
Results and Discussions Experimental results demonstrate the effectiveness of PCB-YOLO: it achieves 95.6% mAP50 on the PCB defect dataset, outperforming YOLOv8n by 2.9%. It also reduces parameters by 23.6% (from 3.006 M to 2.302 M), FLOPs by 22.2% (from 8.1 G to 6.3 G), and model weight by 1.3 M. Moreover, ablation studies are finished to evaluate each proposed component contributes positively: the Conv_SWS module boosts recall by 5% and mAP50 by 2.4%; the FBC2f module reduces parameters by 23.5% with a moderate mAP50 trade-off. the NWD-IoU loss increases mAP50 by 2.3% and mAP50-95 by 2.8%. The full integration of all three modules achieves the best balance of accuracy and efficiency. Comparative evaluations demonstrate that PCB-YOLO outperforms Faster R-CNN, YOLOv5n, YOLOv10n, YOLOv11n, YOLOv12n, and the recently introduced lightweight PIC2f-YOLO in terms of both accuracy and model size. Additionally, it achieves a real-time inference speed of 160 f/s on GPU and 50 f/s on CPU, meeting the throughput demands of industrial applications. Moreover, PCB-YOLO also demonstrates strong generalization on external datasets, attaining mAP50 scores of 98.1% on the industrial aluminum surface defects dataset and 93.6% on the PKU-Market-PCB dataset, thereby verifying its robustness and transferability. Visual comparisons reveal that PCB-YOLO substantially decreases the rates of missed detections and false alarms relative to YOLOv8n, especially in the case of minor defects like shorts and mouse bites. In summary, the results validate that the Conv_SWS module effectively preserves small-object features during downsampling, the FBC2f module maintains representational capacity while reducing computation, and the NWD-IoU loss stabilizes training and improves localization for miniature targets.
Conclusions This paper proposes PCB-YOLO, a lightweight and accurate detection model designed for tiny PCB defects. The approach integrates grayscale transformation and adaptive slicing during preprocessing to enhance input data quality. It introduces the Conv_SWS module to improve small-object feature retention and designs the parameter-efficient FBC2f module. Additionally, the NWD-IoU loss is adopted to refine the regression of minor defects. Together, these contributions address key challenges in PCB inspection, including limited sample availability, background variation, small defect size, and the accuracy–complexity trade-off. Experimental results show that PCB-YOLO achieves higher detection accuracy with fewer parameters and faster inference than current leading models. It also demonstrates strong generalization across diverse industrial defect datasets. The framework offers a practical, deployable solution for real-time, high-precision PCB quality inspection in manufacturing. Future work may explore further architectural optimizations and extend the method to other micro-defect detection domains.