Skip to content

SRM-Hack/Duality-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏁 CodeWizards 2.0 Β· Duality AI β€” Offroad Semantic Scene Segmentation

Python PyTorch SegFormer Val mIoU License

Team Vortex Β· Ajay Kumar Garg Engineering College
SRMIST Delhi-NCR Campus Β· 17–18 April 2026


πŸ“ Google Drive β€” Project Assets

All training checkpoints, backup runs, and the full dataset are hosted on Google Drive.

Open in Google Drive

β†’ Access the Full Project Drive Folder

The Drive contains:

  • Offroad_Segmentation_Training_Dataset/ β€” official train / val / test splits
  • offroad_project_backup/ β€” all Colab training runs and checkpoint history
  • CodeWizards_Offroad_Submission/ β€” this submission package

🧠 What This Project Does

We tackle Duality AI's Offroad Semantic Scene Segmentation challenge β€” classifying every pixel of synthetic desert RGB images into 10 terrain classes using the Falcon digital-twin pipeline.

Our solution fine-tunes SegFormer-B2 (nvidia/mit-b2, ImageNet-22k pretrained) with:

  • Median-frequency class weighting to handle severe pixel imbalance
  • Strong colour + geometric augmentation for domain robustness
  • Mixed-precision (AMP) training for GPU efficiency
  • Multi-scale + horizontal flip TTA at inference β€” boosting mIoU without touching test labels
Setting Value
Backbone nvidia/mit-b2
Classes 10 terrain classes
Image size 512 Γ— 512
Optimizer AdamW (lr=6e-5, wd=0.01)
Epochs 60
Val mIoU (flip TTA) ~0.658
Val mIoU (multi-scale + flip TTA) ~0.662

πŸ“‹ Compliance

Rule Practice
Train only on train/ (+ val/ for metrics) βœ… Yes
Never train or tune using testImages/ labels βœ… Test folder has RGB only β€” no masks used
Outputs use official class IDs in PNGs βœ… Saved as uint16 with values 100, 200, … 10000

πŸ—‚οΈ Repository Layout

Duality-AI-main/
β”œβ”€β”€ README.md
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ SUBMISSION_CHECKLIST.md
β”œβ”€β”€ run_evaluate.bat          ← Windows shortcut
β”œβ”€β”€ run_test.bat              ← Windows shortcut
β”‚
β”œβ”€β”€ configs/
β”‚   β”œβ”€β”€ config.yaml           ← Default: Google Colab / Drive paths
β”‚   └── config.windows.yaml  ← Local Windows (P:\ drive) paths
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ dataset.py            ← Custom Dataset + Albumentations augmentation
β”‚   β”œβ”€β”€ model.py              ← SegFormerWrapper + checkpoint normalization
β”‚   β”œβ”€β”€ train.py              ← Training loop (AMP, checkpointing, resume)
β”‚   β”œβ”€β”€ test.py               ← Inference + multi-scale TTA β†’ uint16 PNGs
β”‚   β”œβ”€β”€ evaluate.py           ← Quick per-epoch mIoU
β”‚   β”œβ”€β”€ evaluate_full.py      ← Full report: mIoU, confusion matrix, per-class IoU
β”‚   β”œβ”€β”€ eda.py                ← Class distribution analysis
β”‚   β”œβ”€β”€ bench_infer.py        ← Latency benchmark (median ms)
β”‚   └── visualize.py          ← Side-by-side prediction panels
β”‚
β”œβ”€β”€ runs/
β”‚   β”œβ”€β”€ checkpoints/          ← Place best_model.pth here (copy from Drive backup)
β”‚   β”œβ”€β”€ training_curves.png
β”‚   β”œβ”€β”€ confusion_matrix.png
β”‚   β”œβ”€β”€ per_class_iou.png
β”‚   └── class_distribution.png
β”‚
β”œβ”€β”€ predictions/              ← Output: <stem>_pred.png (uint16, official IDs)
β”‚
└── report/
    β”œβ”€β”€ CODEWIZARDS_REPORT.md
    └── CODEWIZARDS_REPORT.docx

βš™οΈ Setup

Prerequisites

  • Python 3.10 (Miniconda / Anaconda recommended)
  • NVIDIA GPU with CUDA (for training); CPU inference is possible but slow

1 β€” Create environment

conda create -n EDU python=3.10 -y
conda activate EDU
cd CodeWizards_Offroad_Submission
pip install -r requirements.txt

2 β€” Install CUDA-enabled PyTorch (if needed)

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

3 β€” Verify GPU

python -c "import torch; print(torch.cuda.is_available(), torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'CPU only')"

πŸ”§ Configuration

Two config files are provided under configs/. Copy the right one to configs/config.yaml before running.

Google Colab / Drive (default)

configs/config.yaml is pre-configured for Colab after mounting Drive:

data:
  train_rgb:   "/content/drive/MyDrive/Offroad_Project/Offroad_Segmentation_Training_Dataset/train/Color_Images"
  train_masks: "/content/drive/MyDrive/Offroad_Project/Offroad_Segmentation_Training_Dataset/train/Segmentation"
  val_rgb:     "/content/drive/MyDrive/Offroad_Project/Offroad_Segmentation_Training_Dataset/val/Color_Images"
  val_masks:   "/content/drive/MyDrive/Offroad_Project/Offroad_Segmentation_Training_Dataset/val/Segmentation"
  test_rgb:    "/content/drive/MyDrive/Offroad_Project/Offroad_Segmentation_Training_Dataset/testImages"

Shared Drive note: If the dataset is "Shared with me", right-click Offroad_Project β†’ Add shortcut to Drive so the MyDrive/... path resolves in Colab.

Local Windows

# Copy windows config over the default
copy configs\config.windows.yaml configs\config.yaml
data:
  train_rgb:   "P:/SRM Hackathon/Offroad_Segmentation_Training_Dataset/train/Color_Images"
  # ... adjust P:\ paths to your local extract

☁️ Google Colab Quick Start

from google.colab import drive
drive.mount('/content/drive')
%cd /content/drive/MyDrive/Offroad_Project/CodeWizards_Offroad_Submission
!pip install -r requirements.txt
!python src/evaluate_full.py

Always run commands from the CodeWizards_Offroad_Submission root so runs/checkpoints resolves correctly.


πŸ‹οΈ Placing Trained Weights

Training saves checkpoints to offroad_project_backup/ on Drive. Copy your best checkpoint into this repo:

runs/checkpoints/best_model.pth

Supported checkpoint formats (all handled automatically by normalize_training_state_dict() in src/model.py):

Source Key prefix Handled?
This repo's train.py model.segformer.* βœ…
Colab / Hugging Face raw segformer.*, decode_head.* βœ… auto-remapped
DDP multi-GPU module.* prefix βœ… stripped

πŸš€ Commands

Run all commands from the project root.

Task Command
Class distribution analysis python src/eda.py
Training (if re-running) python src/train.py
Full validation report (mIoU + plots) python src/evaluate_full.py
Inference speed benchmark python src/bench_infer.py
Generate test predictions python src/test.py
Visualize predictions (8 samples) python src/visualize.py --limit 8

Outputs:

  • Predictions β†’ predictions/<stem>_pred.png (uint16, official Falcon class IDs)
  • Plots β†’ runs/training_curves.png, runs/confusion_matrix.png, runs/per_class_iou.png

πŸ” Inference Settings

Configured in configs/config.yaml under inference::

inference:
  use_multiscale_tta: true         # Multi-scale + flip averaging (recommended)
  tta_scales: [448, 512, 576]      # Reduce if GPU OOM (remove largest scale)

TTA recommendation: Keep use_multiscale_tta: true for submission-quality predictions. It provides a ~0.4% mIoU gain over single-scale without touching any test labels.


πŸ“Š Class Taxonomy

Raw Falcon ID Class Notes
100 Trees Sparse vegetation
200 Lush Bushes Often confused with Dry Bushes
300 Dry Grass Large region coverage
500 Dry Bushes Frequent desert vegetation
550 Ground Clutter Rarest class; hardest to segment
600 Flowers Small, rare pixels
700 Logs Thin structures
800 Rocks High texture diversity
7100 Landscape Dominant ground cover
10000 Sky Dominant background

Internal training uses 0–9 indices with ignore_index=255 for void pixels. Output PNGs encode the original Falcon IDs as uint16.


πŸ“ˆ Results

Evaluation Mode mIoU
Single forward (evaluate_full.py) 0.6556
Checkpoint metadata (best epoch) 0.6576
Flip TTA (Colab eval) ~0.658
Multi-scale + flip TTA ~0.662 βœ…

The mIoU improvement from ~0.658 β†’ ~0.662 comes entirely from inference-time ensembling on the same weights β€” no additional training data or test labels used.

Strongest classes: Sky, Trees, Landscape
Weakest classes: Ground Clutter, Dry Bushes, Rocks (confusion with adjacent texture classes)


βœ… Pre-Submission Checklist

  • configs/config.yaml β€” all five data paths exist on your machine
  • runs/checkpoints/best_model.pth β€” final weights copied from Drive backup
  • python src/evaluate_full.py β€” completes cleanly; mIoU noted for report
  • python src/test.py β€” predictions/ has one *_pred.png per test image
  • python src/bench_infer.py β€” median ms recorded for report
  • report/CODEWIZARDS_REPORT.md β€” team name filled, PNGs embedded, exported to PDF
  • Zip folder + PDF β†’ Vortex_CodeWizards_Submission.zip

πŸ‘₯ Team

Name Role
Shivanshu Tiwari Model architecture & training pipeline
Anirudh Agarwal Data augmentation & evaluation
Mohammad Raees Inference, TTA & benchmarking
Aditya Gaur EDA, visualisation & report

Institution: Ajay Kumar Garg Engineering College
Team Name: Vortex
Event: CodeWizards 2.0 Β· SRMIST Delhi-NCR Β· April 2026
Challenge: Powered by Duality AI β€” Falcon digital-twin platform


Built for CodeWizards 2.0 Β· Duality AI Offroad Segmentation Challenge Β· April 2026

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors