A Lightweight Detection Method for Blueberry Fruit Maturity Based on an Improved YOLOv5 Algorithm
Abstract
:1. Introduction
2. Materials and Methods
2.1. Dataset Production
2.1.1. Data Acquisition
2.1.2. Data Preprocessing
2.2. The YOLOv5 Algorithm
2.3. The Improved YOLOv5 Algorithm
2.3.1. The ShuffleNet Module
2.3.2. The CABM Module
2.3.3. The Improved YOLOv5 Algorithm
- (1)
- First, because the SPPF module needs to perform pooling operations at multiple scales and splice the results, it takes up more memory space. This limits the application of network models to resource-constrained devices. In order to achieve lightweight deep convolutional neural networks, the improved YOLOv5 algorithm removes the SPPF module from the backbone feature extraction networks of the YOLOv5 algorithm.
- (2)
- Second, the CSP Bottleneck module utilizes the multi-channel separated convolution operation. Frequently using the CSP Bottleneck module can consume a significant amount of cache space and decrease the execution speed of deep convolutional neural networks. The ShuffleNet modules with Shuffle channels are used to replace the CSPDarknet-53 modules in the backbone feature extraction networks of the YOLOv5 algorithm for blueberry fruit feature extraction.
- (3)
- Finally, the CBAM modules are integrated into the neck enhancement feature extraction networks of the YOLOv5 algorithm to enhance the feature fusion capability of deep convolutional neural networks. This enables the efficient extraction of important features and the suppression of irrelevant ones.
3. Results and Discussion
3.1. Experimental Platforms
3.2. Evaluation Metrics
3.3. Experimental Results
3.4. Performance Comparison
4. Conclusions
- (1)
- This research proposes a lightweight detection method based on an improved YOLOv5 algorithm. First, in order to achieve lightweight deep convolutional neural networks, the improved YOLOv5 algorithm removes the SPPF module from the backbone feature extraction networks of the YOLOv5 algorithm. The ShuffleNet modules with Shuffle channels are used to replace the CSPDarknet-53 modules in the backbone feature extraction networks of the YOLOv5 algorithm for blueberry fruit feature extraction. Second, the CBAM modules are integrated into the neck enhancement feature extraction networks of the YOLOv5 algorithm to enhance the feature fusion capability of lightweight deep convolutional neural networks.
- (2)
- The experimental results demonstrate that the improved YOLOv5 algorithm can effectively utilize RGB images to detect blueberry fruits and recognize their ripeness. The improved YOLOv5 algorithm achieves a P of 96.3%, an R of 92%, and a mAP of 91.5% at a threshold of 0.5. The average detection speed of the improved YOLOv5 algorithm is 67.1 fps with a batch size of 1 on the NVIDIA GeForce RTX 3080. The improved YOLOv5 algorithm has a 5.65 MB model size, 2.85 M network parameters, and 5.6 G FLOPs. Compared to other detection algorithms such as YOLOv5, SSD, and Faster R-CNN, this method has a smaller model size, smaller network parameters, lower memory usage, lower computation usage, and faster detection speed while maintaining high detection performance.
Author Contributions
Funding
Institutional Review Board Statement
Data Availability Statement
Conflicts of Interest
References
- Krishna, P.; Pandey, G.; Thomas, R.; Parks, S. Improving Blueberry Fruit Nutritional Quality through Physiological and Genetic Interventions: A Review of Current Research and Future Directions. Antioxidants 2023, 12, 810. [Google Scholar] [CrossRef] [PubMed]
- Xiao, F.; Wang, H.; Li, Y.; Cao, Y.; Lv, X.; Xu, G. Object Detection and Recognition Techniques Based on Digital Image Processing and Traditional Machine Learning for Fruit and Vegetable Harvesting Robots: An Overview and Review. Agronomy 2023, 13, 639. [Google Scholar] [CrossRef]
- Wang, H.; Lv, X.; Xiao, F.; Sun, L. Analysis and Testing of Rigid–Flexible Coupling Collision Harvesting Processes in Blueberry Plants. Agriculture 2022, 12, 1900. [Google Scholar] [CrossRef]
- Obsie, E.Y.; Qu, H.; Zhang, Y.J.; Annis, S.; Drummond, F. Yolov5s-CA: An Improved Yolov5 Based on the Attention Mechanism for Mummy Berry Disease Detection. Agriculture 2023, 13, 78. [Google Scholar] [CrossRef]
- Yang, W.; Ma, X.; Hu, W.; Tang, P. Lightweight Blueberry Fruit Recognition Based on Multi-Scale and Attention Fusion NCBAM. Agronomy 2022, 12, 2354. [Google Scholar] [CrossRef]
- Yang, W.; Ma, X.; An, H. Blueberry Ripeness Detection Model Based on Enhanced Detail Feature and Content-Aware Reassembly. Agronomy 2023, 13, 1613. [Google Scholar] [CrossRef]
- Wang, H.; Feng, J.; Yin, H. Improved Method for Apple Fruit Target Detection Based on YOLOv5s. Agriculture 2023, 13, 2167. [Google Scholar] [CrossRef]
- Gu, B.; Wen, C.; Liu, X.; Hou, Y.; Hu, Y.; Su, H. Improved YOLOv7-Tiny Complex Environment Citrus Detection Based on Lightweighting. Agronomy 2023, 13, 2667. [Google Scholar] [CrossRef]
- Ren, R.; Sun, H.; Zhang, S.; Wang, N.; Lu, X.; Jing, J.; Xin, M.; Cui, T. Intelligent Detection of Lightweight “Yuluxiang” Pear in Non-Structural Environment Based on YOLO-GEW. Agronomy 2023, 13, 2418. [Google Scholar] [CrossRef]
- Xiong, J.; Liu, Z.; Chen, S.; Liu, B.; Zheng, Z.; Zhong, Z.; Yang, Z.; Peng, H. Visual Detection of Green Mangoes by an Unmanned Aerial Vehicle in Orchards Based on a Deep Learning Method. Biosyst. Eng. 2020, 194, 261–272. [Google Scholar] [CrossRef]
- Zhang, W.; Wang, J.; Liu, Y.; Chen, K.; Li, H.; Duan, Y.; Wu, W.; Shi, Y.; Guo, W. Deep-Learning-Based in-Field Citrus Fruit Detection and Tracking. Hortic. Res. 2022, 9, uhac003. [Google Scholar] [CrossRef] [PubMed]
- Gao, F.; Fang, W.; Sun, X.; Wu, Z.; Zhao, G.; Li, G.; Li, R.; Fu, L.; Zhang, Q. A Novel Apple Fruit Detection and Counting Methodology Based on Deep Learning and Trunk Tracking in Modern Orchard. Comput. Electron. Agric. 2022, 197, 107000. [Google Scholar] [CrossRef]
- Miao, Z.; Yu, X.; Li, N.; Zhang, Z.; He, C.; Li, Z.; Deng, C.; Sun, T. Efficient Tomato Harvesting Robot Based on Image Processing and Deep Learning. Precis. Agric. 2023, 24, 254–287. [Google Scholar] [CrossRef]
- Yu, Y.; Zhang, K.; Yang, L.; Zhang, D. Fruit Detection for Strawberry Harvesting Robot in Non-Structural Environment Based on Mask-RCNN. Comput. Electron. Agric. 2019, 163, 104846. [Google Scholar] [CrossRef]
- Jia, W.; Tian, Y.; Luo, R.; Zhang, Z.; Lian, J.; Zheng, Y. Detection and Segmentation of Overlapped Fruits Based on Optimized Mask R-CNN Application in Apple Harvesting Robot. Comput. Electron. Agric. 2020, 172, 105380. [Google Scholar] [CrossRef]
- Li, J.; Zhou, H.; Jayas, D.S.; Jia, Q. Construction of a Dataset of Stored-Grain Insects Images for Intelligent Monitoring. Appl. Eng. Agric. 2019, 35, 647–655. [Google Scholar] [CrossRef]
- Xiong, Z.; Wang, L.; Zhao, Y.; Lan, Y. Precision Detection of Dense Litchi Fruit in UAV Images Based on Improved YOLOv5 Model. Remote Sens. 2023, 15, 4017. [Google Scholar] [CrossRef]
- Cai, D.; Lu, Z.; Fan, X.; Ding, W.; Li, B. Improved YOLOv4-Tiny Target Detection Method Based on Adaptive Self-Order Piecewise Enhancement and Multiscale Feature Optimization. Appl. Sci. 2023, 13, 8177. [Google Scholar] [CrossRef]
- Bie, M.; Liu, Y.; Li, G.; Hong, J.; Li, J. Real-Time Vehicle Detection Algorithm Based on a Lightweight You-Only-Look-Once (YOLOv5n-L) Approach. Expert Syst. Appl. 2023, 213, 119108. [Google Scholar] [CrossRef]
- Zhou, Z.; Fang, Z.; Wang, J.; Chen, J.; Li, H.; Han, L.; Zhang, Z. Driver Vigilance Detection Based on Deep Learning with Fused Thermal Image Information for Public Transportation. Eng. Appl. Artif. Intell. 2023, 124, 106604. [Google Scholar] [CrossRef]
- Li, Y.; Xue, J.; Zhang, M.; Yin, J.; Liu, Y.; Qiao, X.; Zheng, D.; Li, Z. YOLOv5-ASFF: A Multistage Strawberry Detection Algorithm Based on Improved YOLOv5. Agronomy 2023, 13, 1901. [Google Scholar] [CrossRef]
- Yu, G.; Zhou, X. An Improved YOLOv5 Crack Detection Method Combined with a Bottleneck Transformer. Mathematics 2023, 11, 2377. [Google Scholar] [CrossRef]
- Yang, W.; Liu, T.; Jiang, P.; Qi, A.; Deng, L.; Liu, Z.; He, Y. A Forest Wildlife Detection Algorithm Based on Improved YOLOv5s. Animals 2023, 13, 3134. [Google Scholar] [CrossRef] [PubMed]
- Niu, S.; Zhou, X.; Zhou, D.; Yang, Z.; Liang, H.; Su, H. Fault Detection in Power Distribution Networks Based on Comprehensive-YOLOv5. Sensors 2023, 23, 6410. [Google Scholar] [CrossRef] [PubMed]
- Zhang, X.; Zhou, X.; Lin, M.; Sun, J. ShuffleNet: An Extremely Efficient Convolutional Neural Network for Mobile Devices. In Proceedings of the 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR 2018), Salt Lake City, UT, USA, 18–23 June 2018. [Google Scholar] [CrossRef]
- Ma, N.; Zhang, X.; Zheng, H.T.; Sun, J. ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design. In Proceedings of the 15th European Conference on Computer Vision (ECCV 2018), Munich, Germany, 8–14 September 2018. [Google Scholar] [CrossRef]
- Zhang, T.; Sui, Y.; Wu, S.; Shao, F.; Sun, R. Table Structure Recognition Method Based on Lightweight Network and Channel Attention. Electronics 2023, 12, 673. [Google Scholar] [CrossRef]
- Wei, B.; Chen, H.; Ding, Q.; Luo, H. SiamAGN: Siamese Attention-Guided Network for Visual Tracking. Neurocomputing 2022, 512, 69–82. [Google Scholar] [CrossRef]
- Woo, S.; Park, J.; Lee, J.Y.; Kweon, I.S. CBAM: Convolutional Block Attention Module. In Proceedings of the 15th European Conference on Computer Vision (ECCV 2018), Munich, Germany, 8–14 September 2018. [Google Scholar] [CrossRef]
- Wang, Q.; Wu, B.; Zhu, P.; Li, P.; Zuo, W.; Hu, Q. ECA-Net: Efficient Channel Attention for Deep Convolutional Neural Networks. In Proceedings of the 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR 2020), Seattle, WA, USA, 13–19 June 2020. [Google Scholar] [CrossRef]
- Hu, J.; Shen, L.; Albanie, S.; Sun, G.; Wu, E. Squeeze-and-Excitation Networks. IEEE Trans. Pattern Anal. Mach. Intell. 2020, 42, 2011–2023. [Google Scholar] [CrossRef]
- Lu, A.; Ma, L.; Cui, H.; Liu, J.; Ma, Q. Instance Segmentation of Lotus Pods and Stalks in Unstructured Planting Environment Based on Improved YOLOv5. Agriculture 2023, 13, 1568. [Google Scholar] [CrossRef]
Datasets | Number of Blueberry Fruit Images | Number of Target Blueberry Fruits | ||
---|---|---|---|---|
Total | Types | Number | ||
blueberry fruit dataset | 680 | 9935 | mature | 5479 |
semi-ripe | 827 | |||
immature | 3629 | |||
training set | 544 | 7895 | mature | 4310 |
semi-ripe | 655 | |||
immature | 2930 | |||
validation set | 136 | 2040 | mature | 1169 |
semi-ripe | 172 | |||
immature | 699 |
Metrics/Models | YOLOv5 | YOLOv5-Ours | SSD-vgg | Faster R-CNN-vgg | |
---|---|---|---|---|---|
P (%) | mature | 98.7 | 97.8 | 96.0 | 93.1 |
semi-ripe | 95.5 | 96.3 | 92.7 | 87.1 | |
immature | 97.0 | 94.9 | 96.2 | 85.6 | |
mean value | 97.1 | 96.3 | 95.0 | 88.6 | |
R (%) | mature | 93.5 | 92.9 | 96.0 | 95.8 |
semi-ripe | 91.3 | 90.1 | 89.0 | 90.1 | |
immature | 93.4 | 93.0 | 93.9 | 93.0 | |
mean value | 92.7 | 92.0 | 93.0 | 93.0 | |
[email protected] (%) | mature | 95.1 | 93.7 | 95.9 | 95.6 |
semi-ripe | 91.0 | 88.8 | 88.0 | 89.1 | |
immature | 93.5 | 91.9 | 92.5 | 91.0 | |
mean value | 93.2 | 91.5 | 92.1 | 91.9 | |
Model size (MB) | 13.6 | 5.65 | 91.6 | 521.0 | |
Parameter (M) | 7.02 | 2.85 | 23.6 | 136.7 | |
FLOPs (G) | 15.8 | 5.6 | 246.6 | 376.5 | |
Speed (fps) | 66.2 | 67.1 | 44.4 | 17.0 |
Metrics/Models | YOLOv5 | YOLOv5-ShuffleNet | YOLOv5-CBAM | YOLOv5-ShuffleNet-CBAM | |
---|---|---|---|---|---|
P (%) | mature | 98.7 | 97.8 | 98.8 | 97.8 |
semi-ripe | 95.5 | 94.5 | 97.5 | 96.3 | |
immature | 97.0 | 95.9 | 97.1 | 94.9 | |
mean value | 97.1 | 96.1 | 97.8 | 96.3 | |
R (%) | mature | 93.5 | 90.8 | 96.1 | 92.9 |
semi-ripe | 91.3 | 89.5 | 90.6 | 90.1 | |
immature | 93.4 | 88.3 | 95.1 | 93.0 | |
mean value | 92.7 | 89.5 | 93.9 | 92.0 | |
[email protected] (%) | mature | 95.1 | 91.6 | 96.5 | 93.7 |
semi-ripe | 91.0 | 88.8 | 94.0 | 88.8 | |
immature | 93.5 | 87.2 | 90.4 | 91.9 | |
mean value | 93.2 | 89.2 | 93.6 | 91.5 | |
Model size (MB) | 13.6 | 2.8 | 13.6 | 5.65 | |
Parameter (M) | 7.02 | 2.84 | 7.02 | 2.85 | |
FLOPs (G) | 15.8 | 5.5 | 15.8 | 5.6 | |
Speed (fps) | 66.2 | 77.0 | 57.1 | 67.1 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Xiao, F.; Wang, H.; Xu, Y.; Shi, Z. A Lightweight Detection Method for Blueberry Fruit Maturity Based on an Improved YOLOv5 Algorithm. Agriculture 2024, 14, 36. https://doi.org/10.3390/agriculture14010036
Xiao F, Wang H, Xu Y, Shi Z. A Lightweight Detection Method for Blueberry Fruit Maturity Based on an Improved YOLOv5 Algorithm. Agriculture. 2024; 14(1):36. https://doi.org/10.3390/agriculture14010036
Chicago/Turabian StyleXiao, Feng, Haibin Wang, Yueqin Xu, and Zhen Shi. 2024. "A Lightweight Detection Method for Blueberry Fruit Maturity Based on an Improved YOLOv5 Algorithm" Agriculture 14, no. 1: 36. https://doi.org/10.3390/agriculture14010036
APA StyleXiao, F., Wang, H., Xu, Y., & Shi, Z. (2024). A Lightweight Detection Method for Blueberry Fruit Maturity Based on an Improved YOLOv5 Algorithm. Agriculture, 14(1), 36. https://doi.org/10.3390/agriculture14010036