河南农业科学 ›› 2024, Vol. 53 ›› Issue (3): 141-150.DOI: 10.15933/j.cnki.1004-3268.2024.03.015

• 农业信息与工程·农产品加工 • 上一篇    下一篇

基于改进YOLOv7 的苹果表面缺陷轻量化检测算法

李大华1,2,3,孔舒1,2,3,李栋1,2,3,于晓1,2,3   

  1. (1.天津理工大学电气工程与自动化学院,天津 300384;2.天津市新能源电力变换传输与智能控制重点实验室,天津 300384;3.天津市复杂系统控制理论及应用重点实验室,天津 300384)
  • 收稿日期:2023-08-15 出版日期:2024-03-15 发布日期:2024-04-19
  • 通讯作者: 李栋(1985-),男,天津人,实验师,硕士,主要从事自动控制理论、智能制造等研究。E-mail:lid85@163.com
  • 作者简介:李大华(1978-),男,天津人,教授,硕士,主要从事人工智能、智能微电网等研究。E-mail:lidah2005@163.com
  • 基金资助:
    国家自然科学基金项目(61502340);天津市自然科学基金项目(18JCQNJC01000);天津理工大学教学基金项目(YB20-05);天津市复杂系统控制理论与应用重点实验室开放基金项目(TJKL-CATCS-201907)

Light Weight Detection Algorithm for Apple Surface Defect Based on Improved YOLOv7

LI Dahua1,2,3,KONG Shu1,2,3,LI Dong1,2,3,YU Xiao1,2,3   

  1. (1.College of Electrical and Electronic Engineering,Tianjin University of Technology,Tianjin 300384,China;2.Tianjin Key Laboratory of New Energy Power Conversion,Transmission and Intelligent Control,Tianjin 300384,China;3.Tianjin Key Laboratory for Control Theory & Application in Complicated System,Tianjin 300384,China)
  • Received:2023-08-15 Published:2024-03-15 Online:2024-04-19

摘要: 针对如何提高苹果表面缺陷的检测速度和精度,解决模型内存占比大的问题,提出一种基于改进YOLOv7的苹果表面缺陷轻量化检测算法。首先引入GhostNetV2作为YOLOv7网络的backbone,有效降低了模型复杂度,提高了检测速度。并引入SimAM无参注意力机制,以强化不同深度的特征信息。使用双向加权特征金字塔结构BiFPN进行加权特征融合,进一步提升苹果表面缺陷的检测精度。最后采用ECIOU损失函数来计算边界框损失,进一步提高模型收敛速度和整体性能。结果表明,改进YOLOv7模型在苹果表面缺陷检测上mAP@0.5较原YOLOv7网络提高2.0百分点,准确率和召回率也分别提升了1.7、3.9百分点,模型减小20.8 MB,速度提升36.43 帧/s。其综合性能也优于SSD、CenterNet等主流算法,可实现对苹果表面缺陷的快速准确诊断。

关键词: 苹果表面缺陷, YOLOv7, GhostNetV2, 注意力机制, BiFPN, ECIOU

Abstract: Aiming at how to improve the detection speed and accuracy of apple surface defects and solve the problem of large model memory ratio,a lightweight detection algorithm for apple surface defects based on improved YOLOv7 was proposed. Firstly,GhostNetV2 was introduced as the backbone of YOLOv7 network,which effectively reduced the model complexity and improved the detection speed.SimAM attention‐free mechanism was introduced to enhance the feature information of different depth.The bidirectional weighted feature pyramid BiFPN was used for weighted feature fusion to further improve the detection accuracy of apple surface defects.Finally,the ECIOU loss function was used to calculate the boundary frame loss,which further improved the convergence speed and the overall performance of the model.Experimental results showed that compared with the original YOLOv7 network,the improved model improved the apple surface defect detection mAP@0.5 by 2 percentage points,the accuracy rate and recall rate by 1.7 and 3.9 percentage points respectively. The model decreased by 20.8 MB and the speed increased by 36.43 FPS.Its comprehensive performance was also better than SSD,CenterNet and other mainstream algorithms,which can realize the rapid and accurate diagnosis of apple surface defects.

Key words: Apple surface defect, YOLOv7, GhostNetV2, Attention mechanism, BiFPN, ECIOU

中图分类号: