A high-performance Computer Vision system for autonomous driving scene understanding. The system takes a single RGB image as input and simultaneously performs:
An autonomous vehicle requires real-time, comprehensive spatial and semantic understanding of its environment. Traditional architectures deploy independent models for segmentation and depth estimation:
RGB Image
│
┌─────────┴─────────┐
▼ ▼
Segmentation Model Depth Model
(Encoder+Dec) (Encoder+Dec)
│ │
▼ ▼
Segmentation Mask Depth Map
A unified Multi-Task Learning framework powered by a Shared Hierarchical Vision Transformer (SegFormer MiT) Encoder with two task-specialized decoders:
Input: Single RGB Image
│
▼
┌──────────────────────────────┐
│ Shared SegFormer MiT Encoder │
└──────────────┬───────────────┘
│
Multi-Scale Features (f1–f4)
/ \
/ \
▼ ▼
┌─────────────────┐ ┌───────────────────────────┐
│ SegFormer │ │ Progressive Fusion │
│ All-MLP Decoder │ │ Depth Decoder │
└────────┬────────┘ └─────────────┬─────────────┘
│ │
▼ ▼
Predicted Segmentation Predicted Normalized
Mask Inverse Depth
Each component was selected based on rigorous computer vision principles to maximize dense prediction accuracy and hardware efficiency.
models/segformer_encoder.pymodels/segformer_decoder.pymodels/decoder/progressive_depth_decoder.pydatasets/cityscapes_dataset.pyleftImg8bit/: 8-bit RGB road scene images (the only input given to the encoder).gtFine/: Fine pixel annotations for 19 evaluation classes (supervision ground truth for segmentation).disparity/: 16-bit stereo disparity maps (supervision ground truth for depth). ┌──────────┐
│ RGB Only │
└────┬─────┘
│
▼
┌─────────────────┐
│ Model (Encoder) │
└────────┬────────┘
│
┌───────────┴───────────┐
▼ ▼
Predicted Seg Predicted Depth
│ │
▼ (Loss Only) ▼ (Loss Only)
gtFine Target Disparity Target
Cityscapes stores disparity $D$ as 16-bit integers with a baseline $B = 0.209313\text{ m}$ and focal length $f = 2262.52\text{ px}$.
torch.cuda.amp.autocast(dtype=torch.float16)) and GradScaler().ignore_index=255 and $\text{label_smoothing}=0.0$.For each class $c \in {0, 1, \dots, 18}$: $$\text{IoU}c = \frac{\text{TP}c}{\text{TP}c + \text{FP}c + \text{FN}c} = \frac{\sum{i=1}^N |P{i, c} \cap G{i, c}|}{\sum{i=1}^N |P{i, c} \cup G_{i, c}|}$$ $$\text{mIoU} = \frac{1}{19} \sum_{c=0}^{18} \text{IoU}_c$$
Computed over valid ground truth pixels ($\mathcal{M} = {i : y_i > 0}$):
| Class ID | Class Name | Standard IoU | TTA (+ Flip) IoU | Qualitative Evaluation |
|---|---|---|---|---|
| 0 | Road | $98.40%$ | $98.37%$ | Flawless road plane segmentation |
| 1 | Sidewalk | $86.71%$ | $86.53%$ | Sharp curb and walkway distinction |
| 2 | Building | $93.04%$ | $93.22%$ | Accurate vertical architectural facade |
| 3 | Wall | $62.05%$ | $64.23%$ | Clean texture separation from buildings |
| 4 | Fence | $61.07%$ | $61.60%$ | High-fidelity barrier detection |
| 5 | Pole | $66.25%$ | $66.71%$ | Superior thin vertical structure recovery |
| 6 | Traffic Light | $71.57%$ | $72.02%$ | Accurate small-object localization |
| 7 | Traffic Sign | $79.99%$ | $80.25%$ | Sharp geometric symbol recognition |
| 8 | Vegetation | $92.94%$ | $93.00%$ | Excellent tree and foliage coverage |
| 9 | Terrain | $64.42%$ | $64.75%$ | Reliable grass/ground surface classification |
| 10 | Sky | $95.25%$ | $95.29%$ | Perfect horizon and background capture |
| 11 | Person | $82.94%$ | $83.10%$ | Precise pedestrian silhouette detection |
| 12 | Rider | $62.85%$ | $62.97%$ | Distinct from bikes and motorcycles |
| 13 | Car | $95.21%$ | $95.25%$ | Near-perfect multi-vehicle boundaries |
| 14 | Truck | $84.15%$ | $84.47%$ | Accurate heavy vehicle classification |
| 15 | Bus | $88.17%$ | $88.35%$ | Clean public transport detection |
| 16 | Train | $81.77%$ | $81.75%$ | High-precision rail transit detection |
| 17 | Motorcycle | $69.15%$ | $69.70%$ | Robust two-wheeler identification |
| 18 | Bicycle | $78.12%$ | $78.35%$ | Crisp frame and wheel spoke delineation |
| All | Mean IoU (mIoU) | $79.69%$ | $\mathbf{80.00%}$ | Competitive with published SOTA |
Presentation figures generated at 200 DPI:
Single-Scene 3-Panel Evaluation:
logs/segmentation/eval_sample.pngInput RGB Image (1024×2048) $\to$ Predicted Mask (Ours: 80.00% mIoU) $\to$ Ground Truth (gtFine).Multi-Scene Generalization Grid (3x3):
logs/segmentation/eval_sample_multi.png"A modern hierarchical Vision Transformer shared encoder can learn unified representations supporting both semantic segmentation and monocular depth estimation, maintaining accuracy parity with separate single-task models while reducing encoder parameter count and latency by nearly 50%."
Joint optimization minimizes a combined objective: $$\mathcal{L}{\text{total}} = w{\text{seg}} \mathcal{L}{\text{seg}} + w{\text{depth}} \mathcal{L}_{\text{depth}}$$
To prevent one task from dominating gradients, we investigate two paradigms:
| Model Architecture | Encoder Params | Total Params | Segmentation mIoU | Depth AbsRel | Inference FPS |
|---|---|---|---|---|---|
| Baseline 1: Seg-Only | $24.2\text{ M}$ | $27.5\text{ M}$ | $79.69%$ | — | $1.0\times$ |
| Baseline 2: Depth-Only | $24.2\text{ M}$ | $27.5\text{ M}$ | — | $0.0944$ | $1.0\times$ |
| Combined Independent | $48.4\text{ M}$ (Duplicated) | $55.0\text{ M}$ | $79.69%$ | $0.0944$ | $0.5\times$ |
| Joint MTL (Static Weighting) | $24.2\text{ M}$ | $30.8\text{ M}$ | $\approx 78.5\text{–}79.5%$ | $\approx 0.095$ | $\approx \mathbf{1.8\times}$ |
| Joint MTL (Kendall Uncertainty) | $24.2\text{ M}$ | $30.8\text{ M}$ | $\mathbf{\approx 79.5\text{–}80.5%}$ | $\mathbf{\approx 0.090}$ | $\approx \mathbf{1.8\times}$ |
Capstone/
├── checkpoints/
│ ├── segmentation/
│ │ ├── best_seg_model.pth # Best segmentation model weights (80.00% mIoU)
│ │ └── last_seg_checkpoint.pth # Full training state for resuming
│ └── depth/
│ └── best_depth_model.pth # Best depth model weights
│
├── datasets/
│ └── cityscapes_dataset.py # Native 1024x2048 dataset loader & augmentations
│
├── models/
│ ├── decoder/
│ │ └── progressive_depth_decoder.py # Progressive fusion depth head
│ ├── segformer_encoder.py # SegFormer MiT-B2 hierarchical Transformer
│ ├── segformer_decoder.py # SegFormer All-MLP segmentation head
│ ├── seg_model.py # Single-task segmentation wrapper
│ └── depth_model.py # Single-task depth wrapper
│
├── utils/
│ ├── depth_utils.py # Disparity <-> Metric depth conversion
│ ├── label_mapping.py # 34 raw IDs -> 19 evaluation TrainIDs
│ ├── metrics.py # Academic global accumulator for mIoU & depth
│ └── visualize.py # Color mapping and rendering utilities
│
├── scripts/
│ ├── check_dataset.py # Sanity checking data loader & shapes
│ ├── train_seg.py # Native 1024x2048 segmentation training
│ ├── evaluate_seg.py # Official 19-class benchmark evaluator
│ ├── train_depth.py # Native 1024x2048 depth training
│ └── evaluate_depth.py # Depth evaluation (AbsRel, RMSE, delta)
│
├── logs/
│ ├── segmentation/
│ │ ├── eval_report.txt # Saved official benchmark report
│ │ ├── eval_sample.png # Presentation 3-panel figure
│ │ ├── eval_sample_multi.png # Presentation 3x3 multi-scene figure
│ │ └── train_log.csv # Epoch-by-epoch loss and mIoU log
│ └── depth/
│ ├── eval_report.txt # Saved depth benchmark report
│ └── eval_sample.png # Depth visual comparison
│
├── requirements.txt # Python dependencies
└── README.md # Complete project documentation
# Clone the repository
git clone https://github.com/teju701/Capstone.git
cd Capstone
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate # On Windows: .\venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
To run full evaluation on the 500 validation images and regenerate reports and visuals:
python scripts/evaluate_seg.py
To train the baseline from scratch or resume from a checkpoint:
python scripts/train_seg.py
python scripts/evaluate_depth.py
python scripts/train_depth.py
Python
99.2%
A high-performance Computer Vision system for autonomous driving scene understanding. The system takes a single RGB image as input and simultaneously performs:
An autonomous vehicle requires real-time, comprehensive spatial and semantic understanding of its environment. Traditional architectures deploy independent models for segmentation and depth estimation:
RGB Image
│
┌─────────┴─────────┐
▼ ▼
Segmentation Model Depth Model
(Encoder+Dec) (Encoder+Dec)
│ │
▼ ▼
Segmentation Mask Depth Map
A unified Multi-Task Learning framework powered by a Shared Hierarchical Vision Transformer (SegFormer MiT) Encoder with two task-specialized decoders:
Input: Single RGB Image
│
▼
┌──────────────────────────────┐
│ Shared SegFormer MiT Encoder │
└──────────────┬───────────────┘
│
Multi-Scale Features (f1–f4)
/ \
/ \
▼ ▼
┌─────────────────┐ ┌───────────────────────────┐
│ SegFormer │ │ Progressive Fusion │
│ All-MLP Decoder │ │ Depth Decoder │
└────────┬────────┘ └─────────────┬─────────────┘
│ │
▼ ▼
Predicted Segmentation Predicted Normalized
Mask Inverse Depth
Each component was selected based on rigorous computer vision principles to maximize dense prediction accuracy and hardware efficiency.
models/segformer_encoder.pymodels/segformer_decoder.pymodels/decoder/progressive_depth_decoder.pydatasets/cityscapes_dataset.pyleftImg8bit/: 8-bit RGB road scene images (the only input given to the encoder).gtFine/: Fine pixel annotations for 19 evaluation classes (supervision ground truth for segmentation).disparity/: 16-bit stereo disparity maps (supervision ground truth for depth). ┌──────────┐
│ RGB Only │
└────┬─────┘
│
▼
┌─────────────────┐
│ Model (Encoder) │
└────────┬────────┘
│
┌───────────┴───────────┐
▼ ▼
Predicted Seg Predicted Depth
│ │
▼ (Loss Only) ▼ (Loss Only)
gtFine Target Disparity Target
Cityscapes stores disparity $D$ as 16-bit integers with a baseline $B = 0.209313\text{ m}$ and focal length $f = 2262.52\text{ px}$.
torch.cuda.amp.autocast(dtype=torch.float16)) and GradScaler().ignore_index=255 and $\text{label_smoothing}=0.0$.For each class $c \in {0, 1, \dots, 18}$: $$\text{IoU}c = \frac{\text{TP}c}{\text{TP}c + \text{FP}c + \text{FN}c} = \frac{\sum{i=1}^N |P{i, c} \cap G{i, c}|}{\sum{i=1}^N |P{i, c} \cup G_{i, c}|}$$ $$\text{mIoU} = \frac{1}{19} \sum_{c=0}^{18} \text{IoU}_c$$
Computed over valid ground truth pixels ($\mathcal{M} = {i : y_i > 0}$):
| Class ID | Class Name | Standard IoU | TTA (+ Flip) IoU | Qualitative Evaluation |
|---|---|---|---|---|
| 0 | Road | $98.40%$ | $98.37%$ | Flawless road plane segmentation |
| 1 | Sidewalk | $86.71%$ | $86.53%$ | Sharp curb and walkway distinction |
| 2 | Building | $93.04%$ | $93.22%$ | Accurate vertical architectural facade |
| 3 | Wall | $62.05%$ | $64.23%$ | Clean texture separation from buildings |
| 4 | Fence | $61.07%$ | $61.60%$ | High-fidelity barrier detection |
| 5 | Pole | $66.25%$ | $66.71%$ | Superior thin vertical structure recovery |
| 6 | Traffic Light | $71.57%$ | $72.02%$ | Accurate small-object localization |
| 7 | Traffic Sign | $79.99%$ | $80.25%$ | Sharp geometric symbol recognition |
| 8 | Vegetation | $92.94%$ | $93.00%$ | Excellent tree and foliage coverage |
| 9 | Terrain | $64.42%$ | $64.75%$ | Reliable grass/ground surface classification |
| 10 | Sky | $95.25%$ | $95.29%$ | Perfect horizon and background capture |
| 11 | Person | $82.94%$ | $83.10%$ | Precise pedestrian silhouette detection |
| 12 | Rider | $62.85%$ | $62.97%$ | Distinct from bikes and motorcycles |
| 13 | Car | $95.21%$ | $95.25%$ | Near-perfect multi-vehicle boundaries |
| 14 | Truck | $84.15%$ | $84.47%$ | Accurate heavy vehicle classification |
| 15 | Bus | $88.17%$ | $88.35%$ | Clean public transport detection |
| 16 | Train | $81.77%$ | $81.75%$ | High-precision rail transit detection |
| 17 | Motorcycle | $69.15%$ | $69.70%$ | Robust two-wheeler identification |
| 18 | Bicycle | $78.12%$ | $78.35%$ | Crisp frame and wheel spoke delineation |
| All | Mean IoU (mIoU) | $79.69%$ | $\mathbf{80.00%}$ | Competitive with published SOTA |
Presentation figures generated at 200 DPI:
Single-Scene 3-Panel Evaluation:
logs/segmentation/eval_sample.pngInput RGB Image (1024×2048) $\to$ Predicted Mask (Ours: 80.00% mIoU) $\to$ Ground Truth (gtFine).Multi-Scene Generalization Grid (3x3):
logs/segmentation/eval_sample_multi.png"A modern hierarchical Vision Transformer shared encoder can learn unified representations supporting both semantic segmentation and monocular depth estimation, maintaining accuracy parity with separate single-task models while reducing encoder parameter count and latency by nearly 50%."
Joint optimization minimizes a combined objective: $$\mathcal{L}{\text{total}} = w{\text{seg}} \mathcal{L}{\text{seg}} + w{\text{depth}} \mathcal{L}_{\text{depth}}$$
To prevent one task from dominating gradients, we investigate two paradigms:
| Model Architecture | Encoder Params | Total Params | Segmentation mIoU | Depth AbsRel | Inference FPS |
|---|---|---|---|---|---|
| Baseline 1: Seg-Only | $24.2\text{ M}$ | $27.5\text{ M}$ | $79.69%$ | — | $1.0\times$ |
| Baseline 2: Depth-Only | $24.2\text{ M}$ | $27.5\text{ M}$ | — | $0.0944$ | $1.0\times$ |
| Combined Independent | $48.4\text{ M}$ (Duplicated) | $55.0\text{ M}$ | $79.69%$ | $0.0944$ | $0.5\times$ |
| Joint MTL (Static Weighting) | $24.2\text{ M}$ | $30.8\text{ M}$ | $\approx 78.5\text{–}79.5%$ | $\approx 0.095$ | $\approx \mathbf{1.8\times}$ |
| Joint MTL (Kendall Uncertainty) | $24.2\text{ M}$ | $30.8\text{ M}$ | $\mathbf{\approx 79.5\text{–}80.5%}$ | $\mathbf{\approx 0.090}$ | $\approx \mathbf{1.8\times}$ |
Capstone/
├── checkpoints/
│ ├── segmentation/
│ │ ├── best_seg_model.pth # Best segmentation model weights (80.00% mIoU)
│ │ └── last_seg_checkpoint.pth # Full training state for resuming
│ └── depth/
│ └── best_depth_model.pth # Best depth model weights
│
├── datasets/
│ └── cityscapes_dataset.py # Native 1024x2048 dataset loader & augmentations
│
├── models/
│ ├── decoder/
│ │ └── progressive_depth_decoder.py # Progressive fusion depth head
│ ├── segformer_encoder.py # SegFormer MiT-B2 hierarchical Transformer
│ ├── segformer_decoder.py # SegFormer All-MLP segmentation head
│ ├── seg_model.py # Single-task segmentation wrapper
│ └── depth_model.py # Single-task depth wrapper
│
├── utils/
│ ├── depth_utils.py # Disparity <-> Metric depth conversion
│ ├── label_mapping.py # 34 raw IDs -> 19 evaluation TrainIDs
│ ├── metrics.py # Academic global accumulator for mIoU & depth
│ └── visualize.py # Color mapping and rendering utilities
│
├── scripts/
│ ├── check_dataset.py # Sanity checking data loader & shapes
│ ├── train_seg.py # Native 1024x2048 segmentation training
│ ├── evaluate_seg.py # Official 19-class benchmark evaluator
│ ├── train_depth.py # Native 1024x2048 depth training
│ └── evaluate_depth.py # Depth evaluation (AbsRel, RMSE, delta)
│
├── logs/
│ ├── segmentation/
│ │ ├── eval_report.txt # Saved official benchmark report
│ │ ├── eval_sample.png # Presentation 3-panel figure
│ │ ├── eval_sample_multi.png # Presentation 3x3 multi-scene figure
│ │ └── train_log.csv # Epoch-by-epoch loss and mIoU log
│ └── depth/
│ ├── eval_report.txt # Saved depth benchmark report
│ └── eval_sample.png # Depth visual comparison
│
├── requirements.txt # Python dependencies
└── README.md # Complete project documentation
# Clone the repository
git clone https://github.com/teju701/Capstone.git
cd Capstone
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate # On Windows: .\venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
To run full evaluation on the 500 validation images and regenerate reports and visuals:
python scripts/evaluate_seg.py
To train the baseline from scratch or resume from a checkpoint:
python scripts/train_seg.py
python scripts/evaluate_depth.py
python scripts/train_depth.py
Python
99.2%