基于CFSC–DETR的PCB缺陷检测算法

PCB defect detection algorithm based on CFSC–DETR

  • 摘要: 印刷电路板(Printed circuit board,PCB)缺陷检测是电子制造质量控制中的关键环节,其检测精度与实时性直接影响产品可靠性和生产效率. 然而,PCB缺陷通常具有尺度微小且易与复杂线路背景混淆等特点,导致现有检测方法在微小目标表征、背景干扰抑制和精确定位方面仍存在不足. 为此,本文在RT-DETR基础上构建一种跨尺度特征融合与状态空间协同建模的检测模型(CFSC–DETR). 在骨干网络ResNet18中引入DualConv模块,降低计算冗余并增强局部纹理提取能力;在编码阶段,提出注意力状态空间推理模块(DASM),通过窗口注意力与状态空间建模的协同作用增强对PCB拓扑结构和长距离上下文信息的表达能力,减弱背景信息干扰;在颈部网络中,构建3D自适应跨尺度融合颈部网络(L3D–AFFN)以提升微小缺陷跨尺度融合过程中的细粒度语义保留能力;同时提出Wasserstein–几何协同损失函数(WGS–IoU),联合分布相似性与几何一致性约束,提高微小及异形缺陷的边界框回归精度. 实验结果表明,该模型在PKU-Market-PCB数据集上较RT-DETR在mAP50、精确率和召回率上分别提升3.29、4.06和4.71个百分点,同时模型参数量降低至15.23 MB,推理速度达到每秒97.64帧,并在DsPCBSD+和DeepPCB数据集上表现出较好的跨场景泛化能力. 与其他主流目标检测模型相比,该方法在复杂背景下PCB微小缺陷检测任务中表现出更强的综合性能.

     

    Abstract: Printed circuit board (PCB) defect detection serves as an essential quality control procedure in the modern electronic manufacturing chain. Its detection precision and real-time inference speed directly influence the final product reliability, production yield, and overall production efficiency of industrial automated assembly lines. Defective regions occupy an extremely small proportion of image pixels and share texture features that are highly similar to dense and complex circuit traces, metal pads, and conductive vias, which pose severe obstacles to most existing detection algorithms and increase the risk of false detections. Current mainstream deep learning detection methods have evident limitations in three key technical aspects: insufficient fine-grained feature characterization for tiny defective targets, limited capacity to suppress complex background interference generated by intertwined and dense wiring, and unsatisfactory localization accuracy for irregular and micro-defects. To address these critical challenges in industrial inspection, this study constructs a cross-scale feature fusion and state-space collaborative modeling detection model (CFSC–DETR) based on the classic real-time detection transformer (RT-DETR) architecture. In the feature extraction backbone network, ResNet18, a lightweight DualConv module is introduced to eliminate redundant convolutional operations and reduce the computational overhead while significantly boosting the capability of the network to capture the fine local textures and edge information associated with tiny micro-PCB defects. During the encoder feature modeling phase, a detail-aware attentive state-space reasoning module(DASM) is proposed for global context learning. By integrating a local window attention mechanism with linear-complexity state-space modeling, this module enhances the ability of the model to capture the integral topological structure of complete PCB boards and long-range contextual information across discrete image regions, thereby effectively reducing the disturbance from irrelevant and visually similar background circuit textures. For multiscale feature aggregation and fusion, a 3D adaptive feature fusion neck network (L3D–AFFN) is specially constructed for small-object detection tasks. This structural design effectively prevents the severe loss of fine-grained semantic information associated with tiny defects during cross-scale feature fusion and preserves the complete defect feature information across all multiscale feature layers. Moreover, a novel Wasserstein–geometric synergistic intersection over union loss function (WGS–IoU) is proposed for regression optimization. This loss function jointly imposes dual complementary constraints including the distribution similarity, measured by the Wasserstein distance, and the geometric consistency of bounding boxes, which stabilizes gradient propagation during model training and remarkably enhances the bounding box regression precision for both ultra-small defects and abnormally shaped irregular defects on PCBs. Extensive ablation and comparative experiments are conducted on the open PKU-Market-PCB public dataset. The experimental results indicate that, compared with the original RT-DETR baseline model, the proposed CFSC–DETR improves mAP50, precision, and recall by 3.29, 4.06, and 4.71 percentage points, respectively. Meanwhile, the total parameter size of the optimized lightweight model is reduced to 15.23 MB, and the real-time inference speed of 97.64 FPS is achieved on a single GPU, balancing the high detection accuracy with low computational cost. Additional cross-domain generalization tests on DsPCBSD+ and DeepPCB datasets further validate the strong cross-scene generalization capacity of the proposed CFSC–DETR model. Comparative experiments with multiple state-of-the-art mainstream object detection algorithms further demonstrate that CFSC-DETR possesses superior performance when addressing the challenging task of tiny PCB defect detection under highly intricate and complex circuit backgrounds.

     

/

返回文章
返回