Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌿 Annotation-efficient weed detection using semi-supervised and self-supervised YOLOv12 frameworks with DINOv3 distillation

A complete deep learning repository for weed detection using supervised YOLO baselines, semi-supervised learning, self-supervised learning, and DINOv3 feature-distribution distillation.

Overview β€’ Features β€’ Datasets β€’ Models and artifacts β€’ Installation β€’ Usage β€’ Notebooks


πŸ“Œ Overview

This repository provides an end-to-end implementation of an annotation-efficient weed detection framework for precision agriculture. The project combines a Streamlit-based deployment interface with reproducible Kaggle notebook experiments and final trained model artifacts.

The repository covers three major learning settings:

  • Fully supervised detection using YOLO-family models.
  • Semi-supervised detection using Soft Teacher-style pseudo-labeling.
  • Self-supervised detection using BYOL and DINOv3-based representation distillation.
  • WEEDINO-YOLOv12, which transfers global-average-pooled DINOv3 ViT-B/16 feature distributions into a lightweight YOLOv12n detector before downstream fine-tuning.

The project evaluates label-efficient weed detection on both a single-class Roboflow Weeds benchmark and the multi-class CottonWeedDet12 dataset.


✨ Features

  • 🌱 Weed detection from agricultural field images.
  • πŸŽ₯ Image and video inference support through a Streamlit app.
  • 🧠 Multiple learning paradigms: supervised, semi-supervised, and self-supervised.
  • πŸ“Š Final model outputs with checkpoints, training curves, CSV logs, and runtime/evaluation summaries.
  • πŸ§ͺ Multi-seed experimental notebooks for reproducibility.
  • 🌾 External multi-class validation using CottonWeedDet12.
  • πŸ“ Organized artifacts for Roboflow Weeds and CottonWeedDet12 experiments.

πŸ“š Datasets

1. Roboflow Weeds

The Roboflow Weeds dataset is used as the primary weed detection benchmark. It contains a single object class, Weeds, with YOLO-format bounding-box annotations.

Used settings include:

  • Full-label supervised training.
  • Fixed train-only 20%-label setting.
  • Unlabeled/reference image use for label-efficient learning.
  • Seeds: 42, 2024, and 3407.

2. CottonWeedDet12

CottonWeedDet12 is used as an external multi-class cotton-field weed detection benchmark.

Used settings include:

  • 12 weed classes.
  • Full-label supervised training.
  • 20%-label supervised training.
  • 20%-label DINOv3 distillation setting.
  • Seeds: 42, 2024, and 3407.

Raw datasets are not included in this repository. Users should download datasets from their original public sources and follow the notebook instructions for preparing YOLO-format data.


πŸ€– Models and artifacts

Final model outputs are stored under:

artifacts/main_models/

The artifact package contains:

  • 18 final best.pt checkpoints.
  • 18 results.csv files.
  • 18 results.png training/evaluation plots.
  • Runtime summaries.
  • Evaluation CSV files.
  • Per-class AP summaries where applicable.
  • Training logs and metadata files.

Main experimental groups

Dataset Setting Seeds
Roboflow Weeds YOLOv12n full-label supervised 42, 2024, 3407
Roboflow Weeds YOLOv12n 20%-label supervised 42, 2024, 3407
Roboflow Weeds WEEDINO-YOLOv12 20%-label DINOv3 distillation 42, 2024, 3407
CottonWeedDet12 YOLOv12n full-label supervised 42, 2024, 3407
CottonWeedDet12 YOLOv12n 20%-label supervised 42, 2024, 3407
CottonWeedDet12 WEEDINO-YOLOv12 20%-label DINOv3 distillation 42, 2024, 3407

Diagnostic baselines are also included for:

  • Soft Teacher.
  • BYOL.
  • YOLOv10n, YOLOv11n, and YOLOv12n supervised baseline notebooks.

πŸ“Š Experimental interpretation

The repository is designed for controlled comparison of annotation-efficient weed detection strategies.

The main empirical finding is that full-label supervision remains the strongest overall setting, while WEEDINO-YOLOv12 provides modest but consistent gains over matched 20%-label YOLOv12n controls. The DINOv3-based setting is therefore best interpreted as a label-efficient improvement over limited-label supervision rather than a replacement for fully labeled training.


πŸš€ Installation

Prerequisites

  • Python 3.8 or higher.
  • Git.
  • pip.
  • Optional: CUDA-enabled GPU for local model inference or training.

Clone the repository

git clone https://github.com/saifkhancse/Weed-Detection-App.git
cd Weed-Detection-App

Create a virtual environment

For Windows:

python -m venv venv
venv\Scripts\activate

For macOS/Linux:

python -m venv venv
source venv/bin/activate

Install dependencies

pip install -r requirements.txt

πŸ’» Usage

Run the Streamlit application:

streamlit run app.py

The app will open locally at:

http://localhost:8501

Typical workflow

  1. Select a trained model.
  2. Upload an image or video.
  3. Set the confidence threshold.
  4. Run weed detection.
  5. View annotated predictions and detection statistics.
  6. Export results if needed.

πŸ“ Project structure

Weed-Detection-App/
β”‚
β”œβ”€β”€ app.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ README.md
β”œβ”€β”€ LICENSE
β”œβ”€β”€ .gitignore
β”‚
β”œβ”€β”€ artifacts/
β”‚   └── main_models/
β”‚       β”œβ”€β”€ roboflow_sup100_seed42/
β”‚       β”œβ”€β”€ roboflow_sup100_seed2024/
β”‚       β”œβ”€β”€ roboflow_sup100_seed3407/
β”‚       β”œβ”€β”€ roboflow_sup20_fixedsplit_allseeds/
β”‚       β”œβ”€β”€ roboflow_dinov3_20_seed42/
β”‚       β”œβ”€β”€ roboflow_dinov3_20_seed2024/
β”‚       β”œβ”€β”€ roboflow_dinov3_20_seed3407/
β”‚       β”œβ”€β”€ cotton_sup100_seed42/
β”‚       β”œβ”€β”€ cotton_sup100_seed2024/
β”‚       β”œβ”€β”€ cotton_sup100_seed3407/
β”‚       β”œβ”€β”€ cotton_sup20_seed42/
β”‚       β”œβ”€β”€ cotton_sup20_seed2024/
β”‚       β”œβ”€β”€ cotton_sup20_seed3407/
β”‚       β”œβ”€β”€ cotton_dinov3_20_seed42/
β”‚       β”œβ”€β”€ cotton_dinov3_20_seed2024/
β”‚       └── cotton_dinov3_20_seed3407/
β”‚
β”œβ”€β”€ notebooks/
β”‚   β”œβ”€β”€ roboflow/
β”‚   β”œβ”€β”€ cottonweeddet12/
β”‚   └── diagnostics/
β”‚
β”œβ”€β”€ splits/
β”‚   β”œβ”€β”€ roboflow/
β”‚   └── cottonweeddet12/
β”‚
└── docs/

πŸ““ Notebooks

The repository includes complete Kaggle notebook exports for the main experimental settings.

Roboflow Weeds notebooks

notebooks/roboflow/

Includes:

  • Full-label YOLOv12n supervised training.
  • 20%-label YOLOv12n supervised training.
  • 20%-label DINOv3 distillation + YOLOv12n fine-tuning.
  • Seeds: 42, 2024, and 3407.

CottonWeedDet12 notebooks

notebooks/cottonweeddet12/

Includes:

  • Full-label YOLOv12n supervised training.
  • 20%-label YOLOv12n supervised training.
  • 20%-label DINOv3 distillation + YOLOv12n fine-tuning.
  • Seeds: 42, 2024, and 3407.

Diagnostic notebooks

notebooks/diagnostics/

Includes:

  • Roboflow BYOL diagnostic runs.
  • Roboflow Soft Teacher diagnostic runs.
  • Seeds: 42, 2024, and 3407.

Additional baseline notebooks for YOLOv10n, YOLOv11n, YOLOv12n, Soft Teacher, BYOL, and DINOv3 are also retained for transparency and comparison.


πŸ” Reproducibility checklist

A complete repository checkout should contain:

24 organized multi-seed experimental notebooks
18 best.pt model checkpoints
18 results.csv files
18 results.png files
Roboflow and CottonWeedDet12 experiment outputs
Streamlit deployment code
Dependency file
Project documentation

You can verify the main counts using:

find notebooks/roboflow -maxdepth 1 -name "*.ipynb" | wc -l
find notebooks/cottonweeddet12 -maxdepth 1 -name "*.ipynb" | wc -l
find notebooks/diagnostics -maxdepth 1 -name "*.ipynb" | wc -l

find artifacts -name "best.pt" | wc -l
find artifacts -name "results.csv" | wc -l
find artifacts -name "results.png" | wc -l

Expected output:

Roboflow notebooks: 9
CottonWeedDet12 notebooks: 9
Diagnostic notebooks: 6

best.pt: 18
results.csv: 18
results.png: 18

πŸ› οΈ Technologies used

  • Python.
  • PyTorch.
  • Ultralytics YOLO.
  • YOLOv10, YOLOv11, and YOLOv12.
  • Streamlit.
  • OpenCV.
  • NumPy.
  • Pandas.
  • Plotly.
  • Pillow.
  • Kaggle Notebooks.
  • DINOv3.
  • BYOL.
  • Soft Teacher-style semi-supervised learning.

πŸ“„ License

This project is distributed under the license provided in the repository LICENSE file.


πŸ™ Acknowledgments

This project uses open-source deep learning and computer vision tools, including Ultralytics YOLO, PyTorch, Streamlit, OpenCV, and the broader Python scientific computing ecosystem. The experiments also build on public agricultural weed detection datasets and Kaggle-based GPU execution environments.


πŸ“¬ Contact

For questions about this repository, please open an issue on GitHub or contact the repository maintainer through the GitHub profile associated with this project.


🌿 Weed detection for precision agriculture using label-efficient YOLOv12 learning

About

A comprehensive deep learning application for automated weed detection in agricultural fields using state-of-the-art YOLO models with supervised, semi-supervised, and self-supervised learning approaches.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages