Please wait a minute...
浙江大学学报(工学版)  2023, Vol. 57 Issue (4): 735-743    DOI: 10.3785/j.issn.1008-973X.2023.04.011
自动化技术、计算机技术     
基于改进YOLOv3的印刷电路板缺陷检测算法
卞佰成(),陈田*(),吴入军,刘军
上海电机学院 机械学院,上海 201306
Improved YOLOv3-based defect detection algorithm for printed circuit board
Bai-cheng BIAN(),Tian CHEN*(),Ru-jun WU,Jun LIU
School of Mechanical Engineering, Shanghai Dianji University, Shanghai 201306, China
 全文: PDF(1420 KB)   HTML
摘要:

针对现有基于深度学习的印刷电路板(PCB)缺陷检测算法无法同时满足精度和效率要求的问题,提出基于YOLOv3改进的AT-YOLO算法来检测PCB缺陷. 将主干网络替换为ResNeSt50,提高特征提取能力,减少参数量. 引入SPP模块,融合不同感受野的特征,丰富了特征的表达能力. 改进PANet结构替换FPN,插入SE模块提升有效特征图的表达能力,增加1组高分辨率特征图的输入输出,提升对小目标物体的敏感程度,检测尺度由3个增加到4个. 使用K-means算法重新聚类生成锚框尺寸,提高了模型的目标检测精度. 实验证明,AT-YOLO算法在PCB缺陷检测数据集上的精度均值AP0.5达到98.42%,参数量为3.523×107,平均检测速度为36帧/s,满足精度和效率的要求.

关键词: YOLOv3ResNeSt缺陷检测注意力机制印刷电路板(PCB)    
Abstract:

An AT-YOLO algorithm based on improved YOLOv3 was proposed aiming at the problem that the existing deep learning-based defect detection algorithm for printed circuit boards (PCB) could not meet the accuracy and efficiency requirements at the same time. Feature extraction capabilities were improved and the number of parameters was reduced by replacing the backbone with ResNeSt50. SPP module was added to integrate the features of different receptive fields and enrich the ability of feature representation. The PANet structure was improved to replace FPN, and the SE module was inserted to enhance the expression capability of effective feature maps. A set of high-resolution feature maps were added to the input and output in order to improve the sensitivity to small target objects, and the detection scale was increased from three to four. K-means algorithm was re-used to generate sizes of anchors in order to improve the accuracy of object detection. The experimental results showed that the AT-YOLO algorithm had an AP0.5 value of 98.42%, the number of parameters was 3.523×107, and the average detection speed was 36 frame per second on the PCB defect detection dataset, which met the requirements of accuracy and efficiency.

Key words: YOLOv3    ResNeSt    defect detection    attention mechanism    printed circuit board (PCB)
收稿日期: 2022-04-20 出版日期: 2023-04-21
CLC:  TP 391  
基金资助: 上海市地方院校能力建设计划资助项目(22010501000); 上海多向模锻工程技术研究中心资助项目(20DZ2253200); 上海市临港新片区智能制造产业学院资助项目(B1-0299-21-023)
通讯作者: 陈田     E-mail: 374989167@qq.com;chent@sdju.edu.cn
作者简介: 卞佰成(1994—),男,硕士生,从事计算机视觉的研究. orcid.org/0000-0002-7776-5904. E-mail: 374989167@qq.com
服务  
把本文推荐给朋友
加入引用管理器
E-mail Alert
作者相关文章  
卞佰成
陈田
吴入军
刘军

引用本文:

卞佰成,陈田,吴入军,刘军. 基于改进YOLOv3的印刷电路板缺陷检测算法[J]. 浙江大学学报(工学版), 2023, 57(4): 735-743.

Bai-cheng BIAN,Tian CHEN,Ru-jun WU,Jun LIU. Improved YOLOv3-based defect detection algorithm for printed circuit board. Journal of ZheJiang University (Engineering Science), 2023, 57(4): 735-743.

链接本文:

https://www.zjujournals.com/eng/CN/10.3785/j.issn.1008-973X.2023.04.011        https://www.zjujournals.com/eng/CN/Y2023/V57/I4/735

图 1  AT-YOLO 网络结构
图 2  AT-YOLO网络中各模块的结构
主干网络模型 输入图像分辨率/像素 感受野分辨率/像素 NP/106 GFLOPs ti/ms
DarkNet53 416×416 725×725 40.603 49.2 13
ResNet50 416×416 483×483 23.508 28.3 10.9
ResNet101 416×416 1027×1027 42.5 54.0 21.7
ResNeSt50 416×416 543×543 25.434 37.2 17
ResNeSt101 416×416 1119×1119 46.226 70.6 27
表 1  不同主干网络参数的对比
图 3  PANet的4个变形
主干网络 输入图像分辨率/像素 AP/% AP0.5/% AP0.75/%
ResNeSt50 416×416 61.07 98.43 68.41
ResNeSt101 416×416 59.90 97.48 67.08
表 2  不同大小的ResNeSt对算法检测精度的测试结果
颈部网络 输入图像分辨率/像素 AP/% AP0.5/% AP0.75/%
结构A 416×416 61.07 98.43 68.41
结构B 416×416 64.53 98.42 76.23
结构C 416×416 61.06 98.52 69.71
结构D 416×416 62.46 98.22 72.78
改进PANet 416×416 59.71 97.60 66.78
表 3  改进PANet的4个变形对算法检测精度的测试结果
缺陷类型 Ng Nd
缺孔(missing hole) 1 832 3 612
缺口(mouse bite) 1 852 3 684
开路(open circuit) 1 740 3 548
短路(short) 1 732 3 508
毛刺(spur) 1 752 3 636
铜渣(spurious copper) 1 760 3 676
总计 10 668 21 664
表 4  PCB缺陷数据集[12]
图 4  图片放大后的缺陷类型实例
名称 型号
CPU Intel(R) Xeon(R) Silver 4110 CPU@ 2.10 GHz
内存 16 GB
显卡 RTX 2080Ti
显存 12 GB
操作系统 Ubuntu 18.04
编程软件 Python 3.8
深度学习框架 PyTorch 1.10
表 5  算法训练环境的配置
网络模型 主干网络 NP/106 AP,AR/% AP0.5/% AP0.75/% GFLOPs
Faster R-CNN[12] VGG-16 58.57
Faster R-CNN[12] ResNet-101 94.27
FPN[12] ResNet-101 92.23
Faster R-CNN(fine-tuned)[12] ResNet-101 96.44
TDD-Net[12] ResNet-101 98.90
YOLOv3[12] DarkNet53 81.42
YOLOv3-ultralytics DarkNet53 62.999 58.78,33.05 96.71 64.64 66.5
YOLOv5m CSP-DarkNet53 21.077 61.17,34.27 98.43 68.21 32.3
YOLOv5l CSP-DarkNet53 46.658 64.88,35.77 98.95 75.45 73.2
本文算法 ResNeSt50 35.227 64.53,35.49 98.42 76.23 45.9
表 6  PCB缺陷数据集上不同算法的参数对比和检测精度测试结果
缺陷类型 AP0.5/% pu/%
Missing hole 98.90 0.48↑
Mouse bite 98.42 0
Open circuit 98.58 0.16↑
Short 97.29 ?1.13↓
Spur 98.69 0.27↑
Spurious copper 98.61 0.19↑
表 7  不同类别缺陷的AP0.5
ResNeSt SPP 改进PANet 训练技巧 AP0.5/% pu/%
81.42
92.72 11.3↑
93.25 0.53↑
98.42 4.17
表 8  对改进算法进行消融实验的结果
图 5  不同背景下的缺陷检测效果
图 6  AT-YOLO算法在训练阶段的损失曲线
图 7  AT-YOLO算法的AP增长曲线
1 GIRSHICK R, DONAHUE J, DARRELL T, et al. Rich feature hierarchies for accurate object detection and semantic segmentation [C]// Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. Columbus: IEEE, 2014: 580-587.
2 ZOU Z, SHI Z, GUO Y, et al. Object detection in 20 years: a survey [EB/OL]. [2022-06-28]. https://arxiv.org/abs/1905.05055.
3 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
4 LIU W, ANGUELOV D, ERHAN D, et al. SSD: single shot multibox detector [C]// Proceedings of 14th European Conference on Computer Vision. Amsterdam: Springer, 2016: 21-37.
5 REDMON J, DIVVALA S, GIRSHICK R, et al. You only look once: unified, real-time object detection [C]// Proceedings of 2016 IEEE Conference on Computer Vision and Pattern Recognition. Seattle: IEEE, 2016: 779-788.
6 REDMON J, FARHADI A. YOLO9000: better, faster, stronger [C]// Proceedings of 30th IEEE/CVF Conference on Computer Vision and Pattern Recognition. Honolulu: IEEE, 2017: 6517-6525.
7 REDMON J, FARHADI A. YOLOv3: an incremental improvement [EB/OL]. [2022-06-28]. https://arxiv.org/abs/1804.02767.
8 LU Z, HE Q, XIANG X, et al Defect detection of PCB based on bayes feature fusion[J]. The Journal of Engineering, 2018, 2018 (16): 1741- 1745
doi: 10.1049/joe.2018.8270
9 ZHANG C, SHI W, LI X, et al An improved bare PCB defect detection approach based on deep feature learning[J]. The Journal of Engineering, 2018, 2018 (16): 1415- 1420
doi: 10.1049/joe.2018.8275
10 SHI W, LU Z, WU W, et al Single-shot detector with enriched semantics for PCB tiny defect detection[J]. The Journal of Engineering, 2020, 2020 (13): 366- 372
doi: 10.1049/joe.2019.1180
11 HU B, WANG J Detection of PCB surface defects with improved Faster-RCNN and feature pyramid network[J]. IEEE Access, 2020, 8: 108335- 108345
doi: 10.1109/ACCESS.2020.3001349
12 DING R, DAI L, LI G, et al TDD-Net: a tiny defect detection network for printed circuit boards[J]. 智能技术学报, 2019, 4 (2): 110- 116
DING R, DAI L, LI G, et al TDD-Net: a tiny defect detection network for printed circuit boards[J]. CAAI Transactions on Intelligence Technology, 2019, 4 (2): 110- 116
doi: 10.1049/trit.2019.0019
13 HE K, ZHANG X, REN S, et al. Deep residual learning for image recognition [C]// Proceedings of 2016 IEEE Conference on Computer Vision and Pattern Recognition. Seattle: IEEE, 2016: 770-778.
14 HUANG G, LIU Z, LAURENS V, et al. Densely connected convolutional networks [C]// Proceedings of 30th IEEE/CVF Conference on Computer Vision and Pattern Recognition. Honolulu: IEEE, 2017: 2261-2269.
15 TAN M, LE Q V. EfficientNet: rethinking model scaling for convolutional neural networks [C]// Proceedings of 36th International Conference on Machine Learning. Long Beach: PMLR, 2019: 97.
16 RADOSAVOVIC I, KOSARAJU R P, GIRSHICK R, et al. Designing network design spaces [C]// Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. Seattle: IEEE, 2020: 10425-10433.
17 ZHANG H, WU C, ZHANG Z, et al. ResNeSt: split-attention networks [C]// Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. New Orleans: IEEE, 2022: 2736-2746.
18 JIE H, LI S, GANG S, et al. Squeeze-and-excitation networks [C]// Proceedings of the 31st IEEE/CVF Conference on Computer Vision and Pattern Recognition. Salt Lake City: IEEE, 2018: 7132-7141.
19 ZHANG X, ZHOU X, LIN M, et al. ShuffleNet: an extremely efficient convolutional neural network for mobile devices [C]// Proceedings of the 31st IEEE/CVF Conference on Computer Vision and Pattern Recognition. Salt Lake City: IEEE, 2018: 6848-6856.
20 HAN K, WANG Y, TIAN Q, et al. GhostNet: more features from cheap operations [C]// Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. Seattle: IEEE, 2020: 1577-1586.
21 LIN T Y, DOLLAR P, GIRSHICK R, et al. Feature pyramid networks for object detection [C]// Proceedings of the 30th IEEE/CVF Conference on Computer Vision and Pattern Recognition. Honolulu: IEEE, 2017: 936-944.
22 LIU S, QI L, QIN H, et al. Path aggregation network for instance segmentation [C]// Proceedings of the 31st IEEE/CVF Conference on Computer Vision and Pattern Recognition. Salt Lake City: IEEE, 2018: 8759-8768.
23 GHIASI G, LIN T Y, LE Q V. NAS-FPN: learning scalable feature pyramid architecture for object detection [C]// Proceedings of the 32nd IEEE/CVF Conference on Computer Vision and Pattern Recognition. Long Beach: IEEE, 2019: 7029-7038.
24 LIU S, HUANG D, WANG Y. Learning spatial fusion for single-shot object detection [EB/OL]. [2022-06-28]. https://arxiv.org/abs/1911.09516.
25 TAN M, PANG R, LE Q V. EfficientDet: scalable and efficient object detection [C]// Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. Seattle: IEEE, 2020: 10781-10790.
26 BOCHKOVSKIY A, WANG C Y, LIAO H. YOLOv4: optimal speed and accuracy of object detection [EB/OL]. [2022-06-28]. https://arxiv.org/abs/2004.10934?.
27 WOO S, PARK J, LEE J Y, et al. CBAM: convolutional block attention module [C]// Proceedings of 15th European Conference on Computer Vision. Munich: Springer, 2018: 3-19.
28 WANG Q, WU B, ZHU P, et al. Supplementary material for ECA-Net: efficient channel attention for deep convolutional neural networks [C]// Proceedings of the 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition. Seattle: IEEE, 2020: 13-19.
[1] 苏育挺,陆荣烜,张为. 基于注意力和自适应权重的车辆重识别算法[J]. 浙江大学学报(工学版), 2023, 57(4): 712-718.
[2] 程艳芬,吴家俊,何凡. 基于关系门控图卷积网络的方面级情感分析[J]. 浙江大学学报(工学版), 2023, 57(3): 437-445.
[3] 曾耀,高法钦. 基于改进YOLOv5的电子元件表面缺陷检测算法[J]. 浙江大学学报(工学版), 2023, 57(3): 455-465.
[4] 兰欢,余建波. 基于深度学习三维成型的钢板表面缺陷检测[J]. 浙江大学学报(工学版), 2023, 57(3): 466-476.
[5] 杨帆,宁博,李怀清,周新,李冠宇. 基于语义增强特征融合的多模态图像检索模型[J]. 浙江大学学报(工学版), 2023, 57(2): 252-258.
[6] 刘超,孔兵,杜国王,周丽华,陈红梅,包崇明. 高阶互信息最大化与伪标签指导的深度聚类[J]. 浙江大学学报(工学版), 2023, 57(2): 299-309.
[7] 王林涛,毛齐. 基于RGB与深度信息融合的管片抓取位置测量方法[J]. 浙江大学学报(工学版), 2023, 57(1): 47-54.
[8] 凤丽洲,杨阳,王友卫,杨贵军. 基于Transformer和知识图谱的新闻推荐新方法[J]. 浙江大学学报(工学版), 2023, 57(1): 133-143.
[9] 郝琨,王阔,王贝贝. 基于改进Mobilenet-YOLOv3的轻量级水下生物检测算法[J]. 浙江大学学报(工学版), 2022, 56(8): 1622-1632.
[10] 莫仁鹏,司小胜,李天梅,朱旭. 基于多尺度特征与注意力机制的轴承寿命预测[J]. 浙江大学学报(工学版), 2022, 56(7): 1447-1456.
[11] 王友卫,童爽,凤丽洲,朱建明,李洋,陈福. 基于图卷积网络的归纳式微博谣言检测新方法[J]. 浙江大学学报(工学版), 2022, 56(5): 956-966.
[12] 鞠晓臣,赵欣欣,钱胜胜. 基于自注意力机制的桥梁螺栓检测算法[J]. 浙江大学学报(工学版), 2022, 56(5): 901-908.
[13] 张雪芹,李天任. 基于Cycle-GAN和改进DPN网络的乳腺癌病理图像分类[J]. 浙江大学学报(工学版), 2022, 56(4): 727-735.
[14] 许萌,王丹,李致远,陈远方. IncepA-EEGNet: 融合Inception网络和注意力机制的P300信号检测方法[J]. 浙江大学学报(工学版), 2022, 56(4): 745-753, 782.
[15] 柳长源,何先平,毕晓君. 融合注意力机制的高效率网络车型识别[J]. 浙江大学学报(工学版), 2022, 56(4): 775-782.