Please wait a minute...
Journal of ZheJiang University (Engineering Science)  2026, Vol. 60 Issue (11): 2431-2441    DOI: 10.3785/j.issn.1008-973X.2026.11.012
    
PCB defect detection algorithm based on detail enhancement and cross-scale attention fusion
Chunjuan LIU1(),Yihang BAO1,Xiaosuo WU1,*(),Haowen YAN1,Tieshuan ZHU2,Haoran ZHAO1
1. School of Electronic and Information Engineering, Lanzhou Jiaotong University, Lanzhou 730070, China
2. China Railway First Survey and Design Institute Group Co., Ltd., Xi’an 710043, China
Download: HTML     PDF(10074KB) HTML
Export: BibTeX | EndNote (RIS)      

Abstract  

An improved algorithm for printed circuit board (PCB) defect detection, named DCFA-DETR, was proposed to address the challenge of balancing detection accuracy and speed arising from the multi-scale variations and fine-grained features of PCB surface defects and complex circuit backgrounds. DCFA-DETR was developed based on the RT-DETR baseline. In the backbone, detail-enhanced convolution (DEConv) and wavelet pooling were introduced to enhance the algorithm’s capability of representing high-frequency details, such as defect edges, from the source. In the neck, a rectangular context-aware feature pyramid network (RCAFPN) and a high-resolution cross-attention module (HRCAM) were designed to aggregate multi-scale contextual information efficiently, fusing shallow high-resolution features to improve the detection performance for tiny-target defects. Furthermore, the dynamic focusing mechanism of the Wise-IoUv3 loss function was utilized to optimize the regression precision of bounding boxes. Experiments were conducted on the PKU-Market-PCB dataset. DCFA-DETR achieved an mAP50 of 97.0%, an mAP50-95 of 57.3%, and an inference speed of 84.4 FPS for single image inputs. The proposed algorithm balances detection accuracy and speed effectively.



Key words: printed circuit board (PCB)      defect detection      RT-DETR      multi-scale feature fusion      wavelet pooling     
Received: 18 November 2025      Published: 16 October 2026
CLC:  TP 391  
Fund:  国家重点研发计划资助项目(2022YFB3903604);甘肃省自然科学基金资助项目(21JR7RA310);青海理工学院“昆仑英才”人才引进科研项目(W2023-QLGKLYCZX-034).
Corresponding Authors: Xiaosuo WU     E-mail: liuchj@mail.lzjtu.cn;43452740@qq.com
Cite this article:

Chunjuan LIU,Yihang BAO,Xiaosuo WU,Haowen YAN,Tieshuan ZHU,Haoran ZHAO. PCB defect detection algorithm based on detail enhancement and cross-scale attention fusion. Journal of ZheJiang University (Engineering Science), 2026, 60(11): 2431-2441.

URL:

https://www.zjujournals.com/eng/10.3785/j.issn.1008-973X.2026.11.012     OR     https://www.zjujournals.com/eng/Y2026/V60/I11/2431


基于细节增强和跨尺度注意力融合的PCB缺陷检测算法

印刷电路板(PCB)表面缺陷尺度多变、特征精细且电路背景复杂,导致缺陷检测的精度与速度难以平衡,为此提出改进的PCB缺陷检测算法DCFA-DETR. 以RT-DETR为基线,将细节增强卷积(DEConv)与小波池化引入骨干网络,从源头强化算法对高频细节(如缺陷边缘)的表征能力. 颈部设计矩形上下文感知特征金字塔网络(RCAFPN)和高分辨率交叉注意力模块(HRCAM),高效聚合多尺度上下文信息,通过融合浅层高分辨率特征提升检测微小目标缺陷的性能,利用Wise-IoUv3损失函数的动态聚焦机制优化边界框的回归精度. 实验结果表明,DCFA-DETR在PKU-Market-PCB数据集上的mAP50达到97.0%,mAP50-95达到57.3%,单张图片推理速度为84.4 帧/s. 所提算法在检测精度与速度间取得了平衡.


关键词: 印制电路板(PCB),  缺陷检测,  RT-DETR,  多尺度特征融合,  小波池化 
Fig.1 Overall framework of improved algorithm for PCB defect detection
Fig.2 Re-parameterization process of detail-enhanced convolution
Fig.3 Structure of wavelet pooling downsampling algorithm
Fig.4 Structures of different feature pyramid networks
Fig.5 Structure of rectangular context-aware feature pyramid network components
Fig.6 Structure of cross attention block
Fig.7 Images of different types of defects on PCBs
ID缺陷类别实例数量
训练集验证集测试集总计
0缺孔24083606993467
1鼠咬30794008374316
2断路23453516973393
3短路23643297153408
4毛刺24073476763430
5残铜23863186833387
Tab.1 Instance counts of different PCB defect types in dataset
Fig.8 Visual comparison of heatmaps between two blocks
DEConv位置mAP50/%mAP50-95/%NP
第一阶段第二阶段第三阶段第四阶段
√———97.057.320 401 024
—√——96.557.120 401 280
——√—96.257.120 401 792
———√95.454.920 402 816
——√√95.456.420 403 840
—√√√95.552.120 404 352
√√√√96.757.220 141 440
Tab.2 Effect of deployment position of detail-enhanced convolution on back bone
方法mAP50/%mAP50-95/%NP
线性映射96.755.820 393 344
标准卷积97.157.423 343 232
DWConv97.057.320 401 024
Tab.3 Analysis of effectiveness of depth-wise separable convolution
算法RCAFPNHRCAMWPDEConvWIoUP/%R/%mAP50/%mAP50-95/%GFLOPsRF/(帧·s?1)
基线—————96.391.994.752.157.070.8
2√————97.092.595.455.448.276.7
3—√———96.992.895.755.162.382.8
4——√——97.193.195.555.063.394.5
5———√—97.292.795.656.157.095.0
6————√96.793.095.654.257.098.9
7√√———97.192.796.255.955.376.9
8√√√——96.792.896.156.661.684.3
9√√√√—97.293.496.657.161.684.3
DCFA-DETR√√√√√97.894.397.057.361.684.4
Tab.4 Ablation results of improved modules
Fig.9 Loss function curves on validation set
Fig.10 Comparison of normalized confusion matrices of different algorithms on test set
算法NPP/%R/%AP50/%mAP50/%GFLOPsRF/(帧·s?1)
缺孔鼠咬断路短路毛刺残铜
Faster-RCNN136 851 73488.381.693.081.482.491.980.485.385.7271.421.7
SSD26 275 48579.271.885.671.175.681.265.479.076.362.790.2
YOLOv8m25 843 23495.788.299.492.390.697.884.096.693.578.779.8
YOLOv9m20 159 26695.386.899.389.787.797.084.294.692.177.080.2
YOLOv10m15 316 64294.486.799.389.487.196.583.494.791.758.983.1
RT-DETR-l31 996 32696.993.897.596.892.295.793.899.395.9103.546.2
RT-DETR-R1819 879 46496.391.996.596.191.793.691.598.894.757.070.8
DCFA-DETR20 401 02497.894.397.897.794.696.995.499.597.061.684.4
Tab.5 Performance comparison of different PCB defect detection algorithms
Fig.11 Visual comparison of detection results between two algorithms in multiple scenarios
算法PRmAP50mAP50-95
Faster R-CNN92.683.483.154.6
YOLOv8m97.295.397.567.6
YOLOv9m97.094.897.363.2
YOLOv10m94.993.997.165.9
RT-DETR-R1896.293.597.765.3
DCFA-DETR98.394.598.370.8
Tab.6 Generalization comparison results of algorithms on DeepPCB dataset %
Fig.12 Visual comparison of generalization ability experimental results on DeepPCB dataset
[1]   BALAKRISHNAN T, SENGAR S S. RepVGG-GELAN: enhanced GELAN with VGG-STYLE convnets for brain tumour detection [C]// Computer Vision and Image Processing. Cham: Springer, 2026: 417–430.
[2]   ZHENG X, ZHENG S, KONG Y, et al Recent advances in surface defect inspection of industrial products using deep learning techniques[J]. The International Journal of Advanced Manufacturing Technology, 2021, 113 (1): 35- 58
doi: 10.1007/s00170-021-06592-8
[3]   YANG J, WANG C, JIANG B, et al Visual perception enabled industry intelligence: state of the art, challenges and prospects[J]. IEEE Transactions on Industrial Informatics, 2021, 17 (3): 2204- 2219
doi: 10.1109/TII.2020.2998818
[4]   CHEN X, WU Y, HE X, et al A comprehensive review of deep learning-based PCB defect detection[J]. IEEE Access, 2023, 11: 139017- 139038
doi: 10.1109/ACCESS.2023.3339561
[5]   REN S, HE K, GIRSHICK R, et al Faster R-CNN: towards real-time object detection with region proposal networks[J]. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2017, 39 (6): 1137- 1149
doi: 10.1109/TPAMI.2016.2577031
[6]   REDMON J, DIVVALA S, GIRSHICK R, et al. You only look once: unified, real-time object detection [C]// Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. Las Vegas: IEEE, 2016: 779–788.
[7]   VARGHESE R, M S. YOLOv8: a novel object detection algorithm with enhanced performance and robustness [C]// Proceedings of the International Conference on Advances in Data Engineering and Intelligent Computing Systems. Chennai: IEEE, 2024: 1–6.
[8]   WANG C Y, YEH I H, MARK LIAO H Y. YOLOv9: learning what you want toLearn using programmable gradient information [C]// Computer Vision – ECCV 2024. Cham: Springer, 2025: 1–21.
[9]   WANG A, CHEN H, LIU L, et al. YOLOv10: real-time end-to-end object detection [C]// Proceedings of the Advances in Neural Information Processing Systems 37. Vancouver: NeurIPS, 2024: 107984–108011.
[10]   SABERIRONAGHI A, REN J, EL-GINDY M Defect detection methods for industrial products using deep learning techniques: a review[J]. Algorithms, 2023, 16 (2): 95
doi: 10.3390/a16020095
[11]   卞佰成, 陈田, 吴入军, 等 基于改进YOLOv3的印刷电路板缺陷检测算法[J]. 浙江大学学报: 工学版, 2023, 57 (4): 735- 743
BIAN Baicheng, CHEN Tian, WU Rujun, et al Improved YOLOv3-based defect detection algorithm for printed circuit board[J]. Journal of Zhejiang University: Engineering Science, 2023, 57 (4): 735- 743
doi: 10.3785/j.issn.1008-973X.2023.04.011
[12]   LI K, ZHONG X, HAN Y Pcb defect detection based on a novel dual-domain high-frequency adaptive enhanced pooling method[J]. Cluster Computing, 2025, 28 (11): 707
doi: 10.1007/s10586-025-05438-2
[13]   周著国, 鲁玉军, 吕利叶 基于改进YOLOv5s的印刷电路板缺陷检测算法[J]. 浙江大学学报: 工学版, 2025, 59 (8): 1608- 1616
ZHOU Zhuoguo, LU Yujun, LV Liye Improved YOLOv5s-based algorithm for printed circuit board defect detection[J]. Journal of Zhejiang University: Engineering Science, 2025, 59 (8): 1608- 1616
doi: 10.3785/j.issn.1008-973X.2025.08.007
[14]   VASWANI A, SHAZEER N, PARMAR N, et al. Attention is all you need [C]// Proceedings of the 31st International Conference on Neural Information Processing Systems. [S.l.]: Curran Associates Inc. , 2017: 6000–6010.
[15]   CARION N, MASSA F, SYNNAEVE G, et al. End-to-end object detection with transformers [C]// Computer Vision – ECCV 2020. Cham: Springer, 2020: 213–229.
[16]   ZHU X, SU W, LU L, et al. Deformable DETR: deformable transformers for end-to-end object detection [EB/OL]. (2021–03–18)[2025–10–07]. https://arxiv.org/pdf/2010.04159.
[17]   LIU S, LI F, ZHANG H, et al. DAB-DETR: dynamic anchor boxes are better queries for DETR [EB/OL]. (2022–03–30)[2025–10–07]. https://arxiv.org/pdf/2201.12329.
[18]   LI F, ZHANG H, LIU S, et al. DN-DETR: accelerate DETR training by introducing query denoising [C]// Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. New Orleans: IEEE, 2023: 13619–13627.
[19]   ZHANG H, LI F, LIU S, et al. DINO: DETR with improved denoising anchor boxes for end-to-end object detection [EB/OL]. (2022–07–11)[2025–10–07]. https://arxiv.org/pdf/2203.03605.
[20]   ZHAO Y, LV W, XU S, et al. DETRs beat YOLOs on real-time object detection [C]// Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. Seattle: IEEE, 2024: 16965–16974.
[21]   CHEN Z, HE Z, LU Z M DEA-net: single image dehazing based on detail-enhanced convolution and content-guided attention[J]. IEEE Transactions on Image Processing, 2024, 33: 1002- 1015
doi: 10.1109/TIP.2024.3354108
[22]   WILLIAMS T, LI R Y. Wavelet pooling for convolutional neural networks [C]// Proceedings of the International Conference on Learning Representations. Vancouver: [s.n.], 2018: 1–12.
[23]   LIN H, CHENG X, WU X, et al. CAT: cross attention in vision transformer [C]// Proceedings of the IEEE International Conference on Multimedia and Expo. Taipei. IEEE, 2022: 1–6.
[24]   TONG Z, CHEN Y, XU Z, et al. Wise-IoU: bounding box regression loss with dynamic focusing mechanism [EB/OL]. (2023–04–08)[2025–10–07]. https://arxiv.org/pdf/2301.10051.
[25]   DING X, XIA C, ZHANG X, et al. RepMLP: re-parameterizing convolutions into fully-connected layers for image recognition [EB/OL]. (2022–03–30)[2025–10–07]. https://arxiv.org/pdf/2105.01883.
[1] Shaojiang DONG,Tao XIAO,Zhenming LV,Haoran XIA,Jiayuan LUO,Shizheng SUN,Xia ZHANG,Chao LIU. Small organism detection in underwater color-cast environments based on improved RT-DETR[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(7): 1404-1415.
[2] Jian XIAO,Xiaoyuan YANG,Xinze HE,Lin CHEN,Xin HU. Lightweight rebar surface defect detection algorithm based on global information perception[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(7): 1438-1451.
[3] Baijing WU,Guanghui YAN,Long MA,Wenxin CHENG,Yaning HUANG. Small-target water-floating garbage detection based on edge perception and cross-scale feature enhancement[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(7): 1452-1463.
[4] Guoyan LI,Wei YU,Yupeng MEI,Minghui ZHANG,Xinqiang WANG. Building extraction from remote sensing images with global-local feature fusion[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(5): 1100-1108.
[5] Wei TIAN,Linhong ZHOU,Xinyang LI,Jianming WANG,Yukang HUANG. 3D-printed concrete apparent defect detection method based on improved YOLOv8[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(4): 833-843.
[6] Guoyan LI,Penghui LI,Rong LIU,Yupeng MEI,Minghui ZHANG. Remote sensing road extraction by fusing multi-scale resolution and strip feature[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(3): 585-593.
[7] Hui LIU,Fangxiu WANG,Yi WANG,Zibo HUANG,Chen SU. Lightweight improved RT-DETR algorithm for grape leaf disease detection[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(3): 604-613.
[8] Ming CAO,Daokuan CHEN,Pengfei YUAN,Jinpeng ZHOU,Kui ZHOU. Real-time optimization method for desktop level 3D printing parameters based on deep learning[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(11): 2355-2363.
[9] Guimei GU,Xinlong ZHANG,Kejin ZHAO. Small-target fault detection algorithm for dropper bolts in overhead catenary systems based on improved RT-DETR[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(11): 2418-2430.
[10] Jiangang ZHANG,Xiao LI,Dandan FENG. Dynamic kernel perception for pavement distress detection in UAV inspection[J]. Journal of ZheJiang University (Engineering Science), 2026, 60(10): 2141-2152.
[11] Tao ZHOU,Pengfei WANG,Weijie GAO. Device defect detection based on intrinsic rotational symmetry[J]. Journal of ZheJiang University (Engineering Science), 2025, 59(9): 1856-1863.
[12] Zihao LIU,Jiaxin ZHANG,Feng XUE,Jun ZHANG,Weijie CHEN,Yebo LU. Surface defect detection method of precision pipe fittings based on improved YOLO-v8[J]. Journal of ZheJiang University (Engineering Science), 2025, 59(7): 1514-1522.
[13] Wenbo JU,Huajun DONG. Motherboard defect detection method based on context information fusion and dynamic sampling[J]. Journal of ZheJiang University (Engineering Science), 2025, 59(6): 1159-1168.
[14] Gengliang LIANG,Shuguang HAN. Denim fabric defect detection algorithm based on improved RT-DETR[J]. Journal of ZheJiang University (Engineering Science), 2025, 59(6): 1169-1178.
[15] Dengfeng LIU,Wenjing GUO,Shihai CHEN. Content-guided attention-based lane detection network[J]. Journal of ZheJiang University (Engineering Science), 2025, 59(3): 451-459.