Skip to main content

Thank you for visiting nature.com. You are using a browser version with limited support for CSS. To obtain the best experience, we recommend you use a more up to date browser (or turn off compatibility mode in Internet Explorer). In the meantime, to ensure continued support, we are displaying the site without styles and JavaScript.

Advertisement

Scientific Reports
  • View all journals
  • Search
  • My Account Login
  • Content Explore content
  • About the journal
  • Publish with us
  • Sign up for alerts
  • RSS feed
  1. nature
  2. scientific reports
  3. articles
  4. article
Architecture and hyperparameter optimization of YOLOv5 and YOLOv8 for weed detection in garlic fields
Download PDF
Download PDF
  • Article
  • Open access
  • Published: 04 May 2026

Architecture and hyperparameter optimization of YOLOv5 and YOLOv8 for weed detection in garlic fields

  • Siavash Shamohammadi  ORCID: orcid.org/0009-0000-2916-42851,
  • Hossein Bagherpour  ORCID: orcid.org/0000-0002-6877-62811 &
  • Mohammad Reza Bakhtiari  ORCID: orcid.org/0000-0002-5620-27822 

Scientific Reports , Article number:  (2026) Cite this article

  • 288 Accesses

  • Metrics details

We are providing an unedited version of this manuscript to give early access to its findings. Before final publication, the manuscript will undergo further editing. Please note there may be errors present which affect the content, and all legal disclaimers apply.

Subjects

  • Computational biology and bioinformatics
  • Mathematics and computing
  • Plant sciences

Abstract

Weed adaptability to environmental conditions poses a major challenge in agricultural production, often leading to yield reduction or even complete crop loss. Effective weed detection requires algorithms tailored to the unique visual and biological characteristics of each crop. However, despite the agricultural importance of garlic, no studies have developed optimized state-of-the-art deep learning models for weed identification in garlic fields. Addressing this gap, the present study focuses on optimizing two prominent object detection frameworks—YOLOv5 and YOLOv8—for accurate weed detection under real field conditions. A dataset of 600 RGB images containing garlic plants and five weed species was collected directly from the field. Different versions of YOLOv5 and YOLOv8 were optimized and evaluated based on mAP@0.5 and inference speed. Experimental results showed that YOLOv8n achieved superior performance, yielding an mAP@0.5 of 87.0% with an average inference time of 16 ms, compared to YOLOv5m with an mAP@0.5 of 85.0% and 50 ms. The findings highlight that YOLOv8n, with an input resolution of 320 × 320 pixels and optimized using the SGD optimizer, provides the best trade-off between detection accuracy and computational efficiency. These results demonstrate the potential of YOLOv8n for real-time weed detection and its application in precision agriculture machinery.

Similar content being viewed by others

DC-YOLO: an improved field plant detection algorithm based on YOLOv7-tiny

Article Open access 02 November 2024

Deep learning framework for timely detection and classification of chili leaf diseases and pests

Article Open access 31 January 2026

Detection of weeds in teff crops using deep learning and UAV imagery for precision herbicide application

Article Open access 21 August 2025

Funding

This research did not receive any specific grant from funding agencies in the public, commercial, or not-for-profit sectors.

Author information

Authors and Affiliations

  1. Department of Biosystems Engineering, Faculty of Agriculture, Bu-Ali Sina University, Hamedan, Iran

    Siavash Shamohammadi & Hossein Bagherpour

  2. Agricultural Engineering Research Department, Hamedan Agricultural and Natural Resources Research and Education Center, Agricultural Research, Education and Extension Organization (AREEO), Hamadan, Iran

    Mohammad Reza Bakhtiari

Authors
  1. Siavash Shamohammadi
    View author publications

    Search author on:PubMed Google Scholar

  2. Hossein Bagherpour
    View author publications

    Search author on:PubMed Google Scholar

  3. Mohammad Reza Bakhtiari
    View author publications

    Search author on:PubMed Google Scholar

Corresponding author

Correspondence to Hossein Bagherpour.

Ethics declarations

Competing interests

The authors declare no competing interests.

Additional information

Publisher’s note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Open Access This article is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License, which permits any non-commercial use, sharing, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if you modified the licensed material. You do not have permission under this licence to share adapted material derived from this article or parts of it. The images or other third party material in this article are included in the article’s Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Shamohammadi, S., Bagherpour, H. & Bakhtiari, M.R. Architecture and hyperparameter optimization of YOLOv5 and YOLOv8 for weed detection in garlic fields. Sci Rep (2026). https://doi.org/10.1038/s41598-026-51662-0

Download citation

  • Received: 06 February 2026

  • Accepted: 29 April 2026

  • Published: 04 May 2026

  • DOI: https://doi.org/10.1038/s41598-026-51662-0

Share this article

Anyone you share the following link with will be able to read this content:

Sorry, a shareable link is not currently available for this article.

Provided by the Springer Nature SharedIt content-sharing initiative

Keywords

  • Classification
  • Localization
  • Weeds
  • YOLO
Download PDF

Advertisement

Explore content

  • Research articles
  • News & Comment
  • Collections
  • Subjects
  • Follow us on Facebook
  • Follow us on X
  • Sign up for alerts
  • RSS feed

About the journal

  • About Scientific Reports
  • Contact
  • Journal policies
  • Guide to referees
  • Calls for Papers
  • Editor's Choice
  • Journal highlights
  • Open Access Fees and Funding

Publish with us

  • For authors
  • Language editing services
  • Open access funding
  • Submit manuscript

Search

Advanced search

Quick links

  • Explore articles by subject
  • Find a job
  • Guide to authors
  • Editorial policies

Scientific Reports (Sci Rep)

ISSN 2045-2322 (online)

nature.com footer links

About Nature Portfolio

  • About us
  • Press releases
  • Press office
  • Contact us

Discover content

  • Journals A-Z
  • Articles by subject
  • protocols.io
  • Nature Index

Publishing policies

  • Nature portfolio policies
  • Open access

Author & Researcher services

  • Reprints & permissions
  • Research data
  • Language editing
  • Scientific editing
  • Nature Masterclasses
  • Research Solutions

Libraries & institutions

  • Librarian service & tools
  • Librarian portal
  • Open research
  • Recommend to library

Advertising & partnerships

  • Advertising
  • Partnerships & Services
  • Media kits
  • Branded content

Professional development

  • Nature Awards
  • Nature Careers
  • Nature Conferences

Regional websites

  • Nature Africa
  • Nature China
  • Nature India
  • Nature Japan
  • Nature Middle East
  • Privacy Policy
  • Use of cookies
  • Legal notice
  • Accessibility statement
  • Terms & Conditions
  • Your US state privacy rights
Springer Nature

© 2026 Springer Nature Limited

Nature Briefing AI and Robotics

Sign up for the Nature Briefing: AI and Robotics newsletter — what matters in AI and robotics research, free to your inbox weekly.

Get the most important science stories of the day, free in your inbox. Sign up for Nature Briefing: AI and Robotics