Duality AI Code Sprint Hackathon – Offroad Autonomy Track
Semantic segmentation for desert environment understanding
- Project Overview
- System Requirements
- Environment Setup
- Project Structure
- Training
- Testing & Inference
- Expected Outputs
- Troubleshooting
- Hackathon Compliance
This project implements a semantic segmentation model for off-road autonomous navigation in desert environments. The model segments images into 10 semantic classes relevant for path planning and obstacle avoidance.
- DINOv2 Backbone: Leverages self-supervised vision transformer features
- Multi-Scale Decoder: Progressive upsampling for precise segmentation
- Mixed Precision Training: FP16 for memory efficiency
- Robust Pipeline: Automatic handling of missing data and edge cases
| Metric | Value |
|---|---|
| Best mIoU | 27.69% |
| Best Dice | 35.62% |
| Accuracy | 67.23% |
| Component | Specification |
|---|---|
| OS | Windows 10/11, Linux, macOS |
| Python | 3.8 or higher |
| RAM | 8 GB |
| GPU | NVIDIA GPU with 4GB+ VRAM |
| CUDA | 11.8 or higher |
| Storage | 5 GB free space |
| Component | Specification |
|---|---|
| GPU | NVIDIA RTX 3050 or better (8GB+ VRAM) |
| RAM | 16 GB |
| Storage | SSD with 10 GB free space |
-
Install Miniconda (if not already installed):
- Download from: https://docs.conda.io/en/latest/miniconda.html
- Run the installer and follow prompts
-
Run the setup script:
cd ENV_SETUP setup_env.bat # Windows # OR bash setup_env.sh # Linux/macOS
-
Activate the environment:
conda activate EDU
-
Create conda environment:
conda create -n EDU python=3.10 -y conda activate EDU
-
Install PyTorch with CUDA:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
-
Install remaining dependencies:
pip install -r requirements.txt
python -c "import torch; print(f'PyTorch: {torch.__version__}'); print(f'CUDA: {torch.cuda.is_available()}')"Expected output:
PyTorch: 2.x.x
CUDA: True
segmentation_project/
│
├── train_segmentation.py # Training script
├── test_segmentation.py # Inference script
├── failure_analysis.py # Visualization utilities
├── visualize.py # Color mapping utilities
├── requirements.txt # Python dependencies
├── README.md # This file
├── HACKATHON_REPORT.md # Detailed project report
│
├── train/ # Training data
│ ├── Color_Images/ # RGB training images
│ └── Segmentation/ # Ground truth masks
│
├── Color_Images/ # Validation RGB images
├── Segmentation/ # Validation masks
│
├── data/
│ └── testImages/ # Test images (no ground truth)
│ └── Color_Images/ # RGB test images
│
├── output/ # Training outputs
│ ├── best_model.pth # Best model checkpoint
│ ├── config.json # Training configuration
│ ├── training_curves.png # Loss/metric plots
│ └── training_report.txt # Training summary
│
├── failure_analysis/ # Failure case visualizations
│ └── case_*.png # Sample analysis images
│
└── ENV_SETUP/ # Environment setup scripts
└── setup_env.bat # Windows setup script
conda activate EDU
python train_segmentation.pypython train_segmentation.py \
--train_dir ./train \
--val_dir . \
--batch_size 4 \
--epochs 50 \
--lr 0.001 \
--backbone small \
--output_dir ./output| Argument | Default | Description |
|---|---|---|
--train_dir |
./train |
Training data directory |
--val_dir |
. |
Validation data directory |
--batch_size |
4 | Batch size (reduce if OOM) |
--epochs |
50 | Maximum training epochs |
--lr |
1e-3 | Learning rate |
--backbone |
small | DINOv2 size: small/base/large |
--output_dir |
./output | Output directory |
--resume |
— | Resume from checkpoint |
--no_amp |
False | Disable mixed precision |
--no_augment |
False | Disable augmentation |
--seed |
42 | Random seed |
After training completes:
output/best_model.pth— Best model weightsoutput/config.json— Training configurationoutput/training_curves.png— Loss and metric plotsoutput/training_report.txt— Detailed metrics per epoch
python test_segmentation.py \
--model_path ./output/best_model.pth \
--test_dir ./data/testImages/Color_Images \
--output_dir ./test_results| Argument | Default | Description |
|---|---|---|
--model_path |
Required | Path to model checkpoint |
--test_dir |
Required | Directory with test images |
--output_dir |
./results | Output directory |
--visualize |
False | Save colored visualizations |
--batch_size |
1 | Inference batch size |
python failure_analysis.py \
--model_path ./output/best_model.pth \
--image_dir ./Color_Images \
--mask_dir ./Segmentation \
--output_dir ./failure_analysis \
--max_images 202026-01-23 10:00:00 | INFO | Starting training...
2026-01-23 10:00:05 | INFO | Loaded 2129 training samples
2026-01-23 10:00:06 | INFO | Loaded 1002 validation samples
Epoch 1 [Train]: 100%|██████████| 1064/1064 [02:15<00:00]
Epoch 1 [Val]: 100%|██████████| 501/501 [00:45<00:00]
2026-01-23 10:03:06 | INFO | Epoch 1: Val IoU=0.2374, Val Loss=1.8050
...
2026-01-23 10:45:00 | INFO | Training completed!
2026-01-23 10:45:00 | INFO | Best Val IoU: 0.2769 (Epoch 3)
2026-01-23 11:00:00 | INFO | Loading model from ./output/best_model.pth
2026-01-23 11:00:05 | INFO | Processing 100 test images...
2026-01-23 11:01:30 | INFO | Saved predictions to ./test_results/
2026-01-23 11:01:30 | INFO | Test IoU: X.XXXX
RuntimeError: CUDA out of memory
Solution: Reduce batch size:
python train_segmentation.py --batch_size 1ModuleNotFoundError: No module named 'torch'
Solution: Activate environment and reinstall:
conda activate EDU
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu124CUDA: False
Solution:
- Verify NVIDIA drivers:
nvidia-smi - Reinstall PyTorch with correct CUDA version
- Check GPU compatibility
Solutions:
- Close unnecessary applications
- Reduce
num_workersin config - Enable mixed precision:
--no_ampremove this flag - Use SSD for data storage
Windows Solution: Run terminal as Administrator
Linux Solution: chmod +x setup_env.sh
| Rule | Status |
|---|---|
| ✓ Train only on provided dataset | Compliant |
| ✓ No test images used for training | Compliant |
| ✓ Original model architecture | Compliant |
| ✓ Reproducible results | Compliant |
-
train_segmentation.py— Training script -
test_segmentation.py— Inference script -
best_model.pth— Trained model weights -
config.json— Training configuration -
README.md— Setup instructions -
HACKATHON_REPORT.md— Project report -
requirements.txt— Dependencies
If you use this work, please cite:
@misc{offroad_segmentation_2026,
title={Offroad Semantic Segmentation for Autonomous Navigation},
author={Rashi innovators},
year={2026},
note={Duality AI Code Sprint Hackathon}
}
For questions or issues:
- Discord: Duality AI Community
- Email: [akshaykammar31@gmail.com]
Built for the Duality AI Code Sprint Hackathon 2026
Tag @DualityAI on LinkedIn to share your results!