Skip to content

shahin-ro/Head-Wheat-Detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Wheat Detection with YOLO11n 🌾

Wheat Detection Python Ultralytics

A project for detecting wheat heads in images using the YOLO11n model from Ultralytics. This repository includes dataset setup, model training, and inference with visualization for the GlobalWheat2020 dataset. πŸš€

πŸ“‹ Table of Contents

🌟 Overview

This project leverages the power of the YOLO11n model to detect wheat heads in agricultural images. It uses the GlobalWheat2020 dataset, automates dataset organization, trains a model, and performs inference with visualized bounding boxes. Perfect for computer vision enthusiasts and agricultural tech researchers! πŸ“Έ

✨ Features

  • πŸ› οΈ Installs Ultralytics for YOLO model support
  • πŸ“‚ Downloads and organizes the GlobalWheat2020 dataset
  • βš™οΈ Trains YOLO11n for wheat head detection
  • πŸ–ΌοΈ Visualizes detection results with bounding boxes
  • πŸ”„ Supports further training and inference

πŸ› οΈ Installation

  1. Clone the repository:
    git clone https://github.com/shahin-ro/wheat-detection.git
    cd wheat-detection
  2. Install dependencies:
    pip install ultralytics

Note: This project is designed to run in a Google Colab environment for easy access to GPU resources. Adjust paths if running locally.

πŸ“Š Dataset

The project uses the GlobalWheat2020 dataset. The script:

  • Downloads images and annotations
  • Organizes them into images, annotations, and labels directories
  • Creates a GlobalWheat2020_subset.yaml file for training and validation subsets

πŸš€ Usage

  1. Setup: Run the dataset setup code to download and organize the GlobalWheat2020 dataset.
  2. Train: Train the YOLO11n model using the provided YAML configuration.
  3. Infer: Upload an image and detect wheat heads with visualized results.

πŸ‹οΈβ€β™‚οΈ Training

Train the model with the following command in the script:

model = YOLO("yolo11n.pt")
model.train(data="GlobalWheat2020_subset.yaml", epochs=5, imgsz=640)
  • Adjust epochs or imgsz for better results.
  • Trained weights are saved in /content/runs/detect/train/weights/best.pt.

πŸ” Inference

Perform inference on a new image:

model = YOLO("/content/runs/detect/train/weights/best.pt")
results = model("path/to/your/image.jpg")
for result in results:
    img = result.plot()
    plt.imshow(img)
    plt.axis('off')
    plt.show()

Upload an image in Colab to see bounding boxes around detected wheat heads.

πŸ“ˆ Results

The model outputs bounding boxes around wheat heads in the input images. Results are visualized using Matplotlib, showing detected wheat heads with confidence scores.

🀝 Contributing

Contributions are welcome! 🌟

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/YourFeature)
  3. Commit changes (git commit -m 'Add YourFeature')
  4. Push to the branch (git push origin feature/YourFeature)
  5. Open a Pull Request

πŸ“œ License

This project is licensed under the MIT License. See the LICENSE file for details.


🌾 Happy wheat detection! If you find this project useful, give it a ⭐ on GitHub!

About

🌾 Wheat Detection using YOLO11n! πŸ“Έ Installs Ultralytics, trains on GlobalWheat2020 dataset, and detects wheat heads with bounding boxes. Includes dataset setup, model training, and inference. πŸš€

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors