Skip to content

Shradd7/Semi_Supervise_Weed_Detection

Repository files navigation

🌿 Semi-Supervised Weed Detection using YOLOv9

PyTorch YOLOv9 Albumentations License

A semi-supervised deep learning pipeline for real-time weed detection in precision agriculture using YOLOv9, GIoU loss, and pseudo-labeling — achieving high accuracy with only 200 labeled images.


📁 Project Structure

📦 Semi_Supervise_Weed_Detection
 ┣ 📓 01_EDA_Augmentation.ipynb       # EDA and augmentation pipeline
 ┣ 📓 02_Train_Inference.ipynb        # Model training and inference
 ┣ 📄 Semi_Supervised_Weed_Detection_Report.pdf
 ┣ 📄 requirements.txt
 ┗ 📄 README.md

📊 Results

Metric Baseline YOLOv9 Final Model
Precision 0.77 0.89
Recall 0.85 0.88
F1 Score 0.81 0.89
mAP@50-95 0.58 0.62
Final Metric 0.69 0.75

🔍 Methodology

1. Dataset

  • 200 labeled images annotated with crops and weeds
  • 1,000 unlabeled images used for semi-supervised training

2. Data Augmentation

Applied using Albumentations — each image augmented 5x to simulate real-world conditions:

  • RandomBrightnessContrast, HueSaturationValue
  • RandomFog, RandomRain, RandomSnow
  • MotionBlur, GaussianBlur, GaussianNoise
  • CLAHE, GridDistortion

3. Semi-Supervised Learning Pipeline

  1. Initial Training — YOLOv9 trained on 200 labeled images
  2. Pseudo-Labeling — model predicts labels for 1,000 unlabeled images
  3. Confidence Filtering — top 200 predictions with confidence ≥ 0.5 selected
  4. Iterative Retraining — model retrained on expanded dataset

4. Loss Functions

  • GIoU Loss — improved bounding box alignment under complex field conditions
  • F1 Score Loss — balances precision and recall to minimize false positives and negatives

🚀 Getting Started

1. Clone the repo

git clone https://github.com/Shradd7/Semi_Supervise_Weed_Detection.git
cd Semi_Supervise_Weed_Detection

2. Install dependencies

pip install -r requirements.txt

3. Download model weights

Pre-trained weights available here → Google Drive

Place the weights file in the root directory.

4. Run notebooks in order

01_EDA_Augmentation.ipynb    — run first
02_Train_Inference.ipynb     — run second

🛠️ Tech Stack

Category Tools
Model YOLOv9 (Ultralytics)
Framework PyTorch
Augmentation Albumentations
Image Processing OpenCV
Visualization Matplotlib, Seaborn
Data NumPy, Pandas

🔮 Future Work

  • Deploy as a real-time inference API using FastAPI
  • Extend to multi-class weed species detection
  • Test on drone footage for field-scale deployment
  • Experiment with FixMatch or MixMatch for stronger semi-supervised baselines

👥 Authors

About

Semi-supervised YOLOv9 model for real-time weed detection in precision agriculture — GIoU loss, F1 optimization, pseudo-labeling on 1000+ unlabeled images.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors