计算机与现代化 ›› 2024, Vol. 0 ›› Issue (12): 45-52.doi: 10.3969/j.issn.1006-2475.2024.12.007

• 算法设计与分析 • 上一篇    下一篇

基于YOLOv7改进的PCB缺陷检测方法


  


  1. (中北大学电子测试技术国家重点实验室,山西 太原 030051)
  • 出版日期:2024-12-31 发布日期:2024-12-31
  • 基金资助:
    山西省重点研发项目(201903D121058)

PCB Defect Detection Method Based on Improved YOLOv7

  1. (State Key Laboratory of Electronic Test Technology, North University of China, Taiyuan 030051, China)
  • Online:2024-12-31 Published:2024-12-31

摘要: 针对目前传统网络模型对PCB缺陷检测不准确、检测速度慢、识别精度低等问题, 提出了一种基于YOLOv7改进的PCB缺陷检测方法。首先,该方法在原YOLOv7模型基础上采用FasterNet中的部分卷积PConv代替CatConv,从而减少内存访问和参数量,提高检测速度;其次,将双向特征金字塔网络(BiFPN)引入到YOLOv7模型的头部网络,实现PCB缺陷的多尺度特征融合,提升模型的检测精度,再次,将FasterNet模块与BiFPN融合,形成YOLOv7+FasterNet+BiFPN的PCB缺陷检测模型,增强模型对缺陷的特征表达能力;最后,将原有的CIoU改进为XIoU损失函数,不仅提高了模型的收敛速度和对小目标边界框的扰动抵抗能力,也准确地衡量了边界框预测的准确性和定位精度。实验结果表明:改进后的YOLOv7模型在测试集上的mAP@0.5达到了95.7%,召回率为98.0%,相比于原YOLOv7模型mAP@0.5值和召回率分别提高了7、2个百分点,检测时间仅为21.7 ms,同时,FLOPs值与原模型相比计算量也减小了6.5 G。本文方法在检测速度、查全率和准确率等方面均优于传统网络,为PCB缺陷检测提供了有效的解决方案。

关键词: FasterNet, PCB缺陷检测, BiFPN, 内存访问, YOLOv7, 多尺度特征融合

Abstract: A PCB defect detection method based on an improved version of YOLOv7 has been proposed to address the issues of inaccurate detection, slow detection speed, and low recognition accuracy in traditional network models. Firstly, this method replaces CatConv with partial convolution PConv from FasterNet in the original YOLOv7 model to reduce memory access and parameter quantity, thereby improving detection speed. Secondly, a bidirectional feature pyramid network (BiFPN) is introduced into the head network of the YOLOv7 model to achieve multi-scale feature fusion for PCB defect detection, enhancing the model’s detection accuracy. The FasterNet module is then fused with BiFPN to form the YOLOv7+FasterNet+BiFPN model for PCB defect detection, enhancing the model's capability to express defect features. Finally, the original CIoU loss function is improved to XIoU loss function, which not only improve the convergence speed of the model and its resistance to perturbations on small bounding boxes, but it also accurately measures the accuracy and localization precision of the bounding box predictions. The experimental results show that the improved YOLOv7 model achieves an mAP@0.5 of 95.7% and a recall rate of 98.0% on the test set. Compared to the original YOLOv7 model, the mAP@0.5 value and recall rate have increased by 7 and 2 percentage points, respectively. The detection time is only 21.7 ms. Additionally, the computational complexity of FLOPs has also decreased by 6.5 G compared to the original model. The proposed method outperforms traditional network models in terms of detection speed, recall rate, and accuracy, providing an effective solution for PCB defect detection.

Key words: FasterNet, PCB defect detection, BiFPN, memory access, YOLOv7, multi-scale feature fusion

中图分类号: