中国农业气象 ›› 2024, Vol. 45 ›› Issue (12): 1521-1532.doi: 10.3969/j.issn.1000-6362.2024.12.012

• 农业气象信息技术 栏目 • 上一篇    下一篇

基于改进YOLOv5的番茄成熟度检测方法

刘洋,宫志宏,黎贞发,刘涛,赵卓,王腾歌   

  1. 1.天津农学院计算机与信息工程学院,天津 300384;2.天津市气候中心,天津 300074
  • 收稿日期:2023-11-24 出版日期:2024-12-20 发布日期:2024-12-20
  • 作者简介:刘洋, E-mail:2468662768@qq.com
  • 基金资助:
    中国气象局气象能力提升联合研究专项(24NLTSQ003);天津市蔬菜产业技术体系创新团队科研专项(ITTVRS2021017)

Tomato Ripeness Detection Method Based On Improved YOLOv5

LIU Yang, GONG Zhi-hong, LI Zhen-fa, LIU Tao, ZHAO Zhuo, WANG Teng-ge   

  1. 1.Computer and Information Engineering College, Tianjin Agricultural University, Tianjin 300384, China; 2.Tianjin Climate Center, Tianjin 300074
  • Received:2023-11-24 Online:2024-12-20 Published:2024-12-20

摘要:

为提高番茄果实成熟度的识别精度,实现番茄种植环节成熟度在线无损自动检测,本研究提出一种基于改进YOLOv5的番茄成熟度检测方法。针对番茄果实间因藤蔓、叶片的遮挡以及光照干扰而导致的识别误差、图像中小目标番茄检测难等问题,在YOLOv5算法的骨干网络Backbone中增加ECA高效通道注意力模块,将Neck结构中PAFPN替换为具有双向加权融合能力的BiFPN,在Head结构中添加小目标检测模块,通过消融试验获取最优改进算法YOLOv5tomatoA。结果表明:相对于YOLOv3TinySSD300Faster RCNN目标检测网络,YOLOv5tomatoA算法在遮挡和光照不均等复杂场景下,平均精度均值和F1得分分别达到97.4%95.4%,图像识别仅需14.7ms,能同时满足高精度和快速响应的番茄果实识别需求。改进后的YOLOv5网络结构优化了内存占比和资源消耗,仅占用15.9M,模型更加轻量化,对实现番茄成熟度的在线无损检测具备一定的实用价值,该技术也可用于番茄自动采摘机器人设计中。

关键词: 番茄, YOLOv5, 数据增强, 目标检测, 注意力机制

Abstract:

In order to improve the recognition accuracy of tomato fruit ripeness and to realize online nondestructive automatic detection in tomato planting chain, this study proposes a tomato ripeness detection method based on improved YOLOv5. In the field of agriculture, accurate identification of tomato ripeness is very important, which can help agricultural production to rationalize labor arrangements and timely harvesting, thus improving the yield and quality of agricultural products. Traditional target detection algorithms face some challenges in tomato ripeness recognition, such as misidentification and missed detection, due to factors such as vines and leaf shading between tomato fruits and light interference. Therefore, this study had carried out a series of optimizations of YOLOv5 to address these problems in order to improve the accuracy and robustness of the algorithm. In the first place, an ECA efficient channel attention module was added to its backbone network Backbone, which generated channel weights by one-dimensional convolution and captured small targets that could be easily ignored in tomatoes of different ripening stages by interacting with the k neighboring channels of each channel, thus enhancing the expressiveness and accuracy of tomato features and effectively mitigating the effects of occlusion and light interference on the recognition results. Moreover, the PAFPN in the Neck structure was replaced by BiFPN with bidirectional weighted fusion capability. BiFPN was able to bi-directionally fuse features of different scales, which better handled the occlusion problem between tomato fruits and improves the accuracy of the recognition, and this optimization also mitigated the effect of multi-targets on the recognition accuracy, which enabled the algorithm to perform better in complex scenarios. Finally, a P2 module for small-target detection was added to the Head structure. The P2 module was able to better combine the advantages of shallow and deep tomato features to improve the detection performance of small-target tomatoes, so that it can accurately detect the target even when there are small-target tomatoes and other complex situations in the image. Through a series of ablation experiments, authors obtained the optimal improved algorithm YOLOv5-tomatoA. Compared to traditional target detection networks such as YOLOv3-Tiny, SSD300 and Faster R-CNN, the algorithm performs well in complex scenes such as occlusion and uneven illumination, with an average accuracy mean and F1 score of 97.4% and 95.4%, respectively, and the recognition of an image takes only 14.7ms, which can simultaneously satisfy the high-precision and fast-response tomato fruit recognition. The improved YOLOv5 network structure also optimizes the memory footprint and resource consumption, occupying only 15.9M, making the model more lightweight. This mean that the algorithm had low equipment requirements for realizing online non-destructive testing of tomato ripening, which can provide a more convenient real-time monitoring tool for agricultural activities. This technique can also be applied to the design of automatic tomato picking robots, which provides a strong support to realize the automation and intelligence of the tomato planting process. Therefore, this improved YOLOv5-tomatoA algorithm has important practical value in the field of tomato ripeness detection and is expected to provide more accurate and intelligent management decision support for agricultural production.

Key words: Tomato, YOLOv5, Data enhancement, Target detection, Attention mechanism