This repository contains tools and pipelines to train Object Detection and Segmentation models using YOLO, Detectron2, and HuggingFace DETR on the TDD-xView2 (or other COCO/YOLO formatted) datasets.
The monolithic Google Colab notebooks have been refactored into a clean, modular Python src/ package to ensure portability and ease of use across different machines.
├── run_pipeline.ipynb # Main orchestrator notebook providing step-by-step instructions
├── src/
│ ├── dataset.py # Data utilities (e.g., Roboflow downloader, path patching)
│ ├── train_detectron2.py # Detectron2 training wrapper
│ ├── train_huggingface.py# HuggingFace DETR training wrapper (PyTorch Lightning)
│ ├── train_yolo.py # YOLOv8 training wrapper
│ └── utils/
│ ├── mask.py # SLIC / Object masking utility
│ └── post_process.py # Evaluation metric plotting utility
-
Install Dependencies Ensure you have Python 3.8+ installed, then install the required packages:
pip install ultralytics roboflow transformers pytorch_lightning scikit-image python -m pip install 'git+https://github.com/facebookresearch/detectron2.git' -
Run Pipeline Launch Jupyter Notebook or JupyterLab and open
run_pipeline.ipynb. From there, you can:- Prepare and download datasets via Roboflow.
- Train the models utilizing the independent
src/train_*.pywrappers. - Run post-processing plotting scripts in
src/utils/.
All hardcoded Colab Paths (/content/drive/MyDrive/...) have been parameterized. When training models, point the dataset_dir or dataset_root arguments to your locally downloaded datasets. For example, to train YOLO:
python src/train_yolo.py --model yolov8n.pt \\
--data_yaml ./datasets/data.yaml \\
--dataset_root ./datasets/ \\
--epochs 100