Please wait a minute...
浙江大学学报(工学版)  2026, Vol. 60 Issue (11): 2431-2441    DOI: 10.3785/j.issn.1008-973X.2026.11.012
计算机技术     
基于细节增强和跨尺度注意力融合的PCB缺陷检测算法
刘春娟1(),包易航1,吴小所1,*(),闫浩文1,朱铁栓2,赵浩然1
1. 兰州交通大学 电子与信息工程学院,甘肃 兰州 730070
2. 中铁第一勘察设计院集团有限公司,陕西 西安 710043
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
 全文: PDF(10074 KB)   HTML
摘要:

印刷电路板(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;  多尺度特征融合;  小波池化    
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
收稿日期: 2025-11-18 出版日期: 2026-10-16
CLC:  TP 391  
基金资助: 国家重点研发计划资助项目(2022YFB3903604);甘肃省自然科学基金资助项目(21JR7RA310);青海理工学院“昆仑英才”人才引进科研项目(W2023-QLGKLYCZX-034).
通讯作者: 吴小所     E-mail: liuchj@mail.lzjtu.cn;43452740@qq.com
作者简介: 刘春娟(1973—),女,教授,从事硅基光学器件及深度学习研究. orcid.org/0000-0001-5118-3327. E-mail:liuchj@mail.lzjtu.cn
服务  
把本文推荐给朋友
加入引用管理器
E-mail Alert
作者相关文章  
刘春娟
包易航
吴小所
闫浩文
朱铁栓
赵浩然

引用本文:

刘春娟,包易航,吴小所,闫浩文,朱铁栓,赵浩然. 基于细节增强和跨尺度注意力融合的PCB缺陷检测算法[J]. 浙江大学学报(工学版), 2026, 60(11): 2431-2441.

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.

链接本文:

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

图 1  改进的PCB缺陷检测算法整体框架
图 2  细节增强卷积的重参数技术流程
图 3  小波池化下采样算法结构
图 4  不同特征金字塔网络的结构
图 5  矩形上下文感知特征金字塔网络的组件结构
图 6  交叉注意力模块结构
图 7  不同类型PCB缺陷图像
ID缺陷类别实例数量
训练集验证集测试集总计
0缺孔24083606993467
1鼠咬30794008374316
2断路23453516973393
3短路23643297153408
4毛刺24073476763430
5残铜23863186833387
表 1  数据集中PCB缺陷类型的实例数量统计
图 8  模块的热力图可视化对比
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
表 2  细节增强卷积的部署位置对骨干网络的影响
方法mAP50/%mAP50-95/%NP
线性映射96.755.820 393 344
标准卷积97.157.423 343 232
DWConv97.057.320 401 024
表 3  深度可分离卷积的有效性分析
算法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
表 4  改进模块的消融实验结果
图 9  验证集的损失函数曲线图
图 10  不同算法在测试集上的归一化混淆矩阵对比
算法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
表 5  不同PCB缺陷检测算法的性能对比结果
图 11  多场景下2种算法的检测效果可视化对比
算法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
表 6  在DeepPCB数据集上的算法泛化能力对比实验结果
图 12  DeepPCB数据集上的算法泛化能力实验结果可视化对比
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] 董绍江,肖涛,吕振鸣,夏浩然,罗家元,孙世政,张霞,刘超. 基于改进RT-DETR的水下色偏环境中小型生物检测[J]. 浙江大学学报(工学版), 2026, 60(7): 1404-1415.
[2] 肖剑,杨小苑,何昕泽,陈林,胡欣. 基于全局信息感知的轻量级螺纹钢表面缺陷检测算法[J]. 浙江大学学报(工学版), 2026, 60(7): 1438-1451.
[3] 吴佰靖,闫光辉,马龙,程文鑫,黄亚宁. 边缘感知和跨尺度特征增强的小目标水漂垃圾检测[J]. 浙江大学学报(工学版), 2026, 60(7): 1452-1463.
[4] 李国燕,于威,梅玉鹏,张明辉,王新强. 全局局部特征融合的遥感图像建筑物提取[J]. 浙江大学学报(工学版), 2026, 60(5): 1100-1108.
[5] 田卫,周菻鈜,李欣阳,王建明,黄余康. 基于改进YOLOv8的3D打印混凝土表观缺陷检测方法[J]. 浙江大学学报(工学版), 2026, 60(4): 833-843.
[6] 李国燕,李鹏辉,刘榕,梅玉鹏,张明辉. 融合多尺度分辨率和带状特征的遥感道路提取[J]. 浙江大学学报(工学版), 2026, 60(3): 585-593.
[7] 刘慧,王防修,王意,黄淄博,苏晨. 轻量级改进RT-DETR的葡萄叶片病害检测算法[J]. 浙江大学学报(工学版), 2026, 60(3): 604-613.
[8] 曹铭,谌道宽,原鹏飞,周锦鹏,周奎. 基于深度学习的桌面级3D打印参数实时优化方法[J]. 浙江大学学报(工学版), 2026, 60(11): 2355-2363.
[9] 顾桂梅,张新龙,赵克进. 基于改进RT-DETR的接触网吊弦螺栓小目标故障检测算法[J]. 浙江大学学报(工学版), 2026, 60(11): 2418-2430.
[10] 张建刚,李肖,冯丹丹. 基于动态核感知的无人机视角路面病害检测方法[J]. 浙江大学学报(工学版), 2026, 60(10): 2141-2152.
[11] 刘子豪,张佳欣,薛峰,张俊,陈伟杰,鹿业波. 基于改进YOLO-v8的精密管件表面缺陷检测方法[J]. 浙江大学学报(工学版), 2025, 59(7): 1514-1522.
[12] 鞠文博,董华军. 基于上下文信息融合与动态采样的主板缺陷检测方法[J]. 浙江大学学报(工学版), 2025, 59(6): 1159-1168.
[13] 梁耕良,韩曙光. 基于改进RT-DETR的牛仔面料疵点检测算法[J]. 浙江大学学报(工学版), 2025, 59(6): 1169-1178.
[14] 刘登峰,郭文静,陈世海. 基于内容引导注意力的车道线检测网络[J]. 浙江大学学报(工学版), 2025, 59(3): 451-459.
[15] 梁礼明,龙鹏威,金家新,李仁杰,曾璐. 基于改进YOLOv8s的钢材表面缺陷检测算法[J]. 浙江大学学报(工学版), 2025, 59(3): 512-522.