πΏ 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
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.
- π± 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.
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, and3407.
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, and3407.
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.
Final model outputs are stored under:
artifacts/main_models/
The artifact package contains:
- 18 final
best.ptcheckpoints. - 18
results.csvfiles. - 18
results.pngtraining/evaluation plots. - Runtime summaries.
- Evaluation CSV files.
- Per-class AP summaries where applicable.
- Training logs and metadata files.
| 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.
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.
- Python 3.8 or higher.
- Git.
- pip.
- Optional: CUDA-enabled GPU for local model inference or training.
git clone https://github.com/saifkhancse/Weed-Detection-App.git
cd Weed-Detection-AppFor Windows:
python -m venv venv
venv\Scripts\activateFor macOS/Linux:
python -m venv venv
source venv/bin/activatepip install -r requirements.txtRun the Streamlit application:
streamlit run app.pyThe app will open locally at:
http://localhost:8501
- Select a trained model.
- Upload an image or video.
- Set the confidence threshold.
- Run weed detection.
- View annotated predictions and detection statistics.
- Export results if needed.
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/
The repository includes complete Kaggle notebook exports for the main experimental settings.
notebooks/roboflow/
Includes:
- Full-label YOLOv12n supervised training.
- 20%-label YOLOv12n supervised training.
- 20%-label DINOv3 distillation + YOLOv12n fine-tuning.
- Seeds:
42,2024, and3407.
notebooks/cottonweeddet12/
Includes:
- Full-label YOLOv12n supervised training.
- 20%-label YOLOv12n supervised training.
- 20%-label DINOv3 distillation + YOLOv12n fine-tuning.
- Seeds:
42,2024, and3407.
notebooks/diagnostics/
Includes:
- Roboflow BYOL diagnostic runs.
- Roboflow Soft Teacher diagnostic runs.
- Seeds:
42,2024, and3407.
Additional baseline notebooks for YOLOv10n, YOLOv11n, YOLOv12n, Soft Teacher, BYOL, and DINOv3 are also retained for transparency and comparison.
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 -lExpected output:
Roboflow notebooks: 9
CottonWeedDet12 notebooks: 9
Diagnostic notebooks: 6
best.pt: 18
results.csv: 18
results.png: 18
- Python.
- PyTorch.
- Ultralytics YOLO.
- YOLOv10, YOLOv11, and YOLOv12.
- Streamlit.
- OpenCV.
- NumPy.
- Pandas.
- Plotly.
- Pillow.
- Kaggle Notebooks.
- DINOv3.
- BYOL.
- Soft Teacher-style semi-supervised learning.
This project is distributed under the license provided in the repository LICENSE file.
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.
For questions about this repository, please open an issue on GitHub or contact the repository maintainer through the GitHub profile associated with this project.