计算机工程与应用 ›› 2025, Vol. 61 ›› Issue (15): 288-297.DOI: 10.3778/j.issn.1002-8331.2406-0020

• 图形图像处理 • 上一篇    下一篇

基于改进YOLOv8s的PCB小目标缺陷检测模型

王健,肖迪,冯李航,沈成   

  1. 南京工业大学 电气工程与控制科学学院,南京 211816
  • 出版日期:2025-08-01 发布日期:2025-07-31

PCB Small Object Defect Detection Model Based on Improved YOLOv8s

WANG Jian, XIAO Di, FENG Lihang, SHEN Cheng   

  1. Colloge of Electrical Engineering and Control Science, Nanjing Tech University, Nanjing 211816, China
  • Online:2025-08-01 Published:2025-07-31

摘要: 针对目前PCB缺陷检测中面临缺陷的形态复杂、目标小,难以对其进行精确的捕捉,导致识别检出率、准确率低等问题,提出了基于改进YOLOv8s的PCB小目标缺陷检测算法优化。提出增设小目标检测层,同时添加小物体检测头提高在小目标情况下的检测效果;在骨干网络中引入可选择空洞卷积(S-Conv)与CAFM(context-aware feature modulation)卷积和注意力融合模块,扩大感受野,在提升特征表示能力的同时增强对各尺度特征进行融合;使用可变形卷积和空间信息增强模块设计更加灵活和有效的空间金字塔池化层,提高模型对目标特征的表征能力和检测精度;融合信息聚集-分发机制对颈部结构进行改进。改进损失函数,以VFWD-CIoU代替原损失函数,提升密集小目标检测。改进后的模型算法在四张拼凑的PCB小目标数据集上进行相关对比实验。结果表明,改进后算法模型的平均精度(mAP)为99.1%。相比于Faster R-CNN、YOLOv5、YOLOv7等网络模型,检测精度得到很大的提升,表明该算法可以运用于实际生产环境中的PCB小目标缺陷检测。

关键词: PCB, 小目标缺陷检测, YOLOv8s, 特征融合, 注意力机制, 损失函数

Abstract: In response to the complex morphology and small targets of defects in current PCB defect detection, which make it difficult to accurately capture them, resulting in low recognition and detection rates, this paper proposes an optimized PCB small target defect detection algorithm based on improved YOLOv8s. Firstly, a small object detection layer and a small object detection head is added to improve the detection performance in the case of small targets. Secondly, optional dilated convolution (S-Conv), CAFM (context aware feature modulation) convolution and attention fusion modules are introduced into the backbone network to expand the receptive field, enhance feature representation ability, and enhance the fusion of features at various scales. Using deformable convolution and spatial information enhancement modules, more flexible and effective spatial pyramid pooling layers are designed to improve the representation ability and detection accuracy of target features of the model. This paper introduces an information aggregation distribution mechanism to improve the neck structure. Finally, the loss function is improved by replacing the original loss function with VFWD-CIoU to enhance the detection of dense small targets. The improved model algorithm is used for comparative experiments on four pieced PCB small target datasets. The results show that the average accuracy (mAP) of the improved algorithm model is 99.1%. Compared with Faster R-CNN, YOLOv5, and YOLOv7 network models, the detection accuracy has been greatly improved, indicating that this algorithm can be applied to PCB small target defect detection in actual production environments.

Key words: PCB, small target defect detection, YOLOv8s, feature fusion, attention mechanism, loss function