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.
📦 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
| 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 |
- 200 labeled images annotated with crops and weeds
- 1,000 unlabeled images used for semi-supervised training
Applied using Albumentations — each image augmented 5x to simulate real-world conditions:
- RandomBrightnessContrast, HueSaturationValue
- RandomFog, RandomRain, RandomSnow
- MotionBlur, GaussianBlur, GaussianNoise
- CLAHE, GridDistortion
- Initial Training — YOLOv9 trained on 200 labeled images
- Pseudo-Labeling — model predicts labels for 1,000 unlabeled images
- Confidence Filtering — top 200 predictions with confidence ≥ 0.5 selected
- Iterative Retraining — model retrained on expanded dataset
- GIoU Loss — improved bounding box alignment under complex field conditions
- F1 Score Loss — balances precision and recall to minimize false positives and negatives
git clone https://github.com/Shradd7/Semi_Supervise_Weed_Detection.git
cd Semi_Supervise_Weed_Detectionpip install -r requirements.txtPre-trained weights available here → Google Drive
Place the weights file in the root directory.
01_EDA_Augmentation.ipynb — run first
02_Train_Inference.ipynb — run second
| Category | Tools |
|---|---|
| Model | YOLOv9 (Ultralytics) |
| Framework | PyTorch |
| Augmentation | Albumentations |
| Image Processing | OpenCV |
| Visualization | Matplotlib, Seaborn |
| Data | NumPy, Pandas |
- 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