浙江农业学报 ›› 2026, Vol. 38 ›› Issue (2): 383-396.DOI: 10.3969/j.issn.1004-1524.20250100

• 生物系统工程 • 上一篇    下一篇

轻量化改进的苹果园果实识别模型CS_YOLOv7

欧阳宇(), 刘朔(), 李萌民, 张鹏   

  1. 武汉轻工大学 数学与计算机学院, 湖北 武汉 430048
  • 收稿日期:2025-02-10 出版日期:2026-02-25 发布日期:2026-03-24
  • 作者简介:欧阳宇,研究方向为计算机视觉、目标检测。E-mail:528038794@qq.com
  • 通讯作者: *刘朔,E-mail:874477154@qq.com
  • 基金资助:
    国家自然科学基金民航联合研究基金(U1833119);湖北省重点研发计划(2023BBB046)

Lightweight and improved apple orchard fruit recognition model CS_YOLOv7

OUYANG Yu(), LIU Shuo(), LI Mengmin, ZHANG Peng   

  1. School of Mathematics & Computer Science, Wuhan Polytechnic University, Wuhan 430048, China
  • Received:2025-02-10 Online:2026-02-25 Published:2026-03-24

摘要:

针对当前苹果园果实识别面临的模型参数规模庞大、计算资源消耗量过多、模型检测精度和检测速度难以实现良好平衡的问题,提出一种基于YOLOv7改进的轻量化模型CS_YOLOv7。首先,引入通道分离的高效层注意网络(CS_ELAN)和快速空间金字塔池化(SPPF)模块,实现模型整体轻量化;其次,采用K-means++算法生成适合本研究数据集的新先验框,增强模型定位目标的能力;然后,改用Wise-IoU损失函数代替原损失函数,减少低质量示例的有害梯度,提升模型收敛速度和目标识别的定位能力;最后,通过添加一种基于空间和通道维度的注意力机制SE_CBAM,使模型在更全局角度下提取苹果小目标的关键特征。结果表明:相较于原YOLOv7模型,改进模型的平均精确率(交并比为0.5,mAP@0.5)提升了1.7百分点,模型大小减少22.3 MB,检测速度提升118.9 frame·s-1,模型参数量和计算量分别减少31.8%和16.1%。CS_YOLOv7模型在优化准确度的同时实现了多方位的轻量化,可应用于果园幼果数据集目标的快速识别,为今后高效的实时目标识别和后续的机器采摘奠定基础。

关键词: 苹果园, 果实识别, 机器视觉, 模型优化

Abstract:

Aiming at the problems faced by current fruit recognition in apple orchards, such as excessive model parameter scale, high computational resource consumption, and difficulty in achieving a good balance between model detection accuracy and speed, a lightweight improved model CS_YOLOv7 based on YOLOv7 was proposed. Firstly, the channel-split efficient layer aggregation network (CS_ELAN) and the spatial pyramid pooling fast (SPPF) module were introduced into the model to achieve overall lightweighting of the model. Secondly, the K-means++algorithm was adopted to generate new anchor boxes suitable for the dataset in this study, so as to enhance the model’s target localization capability. Thirdly, the Wise-IoU loss function was used to replace the original loss function, which reduced the harmful gradients of low-quality samples and improved the model convergence speed and target recognition localization accuracy. Finally, an attention mechanism SE_CBAM based on spatial and channel dimensions was added to enable the model to extract key features of small apple targets from a more global perspective. The results showed that, compared with the original YOLOv7 model, the improved model achieved a 1.7 percentage points increase in the mean average precision under the intersection over union of 0.5 (mAP@0.5), a reduction of 22.3 MB in model size, and an improvement of 118.9 frames·s-1 in detection speed. Meanwhile, the number of model parameters and computational complexity decreased by 31.8% and 16.1%, respectively. The CS_YOLOv7 model achieves multi-dimensional lightweighting while optimizing accuracy, which can be applied to the rapid recognition of young fruits in orchard datasets, and lays a foundation for efficient real-time target recognition and subsequent robotic picking in the future.

Key words: apple orchard, fruit recognition, machine vision, model optimization

中图分类号: