Chinese Journal of Agrometeorology ›› 2024, Vol. 45 ›› Issue (12): 1521-1532.doi: 10.3969/j.issn.1000-6362.2024.12.012

Previous Articles     Next Articles

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

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