Welcome to the Wheat Detection project! This repository uses the YOLO11 model to detect wheat heads in agricultural images, leveraging the GlobalWheat2020 dataset. Perfect for precision agriculture and crop monitoring! π±
This project implements wheat head detection using the Ultralytics YOLO framework. It includes downloading the GlobalWheat2020 dataset, training a YOLO11n model, and performing inference on uploaded images. The results are visualized with bounding boxes around detected wheat heads. πΎ
- π₯ Downloads and organizes the GlobalWheat2020 dataset
- π οΈ Trains a YOLO11n model for wheat head detection
- πΌοΈ Performs inference on uploaded images
- π Visualizes results with bounding boxes using Matplotlib
- βοΈ Easy-to-use Python script for end-to-end workflow
- Python 3.8+
- Ultralytics YOLO (
pip install ultralytics) - Matplotlib
- NumPy
- Pillow
- Google Colab (optional for running in the cloud βοΈ)
Install dependencies:
pip install ultralytics matplotlib numpy pillow-
Clone the repository:
git clone https://github.com/shervinnd/wheat-detection.git cd wheat-detection -
Install required packages:
pip install -r requirements.txt
-
Run the script in a Python environment or Google Colab:
python wheat_detection.py
The project uses the GlobalWheat2020 dataset:
- Images and annotations are downloaded from Zenodo and Ultralytics.
- The dataset is organized into
images,labels, andannotationsdirectories. - A YAML file (
GlobalWheat2020_subset.yaml) is created for training and validation subsets.
The script trains a pre-trained YOLO11n model on the GlobalWheat2020 dataset for 5 epochs. Adjust the number of epochs or image size as needed:
model.train(data="GlobalWheat2020_subset.yaml", epochs=5, imgsz=640)Upload an image to perform wheat head detection:
- The script prompts for image upload.
- Results are displayed with bounding boxes using Matplotlib.
Example:
results = model("path/to/image.jpg")
for result in results:
img = result.plot()
plt.imshow(img)
plt.show()The trained model outputs bounding boxes around wheat heads in images.
Results are saved in the runs/detect directory.
Contributions are welcome! π Feel free to:
- Open issues for bugs or feature requests
- Submit pull requests with improvements
- Add new datasets or enhance the model
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or feedback, reach out via GitHub Issues or email at shervindanesh8282@gmail.com
Happy wheat detecting! πΎπ