Please wait a minute...
Journal of ZheJiang University (Engineering Science)  2023, Vol. 57 Issue (3): 455-465    DOI: 10.3785/j.issn.1008-973X.2023.03.003
    
Surface defect detection algorithm of electronic components based on improved YOLOv5
Yao ZENG(),Fa-qin GAO*()
School of Information Science and Engineering, Zhejiang Sci-Tech University, Hangzhou 310018, China
Download: HTML     PDF(1697KB) HTML
Export: BibTeX | EndNote (RIS)      

Abstract  

For the poor real-time detection capability of the current object detection model in the production environment of electronic components, GhostNet was used to replace the backbone network of YOLOv5. And for the existence of small objects and objects with large scale changes on the surface defects of electronic components, a coordinate attention module was added to the YOLOv5 backbone network, which enhanced the sensory field while avoiding the consumption of large computational resources. The coordinate information was embedded into the channel attention to improve the object localization of the model. The feature pyramid networks (FPN) structure in the YOLOv5 feature fusion module was replaced with a weighted bi-directional feature pyramid network structure, to enhance the fusion capability of multi-scale weighted features. Experimental results on the self-made defective electronic component dataset showed that the improved GCB-YOLOv5 model achieved an average accuracy of 93% and an average detection time of 33.2 ms, which improved the average accuracy by 15.0% and the average time by 7 ms compared with the original YOLOv5 model. And the improved model can meet the requirements of both accuracy and speed of electronic component surface defect detection.



Key wordsobject detection network      deep learning      surface defect of electronic component      YOLOv5      attention module     
Received: 30 May 2022      Published: 31 March 2023
CLC:  TP 391.4  
Fund:  浙江省教育厅一般科研项目(专业学位专项)(Y202147956)
Corresponding Authors: Fa-qin GAO     E-mail: yaozeng2019@163.com;gfqzjlg@126.com
Cite this article:

Yao ZENG,Fa-qin GAO. Surface defect detection algorithm of electronic components based on improved YOLOv5. Journal of ZheJiang University (Engineering Science), 2023, 57(3): 455-465.

URL:

https://www.zjujournals.com/eng/10.3785/j.issn.1008-973X.2023.03.003     OR     https://www.zjujournals.com/eng/Y2023/V57/I3/455


基于改进YOLOv5的电子元件表面缺陷检测算法

目标检测模型在电子元件生产环境中的实时检测能力不佳,为此采用GhostNet替换YOLOv5的主干网络. 针对电子元件表面缺陷存在小目标及尺度变化较大的目标的情况,在YOLOv5主干网络中加入坐标注意力机制,在避免大量计算资源消耗的前提下增强感受野,将坐标信息嵌入通道注意力中以提升模型对目标的定位. 使用加权双向特征金字塔网络结构替换YOLOv5特征融合模块中的特征金字塔网络(FPN)结构,提升多尺度加权特征的融合能力. 在自制缺陷电子元件数据集上的实验结果表明,改进的GCB-YOLOv5模型平均精度达到93%,平均检测时间为33.2 ms,相比于原始YOLOv5模型,平均精度提高了15.0%,平均时间提升了7 ms,可以同时满足电子元件表面缺陷检测精度与速度的需求.


关键词: 目标检测网络,  深度学习,  电子元件表面缺陷,  YOLOv5,  注意力机制 
Fig.1 Network structure of YOLOv5-6.0
Fig.2 Results of data augmentation using Mosaic for self-made dataset
Fig.3 Results of data augmentation using Copy-Paste for self-made dataset
Fig.4 Traditional convolution and Ghost module convolution
Fig.5 Two structures of Ghost bottleneck layer
Fig.6 Structure of improved CSP_1
Fig.7 Coordinate attention module
Fig.8 Comparison of three feature pyramid structures
Fig.9 Self-made electronic components surface defects dataset display
配置对象 配置内容
操作系统 Windows 10
处理器 NVIDIA GeForce GTX 1050
开发环境 PyCharm
深度学习框架 Pytorch 1.7.1
CUDA Cuda 10.1
CUDNN Cudnn 7.6.5
采样相机 海康工业相机MV-CE050-31GM
Tab.1 Configuration of YOLOv5 model training experimental environment
模型 权重大小/106 Np /106 GFLOPs mAP@0.5 RF/(帧·s?1)
YOLOv5s 13.70 7.02 15.9 0.809 25
YOLOv5m 68.90 34.00 50.0 0.824 14
YOLOv5l 147.00 73.20 111.4 0.833 9
YOLOv5x 269.00 134.20 209.8 0.846 5
YOLOv5s-Mobilenet-small 7.17 3.25 6.0 0.857 32
YOLOv5s-Shufflenet 1.97 3.79 7.9 0.887 34
GCB-YOLOv5 11.60 5.90 14.0 0.930 30
Tab.2 Experimental comparison results of different algorithms for detection on self-made dataset
Fig.10 Comparison of defect detection results on self-made electronic component surface defect datasets with two models
模型 mAP@0.5
轧入氧化皮 划痕
YOLOv5s 0.608 0.842
GCB-YOLOv5 0.728 0.925
Tab.3 Comparative experimental results on NEU surface defect database with two models
Fig.11 Comparison of surface defect detection results on NEU surface defect database with two models
模型 Ghostnet替换主干 加入注意力模块 修改特征金字塔 mAP@0.5 mAP@0.5 RF/(帧·s?1)
划伤类 压印类
YOLOv5s × × × 0.809 0.766 0.852 25
模型一 × × 0.823 0.771 0.875 37
模型二 × × 0.890 0.853 0.927 24
模型三 × × 0.854 0.804 0.894 21
GCB-YOLOv5 0.930 0.887 0.972 30
Tab.4 Result of ablation experiment with YOLOv5s adding different modules
[1]   王宇, 吴智恒, 邓志文, 等 基于机器视觉的金属零件表面缺陷检测系统[J]. 机械工程与自动化, 2018, (4): 210- 211+214
WANG Yu, WU Zhi-heng, DENG Zhi-wen, et al Metal component surface defect detection system based on machine vision[J]. Mechanical Engineering and Automation, 2018, (4): 210- 211+214
doi: 10.3969/j.issn.1672-6413.2018.04.088
[2]   HO C C, SU E, LI P, et al Machine vision and deep learning based rubber gasket defect detection[J]. Advances in Technology Innovation, 2020, 5 (2): 76- 83
doi: 10.46604/aiti.2020.4278
[3]   李璟钰, 肖俊良, 付晗, 等 基于机器视觉的导光板表面微小缺陷检测[J]. 信息系统工程, 2021, (2): 65- 69
LI Jing-yu, XIAO Jun-liang, FU Han, et al Detection of small defects on the surface of light guide plates[J]. China CIO News, 2021, (2): 65- 69
[4]   戴君洁. 基于机器视觉的目标识别和表面缺陷检测研究[D]. 大理: 大理大学, 2021.
DAI Jun-jie. Research on object recognition and surface defect detection based on machine vision [D]. Dali: Dali University, 2021.
[5]   LIU W, ANGUELOV D, ERHAN D, et al. SSD: single shot MultiBox detector [EB/OL]. [2022-04-07]. https://arxiv.org/pdf/1512.02325.pdf.
[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]   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.
[8]   GIRSHICK R. Fast R-CNN [C]// 2015 IEEE International Conference on Computer Vision. Santiago: IEEE, 2015: 1440-1448.
[9]   REN S Q, HE K M, 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
[10]   HE K M, GKIOXARI G, DOLLÁR P, et al. Mask R-CNN [C]// 2017 IEEE International Conference on Computer Vision. Venice: IEEE, 2017: 2980−2988.
[11]   黄海新, 金鑫. 基于YOLOv4的小目标缺陷检测[J]. 电子世界, 2021(5): 146-147.
HUANG Hai-xin, JIN Xin. Detection of small object defect based on YOLOv4 [J]. Electronics World, 2021(5): 146-147.
[12]   刘聪. 基于卷积神经网络的微小零件表面缺陷检测技术研究[D]. 哈尔滨: 哈尔滨理工大学, 2019.
LIU Cong. Research on surface defects detection of micro parts based on convolution neural network [D]. Harbin: Harbin University of Science and Technology, 2019.
[13]   陈绪浩. 基于深度学习的高速连接器高精度表面缺陷检测算法研究[D]. 成都: 电子科技大学, 2021.
CHEN Xu-hao. Research on high precision surface defect detection algorithm of high speed connector based on deep learning [D]. Chengdu: University of Electronic Science and Technology of China, 2021.
[14]   代牮, 赵旭, 李连鹏, 等 基于改进YOLOv5的复杂背景红外弱小目标检测算法[J]. 红外技术, 2022, 44 (5): 504- 512
DAI Jian, ZHAO Xu, LI Lian-peng, et al Improved YOLOv5-based infrared dim-small target detection under complex background[J]. Infrared Technology, 2022, 44 (5): 504- 512
[15]   HOU Q, ZHOU D, FENG J. Coordinate attention for efficient mobile network design [C]// Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. Nashville: IEEE, 2021: 13708-13717.
[16]   TAN M, PANG R, LE Q V. EfficientDet: scalable and efficient object detection [EB/OL]. [2022-04-07]. https://arxiv.org/pdf/1911.09070.pdf.
[17]   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.
[18]   LIU S, QI L, QIN H, et al. Path aggregation network for instance segmentation [C]// Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. Lake City: IEEE, 2018: 8759-8768.
[19]   BOCHKOVSKIY A, WANG C Y, LIAO H Y M. YOLOv4: optimal speed and accuracy of object detection [EB/OL]. [2022-04-07]. https://arxiv.org/pdf/2004.10934.pdf.
[20]   GHIASI G, CUI Y, SRINIVAS A, et al. Simple copy-paste is a strong data augmentation method for instance segmentation [EB/OL]. [2022-04-07]. https://arxiv.org/pdf/2012.07177.pdf.
[1] Ju-xiang ZENG,Ping-hui WANG,Yi-dong DING,Lin LAN,Lin-xi CAI,Xiao-hong GUAN. Graph neural network based node embedding enhancement model for node classification[J]. Journal of ZheJiang University (Engineering Science), 2023, 57(2): 219-225.
[2] Jian-sha LU,Qin BAO,Hong-tao TANG,Yi-ping SHAO,Wen-bin ZHAO. Optimal tag selection method for device-free human tracking system[J]. Journal of ZheJiang University (Engineering Science), 2023, 57(2): 415-425.
[3] Jun-chi MA,Xiao-xin DI,Zong-tao DUAN,Lei TANG. Survey on program representation learning[J]. Journal of ZheJiang University (Engineering Science), 2023, 57(1): 155-169.
[4] Chen YE,Hong-fei ZHAN,Ying-jun LIN,Jun-he YU,Rui WANG,Wu-chang ZHONG. Design knowledge recommendation based on inference-context-aware activation model[J]. Journal of ZheJiang University (Engineering Science), 2023, 57(1): 32-46.
[5] Jin-zhen LIU,Fei CHEN,Hui XIONG. Open electrical impedance imaging algorithm based on multi-scale residual network model[J]. Journal of ZheJiang University (Engineering Science), 2022, 56(9): 1789-1795.
[6] Wan-liang WANG,Tie-jun WANG,Jia-cheng CHEN,Wen-bo YOU. Medical image segmentation method combining multi-scale and multi-head attention[J]. Journal of ZheJiang University (Engineering Science), 2022, 56(9): 1796-1805.
[7] 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.
[8] Yong-sheng ZHAO,Rui-xiang LI,Na-na NIU,Zhi-yong ZHAO. Shape control method of fuselage driven by digital twin[J]. Journal of ZheJiang University (Engineering Science), 2022, 56(7): 1457-1463.
[9] Li HE,Shan-min PANG. Face reconstruction from voice based on age-supervised learning and face prior information[J]. Journal of ZheJiang University (Engineering Science), 2022, 56(5): 1006-1016.
[10] 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.
[11] Jing-hui CHU,Li-dong SHI,Pei-guang JING,Wei LV. Context-aware knowledge distillation network for object detection[J]. Journal of ZheJiang University (Engineering Science), 2022, 56(3): 503-509.
[12] Ruo-ran CHENG,Xiao-li ZHAO,Hao-jun ZHOU,Han-chen YE. Review of Chinese font style transfer research based on deep learning[J]. Journal of ZheJiang University (Engineering Science), 2022, 56(3): 510-519, 530.
[13] Tian-le YUAN,Ju-long YUAN,Yong-jian ZHU,Han-chen ZHENG. Surface defect detection algorithm of thrust ball bearing based on improved YOLOv5[J]. Journal of ZheJiang University (Engineering Science), 2022, 56(12): 2349-2357.
[14] Yun-zuo ZHANG,Wei GUO,Zhao-quan CAI,Wen-bo LI. Remote sensing image target detection combining multi-scale and attention mechanism[J]. Journal of ZheJiang University (Engineering Science), 2022, 56(11): 2215-2223.
[15] Fan ZHONG,Zheng-yao BAI. 3D point cloud super-resolution with dynamic residual graph convolutional networks[J]. Journal of ZheJiang University (Engineering Science), 2022, 56(11): 2251-2259.