Improved YOLOv8 Weed Segmentation Method Based on Dual-ViT
Abstract
1. Introduction
2. Materials and Methods
2.1. Lettuce Image Acquisition Equipment
2.2. Lettuce Image Dataset
2.3. Overall Workflow of the Segmentation Method
2.4. Data Preprocessing and Image Enhancement
2.4.1. Image Preprocessing
2.4.2. Image Enhancement
2.5. Construction of the Weed Segmentation Method
2.5.1. Embedding of the Dual-ViT Backbone
2.5.2. Lightweight of the Neck Network
2.5.3. Reconstruction of the Feature Fusion Layer
2.6. Improved YOLOv8-seg Model
2.7. Superpixel Voting Mechanism
- Consensus retention: If the pixel-level network label agrees with the majority label of its SLIC superpixel, the label is retained directly. This operation leaves spatially coherent interior regions unchanged.
- Confidence-guided conflict resolution: When the pixel-level label disagrees with the majority label of its superpixel, the decision is made by comparing network confidence with superpixel homogeneity. A highly confident network prediction is retained, whereas an uncertain pixel is corrected by the locally consistent superpixel label.
3. Results and Analysis
3.1. Experimental Environment and Parameter Setting
3.2. Evaluation Metrics
3.3. Experimental Analysis of Data Preprocessing
3.4. Performance Comparison of Different Neck Networks
3.5. Ablation Experiment
3.6. Comparative Experiments of Different Models
3.7. Discussion and Scope of Applicability
4. Conclusions
- (1)
- In this study, the dataset is augmented through super-resolution preprocessing and image enhancement, which effectively improves the generalization performance of the model. Ablation experiments show that the mean pixel accuracy of the original model on the test set has increased to 84.7%, with an improvement of 10.9 percentage points.
- (2)
- The complete method achieved 88.3% mPA, 75.6% mIoU, and 95.6% FWIoU at 7.9 network-level GFLOPs, showing that complementary feature extraction, fusion, and boundary correction can improve segmentation while maintaining moderate theoretical computation within the segmentation network.
- (3)
- Beyond the numerical gains, the scientific contribution is a task-oriented design showing how global–local representation, lightweight weighted multi-scale fusion, and superpixel boundary regularization can be coordinated for complex crop–weed scenes. The resulting pixel-level masks provide a perception basis for precision spraying, mechanical weeding, and offline field analysis systems. Future work will focus on cross-site and cross-season validation, species-aware segmentation, and optimized end-to-end implementation on edge platforms.
Author Contributions
Funding
Institutional Review Board Statement
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- Calderara-Cea, F.; Torres-Torriti, M.; Cheein, F.A.; Delpiano, J. A two-stage deep learning strategy for weed identification in grassfields. Comput. Electron. Agric. 2024, 225, 109300. [Google Scholar] [CrossRef]
- Hua, C.; Song, Y.; Jiang, Y.; Yu, J.; Chen, Y. RGB channel enhanced lawn weed recognition algorithm. J. Nanjing Agric. Univ. 2024, 47, 1019–1027. [Google Scholar]
- Liang, C.; Wang, H.; Liu, X.; Tang, Q.; Zuo, C. Laser weeding weed detection method based on LSPKI-YOLO multi-scale feature enhancement. Trans. Chin. Soc. Agric. Eng. 2026, 42, 225–233. [Google Scholar]
- Chen, X.; Xiong, Y.; Wang, X.; Cheng, N.; Liu, S.; Qi, L. Evaluation of weed density grade in paddy field seedling line zone based on tactile perception. Trans. Chin. Soc. Agric. Eng. 2023, 39, 116–125. [Google Scholar]
- Chen, X.; Mao, Y.; Xiong, Y.; Qi, L.; Jiang, Y.; Ma, X. Intra-row weed density evaluation in rice field using tactile method. Comput. Electron. Agric. 2022, 193, 106699. [Google Scholar] [CrossRef]
- Mao, Y.; Dang, P.; Zhang, E.; Tang, C.; Chen, Y.; Chen, X. Weed density evaluation using KCCA-CFBLS based on fusion of visual and tactile features in special paddy field environment. Comput. Electron. Agric. 2024, 217, 108619. [Google Scholar] [CrossRef]
- Chen, X.; Dang, P.; Zhang, E.; Chen, Y.; Tang, C.; Qi, L. Accurate recognition of rice plants based on visual and tactile sensing. J. Sci. Food Agric. 2024, 104, 4268–4277. [Google Scholar] [CrossRef] [PubMed]
- Gronewold, A.M.; Mulford, P.; Ray, E.; Ray, L.E. Tactile Sensing & Visually-Impaired Navigation in Densely Planted Row Crops, for Precision Fertilization by Small UGVs. Comput. Electron. Agric. 2025, 231, 110003. [Google Scholar] [CrossRef]
- Miao, R.; Yang, H.; Wu, J.; Liu, H. Weed identification of overlapping spinach leaves based on image sub-block and reconstruction. Trans. Chin. Soc. Agric. Eng. 2020, 36, 178–184. [Google Scholar]
- Zhang, S.; Huang, W.; Wang, Z. Combing modified Grabcut, K-means clustering and sparse representation classification for weed recognition in wheat field. Neurocomputing 2021, 452, 665–674. [Google Scholar] [CrossRef]
- Osorio, K.; Pedraza, C.; Jamaica, D. A Deep Learning Approach for Weed Detection in Lettuce Crops Using Multispectral Images. AgriEngineering 2020, 2, 471–488. [Google Scholar] [CrossRef]
- Hu, R.; Su, W.H.; Li, J.H.; Peng, Y. Real-time lettuce-weed localization and weed severity classification based on lightweight YOLO convolutional neural networks for intelligent intra-row weed control. Comput. Electron. Agric. 2024, 226, 109404. [Google Scholar] [CrossRef]
- Sun, Y.; Chen, Y.; Jin, X.; Yu, J.; Chen, Y. AI Differentiation of Bok Choy Seedlings from Weed. Fujian J. Agric. Sci. 2021, 36, 1484–1490. [Google Scholar]
- Jin, H.; Zhu, W.; Liu, T.; Yu, J.; Jin, X. Identification of vegetable weeds by using convolutional neural networks and color segmentation. J. Chin. Agric. Mech. 2024, 45, 215–220. [Google Scholar]
- Wang, C.; Wu, X.; Zhang, Y.; Wang, W. Recognition and segmentation of maize seedlings in field based on dual attention semantic segmentation network. Trans. Chin. Soc. Agric. Eng. 2021, 37, 211–221. [Google Scholar]
- Abdalla, A.; Cen, H.; Wan, L.; Rashid, R.; Weng, H.; Zhou, W.; He, Y. Fine-tuning convolutional neural network with transfer learning for semantic segmentation of ground-level oilseed rape images in a field with high weed pressure. Comput. Electron. Agric. 2019, 167, 105091. [Google Scholar] [CrossRef]
- Cai, Y.; Xiao, J.; Yu, C.; Song, Z.; Li, J.; Yue, X. UANP-MT based semi-supervised image segmentation method for identifying weeds in cabbage field. Trans. Chin. Soc. Agric. Eng. 2023, 39, 183–191. [Google Scholar]
- Syed, A.; Chen, B.; Abbasi, A.A.; Butt, S.A.; Fang, X. MSEA-Net: Multi-Scale and Edge-Aware Network for Weed Segmentation. AgriEngineering 2025, 7, 103. [Google Scholar] [CrossRef]
- Wang, X.; Xie, L.; Dong, C.; Shan, Y. Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data. In Proceedings of the IEEE/CVF International Conference on Computer Vision Workshops, Montreal, BC, Canada, 11–17 October 2021; IEEE: Piscataway, NJ, USA, 2021; pp. 1905–1914. [Google Scholar]
- Yang, T.; Wei, W.; Fu, C.; Yang, T. Single-image super-resolution reconstruction based on improved Real-ESRGAN. Mod. Electron. Technol. 2025, 48, 31–38. [Google Scholar]
- Wang, X.; Yu, K.; Wu, S.; Gu, J.; Liu, Y.; Dong, C.; Loy, C.C.; Qiao, Y.; Tang, X. ESRGAN: Enhanced Super-Resolution Generative Adversarial Networks. In Proceedings of the European Conference on Computer Vision Workshops, Munich, Germany, 8–14 September 2018. [Google Scholar]
- Chen, S.; Xu, L.; Zhou, B.; Chen, J. Semantic Relocation Parallel Network for Semantic Segmentation. J. Comput. Aided Des. Comput. Graph. 2022, 34, 373–381. [Google Scholar] [CrossRef]
- Vaswani, A.; Shazeer, N.; Parmar, N.; Uszkoreit, J.; Jones, L.; Gomez, A.N.; Kaiser, L.; Polosukhin, I. Attention is All you Need. In Proceedings of the Neural Information Processing Systems, Long Beach, CA, USA, 12 June 2017. [Google Scholar]
- Liu, L.; Li, G.; Du, Y.; Li, X.; Wu, X.; Qiao, Z.; Wang, T. CS-Net: Conv-Simpleformer network for agricultural image segmentation. Pattern Recognit. 2024, 147, 110140. [Google Scholar] [CrossRef]
- Yao, T.; Li, Y.; Pan, Y.; Wang, Y.; Zhang, X.P.; Mei, T. Dual Vision Transformer. IEEE Trans. Pattern Anal. Mach. Intell. 2023, 45, 10870–10882. [Google Scholar] [CrossRef] [PubMed]
- Li, J.; Wen, Y.; He, L. SCConv: Spatial and Channel Reconstruction Convolution for Feature Redundancy. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Vancouver, BC, Canada, 17–24 June 2023; IEEE: Piscataway, NJ, USA, 2023; pp. 6153–6162. [Google Scholar]
- Li, H.; Li, J.; Wei, H.; Liu, Z.; Zhan, Z.; Ren, Q. Slim-neck by GSConv: A lightweight-design for real-time detector architectures. J. Real-Time Image Process. 2024, 21, 62. [Google Scholar] [CrossRef]
- Yang, Q.; Ye, Y.; Gu, L.; Wu, Y. MSFCA-Net: A Multi-Scale Feature Convolutional Attention Network for Segmenting Crops and Weeds in the Field. Agriculture 2023, 13, 1176. [Google Scholar] [CrossRef]
- Wang, Y.; Chen, Q.; Wu, J. Research on Image Semantic Segmentation for Complex Environments. Comput. Sci. 2019, 46, 36–46. [Google Scholar]
- Guo, Q.; Liu, L.; Zhang, C.; Xu, W.; Jing, W. Muti-scale Feature Fusion Network Based on Feature Pyramid Model. Chin. J. Eng. Math. 2020, 37, 521–530. [Google Scholar]
- Tan, M.; Pang, R.; Le, Q.V. EfficientDet: Scalable and Efficient Object Detection. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Seattle, WA, USA, 13–19 June 2020; IEEE: Piscataway, NJ, USA, 2021; pp. 10778–10787. [Google Scholar]
- Wang, L.; Zhang, S.; Zhong, X.; Li, M.; Ma, Z. GDBNet: Boundary improving three-branch semantic segmentation network for remote sensing images. J. Electron. Imaging 2024, 33, 063019. [Google Scholar] [CrossRef]
- Achanta, R.; Shaji, A.; Smith, K.; Lucchi, A.; Fua, P.; Süsstrunk, S. SLIC Superpixels Compared to State-of-the-Art Superpixel Methods. IEEE Trans. Pattern Anal. Mach. Intell. 2012, 34, 2274–2282. [Google Scholar] [CrossRef] [PubMed]
- Yu, Y.; Wang, C.; Fu, Q.; Kou, R.; Wu, W.; Liu, T. Survey of Evaluation Metrics and Methods for Semantic Segmentation. Comput. Eng. Appl. 2023, 59, 57–69. [Google Scholar]













| Modification | Position | Purpose |
|---|---|---|
| C2f-DViT | Backbone | Strengthen interaction between global semantics and local pixel details |
| GSConv + VoVGSCSP | Neck | Reduce redundant convolution while retaining cross-channel feature exchange |
| Improved BiFPN with P2 | Neck | Apply weighted multi-scale fusion and preserve shallow details for small targets |
| SLIC voting | Post-processing | Correct ambiguous boundary pixels using local color and texture consistency |
| Proposed Hyperparameter | Standardized Setting for Reproducible Re-Training |
|---|---|
| Model initialization | YOLOv8n-seg initialized from COCO-pretrained weights |
| Network input | 640 × 640 pixels; aspect ratio preserved by letterbox padding |
| Dataset split | Training/validation/test = 7:2:1 |
| Training duration | Maximum 200 epochs; early stopping patience = 50 epochs |
| Batch and loading | Batch size = 8; data loader workers = 8 |
| Optimizer | AdamW |
| Learning rate | Initial learning rate = 0.001; final learning rate factor = 0.01 |
| Regularization and schedule | Weight decay = 0.0005; cosine annealing schedule; warm-up = 3 epochs |
| Reproducibility and precision | Random seed = 42; automatic mixed precision enabled |
| Model selection | Checkpoint with the highest validation mIoU |
| Inference settings | Confidence threshold = 0.25; NMS IoU threshold = 0.70 |
| Mask settings | Overlapping mask processing enabled; mask downsampling ratio = 4 |
| SLIC settings | n_segments = 500; compactness = 10; sigma = 1.0; maximum iterations = 10 |
| Voting settings | Pixel decision threshold = 0.50; superpixel majority threshold = 0.50 |
| Actual/Predicted | Weed | Non-Weed |
|---|---|---|
| Weed | TP | FN |
| Non-weed | FP | TN |
| Super-Resolution | Expansion Multiple | Mean Pixel Accuracy mPA% | |
|---|---|---|---|
| Training Set | Test Set | ||
| × | None | 80.1 | 73.8 |
| √ | None | 81.2 | 74.8 |
| × | 2 | 81.5 | 80.9 |
| √ | 2 | 82.4 | 81.8 |
| × | 3 | 83.4 | 83.6 |
| √ | 3 | 84.3 | 84.7 |
| × | 4 | 83.7 | 82.8 |
| √ | 4 | 84.5 | 83.7 |
| Neck Network | mPA/% | mIoU/% | GFLOPs |
|---|---|---|---|
| SC | 84.7 | 71.3 | 8.90 |
| DSC | 79.6 | 69.8 | 6.91 |
| Shuffle Net | 79.4 | 69.5 | 6.92 |
| Ghost Net | 82.5 | 70.3 | 7.21 |
| GSConv | 84.9 | 72.2 | 7.21 |
| Dual-ViT | GSConv | BiFPN | SLIC | PA/% | mPA/% | mIoU/% | FWIoU/% | GFLOPs |
|---|---|---|---|---|---|---|---|---|
| × | × | × | × | 94 | 84.7 | 71.3 | 80.6 | 8.9 |
| √ | × | × | × | 94 | 87.3 | 73.6 | 87.1 | 9.4 |
| × | √ | × | × | 94 | 84.9 | 72.2 | 83.5 | 7.2 |
| × | × | √ | × | 94 | 85.5 | 72.4 | 82.1 | 9.1 |
| × | × | × | √ | 96 | 84.7 | 71.3 | 84.7 | 8.9 |
| √ | √ | × | × | 94 | 87.5 | 74.5 | 90 | 7.7 |
| √ | × | √ | × | 94 | 88.1 | 74.7 | 88.6 | 9.6 |
| √ | × | × | √ | 96 | 88.6 | 73.6 | 89.7 | 9.4 |
| × | √ | √ | × | 94 | 85.7 | 73.3 | 85 | 7.4 |
| × | √ | × | √ | 96 | 84.9 | 72.2 | 87.6 | 7.2 |
| × | × | √ | √ | 96 | 85.5 | 72.4 | 86.2 | 9.1 |
| √ | √ | √ | × | 94 | 88.3 | 75.6 | 91.5 | 7.9 |
| √ | √ | × | √ | 96 | 89.5 | 74.5 | 90.2 | 7.3 |
| √ | × | √ | √ | 96 | 88.1 | 74.7 | 92.7 | 9.6 |
| × | √ | √ | √ | 96 | 85.7 | 73.3 | 89.1 | 7.4 |
| √ | √ | √ | √ | 96 | 88.3 | 75.6 | 95.6 | 7.9 |
| Model | mPA/% | mIoU/% | GFLOPs |
|---|---|---|---|
| YOLOv5-seg | 86.3 | 77.8 | 64.0 |
| DeepLabv3+ | 88.6 | 84.3 | 176 |
| Fast-SCNN | 81.8 | 58.0 | 0.5 |
| YOLOv10 | 90.1 | 74.2 | 59.1 |
| Method in this paper | 88.3 | 75.6 | 7.9 |
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. |
© 2026 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.
Share and Cite
Wu, W.; Huang, K.; Ji, H.; Chen, T.; Chen, X. Improved YOLOv8 Weed Segmentation Method Based on Dual-ViT. Agriculture 2026, 16, 1675. https://doi.org/10.3390/agriculture16151675
Wu W, Huang K, Ji H, Chen T, Chen X. Improved YOLOv8 Weed Segmentation Method Based on Dual-ViT. Agriculture. 2026; 16(15):1675. https://doi.org/10.3390/agriculture16151675
Chicago/Turabian StyleWu, Weihan, Kaiwen Huang, Haonan Ji, Tujia Chen, and Xueshen Chen. 2026. "Improved YOLOv8 Weed Segmentation Method Based on Dual-ViT" Agriculture 16, no. 15: 1675. https://doi.org/10.3390/agriculture16151675
APA StyleWu, W., Huang, K., Ji, H., Chen, T., & Chen, X. (2026). Improved YOLOv8 Weed Segmentation Method Based on Dual-ViT. Agriculture, 16(15), 1675. https://doi.org/10.3390/agriculture16151675
