Please wait a minute...
Journal of ZheJiang University (Engineering Science)  2023, Vol. 57 Issue (4): 735-743    DOI: 10.3785/j.issn.1008-973X.2023.04.011
    
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
Download: HTML     PDF(1420KB) HTML
Export: BibTeX | EndNote (RIS)      

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 wordsYOLOv3      ResNeSt      defect detection      attention mechanism      printed circuit board (PCB)     
Received: 20 April 2022      Published: 21 April 2023
CLC:  TP 391  
Fund:  上海市地方院校能力建设计划资助项目(22010501000); 上海多向模锻工程技术研究中心资助项目(20DZ2253200); 上海市临港新片区智能制造产业学院资助项目(B1-0299-21-023)
Corresponding Authors: Tian CHEN     E-mail: 374989167@qq.com;chent@sdju.edu.cn
Cite this article:

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.

URL:

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


基于改进YOLOv3的印刷电路板缺陷检测算法

针对现有基于深度学习的印刷电路板(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,满足精度和效率的要求.


关键词: YOLOv3,  ResNeSt,  缺陷检测,  注意力机制,  印刷电路板(PCB) 
Fig.1 AT-YOLO network structure
Fig.2 Structure of each module in AT-YOLO network
主干网络模型 输入图像分辨率/像素 感受野分辨率/像素 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
Tab.1 Comparison of different backbone network parameters
Fig.3 Four variations of PANet
主干网络 输入图像分辨率/像素 AP/% AP0.5/% AP0.75/%
ResNeSt50 416×416 61.07 98.43 68.41
ResNeSt101 416×416 59.90 97.48 67.08
Tab.2 Test results of different sizes of ResNeSt on detection accuracy of algorithm
颈部网络 输入图像分辨率/像素 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
Tab.3 Test results of four variations of improved PANet on detection accuracy of algorithm
缺陷类型 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
Tab.4 PCB defect dataset[12]
Fig.4 Examples of defect types after image enlargement
名称 型号
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
Tab.5 Configuration of algorithm training environment
网络模型 主干网络 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
Tab.6 Parameter comparison and detection accuracy test results of different algorithms on PCB defect dataset
缺陷类型 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↑
Tab.7 AP0.5 for different categories of defects
ResNeSt SPP 改进PANet 训练技巧 AP0.5/% pu/%
81.42
92.72 11.3↑
93.25 0.53↑
98.42 4.17
Tab.8 Results of ablation experiments of improved algorithms
Fig.5 Effect of defect detection in different backgrounds
Fig.6 Loss curve of AT-YOLO algorithm in training phase
Fig.7 AP growth curve of AT-YOLO algorithm
[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] Yu-ting SU,Rong-xuan LU,Wei ZHANG. Vehicle re-identification algorithm based on attention mechanism and adaptive weight[J]. Journal of ZheJiang University (Engineering Science), 2023, 57(4): 712-718.
[2] Yan-fen CHENG,Jia-jun WU,Fan HE. Aspect level sentiment analysis based on relation gated graph convolutional network[J]. Journal of ZheJiang University (Engineering Science), 2023, 57(3): 437-445.
[3] Huan LAN,Jian-bo YU. Steel surface defect detection based on deep learning 3D reconstruction[J]. Journal of ZheJiang University (Engineering Science), 2023, 57(3): 466-476.
[4] Fan YANG,Bo NING,Huai-qing LI,Xin ZHOU,Guan-yu LI. Multimodal image retrieval model based on semantic-enhanced feature fusion[J]. Journal of ZheJiang University (Engineering Science), 2023, 57(2): 252-258.
[5] Chao LIU,Bing KONG,Guo-wang DU,Li-hua ZHOU,Hong-mei CHEN,Chong-ming BAO. Deep clustering via high-order mutual information maximization and pseudo-label guidance[J]. Journal of ZheJiang University (Engineering Science), 2023, 57(2): 299-309.
[6] Lin-tao WANG,Qi MAO. Position measurement method for tunnel segment grabbing based on RGB and depth information fusion[J]. Journal of ZheJiang University (Engineering Science), 2023, 57(1): 47-54.
[7] Li-zhou FENG,Yang YANG,You-wei WANG,Gui-jun YANG. New method for news recommendation based on Transformer and knowledge graph[J]. Journal of ZheJiang University (Engineering Science), 2023, 57(1): 133-143.
[8] Kun HAO,Kuo WANG,Bei-bei WANG. Lightweight underwater biological detection algorithm based on improved Mobilenet-YOLOv3[J]. Journal of ZheJiang University (Engineering Science), 2022, 56(8): 1622-1632.
[9] Ren-peng MO,Xiao-sheng SI,Tian-mei LI,Xu ZHU. Bearing life prediction based on multi-scale features and attention mechanism[J]. Journal of ZheJiang University (Engineering Science), 2022, 56(7): 1447-1456.
[10] You-wei WANG,Shuang TONG,Li-zhou FENG,Jian-ming ZHU,Yang LI,Fu CHEN. New inductive microblog rumor detection method based on graph convolutional network[J]. Journal of ZheJiang University (Engineering Science), 2022, 56(5): 956-966.
[11] Xiao-chen JU,Xin-xin ZHAO,Sheng-sheng QIAN. Self-attention mechanism based bridge bolt detection algorithm[J]. Journal of ZheJiang University (Engineering Science), 2022, 56(5): 901-908.
[12] Xue-qin ZHANG,Tian-ren LI. Breast cancer pathological image classification based on Cycle-GAN and improved DPN network[J]. Journal of ZheJiang University (Engineering Science), 2022, 56(4): 727-735.
[13] Meng XU,Dan WANG,Zhi-yuan LI,Yuan-fang CHEN. IncepA-EEGNet: P300 signal detection method based on fusion of Inception network and attention mechanism[J]. Journal of ZheJiang University (Engineering Science), 2022, 56(4): 745-753, 782.
[14] Chang-yuan LIU,Xian-ping HE,Xiao-jun BI. Efficient network vehicle recognition combined with attention mechanism[J]. Journal of ZheJiang University (Engineering Science), 2022, 56(4): 775-782.
[15] Qiao-hong CHEN,Hao-lei PEI,Qi SUN. Image caption based on relational reasoning and context gate mechanism[J]. Journal of ZheJiang University (Engineering Science), 2022, 56(3): 542-549.