Rapid Identification and Accurate Localization of Walnut Trunks Based on TIoU-YOLOv8n-Pruned
Abstract
1. Introduction
- (1)
- A walnut trunk dataset was created.
- (2)
- The loss function of TIoU was designed to increase the generation of prediction frames for the YOLOv8 model for walnut trunks with high overlap.
- (3)
- The YOLOv8 model was pruned, and the effects of different pruning rates on model performance were compared to determine the optimal pruning rate applicable to this study.
- (4)
- Corrected trunk coordinates by fitting vibration trajectories generated by towing equipment during identification, improving the positioning accuracy of vibration capture points on the trunk.
2. Materials and Methods
2.1. Walnut Shaking Vibration Harvesting Platform
2.1.1. Hardware Platform
2.1.2. Overall Process
2.2. Field Walnut Tree Trunk Sample Data
2.3. Algorithmic Improvements
2.3.1. Overview of YOLOv8 Model
2.3.2. TIoU Loss
2.3.3. Model Pruning
- (1)
- Sparsity training
- (2)
- Channel pruning model fine-tuning
- (3)
- Model fine-tuning
2.4. Spatial Localization of the Clamping Point
- (1)
- Spatial 3D Positioning
- (2)
- Trajectory Fitting and Coordinate Correction
2.5. Experimental Setup
2.5.1. Training Platform and Parameters
2.5.2. Evaluation Criteria
3. Results
3.1. Comparison of Recognition Algorithms
3.2. Impact of Loss on Models
3.3. Sparse Rate Selection
3.4. Impact of Pruning Rate on the Model
3.5. Ablation Study
3.6. Comparative Experimental Analysis of Different Lightweighting Models
3.7. Edge Device Deployment
3.8. Comparison of Recognition Error
4. Discussion
5. Conclusions
- (1)
- Using the TIoU loss, the mAP@0.5:0.95 is 59.3%, which is higher than that of other loss functions. This indicates that for objects such as tree trunks with large variations in aspect ratios, the predicted bounding boxes of YOLOv8n using the TIoU loss have a higher overlap with the ground truth bounding boxes. However, the recall is slightly lower compared to the YOLOv8n model trained with the WIoU loss.
- (2)
- When pruning the model, the performance remains almost unchanged at low pruning rates, but it decreases rapidly once the pruning rate exceeds a certain threshold. In this experiment, this rapid decrease occurs when the pruning rate reaches 55%. With a 55% pruning rate, after fine-tuning the model, the computation is reduced by 56.1%, and the frame rate increases by 1.45 times compared to the original. Meanwhile, the model’s precision, recall, and mAP@0.5:0.95 are only reduced by 2.7%, 4.1%, and 3.6%, respectively, which demonstrates the effectiveness of the pruning method.
- (3)
- The improved model proposed in this paper has lower computational cost and higher precision and mAP@0.5:0.95 compared to other lightweight networks. The model achieves 94.1% precision, 57.2% mAP@0.5:0.95, and 3.6 GFLOPs. Although the recall rate of 89.2% is slightly lower than that of Ghost-YOLOv8n by 0.5%, the TIoU-YOLOv8n-Pruned model is significantly smaller in size compared to Ghost-YOLOv8n. Additionally, the recognition frame rate is 20.3 frames per second on the NVIDIA Jetson Xavier NX, which is sufficient to meet the operational requirements of walnut harvesting equipment, including shaking and vibrating.
- (4)
- By applying least squares fitting for coordinate calibration based on tractor PTO shaft vibrations, the lateral positioning error in the x-direction was reduced to 5.15%.
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
References
- Wang, R.; Zhong, D.; Wu, S.; Han, Y.; Zheng, Y.; Tang, F.; NI, Z.; Liu, Y. The phytochemical profiles for walnuts (J. regia and J. sigillata) from China with protected geographical indications. Food Sci. Technol. 2021, 41 (Suppl. 2), 695–701. [Google Scholar] [CrossRef]
- Meng, J.; Fang, X.P.; Shi, X.M.; Zhang, Y.; Liu, J. Situation, problems and suggestions on the development of walnut industry in China. Mag. Press China Oils Fats 2023, 48, 84–86. [Google Scholar]
- Fukasawa, R.; Miyazawa, T.; Abe, C.; Bhaswant, M.; Toda, M. Quantification and Comparison of Nutritional Components in Oni Walnut (Juglans ailanthifolia Carr.), Hime Walnut (Juglans subcordiformis Dode.), and Cultivars. Horticulturae 2023, 9, 1221. [Google Scholar] [CrossRef]
- Wang, Y.; Xu, L.; Zhang, Y.; Zhu, Y.; Zhou, H.; Cui, W.; Zhang, A. Study of vibration patterns and response transfer relationships in walnut tree trunks. Sci. Hortic. 2024, 337, 113567. [Google Scholar] [CrossRef]
- Yu, R.; Fan, G.; Xu, G.; Xu, L.; Zhou, H.; Chen, J. Research Status and Development Trend of Walnut Vibration Harvesting. J. For. Eng. 2024, 9, 21–31. [Google Scholar]
- Zhuo, P.; Li, Y.; Wang, B.; Jiao, H.; Wang, P.; Li, C.; Niu, Q.; Wang, L. Analysis and experimental study on vibration response characteristics of mechanical harvesting of jujube. Comput. Electron. Agric. 2022, 203, 107446. [Google Scholar] [CrossRef]
- Zhou, J.; Xu, L.; Zhang, A.; Hang, X. Finite element explicit dynamics simulation of motion and shedding of jujube fruits under forced vibration. Comput. Electron. Agric. 2022, 198, 107009. [Google Scholar] [CrossRef]
- Hoshyarmanesh, H.; Dastgerdi, H.R.; Ghodsi, M.; Khandan, R.; Zareinia, K. Numerical and experimental vibration analysis of olive tree for optimal mechanized harvesting efficiency and productivity. Comput. Electron. Agric. 2017, 132, 34–48. [Google Scholar] [CrossRef]
- He, L.; Liu, X.; Du, X.; Wu, C. In-situ identification of shaking frequency for adaptive vibratory fruit harvesting. Comput. Electron. Agric. 2020, 170, 105245. [Google Scholar] [CrossRef]
- de Gonzaga Ferreira Júnior, L.; da Silva, F.M.; Ferreira, D.D.; de Souza, C.E.P.; Pinto, A.W.M.; de Melo Borges, F.E. Dynamic behavior of coffee tree branches during mechanical harvest. Comput. Electron. Agric. 2020, 173, 105415. [Google Scholar] [CrossRef]
- Du, X.; Jiang, F.; Li, S.; Xu, N.; Li, D.; Wu, C. Design and experiment of vibratory harvesting mechanism for Chinese hickory nuts based on orthogonal eccentric masses. Comput. Electron. Agric. 2019, 156, 178–186. [Google Scholar] [CrossRef]
- Fang, J.; Shi, Y.; Cao, J.; Sun, Y.; Zhang, W. Active Navigation System for a Rubber-Tapping Robot Based on Trunk Detection. Remote. Sens. 2023, 15, 3717. [Google Scholar] [CrossRef]
- Juman, M.A.; Wong, Y.W.; Rajkumar, R.K.; Goh, L.J. A novel tree trunk detection method for oil-palm plantation navigation. Comput. Electron. Agric. 2016, 128, 172–180. [Google Scholar] [CrossRef]
- Shen, Y.; Zhuang, Z.; Liu, H.; Jiang, J.; Ou, M. Fast recognition method of multi-feature trunk based on realsense depth camera. Trans. Chin. Soc. Agric. Mach. 2021, 53, 304–312. [Google Scholar]
- LeCun, Y.; Bengio, Y.; Hinton, G. Deep learning. Nature 2015, 521, 436–444. [Google Scholar] [CrossRef]
- de Aguiar, A.S.P.; dos Santos, F.B.N.; dos Santos, L.C.F.; de Jesus Filipe, V.M.; de Sousa, A.J.M. Vineyard trunk detection using deep learning—An experimental device benchmark. Comput. Electron. Agric. 2020, 175, 105535. [Google Scholar] [CrossRef]
- Da Silva, D.Q.; Dos Santos, F.N.; Sousa, A.J.; Filipe, V. Visible and Thermal Image-Based Trunk Detection with Deep Learning for Forestry Mobile Robotics. J. Imaging 2021, 7, 176. [Google Scholar] [CrossRef] [PubMed]
- da Silva, D.Q.; dos Santos, F.N.; Filipe, V.; Sousa, A.J.; Oliveira, P.M. Edge AI-Based Tree Trunk Detection for Forestry Monitoring Robotics. Robotics 2022, 11, 136. [Google Scholar] [CrossRef]
- Xu, Z.; Li, X. Research on tree trunk detection and navigation line fitting algorithm in orchard. J. Chin. Agric. Mech. 2024, 45, 217–222. [Google Scholar]
- Zhang, J.; Tian, M.; Yang, Z.; Li, J.; Zhao, L. An improved target detection method based on YOLOv5 in natural orchard environments. Comput. Electron. Agric. 2024, 219, 108780. [Google Scholar] [CrossRef]
- Wang, H.; Liu, Y.; Luo, H.; Luo, Y.; Zhang, Y.; Long, F.; Li, L. Camellia oleifera trunks detection and identification based on improved YOLOv7. Concurr. Comput. Pract. Exp. 2024, 36, e8265. [Google Scholar] [CrossRef]
- Brown, J.; Paudel, A.; Biehler, D.; Thompson, A.; Karkee, M.; Grimm, C.; Davidson, J.R. Tree detection and in-row localization for autonomous precision orchard management. Comput. Electron. Agric. 2024, 227, 109454. [Google Scholar] [CrossRef]
- Zhu, X.; Chen, F.; Zheng, Y.; Chen, C.; Peng, X. Detection of Camellia oleifera fruit maturity in orchards based on modified lightweight YOLO. Comput. Electron. Agric. 2024, 226, 109471. [Google Scholar] [CrossRef]
- Fan, X.; Sun, T.; Chai, X.; Zhou, J. YOLO-WDNet: A lightweight and accurate model for weeds detection in cotton field. Comput. Electron. Agric. 2024, 225, 109317. [Google Scholar] [CrossRef]
- Liu, Z.; Abeyrathna, R.R.D.; Sampurno, R.M.; Nakaguchi, V.M.; Ahamed, T. Faster-YOLO-AP: A lightweight apple detection algorithm based on improved YOLOv8 with a new efficient PDWConv in orchard. Comput. Electron. Agric. 2024, 223, 109118. [Google Scholar] [CrossRef]
- Zhao, S.; Zhang, S.; Lu, J.; Wang, H.; Feng, Y.; Shi, C.; Li, D.; Zhao, R. A lightweight dead fish detection method based on deformable convolution and YOLOV4. Comput. Electron. Agric. 2022, 198, 107098. [Google Scholar] [CrossRef]
- Shannon, C.E. Communication in the presence of noise. Proc. IRE 1984, 72, 1192–1201. [Google Scholar] [CrossRef]
- Jin, W.; Zhao, J.; Zhuang, T.; Liu, L.; Zhao, E.; Yang, X. Energy Transfer Characteristics of Walnut Trunk and Branches in Mechanical Vibration Picking. Trans. Chin. Soc. Agric. Mach. 2024, 55, 2031. [Google Scholar]
- Yu, R.; Fan, G.; Xu, L.; Zhang, H.; Zhou, H.; Shi, M.; Wang, Y.; Cui, W.; Xu, G. Design and Vibration Performance of a Flexible Rocker-Arm Walnut Vibrating Harvester. Sci. Silvae Sin. 2025, 61, 180–195. [Google Scholar]
- Zheng, Z.; Wang, P.; Liu, W.; Li, J.; Ye, R.; Ren, D. Distance-IoU Loss: Faster and Better Learning for Bounding Box Regression. Proc. AAAI Conf. Artif. Intell. 2020, 34, 12993–13000. [Google Scholar] [CrossRef]
- Tong, Z.; Chen, Y.; Xu, Z.; Yu, R. Wise-IoU: Bounding Box Regression Loss with Dynamic Focusing Mechanism. arXiv 2023, arXiv:2301.10051. [Google Scholar]
- Wu, D.; Lv, S.; Jiang, M.; Song, H. Using channel pruning-based YOLO v4 deep learning algorithm for the real-time and accurate detection of apple flowers in natural environments. Comput. Electron. Agric. 2020, 178, 105742. [Google Scholar] [CrossRef]
- Liu, Z.; Li, J.; Shen, Z.; Huang, G.; Yan, S.; Zhang, C. Learning Efficient Convolutional Networks through Network Slimming. In Proceedings of the IEEE International Conference on Computer Vision, Venice, Italy, 22–29 October 2017. [Google Scholar]
- Wang, D.; He, D. Channel pruned YOLO V5s-based deep learning approach for rapid and accurate apple fruitlet detection before fruit thinning. Biosyst. Eng. 2021, 210, 271–281. [Google Scholar] [CrossRef]
- Zhang, R.; Yan, K.; Ye, J. Lightweight YOLO-v7 for Digital Instrumentation Detection and Reading. Comput. Eng. Appl. 2024, 60, 192–201. [Google Scholar]
- Wang, F.; He, Z.; Zhang, Z.; Xie, K.; Zeng, Y. Lightweight Object Detection Method for Panax notoginseng Based on Edge. Trans. Chin. Soc. Agric. Mach. 2024, 55, 171–183. [Google Scholar]










| Model | Precision | Recall | mAP@0.5:95 | Parameters | GFLOPs |
|---|---|---|---|---|---|
| YOLOv5n | 87.5% | 84.1% | 39.7% | 7.06 × 105 | 16.5 |
| YOLOv8n | 93.8% | 91.6% | 57.0% | 3.01 × 106 | 8.2 |
| YOLOv11n | 92.9% | 90.3% | 54.9% | 2.59 × 105 | 6.3 |
| Loss | Precision | Recall | mAP@0.5:0.95 |
|---|---|---|---|
| GIoU | 92.5% | 91.0% | 55.4% |
| DIoU | 91.6% | 88.8% | 55.9% |
| EIoU | 93.3% | 89.3% | 55.3% |
| SIoU | 93.4% | 91.8% | 57.0% |
| WIoU | 92.4% | 94.1% | 55.7% |
| TIoU | 93.8% | 90.3% | 59.3% |
| Model | Precision | Recall | mAP@0.5:95 | Parameters | GFLOPs |
|---|---|---|---|---|---|
| YOLOv8n | 93.8% | 91.6% | 57.0% | 3.01 × 106 | 8.2 |
| TIoU-YOLOv8n | 93.8% | 90.3% | 59.3% | 3.01 × 106 | 8.2 |
| YOLOv8n-Pruned | 91.1% | 87.5% | 53.4% | 7.59 × 105 | 3.6 |
| TIoU-YOLOv8n-Pruned | 94.1% | 89.2% | 57.2% | 9.50 × 105 | 3.6 |
| Model | Precision | Recall | mAP@0.5:95 | Parameters | GFLOPs |
|---|---|---|---|---|---|
| MobileNetV3-YOLOv8n | 89.2% | 84.1% | 50.5% | 2.35 × 106 | 5.7 |
| FasterNet-YOLOv8n | 87.6% | 82.1% | 47.7% | 1.75 × 106 | 5 |
| Ghost-YOLOv8n | 89.9% | 89.7% | 54.3% | 1.71 × 106 | 5 |
| EfficientNet-YOLOv8n | 89.7% | 85.9% | 50.6% | 1.91 × 106 | 5.6 |
| ShuffleNetv2-YOLOv8n | 85.6% | 79.4% | 42.5% | 1.71 × 106 | 5 |
| GhostNetV3-YOLOv8n | 88.9% | 84.5% | 54.5% | 1.72 × 106 | 5 |
| MobileNetV4-YOLOv8n | 88.4% | 88.5% | 53.5% | 4.30 × 106 | 8.0 |
| TIoU-YOLOv8n-Pruned | 94.1% | 89.2% | 57.2% | 9.50 × 105 | 3.6 |
| Number | Actual Detection Value (mm) | Visual Measurement Value (mm) | Error Ratio % |
|---|---|---|---|
| (x, y, z) | (x, y, z) | (x, y, z) | |
| 1 | (569, 338, 261) | (501, 302, 249) | (11.95, 10.65, 4.60) |
| 2 | (−37, 629, 2157) | (−49, 673, 2173) | (32.43, 7.00, 0.74) |
| 3 | (−118, 507, 2115) | (−139, 478, 2107) | (17.80, 5.72, 0.38) |
| 4 | (−142, 663, 2337) | (−216, 693, 2358) | (52.11, 4.52, 0.90) |
| 5 | (−237, 347, 2206) | (−299, 368, 2243) | (26.16, 6.05, 1.68) |
| 6 | (136, 453, 1899) | (177, 419, 1954) | (30.15, 7.51, 2.90) |
| 7 | (251, 573, 2495) | (205, 543, 2398) | (18.33, 5.24, 3.89) |
| 8 | (−351, 356, 2389) | (−289, 388, 2234) | (17.66, 8.99, 6.49) |
| 9 | (135, 475, 2486) | (195, 449, 2401) | (44.44, 5.47, 3.42) |
| 10 | (−276, 379, 2884) | (−209, 401, 2783) | (24.28, 5.80, 3.50) |
| 11 | (−168, 335, 2000) | (−175, 304, 1924) | (4.17, 9.25, 3.80) |
| 12 | (47, 299, 2759) | (38, 318, 2863) | (19.15, 6.35, 3.77) |
| 13 | (−899, 357, 2346) | (−917, 379, 243)6 | (2.00, 6.16, 3.84) |
| 14 | (−739, 275, 1941) | (−768, 298, 1872) | (3.92, 8.36, 3.55) |
| 15 | (−344, 792, 2923) | (−328, 771, 2989) | (4.65, 2.65, 2.26) |
| 16 | (396, 345, 2657) | (412, 320, 2677) | (4.04, 7.25, 0.75) |
| 17 | (−247, 465, 2787) | (−254, 443, 2821) | (2.83, 4.73, 1.22) |
| 18 | (−463, 683, 2357) | (−488, 726, 2421) | (5.40, 6.30, 2.72) |
| 19 | (386, 567, 2854) | (375, 599, 2941) | (2.85, 5.64, 3.05) |
| 20 | (573, 756, 2597) | (559, 724, 2532) | (2.44, 4.23, 2.50) |
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. |
© 2025 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
Ye, C.; Xu, Y.; Zhou, J.; Li, C.; Fang, F.; Jin, Z. Rapid Identification and Accurate Localization of Walnut Trunks Based on TIoU-YOLOv8n-Pruned. Agriculture 2025, 15, 2405. https://doi.org/10.3390/agriculture15232405
Ye C, Xu Y, Zhou J, Li C, Fang F, Jin Z. Rapid Identification and Accurate Localization of Walnut Trunks Based on TIoU-YOLOv8n-Pruned. Agriculture. 2025; 15(23):2405. https://doi.org/10.3390/agriculture15232405
Chicago/Turabian StyleYe, Chenchen, Yan Xu, Jianping Zhou, Chengcheng Li, Fubao Fang, and Zhengyang Jin. 2025. "Rapid Identification and Accurate Localization of Walnut Trunks Based on TIoU-YOLOv8n-Pruned" Agriculture 15, no. 23: 2405. https://doi.org/10.3390/agriculture15232405
APA StyleYe, C., Xu, Y., Zhou, J., Li, C., Fang, F., & Jin, Z. (2025). Rapid Identification and Accurate Localization of Walnut Trunks Based on TIoU-YOLOv8n-Pruned. Agriculture, 15(23), 2405. https://doi.org/10.3390/agriculture15232405

