Recognition Method of Cabbage Heads at Harvest Stage under Complex Background Based on Improved YOLOv8n
Abstract
:1. Introduction
2. Materials and Methods
2.1. Image Data Acquisition
2.2. Data Preprocessing
2.3. Model Architecture
2.3.1. Backbone
2.3.2. Head
2.3.3. Improved Loss Function
2.3.4. Model Compress
2.3.5. The YOLOv8n-Cabbage Network Structure
2.4. Experimental Environment and Training Strategies
2.5. Evaluation Metrics
3. Experiments and Results
3.1. Comparison Experiments
3.2. Pruning Experiments
3.3. Ablation Experiments
- Model 1 signifies the original YOLOv8n model serving as a baseline.
- For Model 2, the backbone network was replaced with ConvNeXt V2, optimizing the base model.
- Model 3 saw improvements to the backbone network, neck, and head by swapping the base model for ConvNeXt V2, optimizing the detection head with the DyHead block.
- Model 4 upgrades the backbone network, head, slide weighting function, and the loss function by substituting the base model with ConvNeXt V2, optimizing the detection head with the DyHead block, and altering the loss function to Slide Loss.
- Lastly, Model 5 upgrades the backbone network, head, and loss function by substituting the base model with ConvNeXt V2, optimizing the detection head with the DyHead block, and altering the loss function to Slide Loss. Finally, the model is compressed using the LAMP light-weighting approach.
3.4. Visual Analysis of Experimental Outcomes
4. Conclusions and Discussion
Author Contributions
Funding
Institutional Review Board Statement
Data Availability Statement
Conflicts of Interest
References
- Li, T.H.; Meng, Z.W.; Zheng, C.L.; Hou, J.L.; Shi, G.Y.; Xu, R. Research Status and Development of Cabbage Harvester. J. Chin. Agric. Mech. 2019, 40, 40–46. (In Chinese) [Google Scholar] [CrossRef]
- Yao, S.; Zhang, J.F.; Xiao, H.R.; Jin, Y. Research Status and Development Trend of Mechanized Cabbage Harvesting Technology. J. Chin. Agric. Mech. 2019, 40, 36–42. (In Chinese) [Google Scholar] [CrossRef]
- Tong, W.Y.; Zhang, J.F.; Song, Z.Y.; Cao, G.Q.; Jin, Y.; Ning, X.F. Research Status and Development Trend of Cabbage Mechanical Harvesting Equipment and Technology. J. Chin. Agric. Mech. 2024, 45, 322–329. (In Chinese) [Google Scholar] [CrossRef]
- Zou, L.L.; Liu, X.M.; Yuan, J.; Dong, X.H. Research Progress in Mechanized Harvesting Technology and Equipment of Leafy Vegetables. J. Chin. Agric. Mech. 2022, 43, 15–23. (In Chinese) [Google Scholar] [CrossRef]
- Wang, W.; Lv, X.L.; Wang, S.L.; Lu, D.P.; Yi, Z.Y. Current Status and Development of Stem and Leaf Vegetable Mechanized Harvesting Technology. J. China Agric. Univ. 2021, 26, 117–127. [Google Scholar]
- Tian, Y.; Yang, G.; Wang, Z.; Li, E.; Liang, Z. Instance Segmentation of Apple Flowers Using the Improved Mask R-CNN Model. Biosyst. Eng. 2020, 193, 264–278. [Google Scholar] [CrossRef]
- Zhu, X.; Ma, H.; Ji, J.T.; Jin, X.; Zhao, K.X.; Zhang, K. Detecting and Identifying Blueberry Canopy Fruits based on Faster R-CNN. J. South. Agric. 2020, 51, 1493–1501. (In Chinese) [Google Scholar]
- Zhang, L.J.; Zhou, S.H.; Li, N.; Zhang, Y.Q.; Chen, G.Y.; Gao, X. Apple Location and Classification Based on Improved SSD Convolutional Neural Network. Trans. Chin. Soc. Agric. Mach. 2023, 54, 223–232. (In Chinese) [Google Scholar]
- Yang, Z.; Gong, W.X.; Li, K.; Hao, W.; He, Z.; Ding, X.T.; Cui, Y.J. Fruit Recognition and Stem Segmentation of the Elevated Planting of Strawberries. Trans. Chin. Soc. Agric. Eng. 2023, 39, 172–181. (In Chinese) [Google Scholar]
- Hussain, D.; Hussain, I.; Ismail, M.; Alabrah, A.; Ullah, S.S.; Alaghbari, H.M. A Simple and Efficient Deep Learning-Based Framework for Automatic Fruit Recognition. Comput. Intell. Neurosci. 2022, 2022, e6538117. [Google Scholar] [CrossRef]
- Luling, N.; Reiser, D.; Stana, A.; Griepentrog, H.W. Using Depth Information and Color Space Variations for Improving Outdoor Robustness for Instance Segmentation of Cabbage. In Proceedings of the 2021 IEEE International Conference on Robotics and Automation (ICRA), Xi’an, China, 30 May–5 June 2021; IEEE: Xi’an, China, 2021; pp. 2331–2336. [Google Scholar] [CrossRef]
- Yan, J.W.; Zhao, Y.; Zhang, L.W.; Zhang, F.G. Recognition of Rosa Roxbunghii Fruit in Natural Environment Based on Residual Network. J. Chin. Agric. Mech. 2020, 41, 191–196. (In Chinese) [Google Scholar] [CrossRef]
- Liu, T.Z.; Teng, G.F.; Yuan, Y.C.; Liu, B.; Liu, Z.G. Winter Jujube Fruit Recognition Method Based on Improved YOLO v3 under Natural Scene. Trans. Chin. Soc. Agric. Mach. 2021, 52, 17–25. (In Chinese) [Google Scholar]
- Zhao, H.; Qiao, Y.J.; Wang, H.J.; Yue, Y.J. Apple Fruit Recognition in Complex Orchard Environment based on Improved YOLOv3. Trans. Chin. Soc. Agric. 2021, 37, 127–135. (In Chinese) [Google Scholar]
- Gao, F.Z.; Tang, W.J.; Chen, G.M.; Huang, J.C. Fast Recognition of Ripe Tomato Fruits in Complex Environment based on Improved YOLOv3. J. Chin. Agric. Mech. 2023, 44, 174–183. (In Chinese) [Google Scholar] [CrossRef]
- Cheng, W.; Zhang, W.A.; Feng, Q.C.; Zhang, W.H. Method of Greenhouse Tomato Fruit Identification and Yield Estimation based on Improved YOLOv3. J. Chin. Agric. Mech. 2021, 42, 176–182. (In Chinese) [Google Scholar] [CrossRef]
- Lu, S.; Chen, W.; Zhang, X.; Karkee, M. Canopy-attention-YOLOv4-based immature/mature apple fruit detection on dense-foliage tree architectures for early crop load estimation. Comput. Electron. Agric. 2022, 193, 106696. [Google Scholar] [CrossRef]
- Ma, S.; Zhang, Y.; Zhou, G.H.; Liu, B. Recognition of Pear Fruit Under Natural Environment Using an Improved YOLOv4 Model. J. Agric. Univ. Hebei 2022, 45, 105–111. (In Chinese) [Google Scholar] [CrossRef]
- Wang, N.; Qian, T.; Yang, J.; Li, L.; Zhang, Y.; Zheng, X.; Xu, Y.; Zhao, H.; Zhao, J. An Enhanced YOLOv5 Model for Greenhouse Cucumber Fruit Recognition Based on Color Space Features. Agriculture 2022, 12, 1556. [Google Scholar] [CrossRef]
- Huang, T.B.; Huang, H.Q.; Li, Z.; Lü, S.L.; Xue, X.Y.; Dai, Q.F.; Wen, W. Citrus fruit recognition method based on the improved model of YOLOv5. J. Huazhong Agric. Univ. 2022, 41, 170–177. (In Chinese) [Google Scholar] [CrossRef]
- Hou, G.; Chen, H.; Ma, Y.; Jiang, M.; Hua, C.; Jiang, C.; Niu, R. An Occluded Cherry Tomato Recognition Model Based on Improved YOLOv7. Front. Plant Sci. 2023, 14, 1260808. [Google Scholar] [CrossRef]
- Sun, G.L.; Wang, R.B.; Qian, C.; Zhou, F.; Wang, S.R. Research and Realization of Crop Instance Segmentation Based on YOLACT. In Proceedings of the 2021 3rd International Conference on Management Science and Industrial Engineering, Osaka, Japan, 2–4 April 2021; ACM: New York, NY, USA, 2021; pp. 13–20. [Google Scholar] [CrossRef]
- Liu, C.Y.; Lai, N.X.; Bi, X.J. Spherical Fruit Recognition and Location Algorithm Based on Depth Image. Trans. Chin. Soc. Agric. Mach. 2022, 53, 228–235. (In Chinese) [Google Scholar]
- Sa, I.; Lim, J.Y.; Ahn, H.S.; MacDonald, B. deepNIR: Datasets for Generating Synthetic NIR Images and Improved Fruit Detection System Using Deep Learning Techniques. Sensors 2022, 22, 4721. [Google Scholar] [CrossRef] [PubMed]
- Wang, G.; Chen, Y.; An, P.; Hong, H.; Hu, J.; Huang, T. UAV-YOLOv8: A Small-Object-Detection Model Based on Improved YOLOv8 for UAV Aerial Photography Scenarios. Sensors 2023, 23, 7190. [Google Scholar] [CrossRef] [PubMed]
- Kirillov, A.; Mintun, E.; Ravi, N.; Mao, H.; Rolland, C.; Gustafson, L.; Xiao, T.; Whitehead, S.; Berg, A.C.; Lo, W.-Y.; et al. Segment Anything. arXiv 2023, arXiv:2304.02643. [Google Scholar] [CrossRef]
- Jocher, G.; Chaurasia, A.; Qiu, J. Ultralytics Yolov8 (Ultralytics: A Collection of PyTorch Implementations of State-of-the-Art Models for Computer Vision Tasks. Available online: https://github.com/ultralytics/ultralytics (accessed on 20 October 2023).
- Woo, S.; Debnath, S.; Hu, R.; Chen, X.; Liu, Z.; Kweon, I.S.; Xie, S. ConvNeXt v2: Co-designing and scaling ConvNets with masked autoencoders. arXiv 2023, arXiv:2301.00808. [Google Scholar] [CrossRef]
- Wang, W. Advanced Auto Labeling Solution with Added Features. Advanced Auto Labeling Solution with Added Features. Available online: https://github.com/CVHub520/X-AnyLabeling (accessed on 3 November 2023).
- Dai, X.; Chen, Y.; Xiao, B.; Chen, D.; Liu, M.; Yuan, L.; Zhang, L. Dynamic head: Unifying object detection heads with attentions. arXiv 2021, arXiv:2106.08322. [Google Scholar] [CrossRef]
- Yu, Z.; Huang, H.; Chen, W.; Su, Y.; Liu, Y.; Wang, X. YOLO-FaceV2: A Scale and Occlusion Aware Face Detector. arXiv 2022, arXiv:2208.02019. [Google Scholar] [CrossRef]
- Lee, J.; Park, S.; Mo, S.; Ahn, S.; Shin, J. Layer-Adaptive Sparsity for the Magnitude-Based Pruning. arXiv 2021, arXiv:2010.07611. [Google Scholar] [CrossRef]
- Ren, S.; He, K.; Girshick, R.; Sun, J. Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks. arXiv 2016, arXiv:1506.01497. [Google Scholar] [CrossRef]
- Liu, W.; Anguelov, D.; Erhan, D.; Szegedy, C.; Reed, S.; Fu, C.-Y.; Berg, A.C. SSD: Single Shot MultiBox Detector. arXiv 2016, arXiv:1512.02325. [Google Scholar] [CrossRef]
- Lin, T.Y.; Goyal, P.; Girshick, R.; He, K.; Dollár, P. Focal Loss for Dense Object Detection. arXiv 2018, arXiv:1708.02002. [Google Scholar] [CrossRef]
- Cai, Z.; Vasconcelos, N. Cascade R-CNN: High Quality Object Detection and Instance Segmentation. IEEE Trans. Pattern Anal. Mach. Intell. 2019, 43, 1483–1498. [Google Scholar] [CrossRef] [PubMed]
- Zhu, C.; He, Y.; Savvides, M. Feature Selective Anchor-Free Module for Single-Shot Object Detection. arXiv 2019, arXiv:1903.00621. [Google Scholar] [CrossRef]
- Zhou, X.; Wang, D.; Krähenbühl, P. Objects as Points. arXiv 2019, arXiv:1904.07850. [Google Scholar] [CrossRef]
- Zhang, S.; Chi, C.; Yao, Y.; Lei, Z.; Li, S.Z. Bridging the Gap between Anchor-Based and Anchor-Free Detection via Adaptive Training Sample Selection. arXiv 2020, arXiv:1912.02424. [Google Scholar]
- Zhang, H.; Wang, Y.; Dayoub, F.; Sünderhauf, N. VarifocalNet: An IoU-Aware Dense Object Detector. arXiv 2021, arXiv:2008.13367. [Google Scholar] [CrossRef]
- Zong, Z.; Song, G.; Liu, Y. DETRs with Collaborative Hybrid Assignments Training. arXiv 2023, arXiv:2211.12860. [Google Scholar] [CrossRef]
- Jocher, G. Ultralytics Yolov5. Ultralytics Yolov5. Available online: https://github.com/ultralytics/yolov5 (accessed on 10 May 2024).
- Li, C.; Li, L.; Geng, Y.; Jiang, H.; Cheng, M.; Zhang, B.; Ke, Z.; Xu, X.; Chu, X. YOLOv6 v3.0: A Full-Scale Reloading. arXiv 2023, arXiv:2301.05586. [Google Scholar]
- Wang, C.Y.; Yeh, I.H.; Liao, H.Y.M. YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information. arXiv 2024, arXiv:2402.13616. [Google Scholar] [CrossRef]
- Jiang, P.T.; Zhang, C.B.; Hou, Q.; Cheng, M.M.; Wei, Y. LayerCAM: Exploring Hierarchical Class Activation Maps for Localization. IEEE Trans. Image Process. 2021, 30, 5875–5888. [Google Scholar] [CrossRef]
Parameter Category | Parameter Settings |
---|---|
Input Size | 640 × 640 |
Batch Size | 16 |
Epochs | 200 |
Momentum | 0.937 |
Initial learning rate | 0.01 |
Weight decay rate | 0.0005 |
Models | AP0.5/% | AP0.75/% | AP0.5:0.95/% | APsmall/% | Params/M | FPS |
---|---|---|---|---|---|---|
Faster R-CNN [33] | 91.5 | 74.4 | 66.0 | 25.4 | 41.1 | 20.3 |
SSD [34] | 80.9 | 56.7 | 51.6 | 6.8 | 23.7 | 74.2 |
RetinaNet [35] | 81.3 | 56.0 | 51.2 | 5.0 | 36.1 | 23.9 |
Cascade R-CNN [36] | 91.1 | 76.7 | 68.6 | 27.3 | 68.9 | 13.9 |
FSAF [37] | 92.6 | 75.5 | 67.8 | 24.7 | 35.0 | 24.3 |
CenterNet [38] | 92.4 | 76.4 | 67.5 | 25.6 | 31.8 | 24.9 |
ATSS [39] | 89.6 | 70.5 | 63.6 | 19.0 | 31.9 | 23.8 |
VarifocalNet [40] | 92.7 | 77.0 | 69.2 | 27.9 | 32.5 | 18.6 |
CO-DETR [41] | 90.4 | 74.3 | 67.2 | 20.4 | 64.2 | 1.8 |
YOLOv8n-Cabbage | 93.7 | 81.8 | 74.2 | 33.0 | 2.3 | 119.7 |
Models | Precision | Recall | mAP@50 | mAP@50-95 | Params/M | FPS | GFLOPs | Modelsize/MB |
---|---|---|---|---|---|---|---|---|
YOLOv5n [42] | 90.1% | 86.4% | 93.8% | 72.9% | 2.5 | 505.4 | 7.1 | 5.0 |
YOLOv6n [43] | 90.2% | 85.9% | 93.6% | 73.3% | 4.2 | 500.2 | 11.8 | 8.3 |
YOLOv6s | 89.8% | 88.0% | 94.2% | 74.5% | 16.3 | 225.4 | 44.0 | 31.3 |
YOLOv8n | 90.3% | 86.0% | 93.9% | 73.6% | 3.0 | 382.4 | 8.1 | 6.0 |
YOLOv9c [44] | 90.1% | 89.6% | 95.3% | 77.1% | 25.3 | 49.4 | 102.3 | 49.2 |
Ours | 91% | 87.2% | 94.5% | 74.5% | 2.3 | 119.7 | 7.8 | 4.8 |
Models | Precision | Recall | mAP@50 | mAP@50-95 | Params/M | FPS | GFLOPs |
---|---|---|---|---|---|---|---|
Ours Unpruned (use Separated C2f) | 91.3% | 89.2% | 94.9% | 76.2% | 6.1 | 53.6 | 15.6 |
Ours Pruned (use Separated C2f) | 91% | 87.2% | 94.5% | 74.5% | 2.3 | 119.7 | 7.8 |
Models | Pruning Rate | Precision | Recall | mAP@50 | mAP@50-95 | Params/M | FPS | GFLOPs |
---|---|---|---|---|---|---|---|---|
Ours (speed up = 4.0) | 0.77 | 90.7% | 86.7% | 94.2% | 74.5% | 1.4 | 171.4 | 3.9 |
Ours (speed up = 2.0) | 0.62 | 91% | 87.2% | 94.5% | 74.5% | 2.3 | 119.7 | 7.8 |
Ours (speed up = 1.5) | 0.42 | 91.2% | 88.1% | 94.6% | 74.8% | 3.5 | 81.5 | 10.3 |
Components | 1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|---|
ConvNeXt V2 | √ | √ | √ | √ | |
DyHead | √ | √ | √ | ||
Slide Loss | √ | √ | |||
LAMP Compress | √ | ||||
Precision | 90.3% | 90.8% | 90.7% | 91.6% | 91% (+0.7%) |
Recall | 86% | 87.8% | 87.9% | 87.1% | 87.2% (+1.2%) |
mAP@50 | 93.9% | 94.2% | 94.2% | 94.4% | 94.5% (+0.6%) |
mAP@50-95 | 73.6% | 73.9% | 74.7% | 74.4% | 74.5% (+0.9%) |
Params/M | 3.0 | 5.6 | 6.1 | 6.1 | 2.3 (−0.7) |
Modelsize/MB | 6.0 | 11.0 | 12.0 | 12.0 | 4.8 (−1.2) |
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. |
© 2024 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
Tian, Y.; Zhao, C.; Zhang, T.; Wu, H.; Zhao, Y. Recognition Method of Cabbage Heads at Harvest Stage under Complex Background Based on Improved YOLOv8n. Agriculture 2024, 14, 1125. https://doi.org/10.3390/agriculture14071125
Tian Y, Zhao C, Zhang T, Wu H, Zhao Y. Recognition Method of Cabbage Heads at Harvest Stage under Complex Background Based on Improved YOLOv8n. Agriculture. 2024; 14(7):1125. https://doi.org/10.3390/agriculture14071125
Chicago/Turabian StyleTian, Yongqiang, Chunjiang Zhao, Taihong Zhang, Huarui Wu, and Yunjie Zhao. 2024. "Recognition Method of Cabbage Heads at Harvest Stage under Complex Background Based on Improved YOLOv8n" Agriculture 14, no. 7: 1125. https://doi.org/10.3390/agriculture14071125
APA StyleTian, Y., Zhao, C., Zhang, T., Wu, H., & Zhao, Y. (2024). Recognition Method of Cabbage Heads at Harvest Stage under Complex Background Based on Improved YOLOv8n. Agriculture, 14(7), 1125. https://doi.org/10.3390/agriculture14071125