• 摘要: 针对不同底纹背景颜色的印制电路板 (printed circuit board, PCB)微小缺陷检测样本少、效率低、检测算法参数量大和精度低的问题,本文基于YOLOv8n框架提出了一种轻量化检测模型PCB-YOLO。首先,对原始的多种颜色背景的大幅面PCB数据集进行数据预处理,通过灰度变换和切片操作得到适合YOLOv8输入尺寸的PCB数据和降低颜色背景干扰影响,防止PCB的微小缺陷在缩放的过程中丢失;其次,考虑到PCB存在小目标缺陷的占比较大问题,通过结合SimAM注意力机制和合并切片操作,设计Conv_SWS (SimAM with slicing)模块,替代传统的下采样方式,保留小目标的关键信息,从而增强PCB中微小目标缺陷的特征提取并提高检测准确性;然后,对YOLOv8中原有的C2f模块进行改造,引入部分卷积 (PConv)对关键特征通道进行综合计算,设计FBC2f模块,用于增强特征提取能力并减少模型参数量;最后,采用基于Wasserstein距离的度量标准NWD (normalized Wasserstein distance)与标准IoU (intersection over union)结合改进损失函数来加速模型收敛,进一步提高YOLOv8对微小目标的检测能力。实验结果表明,与原始的YOLOv8n相比,在PCB缺陷检测数据集上的PCB-YOLO模型的参数减少了23.6%,mAP50提高了2.9%,达到95.6%。在工业铝片表面缺陷、PKU-Market-PCB缺陷数据集上的泛化性实验也验证了PCB-YOLO模型的有效性。

       

      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.