Research on Detection Algorithm of Green Walnut in Complex Environment
Abstract
:1. Introduction
- A drone walnut dataset is constructed to collect walnut data under complex environments from different angles. The dataset includes various complex situations such as fruits with similar colors to the background under different lighting conditions, and occlusion by leaves and overlapping fruits.
- We propose a walnut detection algorithm, GDAD-YOLOv5s, designed for complex environments. It includes a lightweight feature extraction module, a more efficient feature fusion module DE_C3, and an improved loss function Alpha CIoU. These enhancements aim to improve the model’s ability to focus on critical information about walnuts, enhance feature extraction performance, accelerate model convergence, and increase the accuracy of walnut recognition.
- The model compression techniques of pruning and knowledge distillation were introduced to obtain a more lightweight and efficient walnut detection model, which was then deployed on a small edge device for inference testing. The results indicate that the model processes each image in an average of 201.95 ms on this device, showing a significant improvement in detection performance compared to the baseline model YOLOv5s.
2. Materials and Methods
2.1. Dataset
2.1.1. Study Area
2.1.2. Drone Data Collection
2.1.3. Dataset Creation
2.2. YOLOv5 Object Detection Algorithm
2.3. Algorithm Improvement
2.3.1. Reconstruction of Backbone Network
2.3.2. Depthwise Separable Convolution
2.3.3. ECA Attention Mechanism
2.3.4. Lightweight C3
2.3.5. Loss Function Improvement
2.4. Model Compression
2.4.1. Pruning
2.4.2. Knowledge Distillation
2.5. Experimental Environment and Parameter Setting
2.6. Metrics
3. Experiment and Analysis
3.1. Experiments
3.1.1. Comparison Experiment of Lightweight Backbone Network
3.1.2. Optimization Experiment of Feature Fusion Layer
3.1.3. Ablation Experiment
3.1.4. Comparison Experiments of Different Models
3.1.5. Pruning Optimization Experiment
3.1.6. Knowledge Distillation Optimization Experiment
3.2. Analysis of Detection Effect in Complex Environment
3.2.1. Comparison of Occlusion Detection
3.2.2. Comparison of Near Background Detection
4. Model Deployment
5. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Data Availability Statement
Conflicts of Interest
References
- Manterola-Barroso, C.; Padilla Contreras, D.; Ondrasek, G.; Horvatinec, J.; Gavilán CuiCui, G.; Meriño-Gergichevich, C. Hazelnut and Walnut Nutshell Features as Emerging Added-Value Byproducts of the Nut Industry: A Review. Plants 2024, 13, 1034. [Google Scholar] [CrossRef] [PubMed]
- Hua, X.; Li, H.; Zeng, J.; Han, C.; Chen, T.; Tang, L.; Luo, Y. A review of target recognition technology for fruit picking robots: From digital image processing to deep learning. Appl. Sci. 2023, 13, 4160. [Google Scholar] [CrossRef]
- Sa, I.; Zong, G.; Feras, D.; Ben, U.; Tristan, P.; Chris, M.C. Deepfruits: A Fruit Detection System Using Deep Neural Networks. Sensors 2016, 16, 1222. [Google Scholar] [CrossRef] [PubMed]
- Supawadee, C.; Dailey, M.N. Texture-based fruit detection. Precis. Agric. 2014, 15, 662–683. [Google Scholar]
- Payne, A.B.; Walsh, K.B.; Subedi, P.P.; Jarvis, D. Estimation of mango crop yield using image analysis–segmentation method. Comput. Electron. Agric. 2013, 91, 57–64. [Google Scholar] [CrossRef]
- Payne, A.; Walsh, K.; Subedi, P.; Jarvis, D. Estimating mango crop yield using image analysis using fruit at ‘stone hardening’stage and night time imaging. Comput. Electron. Agric. 2014, 100, 160–167. [Google Scholar] [CrossRef]
- Bai, Y.; Mao, S.; Zhou, J.; Zhang, B. Clustered tomato detection and picking point location using machine learning-aided image analysis for automatic robotic harvesting. Precis. Agric. 2023, 24, 727–743. [Google Scholar] [CrossRef]
- Montoya-Cavero, L.E.; de León Torres, R.D.; Gómez-Espinosa, A.; Cabello, J.A.E. Vision systems for harvesting robots: Produce detection and localization. Comput. Electron. Agric. 2022, 192, 106562. [Google Scholar] [CrossRef]
- Xiao, F.; Wang, H.; Xu, Y.; Zhang, R. Fruit detection and recognition based on deep learning for automatic harvesting: An overview and review. Agronomy 2023, 13, 1625. [Google Scholar] [CrossRef]
- Wang, Z.; Xun, Y.; Wang, Y.; Yang, Q. Review of smart robots for fruit and vegetable picking in agriculture. Int. J. Agric. Biol. Eng. 2022, 15, 33–54. [Google Scholar]
- Zhang, S.; Mingshan, X. Real-time recognition and localization based on improved YOLOv5s for robot’s picking clustered fruits of chilies. Sensors 2023, 23, 3408. [Google Scholar] [CrossRef] [PubMed]
- Nan, Y.; Zhang, H.; Zeng, Y.; Zheng, J.; Ge, Y. Intelligent detection of Multi-Class pitaya fruits in target picking row based on WGB-YOLO network. Comput. Electron. Agric. 2023, 208, 107780. [Google Scholar] [CrossRef]
- Xu, Z.; Huang, X.; Huang, Y.; Sun, H.; Wan, F. A real-time zanthoxylum target detection method for an intelligent picking robot under a complex background, based on an improved YOLOv5s architecture. Sensors 2022, 22, 682. [Google Scholar] [CrossRef] [PubMed]
- Chen, J.; Ma, A.; Huang, L.; Su, Y.; Li, W.; Zhang, H.; Wang, Z. GA-YOLO: A Lightweight YOLO Model for Dense and Occluded Grape Target Detection. Horticulturae 2023, 9, 443. [Google Scholar] [CrossRef]
- Hou, G.; Chen, H.; Jiang, M.; Niu, R. An Overview of the Application of Machine Vision in Recognition and Localization of Fruit and Vegetable Harvesting Robots. Agriculture 2023, 13, 1814. [Google Scholar] [CrossRef]
- Wu, M.; Yun, L.; Xue, C.; Chen, Z.; Xia, Y. Walnut Recognition Method for UAV Remote Sensing Images. Agriculture 2024, 14, 646. [Google Scholar] [CrossRef]
- Hao, J.; Bing, Z.; Yang, S.; Yang, J.; Sun, L. Detection of green walnut by improved YOLOv3. Trans. Chin. Soc. Agric. Eng. 2022, 38, 183–190. (In Chinese) [Google Scholar]
- Zhong, Z.; Yun, L.; Yang, X.; Chen, Z. Research on Walnut Recognition Algorithm in Natural Environment Based on Improved YOLOX. J. Henan Agric. Sci. 2024, 53, 152–161. (In Chinese) [Google Scholar]
- Fan, X.; Xu, Y.; Zhou, J.; Liu, X.; Tang, J.; Wei, Y. Green Walnut Detection Method Based on Improved Convolutional Neural Network. Trans. Chin. Soc. Agric. Mach. 2021, 52, 149–155. (In Chinese) [Google Scholar]
- Fu, K.; Lei, T.; Halubok, M.; Bailey, B.N. Walnut Detection Through Deep Learning Enhanced by Multispectral Synthetic Images. arXiv 2023, arXiv:2401.03331. [Google Scholar]
- Rejeb, A.; Abdollahi, A.; Rejeb, K.; Treiblmaier, H. Drones in agriculture: A review and bibliometric analysis. Comput. Electron. Agric. 2022, 198, 107017. [Google Scholar] [CrossRef]
- Kecen, L.; Xiaoqiang, W.; Hao, L.; Leixiao, L.; Yanyan, Y.; Chuang, M.; Jing, G. Survey of one-stage small object detection methods in deep learning. J. Front. Comput. Sci. Technol. 2022, 16, 41. [Google Scholar]
- Staff, A.C. The two-stage placental model of preeclampsia: An update. J. Reprod. Immunol. 2019, 134, 1–10. [Google Scholar] [CrossRef] [PubMed]
- Liu, W.; Anguelov, D.; Erhan, D.; Szegedy, C.; Reed, S.; Fu, C.Y.; Berg, A.C. Ssd: Single shot multibox detector. In Computer Vision–ECCV 2016: Proceedings of the 14th European Conference, Amsterdam, The Netherlands, 11–14 October 2016, Proceedings, Part I 14; Springer International Publishing: Berlin/Heidelberg, Germany, 2016. [Google Scholar]
- Lin, T.Y.; Goyal, P.; Girshick, R.; He, K.; Dollár, P. Focal Loss for Dense Object Detection. In Proceedings of the IEEE International Conference on Computer Vision, Venice, Italy, 22–29 October 2017. [Google Scholar]
- Bochkovskiy, A.; Wang, C.-Y.; Liao, H.-Y.M. Yolov4: Optimal speed and accuracy of object detection. arXiv 2020, arXiv:2004.10934. [Google Scholar]
- Redmon, J.; Divvala, S.; Girshick, R.; Farhadi, A. You only look once: Unified, real-time object detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Las Vegas, NV, USA, 27–30 June 2016. [Google Scholar]
- Joseph, R.; Farhadi, A. YOLO9000: Better, faster, stronger. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Honolulu, HI, USA, 21–26 July 2017. [Google Scholar]
- Joseph, R.; Farhadi, A. Yolov3: An incremental improvement. arXiv 2018, arXiv:1804.02767. [Google Scholar]
- Girshick, R.; Donahue, J.; Darrell, T.; Malik, J. Rich feature hierarchies for accurate object detection and semantic segmentation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Columbus, OH, USA, 23–28 June 2014. [Google Scholar]
- He, K.; Zhang, X.; Ren, S.; Sun, J. Spatial pyramid pooling in deep convolutional networks for visual recognition. IEEE Trans. Pattern Anal. Mach. Intell. 2015, 37, 1904–1916. [Google Scholar] [CrossRef] [PubMed]
- Girshick, R. Fast r-cnn. In Proceedings of the IEEE International Conference on Computer Vision, Santiago, Chile, 7–13 December 2015. [Google Scholar]
- Ren, S.; He, K.; Girshick, R.; Sun, J. Faster R-CNN: Towards real-time object detection with region proposal networks. IEEE Trans. Pattern Anal. Mach. Intell. 2016, 39, 1137–1149. [Google Scholar] [CrossRef]
- Dai, J.; Li, Y.; He, K.; Sun, J. R-fcn: Object detection via region-based fully convolutional networks. In Proceedings of the 30th International Conference on Neural Information Processing Systems, Barcelona, Spain, 5–10 December 2016. [Google Scholar]
- Reis, D.; Kupec, J.; Hong, J.; Daoudi, A. Real-time flying object detection with YOLOv8. arXiv 2023, arXiv:2305.09972. [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]
- Lin, T.Y.; Dollár, P.; Girshick, R.; He, K.; Hariharan, B.; Belongie, S. Feature pyramid networks for object detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Honolulu, HI, USA, 21–26 July 2017. [Google Scholar]
- Liu, S.; Qi, L.; Qin, H.; Shi, J.; Jia, J. Path aggregation network for instance segmentation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Salt Lake City, UT, USA, 18–23 June 2018. [Google Scholar]
- Han, K.; Wang, Y.; Tian, Q.; Guo, J.; Xu, C.; Xu, C. Ghostnet: More features from cheap operations. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Seattle, WA, USA, 13–19 June 2020. [Google Scholar]
- 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 IEEE/CVF Conference on Computer Vision and Pattern Recognition, Seattle, WA, USA, 13–19 June 2020. [Google Scholar]
- Hu, J.; Li, S.; Gang, S. Squeeze-and-excitation networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Salt Lake City, UT, USA, 18–23 June 2018. [Google Scholar]
- He, J.; Erfani, S.; Ma, X.; Bailey, J.; Chi, Y.; Hua, X.S. Alpha-IoU: A family of power intersection over union losses for bounding box regression. arXiv 2021, arXiv:2110.13675. [Google Scholar]
- Lee, J.; Park, S.; Mo, S.; Ahn, S.; Shin, J. Layer-adaptive sparsity for the magnitude-based pruning. arXiv 2020, arXiv:2010.07611. [Google Scholar]
- Fang, G.; Ma, X.; Song, M.; Mi, M.B.; Wang, X. Depgraph: Towards any structural pruning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Vancouver, BC, Canada, 17–24 June 2023. [Google Scholar]
- Molchanov, P.; Mallya, A.; Tyree, S.; Frosio, I.; Kautz, J. Importance estimation for neural network pruning. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Long Beach, CA, USA, 15–20 June 2019. [Google Scholar]
- Li, H.; Kadav, A.; Durdanovic, I.; Samet, H.; Graf, H.P. Pruning filters for efficient convnets. arXiv 2016, arXiv:1608.08710. [Google Scholar]
Bright Light | Dim Light | Occlusion | Close-Range | Far-Range | Multiple Fruits |
---|---|---|---|---|---|
316 | 420 | 861 | 641 | 159 | 93 |
Parameter | Value |
---|---|
epoch | 300 |
lr | 0.01 |
momentum | 0.937 |
weight_decay | 0.0005 |
batch_size | 16 |
optimizer | SGD |
Model | mAP0.5 (%) | GFLOPs () | Param () |
---|---|---|---|
YOLOv5s | 94.1 | 15.8 | 7.0 |
MobileNetv3 | 92.9 | 2.5 | 1.3 |
GhostNet | 93.9 | 7.7 | 4.9 |
ShuffleNetv2 | 92.1 | 6.9 | 3.3 |
EfficientNetv2 | 93.4 | 5.6 | 5.9 |
Attention | mAP0.5 (%) | P (%) | R (%) | Parameters | GFLOPs () |
---|---|---|---|---|---|
no attention | 94.3 | 91.7 | 86.7 | 4,045,114 | 6.1 |
ECA | 94.5 | 91.0 | 87.8 | 4,045,126 | 6.1 |
SE | 94.5 | 90.4 | 88.8 | 4,057,914 | 6.1 |
Triplet | 94.5 | 90.9 | 87.7 | 4,046,314 | 6.1 |
SimAM | 94.5 | 89.9 | 88.5 | 4,045,144 | 6.1 |
Components | 1 | 2 | 3 | 4 | 5 | 6 |
---|---|---|---|---|---|---|
GhostNet | √ | √ | √ | √ | √ | |
DE_C3 | √ | √ | √ | √ | ||
Alhpa CIoU | √ | √ | √ | |||
Prune | √ | √ | ||||
KD | √ | |||||
mAP0.5 (%) | 94.1 | 93.9 | 94.5 | 94.8 | 94.3 | 95.2 (+1.1%) |
P (%) | 90.9 | 89.8 | 91.0 | 91.4 | 89.9 | 91.6 (+0.7%) |
R (%) | 88.4 | 88.8 | 86.7 | 88.2 | 88.2 | 88.7 (+0.3%) |
Param () | 7.0 | 4.8 | 4.0 | 4.0 | 1.8 | 1.8 (−72.9%) |
GFLOPs () | 15.8 | 7.7 | 6.1 | 6.1 | 2.5 | 2.5 (−84.1%) |
Model Size/MB | 14.4 | 10.3 | 8.6 | 8.6 | 4.3 | 4.3 (−70.1%) |
Model | Param () | GFLOPs () | mAP0.5 (%) | Model Size/MB | FPS |
---|---|---|---|---|---|
YOLOv3-tiny | 8.7 | 12.9 | 92.3 | 17.4 | 105.3 |
YOLOv4-tiny | 5.8 | 16.2 | 90.8 | 23.6 | - |
YOLOv5s | 7.0 | 15.8 | 94.1 | 14.4 | 75.2 |
YOLOv6s | 18.5 | 45.17 | 93.1 | 38.7 | 91.5 |
YOLOv7-tiny | 6.0 | 13.0 | 94.2 | 12.3 | 61.7 |
YOLOv8s | 11.1 | 28.4 | 94.5 | 22.5 | 90.9 |
YOLOv9t | 2.6 | 10.7 | 94.6 | 6.1 | 52.9 |
GDA-YOLOv5 | 4.0 | 6.1 | 94.8 | 8.6 | 126.6 |
GDA-YOLOv5 (prune) | 1.8 | 2.5 | 94.3 | 4.3 | 128.2 |
GDAD-YOLOv5 | 1.8 | 2.5 | 95.2 | 4.3 | 135.1 |
Prune_method | Param () | GFLOPs () | mAP0.5 (%) | Model Size/MB |
---|---|---|---|---|
LAMP | 1,894,721 | 2.5 | 94.3 | 4.3 |
DepGraph [44] | 1,894,721 | 2.5 | 93.9 | 4.3 |
Taylor Pruning [45] | 1,894,721 | 2.5 | 93.7 | 4.3 |
L1-norm Pruning [46] | 1,894,721 | 2.5 | 93.4 | 4.3 |
Model | Target Numbers | Missed Numbers | Wrong Numbers |
---|---|---|---|
YOLOv5s | 889 | 128 | 16 |
GDAD-YOLOv5s | 899 | 62 | 6 |
Model | Target Numbers | Missed Numbers | Wrong Numbers |
---|---|---|---|
YOLOv5s | 918 | 119 | 18 |
GDAD-YOLOv5s | 918 | 63 | 6 |
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
Yang, C.; Cai, Z.; Wu, M.; Yun, L.; Chen, Z.; Xia, Y. Research on Detection Algorithm of Green Walnut in Complex Environment. Agriculture 2024, 14, 1441. https://doi.org/10.3390/agriculture14091441
Yang C, Cai Z, Wu M, Yun L, Chen Z, Xia Y. Research on Detection Algorithm of Green Walnut in Complex Environment. Agriculture. 2024; 14(9):1441. https://doi.org/10.3390/agriculture14091441
Chicago/Turabian StyleYang, Chenggui, Zhengda Cai, Mingjie Wu, Lijun Yun, Zaiqing Chen, and Yuelong Xia. 2024. "Research on Detection Algorithm of Green Walnut in Complex Environment" Agriculture 14, no. 9: 1441. https://doi.org/10.3390/agriculture14091441
APA StyleYang, C., Cai, Z., Wu, M., Yun, L., Chen, Z., & Xia, Y. (2024). Research on Detection Algorithm of Green Walnut in Complex Environment. Agriculture, 14(9), 1441. https://doi.org/10.3390/agriculture14091441