计算机工程与应用 ›› 2023, Vol. 59 ›› Issue (20): 228-236.DOI: 10.3778/j.issn.1002-8331.2206-0041

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

改进YOLOv4的野生菌视觉检测方法

张泽冰,张冬妍,娄蕴祎,崔明迪,王克奇   

  1. 东北林业大学 机电工程学院,哈尔滨 150040
  • 出版日期:2023-10-15 发布日期:2023-10-15

Improved YOLOv4 Visual Detection Method for Wild Bacteria

ZHANG Zebing, ZHANG Dongyan, LOU Yunyi, CUI Mingdi, WANG Keqi   

  1. College of Mechanical and Electrical Engineering, Northeast Forestry University, Harbin 150040, China
  • Online:2023-10-15 Published:2023-10-15

摘要: 人工搜寻野生香菇效率低下,且存在一定危险性;而对于复杂情况下小目标检测的算法研究多集中于精度提升,检测效率与模型参数量不满足实际需求。基于此,提出一种基于改进YOLOv4的机器视觉检测方法,在保证精度前提下,提升检测效率,满足嵌入式设备的需求。以YOLOv4为框架,采用高效的ShuffleNetv2特征提取网络、轻量级的自适应空间特征融合(ASFF)结构减少网络参数和计算量,针对检测分支,将深度可分离卷积(DWConv)和金字塔卷积(PyConv)替代普通卷积以进行轻量化改进。在此基础上优化模型精度:网络输出端引入SA注意力模块以少量计算代价弥补轻量化改进造成的精度损失;最后Weight DIoU NMS算法优化预测框选取。利用1?112张野生蘑菇图片,按照8∶2的比例划分训练集与测试集。实验结果表明:改进YOLOv4模型检测结果AP为88.76%,F1为0.858,FPS为67.93,模型权重尺寸为52.28?MB,相比于YOLOv4的AP为91.5%,F1为0.890,FPS为37.15,精度变化幅度小,速度提升82.9%,模型权重尺寸仅为原来的21.4%。网络模型在保证检测精度的同时,检测速度明显提升,可为野生菌嵌入式采摘设备提供理论支持。

关键词: 目标检测, 野生香菇, YOLOv4, ShuffleNetv2, 模型轻量化, 检测精度优化

Abstract: Manual search for wild shiitake mushrooms is inefficient and has certain dangers. The research on algorithms for small target detection in complex situations mostly focuses on the improvement of accuracy, and the detection efficiency and model parameters do not meet the actual needs. Based on this, a machine vision detection method based on improved YOLOv4 is proposed to improve the detection efficiency and meet the needs of embedded devices on the premise of ensuring accuracy. With YOLOv4 as the framework, an efficient ShuffleNetv2 feature extraction network and a lightweight adaptively spatial feature fusion(ASFF) structure are adopted to reduce network parameters and computation. In addition, for detection branches, depthwise separable convolution(DWConv) and pyramidal convolution(PyConv) are used to replace ordinary convolution for lightweight improvement. On this basis, the model accuracy is optimized:SA attention module is introduced into the output end of the network to compensate for the accuracy loss caused by the lightweight improvement with a small computational cost. Finally, the WeightDIoUNMS algorithm is proposed to optimize the prediction box selection. Using 1 112 wild mushroom images, the training set and test set are divided in an 8∶2 ratio. The experimental results show that:improved YOLOv4 model detection results AP is 88.76%, F1 is 0.858, FPS is 67.93, model weight size is 52.28 MB, compared with YOLOv4’s AP is 91.5%, F1 is 0.890, FPS is 37.15, accuracy change is small. The speed is increased by 82.9%, and the weight size of the model is only 21.4% of that of the original model. The network model can not only ensure the detection accuracy, but also improve the detection speed, which can provide theoretical support for the wild bacteria embedded picking equipment.

Key words: object detection, wild shiitake mushrooms, YOLOv4, ShuffleNetv2, model lightweight, detection accuracy optimization