Skip to content

Repository files navigation

Road Scene Semantic Segmentation

A PyTorch-based implementation of various deep learning architectures for semantic segmentation of unstructured road scenes using the Indian Driving Dataset (IDD).

Table of Contents

Overview

This project implements and compares five popular deep learning architectures for semantic segmentation:

  • FCN (Fully Convolutional Network)
  • U-Net
  • PSPNet
  • LinkNet
  • DeepLabV3+

Dataset

The models are trained on the IDD-Lite dataset, which contains road scene images from Indian cities, annotated with 8 classes:

  • Drivable area
  • Non-drivable area
  • Living things
  • Vehicles
  • Roadside objects
  • Far objects
  • Sky
  • Miscellaneous

Model Architectures

This project implements five deep learning architectures, each with its unique strengths for semantic segmentation:

1. Fully Convolutional Network (FCN)

graph LR
subgraph VGG16_Backbone
I[Input] --> C1[Conv Block 1]
C1 --> C2[Conv Block 2]
C2 --> C3[Conv Block 3]
C3 --> C4[Conv Block 4]
C4 --> C5[Conv Block 5]
end
subgraph FCN_Head
C5 --> FC6[Conv 7x7]
FC6 --> FC7[Conv 1x1]
FC7 --> S1[Score]
end
subgraph Skip_Connections
C4 --> S2[Score Pool4]
C3 --> S3[Score Pool3]
S1 --> U1[Upsample 2x]
U1 --> F1[Fuse]
S2 --> F1
F1 --> U2[Upsample 2x]
U2 --> F2[Fuse]
S3 --> F2
F2 --> U3[Upsample 8x]
U3 --> O[Output]
end
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
Loading

The FCN architecture transforms traditional classification networks into fully convolutional networks for semantic segmentation. Key features:

  • Based on VGG16 backbone
  • Replaces fully connected layers with 1x1 convolutions
  • Uses skip connections from earlier layers for fine-grained prediction
  • Multi-scale prediction fusion for better segmentation details

2. U-Net Architecture

graph TD
subgraph Encoder
I[Input Image] --> C1[Conv Block 1]
C1 --> P1[MaxPool]
P1 --> C2[Conv Block 2]
C2 --> P2[MaxPool]
P2 --> C3[Conv Block 3]
C3 --> P3[MaxPool]
P3 --> C4[Conv Block 4]
end
subgraph Bottleneck
C4 --> B[Bottleneck]
end
subgraph Decoder
B --> U1[UpConv 1]
U1 --> D1[Conv Block 5]
D1 --> U2[UpConv 2]
U2 --> D2[Conv Block 6]
D2 --> U3[UpConv 3]
U3 --> D3[Conv Block 7]
D3 --> O[Output]
end
%% Skip Connections
C1 -.-> D3
C2 -.-> D2
C3 -.-> D1
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
style B fill:#ff9,stroke:#333
Loading

The U-Net architecture features a symmetric encoder-decoder structure that's particularly effective for detailed segmentation:

  • Contracting path (encoder) captures context
  • Expanding path (decoder) enables precise localization
  • Skip connections transfer detailed features from encoder to decoder
  • Particularly effective at preserving fine structural details

3. LinkNet

graph TD
subgraph Encoder
I[Input] --> E1[Encoder Block 1]
E1 --> E2[Encoder Block 2]
E2 --> E3[Encoder Block 3]
E3 --> E4[Encoder Block 4]
end
subgraph Decoder
E4 --> D4[Decoder Block 4]
D4 --> D3[Decoder Block 3]
D3 --> D2[Decoder Block 2]
D2 --> D1[Decoder Block 1]
end
%% Skip Connections
E1 -.-> D1
E2 -.-> D2
E3 -.-> D3
E4 -.-> D4
D1 --> F[Final Conv]
F --> O[Output]
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
Loading

LinkNet is designed for efficient semantic segmentation:

  • Memory-efficient architecture with strong performance
  • Direct connections between encoder and decoder blocks
  • Residual connections for better gradient flow
  • Lighter computational footprint compared to U-Net
  • Ideal for real-time applications

4. DeepLabV3+

graph TD
subgraph Encoder
I[Input] --> B[Backbone]
B --> ASPP{ASPP Module}
end
subgraph ASPP_Module
ASPP --> A1[1x1 Conv]
ASPP --> A2[3x3 Rate 6]
ASPP --> A3[3x3 Rate 12]
ASPP --> A4[3x3 Rate 18]
ASPP --> A5[Global Pool]
end
subgraph Decoder
A1 & A2 & A3 & A4 & A5 --> C[Concat]
C --> C1[Conv 1x1]
B --> LF[Low-level Features]
LF --> C2[Conv 1x1]
C1 --> U1[Upsample 4x]
U1 --> M[Merge]
C2 --> M
M --> U2[Upsample 4x]
U2 --> O[Output]
end
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
Loading

DeepLabV3+ represents the state-of-the-art in semantic segmentation:

  • Atrous Spatial Pyramid Pooling (ASPP) for multi-scale processing
  • Multiple dilation rates (6, 12, 18) for broader receptive fields
  • Encoder-decoder structure with ASPP module
  • Fusion of low-level and high-level features
  • Superior performance on boundary regions

Architecture Comparison

ArchitectureStrengthsBest Use CasesMemory UsageInference Speed
FCNSimple, effective baselineGeneral segmentationMediumFast
U-NetFine detail preservationMedical imaging, detailed segmentationHighMedium
LinkNetEfficiency, good performanceReal-time applicationsLowFast
DeepLabV3+State-of-the-art accuracyHigh-accuracy requirementsHighSlow

Results

Model performance comparison on IDD-Lite dataset:

ArchitectureTraining SetTesting SetMean F1 Score
FCN0.90320.90340.687
UNET0.87840.74060.586
LINKNET0.92310.75790.750
DEEPLABV3+0.80400.77120.787

Model Results

Installation

# Clone the repository
git clone https://github.com/your-username/road-scene-segmentation.git
cd road-scene-segmentation
# Install dependencies
pip install -e .

Requirements

  • Python 3.7+
  • PyTorch >= 1.9.0
  • torchvision >= 0.10.0
  • albumentations >= 1.0.3
  • OpenCV
  • NumPy
  • Matplotlib
  • tqdm

Dataset Setup

The project uses IDD-Lite dataset (~50MB). To set up the dataset:

python setup_data.py

This will download and organize the IDD-Lite dataset in the correct directory structure.

Usage

Training

To train a model:

python train.py --config config.yaml

Configure training parameters in config.yaml:

MODEL_TYPE: 'unet'# Options: 'fcn', 'unet', 'linknet', 'deeplabv3'BACKBONE: 'resnet34'NUM_CLASSES: 8BATCH_SIZE: 16EPOCHS: 100LEARNING_RATE: 0.001

Evaluation

To evaluate a trained model:

python evaluate.py --config config.yaml --model-path checkpoints/final_model.pth

Inference

For inference on a single image:

fromsegmentationimportSegmentationConfig, UNet, Visualizerimportcv2# Initialize model and load weightsconfig=SegmentationConfig(MODEL_TYPE='unet')
model=UNet(config)
model.load_checkpoint('checkpoints/final_model.pth')
# Run inferenceimage=cv2.imread('path/to/image.jpg')
prediction=model.predict(image)

Project Structure

├── segmentation/
│ ├── models/
│ │ ├── fcn.py
│ │ ├── unet.py
│ │ ├── linknet.py
│ │ └── deeplabv3.py
│ ├── config.py
│ ├── dataset.py
│ └── utils/
├── train.py
├── evaluate.py
├── setup_data.py
└── config.yaml

About

The project utilizes convolutional-based network architectures for semantic image segmentation. This project utilizes the Indian Driving Dataset (IDD) Lite to classify various elements in Indian road scenes into 8 predefined categories. This implementation utilizes FCN - VGG backbone, U-Net, LINKNet, and DEEPLABV3+.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
GitHub - pratheeshkumar99/SegwayVision: The project utilizes convolutional-based network architectures for semantic image segmentation. This project utilizes the Indian Driving Dataset (IDD) Lite to classify various elements in Indian road scenes into 8 predefined categories. This implementation utilizes FCN - VGG backbone, U-Net, LINKNet, and DEEPLABV3+. · GitHub
Skip to content

Repository files navigation

Road Scene Semantic Segmentation

A PyTorch-based implementation of various deep learning architectures for semantic segmentation of unstructured road scenes using the Indian Driving Dataset (IDD).

Table of Contents

Overview

This project implements and compares five popular deep learning architectures for semantic segmentation:

  • FCN (Fully Convolutional Network)
  • U-Net
  • PSPNet
  • LinkNet
  • DeepLabV3+

Dataset

The models are trained on the IDD-Lite dataset, which contains road scene images from Indian cities, annotated with 8 classes:

  • Drivable area
  • Non-drivable area
  • Living things
  • Vehicles
  • Roadside objects
  • Far objects
  • Sky
  • Miscellaneous

Model Architectures

This project implements five deep learning architectures, each with its unique strengths for semantic segmentation:

1. Fully Convolutional Network (FCN)

graph LR
subgraph VGG16_Backbone
I[Input] --> C1[Conv Block 1]
C1 --> C2[Conv Block 2]
C2 --> C3[Conv Block 3]
C3 --> C4[Conv Block 4]
C4 --> C5[Conv Block 5]
end
subgraph FCN_Head
C5 --> FC6[Conv 7x7]
FC6 --> FC7[Conv 1x1]
FC7 --> S1[Score]
end
subgraph Skip_Connections
C4 --> S2[Score Pool4]
C3 --> S3[Score Pool3]
S1 --> U1[Upsample 2x]
U1 --> F1[Fuse]
S2 --> F1
F1 --> U2[Upsample 2x]
U2 --> F2[Fuse]
S3 --> F2
F2 --> U3[Upsample 8x]
U3 --> O[Output]
end
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
Loading

The FCN architecture transforms traditional classification networks into fully convolutional networks for semantic segmentation. Key features:

  • Based on VGG16 backbone
  • Replaces fully connected layers with 1x1 convolutions
  • Uses skip connections from earlier layers for fine-grained prediction
  • Multi-scale prediction fusion for better segmentation details

2. U-Net Architecture

graph TD
subgraph Encoder
I[Input Image] --> C1[Conv Block 1]
C1 --> P1[MaxPool]
P1 --> C2[Conv Block 2]
C2 --> P2[MaxPool]
P2 --> C3[Conv Block 3]
C3 --> P3[MaxPool]
P3 --> C4[Conv Block 4]
end
subgraph Bottleneck
C4 --> B[Bottleneck]
end
subgraph Decoder
B --> U1[UpConv 1]
U1 --> D1[Conv Block 5]
D1 --> U2[UpConv 2]
U2 --> D2[Conv Block 6]
D2 --> U3[UpConv 3]
U3 --> D3[Conv Block 7]
D3 --> O[Output]
end
%% Skip Connections
C1 -.-> D3
C2 -.-> D2
C3 -.-> D1
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
style B fill:#ff9,stroke:#333
Loading

The U-Net architecture features a symmetric encoder-decoder structure that's particularly effective for detailed segmentation:

  • Contracting path (encoder) captures context
  • Expanding path (decoder) enables precise localization
  • Skip connections transfer detailed features from encoder to decoder
  • Particularly effective at preserving fine structural details

3. LinkNet

graph TD
subgraph Encoder
I[Input] --> E1[Encoder Block 1]
E1 --> E2[Encoder Block 2]
E2 --> E3[Encoder Block 3]
E3 --> E4[Encoder Block 4]
end
subgraph Decoder
E4 --> D4[Decoder Block 4]
D4 --> D3[Decoder Block 3]
D3 --> D2[Decoder Block 2]
D2 --> D1[Decoder Block 1]
end
%% Skip Connections
E1 -.-> D1
E2 -.-> D2
E3 -.-> D3
E4 -.-> D4
D1 --> F[Final Conv]
F --> O[Output]
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
Loading

LinkNet is designed for efficient semantic segmentation:

  • Memory-efficient architecture with strong performance
  • Direct connections between encoder and decoder blocks
  • Residual connections for better gradient flow
  • Lighter computational footprint compared to U-Net
  • Ideal for real-time applications

4. DeepLabV3+

graph TD
subgraph Encoder
I[Input] --> B[Backbone]
B --> ASPP{ASPP Module}
end
subgraph ASPP_Module
ASPP --> A1[1x1 Conv]
ASPP --> A2[3x3 Rate 6]
ASPP --> A3[3x3 Rate 12]
ASPP --> A4[3x3 Rate 18]
ASPP --> A5[Global Pool]
end
subgraph Decoder
A1 & A2 & A3 & A4 & A5 --> C[Concat]
C --> C1[Conv 1x1]
B --> LF[Low-level Features]
LF --> C2[Conv 1x1]
C1 --> U1[Upsample 4x]
U1 --> M[Merge]
C2 --> M
M --> U2[Upsample 4x]
U2 --> O[Output]
end
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
Loading

DeepLabV3+ represents the state-of-the-art in semantic segmentation:

  • Atrous Spatial Pyramid Pooling (ASPP) for multi-scale processing
  • Multiple dilation rates (6, 12, 18) for broader receptive fields
  • Encoder-decoder structure with ASPP module
  • Fusion of low-level and high-level features
  • Superior performance on boundary regions

Architecture Comparison

ArchitectureStrengthsBest Use CasesMemory UsageInference Speed
FCNSimple, effective baselineGeneral segmentationMediumFast
U-NetFine detail preservationMedical imaging, detailed segmentationHighMedium
LinkNetEfficiency, good performanceReal-time applicationsLowFast
DeepLabV3+State-of-the-art accuracyHigh-accuracy requirementsHighSlow

Results

Model performance comparison on IDD-Lite dataset:

ArchitectureTraining SetTesting SetMean F1 Score
FCN0.90320.90340.687
UNET0.87840.74060.586
LINKNET0.92310.75790.750
DEEPLABV3+0.80400.77120.787

Model Results

Installation

# Clone the repository
git clone https://github.com/your-username/road-scene-segmentation.git
cd road-scene-segmentation
# Install dependencies
pip install -e .

Requirements

  • Python 3.7+
  • PyTorch >= 1.9.0
  • torchvision >= 0.10.0
  • albumentations >= 1.0.3
  • OpenCV
  • NumPy
  • Matplotlib
  • tqdm

Dataset Setup

The project uses IDD-Lite dataset (~50MB). To set up the dataset:

python setup_data.py

This will download and organize the IDD-Lite dataset in the correct directory structure.

Usage

Training

To train a model:

python train.py --config config.yaml

Configure training parameters in config.yaml:

MODEL_TYPE: 'unet'# Options: 'fcn', 'unet', 'linknet', 'deeplabv3'BACKBONE: 'resnet34'NUM_CLASSES: 8BATCH_SIZE: 16EPOCHS: 100LEARNING_RATE: 0.001

Evaluation

To evaluate a trained model:

python evaluate.py --config config.yaml --model-path checkpoints/final_model.pth

Inference

For inference on a single image:

fromsegmentationimportSegmentationConfig, UNet, Visualizerimportcv2# Initialize model and load weightsconfig=SegmentationConfig(MODEL_TYPE='unet')
model=UNet(config)
model.load_checkpoint('checkpoints/final_model.pth')
# Run inferenceimage=cv2.imread('path/to/image.jpg')
prediction=model.predict(image)

Project Structure

├── segmentation/
│ ├── models/
│ │ ├── fcn.py
│ │ ├── unet.py
│ │ ├── linknet.py
│ │ └── deeplabv3.py
│ ├── config.py
│ ├── dataset.py
│ └── utils/
├── train.py
├── evaluate.py
├── setup_data.py
└── config.yaml

About

The project utilizes convolutional-based network architectures for semantic image segmentation. This project utilizes the Indian Driving Dataset (IDD) Lite to classify various elements in Indian road scenes into 8 predefined categories. This implementation utilizes FCN - VGG backbone, U-Net, LINKNet, and DEEPLABV3+.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - pratheeshkumar99/SegwayVision: The project utilizes convolutional-based network architectures for semantic image segmentation. This project utilizes the Indian Driving Dataset (IDD) Lite to classify various elements in Indian road scenes into 8 predefined categories. This implementation utilizes FCN - VGG backbone, U-Net, LINKNet, and DEEPLABV3+. · GitHub
Skip to content

Repository files navigation

Road Scene Semantic Segmentation

A PyTorch-based implementation of various deep learning architectures for semantic segmentation of unstructured road scenes using the Indian Driving Dataset (IDD).

Table of Contents

Overview

This project implements and compares five popular deep learning architectures for semantic segmentation:

  • FCN (Fully Convolutional Network)
  • U-Net
  • PSPNet
  • LinkNet
  • DeepLabV3+

Dataset

The models are trained on the IDD-Lite dataset, which contains road scene images from Indian cities, annotated with 8 classes:

  • Drivable area
  • Non-drivable area
  • Living things
  • Vehicles
  • Roadside objects
  • Far objects
  • Sky
  • Miscellaneous

Model Architectures

This project implements five deep learning architectures, each with its unique strengths for semantic segmentation:

1. Fully Convolutional Network (FCN)

graph LR
subgraph VGG16_Backbone
I[Input] --> C1[Conv Block 1]
C1 --> C2[Conv Block 2]
C2 --> C3[Conv Block 3]
C3 --> C4[Conv Block 4]
C4 --> C5[Conv Block 5]
end
subgraph FCN_Head
C5 --> FC6[Conv 7x7]
FC6 --> FC7[Conv 1x1]
FC7 --> S1[Score]
end
subgraph Skip_Connections
C4 --> S2[Score Pool4]
C3 --> S3[Score Pool3]
S1 --> U1[Upsample 2x]
U1 --> F1[Fuse]
S2 --> F1
F1 --> U2[Upsample 2x]
U2 --> F2[Fuse]
S3 --> F2
F2 --> U3[Upsample 8x]
U3 --> O[Output]
end
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
Loading

The FCN architecture transforms traditional classification networks into fully convolutional networks for semantic segmentation. Key features:

  • Based on VGG16 backbone
  • Replaces fully connected layers with 1x1 convolutions
  • Uses skip connections from earlier layers for fine-grained prediction
  • Multi-scale prediction fusion for better segmentation details

2. U-Net Architecture

graph TD
subgraph Encoder
I[Input Image] --> C1[Conv Block 1]
C1 --> P1[MaxPool]
P1 --> C2[Conv Block 2]
C2 --> P2[MaxPool]
P2 --> C3[Conv Block 3]
C3 --> P3[MaxPool]
P3 --> C4[Conv Block 4]
end
subgraph Bottleneck
C4 --> B[Bottleneck]
end
subgraph Decoder
B --> U1[UpConv 1]
U1 --> D1[Conv Block 5]
D1 --> U2[UpConv 2]
U2 --> D2[Conv Block 6]
D2 --> U3[UpConv 3]
U3 --> D3[Conv Block 7]
D3 --> O[Output]
end
%% Skip Connections
C1 -.-> D3
C2 -.-> D2
C3 -.-> D1
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
style B fill:#ff9,stroke:#333
Loading

The U-Net architecture features a symmetric encoder-decoder structure that's particularly effective for detailed segmentation:

  • Contracting path (encoder) captures context
  • Expanding path (decoder) enables precise localization
  • Skip connections transfer detailed features from encoder to decoder
  • Particularly effective at preserving fine structural details

3. LinkNet

graph TD
subgraph Encoder
I[Input] --> E1[Encoder Block 1]
E1 --> E2[Encoder Block 2]
E2 --> E3[Encoder Block 3]
E3 --> E4[Encoder Block 4]
end
subgraph Decoder
E4 --> D4[Decoder Block 4]
D4 --> D3[Decoder Block 3]
D3 --> D2[Decoder Block 2]
D2 --> D1[Decoder Block 1]
end
%% Skip Connections
E1 -.-> D1
E2 -.-> D2
E3 -.-> D3
E4 -.-> D4
D1 --> F[Final Conv]
F --> O[Output]
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
Loading

LinkNet is designed for efficient semantic segmentation:

  • Memory-efficient architecture with strong performance
  • Direct connections between encoder and decoder blocks
  • Residual connections for better gradient flow
  • Lighter computational footprint compared to U-Net
  • Ideal for real-time applications

4. DeepLabV3+

graph TD
subgraph Encoder
I[Input] --> B[Backbone]
B --> ASPP{ASPP Module}
end
subgraph ASPP_Module
ASPP --> A1[1x1 Conv]
ASPP --> A2[3x3 Rate 6]
ASPP --> A3[3x3 Rate 12]
ASPP --> A4[3x3 Rate 18]
ASPP --> A5[Global Pool]
end
subgraph Decoder
A1 & A2 & A3 & A4 & A5 --> C[Concat]
C --> C1[Conv 1x1]
B --> LF[Low-level Features]
LF --> C2[Conv 1x1]
C1 --> U1[Upsample 4x]
U1 --> M[Merge]
C2 --> M
M --> U2[Upsample 4x]
U2 --> O[Output]
end
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
Loading

DeepLabV3+ represents the state-of-the-art in semantic segmentation:

  • Atrous Spatial Pyramid Pooling (ASPP) for multi-scale processing
  • Multiple dilation rates (6, 12, 18) for broader receptive fields
  • Encoder-decoder structure with ASPP module
  • Fusion of low-level and high-level features
  • Superior performance on boundary regions

Architecture Comparison

ArchitectureStrengthsBest Use CasesMemory UsageInference Speed
FCNSimple, effective baselineGeneral segmentationMediumFast
U-NetFine detail preservationMedical imaging, detailed segmentationHighMedium
LinkNetEfficiency, good performanceReal-time applicationsLowFast
DeepLabV3+State-of-the-art accuracyHigh-accuracy requirementsHighSlow

Results

Model performance comparison on IDD-Lite dataset:

ArchitectureTraining SetTesting SetMean F1 Score
FCN0.90320.90340.687
UNET0.87840.74060.586
LINKNET0.92310.75790.750
DEEPLABV3+0.80400.77120.787

Model Results

Installation

# Clone the repository
git clone https://github.com/your-username/road-scene-segmentation.git
cd road-scene-segmentation
# Install dependencies
pip install -e .

Requirements

  • Python 3.7+
  • PyTorch >= 1.9.0
  • torchvision >= 0.10.0
  • albumentations >= 1.0.3
  • OpenCV
  • NumPy
  • Matplotlib
  • tqdm

Dataset Setup

The project uses IDD-Lite dataset (~50MB). To set up the dataset:

python setup_data.py

This will download and organize the IDD-Lite dataset in the correct directory structure.

Usage

Training

To train a model:

python train.py --config config.yaml

Configure training parameters in config.yaml:

MODEL_TYPE: 'unet'# Options: 'fcn', 'unet', 'linknet', 'deeplabv3'BACKBONE: 'resnet34'NUM_CLASSES: 8BATCH_SIZE: 16EPOCHS: 100LEARNING_RATE: 0.001

Evaluation

To evaluate a trained model:

python evaluate.py --config config.yaml --model-path checkpoints/final_model.pth

Inference

For inference on a single image:

fromsegmentationimportSegmentationConfig, UNet, Visualizerimportcv2# Initialize model and load weightsconfig=SegmentationConfig(MODEL_TYPE='unet')
model=UNet(config)
model.load_checkpoint('checkpoints/final_model.pth')
# Run inferenceimage=cv2.imread('path/to/image.jpg')
prediction=model.predict(image)

Project Structure

├── segmentation/
│ ├── models/
│ │ ├── fcn.py
│ │ ├── unet.py
│ │ ├── linknet.py
│ │ └── deeplabv3.py
│ ├── config.py
│ ├── dataset.py
│ └── utils/
├── train.py
├── evaluate.py
├── setup_data.py
└── config.yaml

About

The project utilizes convolutional-based network architectures for semantic image segmentation. This project utilizes the Indian Driving Dataset (IDD) Lite to classify various elements in Indian road scenes into 8 predefined categories. This implementation utilizes FCN - VGG backbone, U-Net, LINKNet, and DEEPLABV3+.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - pratheeshkumar99/SegwayVision: The project utilizes convolutional-based network architectures for semantic image segmentation. This project utilizes the Indian Driving Dataset (IDD) Lite to classify various elements in Indian road scenes into 8 predefined categories. This implementation utilizes FCN - VGG backbone, U-Net, LINKNet, and DEEPLABV3+. · GitHub
Skip to content

Repository files navigation

Road Scene Semantic Segmentation

A PyTorch-based implementation of various deep learning architectures for semantic segmentation of unstructured road scenes using the Indian Driving Dataset (IDD).

Table of Contents

Overview

This project implements and compares five popular deep learning architectures for semantic segmentation:

  • FCN (Fully Convolutional Network)
  • U-Net
  • PSPNet
  • LinkNet
  • DeepLabV3+

Dataset

The models are trained on the IDD-Lite dataset, which contains road scene images from Indian cities, annotated with 8 classes:

  • Drivable area
  • Non-drivable area
  • Living things
  • Vehicles
  • Roadside objects
  • Far objects
  • Sky
  • Miscellaneous

Model Architectures

This project implements five deep learning architectures, each with its unique strengths for semantic segmentation:

1. Fully Convolutional Network (FCN)

graph LR
subgraph VGG16_Backbone
I[Input] --> C1[Conv Block 1]
C1 --> C2[Conv Block 2]
C2 --> C3[Conv Block 3]
C3 --> C4[Conv Block 4]
C4 --> C5[Conv Block 5]
end
subgraph FCN_Head
C5 --> FC6[Conv 7x7]
FC6 --> FC7[Conv 1x1]
FC7 --> S1[Score]
end
subgraph Skip_Connections
C4 --> S2[Score Pool4]
C3 --> S3[Score Pool3]
S1 --> U1[Upsample 2x]
U1 --> F1[Fuse]
S2 --> F1
F1 --> U2[Upsample 2x]
U2 --> F2[Fuse]
S3 --> F2
F2 --> U3[Upsample 8x]
U3 --> O[Output]
end
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
Loading

The FCN architecture transforms traditional classification networks into fully convolutional networks for semantic segmentation. Key features:

  • Based on VGG16 backbone
  • Replaces fully connected layers with 1x1 convolutions
  • Uses skip connections from earlier layers for fine-grained prediction
  • Multi-scale prediction fusion for better segmentation details

2. U-Net Architecture

graph TD
subgraph Encoder
I[Input Image] --> C1[Conv Block 1]
C1 --> P1[MaxPool]
P1 --> C2[Conv Block 2]
C2 --> P2[MaxPool]
P2 --> C3[Conv Block 3]
C3 --> P3[MaxPool]
P3 --> C4[Conv Block 4]
end
subgraph Bottleneck
C4 --> B[Bottleneck]
end
subgraph Decoder
B --> U1[UpConv 1]
U1 --> D1[Conv Block 5]
D1 --> U2[UpConv 2]
U2 --> D2[Conv Block 6]
D2 --> U3[UpConv 3]
U3 --> D3[Conv Block 7]
D3 --> O[Output]
end
%% Skip Connections
C1 -.-> D3
C2 -.-> D2
C3 -.-> D1
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
style B fill:#ff9,stroke:#333
Loading

The U-Net architecture features a symmetric encoder-decoder structure that's particularly effective for detailed segmentation:

  • Contracting path (encoder) captures context
  • Expanding path (decoder) enables precise localization
  • Skip connections transfer detailed features from encoder to decoder
  • Particularly effective at preserving fine structural details

3. LinkNet

graph TD
subgraph Encoder
I[Input] --> E1[Encoder Block 1]
E1 --> E2[Encoder Block 2]
E2 --> E3[Encoder Block 3]
E3 --> E4[Encoder Block 4]
end
subgraph Decoder
E4 --> D4[Decoder Block 4]
D4 --> D3[Decoder Block 3]
D3 --> D2[Decoder Block 2]
D2 --> D1[Decoder Block 1]
end
%% Skip Connections
E1 -.-> D1
E2 -.-> D2
E3 -.-> D3
E4 -.-> D4
D1 --> F[Final Conv]
F --> O[Output]
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
Loading

LinkNet is designed for efficient semantic segmentation:

  • Memory-efficient architecture with strong performance
  • Direct connections between encoder and decoder blocks
  • Residual connections for better gradient flow
  • Lighter computational footprint compared to U-Net
  • Ideal for real-time applications

4. DeepLabV3+

graph TD
subgraph Encoder
I[Input] --> B[Backbone]
B --> ASPP{ASPP Module}
end
subgraph ASPP_Module
ASPP --> A1[1x1 Conv]
ASPP --> A2[3x3 Rate 6]
ASPP --> A3[3x3 Rate 12]
ASPP --> A4[3x3 Rate 18]
ASPP --> A5[Global Pool]
end
subgraph Decoder
A1 & A2 & A3 & A4 & A5 --> C[Concat]
C --> C1[Conv 1x1]
B --> LF[Low-level Features]
LF --> C2[Conv 1x1]
C1 --> U1[Upsample 4x]
U1 --> M[Merge]
C2 --> M
M --> U2[Upsample 4x]
U2 --> O[Output]
end
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
Loading

DeepLabV3+ represents the state-of-the-art in semantic segmentation:

  • Atrous Spatial Pyramid Pooling (ASPP) for multi-scale processing
  • Multiple dilation rates (6, 12, 18) for broader receptive fields
  • Encoder-decoder structure with ASPP module
  • Fusion of low-level and high-level features
  • Superior performance on boundary regions

Architecture Comparison

ArchitectureStrengthsBest Use CasesMemory UsageInference Speed
FCNSimple, effective baselineGeneral segmentationMediumFast
U-NetFine detail preservationMedical imaging, detailed segmentationHighMedium
LinkNetEfficiency, good performanceReal-time applicationsLowFast
DeepLabV3+State-of-the-art accuracyHigh-accuracy requirementsHighSlow

Results

Model performance comparison on IDD-Lite dataset:

ArchitectureTraining SetTesting SetMean F1 Score
FCN0.90320.90340.687
UNET0.87840.74060.586
LINKNET0.92310.75790.750
DEEPLABV3+0.80400.77120.787

Model Results

Installation

# Clone the repository
git clone https://github.com/your-username/road-scene-segmentation.git
cd road-scene-segmentation
# Install dependencies
pip install -e .

Requirements

  • Python 3.7+
  • PyTorch >= 1.9.0
  • torchvision >= 0.10.0
  • albumentations >= 1.0.3
  • OpenCV
  • NumPy
  • Matplotlib
  • tqdm

Dataset Setup

The project uses IDD-Lite dataset (~50MB). To set up the dataset:

python setup_data.py

This will download and organize the IDD-Lite dataset in the correct directory structure.

Usage

Training

To train a model:

python train.py --config config.yaml

Configure training parameters in config.yaml:

MODEL_TYPE: 'unet'# Options: 'fcn', 'unet', 'linknet', 'deeplabv3'BACKBONE: 'resnet34'NUM_CLASSES: 8BATCH_SIZE: 16EPOCHS: 100LEARNING_RATE: 0.001

Evaluation

To evaluate a trained model:

python evaluate.py --config config.yaml --model-path checkpoints/final_model.pth

Inference

For inference on a single image:

fromsegmentationimportSegmentationConfig, UNet, Visualizerimportcv2# Initialize model and load weightsconfig=SegmentationConfig(MODEL_TYPE='unet')
model=UNet(config)
model.load_checkpoint('checkpoints/final_model.pth')
# Run inferenceimage=cv2.imread('path/to/image.jpg')
prediction=model.predict(image)

Project Structure

├── segmentation/
│ ├── models/
│ │ ├── fcn.py
│ │ ├── unet.py
│ │ ├── linknet.py
│ │ └── deeplabv3.py
│ ├── config.py
│ ├── dataset.py
│ └── utils/
├── train.py
├── evaluate.py
├── setup_data.py
└── config.yaml

About

The project utilizes convolutional-based network architectures for semantic image segmentation. This project utilizes the Indian Driving Dataset (IDD) Lite to classify various elements in Indian road scenes into 8 predefined categories. This implementation utilizes FCN - VGG backbone, U-Net, LINKNet, and DEEPLABV3+.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' GitHub - pratheeshkumar99/SegwayVision: The project utilizes convolutional-based network architectures for semantic image segmentation. This project utilizes the Indian Driving Dataset (IDD) Lite to classify various elements in Indian road scenes into 8 predefined categories. This implementation utilizes FCN - VGG backbone, U-Net, LINKNet, and DEEPLABV3+. · GitHub
Skip to content

Repository files navigation

Road Scene Semantic Segmentation

A PyTorch-based implementation of various deep learning architectures for semantic segmentation of unstructured road scenes using the Indian Driving Dataset (IDD).

Table of Contents

Overview

This project implements and compares five popular deep learning architectures for semantic segmentation:

  • FCN (Fully Convolutional Network)
  • U-Net
  • PSPNet
  • LinkNet
  • DeepLabV3+

Dataset

The models are trained on the IDD-Lite dataset, which contains road scene images from Indian cities, annotated with 8 classes:

  • Drivable area
  • Non-drivable area
  • Living things
  • Vehicles
  • Roadside objects
  • Far objects
  • Sky
  • Miscellaneous

Model Architectures

This project implements five deep learning architectures, each with its unique strengths for semantic segmentation:

1. Fully Convolutional Network (FCN)

graph LR
subgraph VGG16_Backbone
I[Input] --> C1[Conv Block 1]
C1 --> C2[Conv Block 2]
C2 --> C3[Conv Block 3]
C3 --> C4[Conv Block 4]
C4 --> C5[Conv Block 5]
end
subgraph FCN_Head
C5 --> FC6[Conv 7x7]
FC6 --> FC7[Conv 1x1]
FC7 --> S1[Score]
end
subgraph Skip_Connections
C4 --> S2[Score Pool4]
C3 --> S3[Score Pool3]
S1 --> U1[Upsample 2x]
U1 --> F1[Fuse]
S2 --> F1
F1 --> U2[Upsample 2x]
U2 --> F2[Fuse]
S3 --> F2
F2 --> U3[Upsample 8x]
U3 --> O[Output]
end
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
Loading

The FCN architecture transforms traditional classification networks into fully convolutional networks for semantic segmentation. Key features:

  • Based on VGG16 backbone
  • Replaces fully connected layers with 1x1 convolutions
  • Uses skip connections from earlier layers for fine-grained prediction
  • Multi-scale prediction fusion for better segmentation details

2. U-Net Architecture

graph TD
subgraph Encoder
I[Input Image] --> C1[Conv Block 1]
C1 --> P1[MaxPool]
P1 --> C2[Conv Block 2]
C2 --> P2[MaxPool]
P2 --> C3[Conv Block 3]
C3 --> P3[MaxPool]
P3 --> C4[Conv Block 4]
end
subgraph Bottleneck
C4 --> B[Bottleneck]
end
subgraph Decoder
B --> U1[UpConv 1]
U1 --> D1[Conv Block 5]
D1 --> U2[UpConv 2]
U2 --> D2[Conv Block 6]
D2 --> U3[UpConv 3]
U3 --> D3[Conv Block 7]
D3 --> O[Output]
end
%% Skip Connections
C1 -.-> D3
C2 -.-> D2
C3 -.-> D1
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
style B fill:#ff9,stroke:#333
Loading

The U-Net architecture features a symmetric encoder-decoder structure that's particularly effective for detailed segmentation:

  • Contracting path (encoder) captures context
  • Expanding path (decoder) enables precise localization
  • Skip connections transfer detailed features from encoder to decoder
  • Particularly effective at preserving fine structural details

3. LinkNet

graph TD
subgraph Encoder
I[Input] --> E1[Encoder Block 1]
E1 --> E2[Encoder Block 2]
E2 --> E3[Encoder Block 3]
E3 --> E4[Encoder Block 4]
end
subgraph Decoder
E4 --> D4[Decoder Block 4]
D4 --> D3[Decoder Block 3]
D3 --> D2[Decoder Block 2]
D2 --> D1[Decoder Block 1]
end
%% Skip Connections
E1 -.-> D1
E2 -.-> D2
E3 -.-> D3
E4 -.-> D4
D1 --> F[Final Conv]
F --> O[Output]
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
Loading

LinkNet is designed for efficient semantic segmentation:

  • Memory-efficient architecture with strong performance
  • Direct connections between encoder and decoder blocks
  • Residual connections for better gradient flow
  • Lighter computational footprint compared to U-Net
  • Ideal for real-time applications

4. DeepLabV3+

graph TD
subgraph Encoder
I[Input] --> B[Backbone]
B --> ASPP{ASPP Module}
end
subgraph ASPP_Module
ASPP --> A1[1x1 Conv]
ASPP --> A2[3x3 Rate 6]
ASPP --> A3[3x3 Rate 12]
ASPP --> A4[3x3 Rate 18]
ASPP --> A5[Global Pool]
end
subgraph Decoder
A1 & A2 & A3 & A4 & A5 --> C[Concat]
C --> C1[Conv 1x1]
B --> LF[Low-level Features]
LF --> C2[Conv 1x1]
C1 --> U1[Upsample 4x]
U1 --> M[Merge]
C2 --> M
M --> U2[Upsample 4x]
U2 --> O[Output]
end
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
Loading

DeepLabV3+ represents the state-of-the-art in semantic segmentation:

  • Atrous Spatial Pyramid Pooling (ASPP) for multi-scale processing
  • Multiple dilation rates (6, 12, 18) for broader receptive fields
  • Encoder-decoder structure with ASPP module
  • Fusion of low-level and high-level features
  • Superior performance on boundary regions

Architecture Comparison

ArchitectureStrengthsBest Use CasesMemory UsageInference Speed
FCNSimple, effective baselineGeneral segmentationMediumFast
U-NetFine detail preservationMedical imaging, detailed segmentationHighMedium
LinkNetEfficiency, good performanceReal-time applicationsLowFast
DeepLabV3+State-of-the-art accuracyHigh-accuracy requirementsHighSlow

Results

Model performance comparison on IDD-Lite dataset:

ArchitectureTraining SetTesting SetMean F1 Score
FCN0.90320.90340.687
UNET0.87840.74060.586
LINKNET0.92310.75790.750
DEEPLABV3+0.80400.77120.787

Model Results

Installation

# Clone the repository
git clone https://github.com/your-username/road-scene-segmentation.git
cd road-scene-segmentation
# Install dependencies
pip install -e .

Requirements

  • Python 3.7+
  • PyTorch >= 1.9.0
  • torchvision >= 0.10.0
  • albumentations >= 1.0.3
  • OpenCV
  • NumPy
  • Matplotlib
  • tqdm

Dataset Setup

The project uses IDD-Lite dataset (~50MB). To set up the dataset:

python setup_data.py

This will download and organize the IDD-Lite dataset in the correct directory structure.

Usage

Training

To train a model:

python train.py --config config.yaml

Configure training parameters in config.yaml:

MODEL_TYPE: 'unet'# Options: 'fcn', 'unet', 'linknet', 'deeplabv3'BACKBONE: 'resnet34'NUM_CLASSES: 8BATCH_SIZE: 16EPOCHS: 100LEARNING_RATE: 0.001

Evaluation

To evaluate a trained model:

python evaluate.py --config config.yaml --model-path checkpoints/final_model.pth

Inference

For inference on a single image:

fromsegmentationimportSegmentationConfig, UNet, Visualizerimportcv2# Initialize model and load weightsconfig=SegmentationConfig(MODEL_TYPE='unet')
model=UNet(config)
model.load_checkpoint('checkpoints/final_model.pth')
# Run inferenceimage=cv2.imread('path/to/image.jpg')
prediction=model.predict(image)

Project Structure

├── segmentation/
│ ├── models/
│ │ ├── fcn.py
│ │ ├── unet.py
│ │ ├── linknet.py
│ │ └── deeplabv3.py
│ ├── config.py
│ ├── dataset.py
│ └── utils/
├── train.py
├── evaluate.py
├── setup_data.py
└── config.yaml

About

The project utilizes convolutional-based network architectures for semantic image segmentation. This project utilizes the Indian Driving Dataset (IDD) Lite to classify various elements in Indian road scenes into 8 predefined categories. This implementation utilizes FCN - VGG backbone, U-Net, LINKNet, and DEEPLABV3+.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - pratheeshkumar99/SegwayVision: The project utilizes convolutional-based network architectures for semantic image segmentation. This project utilizes the Indian Driving Dataset (IDD) Lite to classify various elements in Indian road scenes into 8 predefined categories. This implementation utilizes FCN - VGG backbone, U-Net, LINKNet, and DEEPLABV3+. · GitHub
Skip to content

Repository files navigation

Road Scene Semantic Segmentation

A PyTorch-based implementation of various deep learning architectures for semantic segmentation of unstructured road scenes using the Indian Driving Dataset (IDD).

Table of Contents

Overview

This project implements and compares five popular deep learning architectures for semantic segmentation:

  • FCN (Fully Convolutional Network)
  • U-Net
  • PSPNet
  • LinkNet
  • DeepLabV3+

Dataset

The models are trained on the IDD-Lite dataset, which contains road scene images from Indian cities, annotated with 8 classes:

  • Drivable area
  • Non-drivable area
  • Living things
  • Vehicles
  • Roadside objects
  • Far objects
  • Sky
  • Miscellaneous

Model Architectures

This project implements five deep learning architectures, each with its unique strengths for semantic segmentation:

1. Fully Convolutional Network (FCN)

graph LR
subgraph VGG16_Backbone
I[Input] --> C1[Conv Block 1]
C1 --> C2[Conv Block 2]
C2 --> C3[Conv Block 3]
C3 --> C4[Conv Block 4]
C4 --> C5[Conv Block 5]
end
subgraph FCN_Head
C5 --> FC6[Conv 7x7]
FC6 --> FC7[Conv 1x1]
FC7 --> S1[Score]
end
subgraph Skip_Connections
C4 --> S2[Score Pool4]
C3 --> S3[Score Pool3]
S1 --> U1[Upsample 2x]
U1 --> F1[Fuse]
S2 --> F1
F1 --> U2[Upsample 2x]
U2 --> F2[Fuse]
S3 --> F2
F2 --> U3[Upsample 8x]
U3 --> O[Output]
end
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
Loading

The FCN architecture transforms traditional classification networks into fully convolutional networks for semantic segmentation. Key features:

  • Based on VGG16 backbone
  • Replaces fully connected layers with 1x1 convolutions
  • Uses skip connections from earlier layers for fine-grained prediction
  • Multi-scale prediction fusion for better segmentation details

2. U-Net Architecture

graph TD
subgraph Encoder
I[Input Image] --> C1[Conv Block 1]
C1 --> P1[MaxPool]
P1 --> C2[Conv Block 2]
C2 --> P2[MaxPool]
P2 --> C3[Conv Block 3]
C3 --> P3[MaxPool]
P3 --> C4[Conv Block 4]
end
subgraph Bottleneck
C4 --> B[Bottleneck]
end
subgraph Decoder
B --> U1[UpConv 1]
U1 --> D1[Conv Block 5]
D1 --> U2[UpConv 2]
U2 --> D2[Conv Block 6]
D2 --> U3[UpConv 3]
U3 --> D3[Conv Block 7]
D3 --> O[Output]
end
%% Skip Connections
C1 -.-> D3
C2 -.-> D2
C3 -.-> D1
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
style B fill:#ff9,stroke:#333
Loading

The U-Net architecture features a symmetric encoder-decoder structure that's particularly effective for detailed segmentation:

  • Contracting path (encoder) captures context
  • Expanding path (decoder) enables precise localization
  • Skip connections transfer detailed features from encoder to decoder
  • Particularly effective at preserving fine structural details

3. LinkNet

graph TD
subgraph Encoder
I[Input] --> E1[Encoder Block 1]
E1 --> E2[Encoder Block 2]
E2 --> E3[Encoder Block 3]
E3 --> E4[Encoder Block 4]
end
subgraph Decoder
E4 --> D4[Decoder Block 4]
D4 --> D3[Decoder Block 3]
D3 --> D2[Decoder Block 2]
D2 --> D1[Decoder Block 1]
end
%% Skip Connections
E1 -.-> D1
E2 -.-> D2
E3 -.-> D3
E4 -.-> D4
D1 --> F[Final Conv]
F --> O[Output]
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
Loading

LinkNet is designed for efficient semantic segmentation:

  • Memory-efficient architecture with strong performance
  • Direct connections between encoder and decoder blocks
  • Residual connections for better gradient flow
  • Lighter computational footprint compared to U-Net
  • Ideal for real-time applications

4. DeepLabV3+

graph TD
subgraph Encoder
I[Input] --> B[Backbone]
B --> ASPP{ASPP Module}
end
subgraph ASPP_Module
ASPP --> A1[1x1 Conv]
ASPP --> A2[3x3 Rate 6]
ASPP --> A3[3x3 Rate 12]
ASPP --> A4[3x3 Rate 18]
ASPP --> A5[Global Pool]
end
subgraph Decoder
A1 & A2 & A3 & A4 & A5 --> C[Concat]
C --> C1[Conv 1x1]
B --> LF[Low-level Features]
LF --> C2[Conv 1x1]
C1 --> U1[Upsample 4x]
U1 --> M[Merge]
C2 --> M
M --> U2[Upsample 4x]
U2 --> O[Output]
end
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
Loading

DeepLabV3+ represents the state-of-the-art in semantic segmentation:

  • Atrous Spatial Pyramid Pooling (ASPP) for multi-scale processing
  • Multiple dilation rates (6, 12, 18) for broader receptive fields
  • Encoder-decoder structure with ASPP module
  • Fusion of low-level and high-level features
  • Superior performance on boundary regions

Architecture Comparison

ArchitectureStrengthsBest Use CasesMemory UsageInference Speed
FCNSimple, effective baselineGeneral segmentationMediumFast
U-NetFine detail preservationMedical imaging, detailed segmentationHighMedium
LinkNetEfficiency, good performanceReal-time applicationsLowFast
DeepLabV3+State-of-the-art accuracyHigh-accuracy requirementsHighSlow

Results

Model performance comparison on IDD-Lite dataset:

ArchitectureTraining SetTesting SetMean F1 Score
FCN0.90320.90340.687
UNET0.87840.74060.586
LINKNET0.92310.75790.750
DEEPLABV3+0.80400.77120.787

Model Results

Installation

# Clone the repository
git clone https://github.com/your-username/road-scene-segmentation.git
cd road-scene-segmentation
# Install dependencies
pip install -e .

Requirements

  • Python 3.7+
  • PyTorch >= 1.9.0
  • torchvision >= 0.10.0
  • albumentations >= 1.0.3
  • OpenCV
  • NumPy
  • Matplotlib
  • tqdm

Dataset Setup

The project uses IDD-Lite dataset (~50MB). To set up the dataset:

python setup_data.py

This will download and organize the IDD-Lite dataset in the correct directory structure.

Usage

Training

To train a model:

python train.py --config config.yaml

Configure training parameters in config.yaml:

MODEL_TYPE: 'unet'# Options: 'fcn', 'unet', 'linknet', 'deeplabv3'BACKBONE: 'resnet34'NUM_CLASSES: 8BATCH_SIZE: 16EPOCHS: 100LEARNING_RATE: 0.001

Evaluation

To evaluate a trained model:

python evaluate.py --config config.yaml --model-path checkpoints/final_model.pth

Inference

For inference on a single image:

fromsegmentationimportSegmentationConfig, UNet, Visualizerimportcv2# Initialize model and load weightsconfig=SegmentationConfig(MODEL_TYPE='unet')
model=UNet(config)
model.load_checkpoint('checkpoints/final_model.pth')
# Run inferenceimage=cv2.imread('path/to/image.jpg')
prediction=model.predict(image)

Project Structure

├── segmentation/
│ ├── models/
│ │ ├── fcn.py
│ │ ├── unet.py
│ │ ├── linknet.py
│ │ └── deeplabv3.py
│ ├── config.py
│ ├── dataset.py
│ └── utils/
├── train.py
├── evaluate.py
├── setup_data.py
└── config.yaml

About

The project utilizes convolutional-based network architectures for semantic image segmentation. This project utilizes the Indian Driving Dataset (IDD) Lite to classify various elements in Indian road scenes into 8 predefined categories. This implementation utilizes FCN - VGG backbone, U-Net, LINKNet, and DEEPLABV3+.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); GitHub - pratheeshkumar99/SegwayVision: The project utilizes convolutional-based network architectures for semantic image segmentation. This project utilizes the Indian Driving Dataset (IDD) Lite to classify various elements in Indian road scenes into 8 predefined categories. This implementation utilizes FCN - VGG backbone, U-Net, LINKNet, and DEEPLABV3+. · GitHub
Skip to content

Repository files navigation

Road Scene Semantic Segmentation

A PyTorch-based implementation of various deep learning architectures for semantic segmentation of unstructured road scenes using the Indian Driving Dataset (IDD).

Table of Contents

Overview

This project implements and compares five popular deep learning architectures for semantic segmentation:

  • FCN (Fully Convolutional Network)
  • U-Net
  • PSPNet
  • LinkNet
  • DeepLabV3+

Dataset

The models are trained on the IDD-Lite dataset, which contains road scene images from Indian cities, annotated with 8 classes:

  • Drivable area
  • Non-drivable area
  • Living things
  • Vehicles
  • Roadside objects
  • Far objects
  • Sky
  • Miscellaneous

Model Architectures

This project implements five deep learning architectures, each with its unique strengths for semantic segmentation:

1. Fully Convolutional Network (FCN)

graph LR
subgraph VGG16_Backbone
I[Input] --> C1[Conv Block 1]
C1 --> C2[Conv Block 2]
C2 --> C3[Conv Block 3]
C3 --> C4[Conv Block 4]
C4 --> C5[Conv Block 5]
end
subgraph FCN_Head
C5 --> FC6[Conv 7x7]
FC6 --> FC7[Conv 1x1]
FC7 --> S1[Score]
end
subgraph Skip_Connections
C4 --> S2[Score Pool4]
C3 --> S3[Score Pool3]
S1 --> U1[Upsample 2x]
U1 --> F1[Fuse]
S2 --> F1
F1 --> U2[Upsample 2x]
U2 --> F2[Fuse]
S3 --> F2
F2 --> U3[Upsample 8x]
U3 --> O[Output]
end
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
Loading

The FCN architecture transforms traditional classification networks into fully convolutional networks for semantic segmentation. Key features:

  • Based on VGG16 backbone
  • Replaces fully connected layers with 1x1 convolutions
  • Uses skip connections from earlier layers for fine-grained prediction
  • Multi-scale prediction fusion for better segmentation details

2. U-Net Architecture

graph TD
subgraph Encoder
I[Input Image] --> C1[Conv Block 1]
C1 --> P1[MaxPool]
P1 --> C2[Conv Block 2]
C2 --> P2[MaxPool]
P2 --> C3[Conv Block 3]
C3 --> P3[MaxPool]
P3 --> C4[Conv Block 4]
end
subgraph Bottleneck
C4 --> B[Bottleneck]
end
subgraph Decoder
B --> U1[UpConv 1]
U1 --> D1[Conv Block 5]
D1 --> U2[UpConv 2]
U2 --> D2[Conv Block 6]
D2 --> U3[UpConv 3]
U3 --> D3[Conv Block 7]
D3 --> O[Output]
end
%% Skip Connections
C1 -.-> D3
C2 -.-> D2
C3 -.-> D1
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
style B fill:#ff9,stroke:#333
Loading

The U-Net architecture features a symmetric encoder-decoder structure that's particularly effective for detailed segmentation:

  • Contracting path (encoder) captures context
  • Expanding path (decoder) enables precise localization
  • Skip connections transfer detailed features from encoder to decoder
  • Particularly effective at preserving fine structural details

3. LinkNet

graph TD
subgraph Encoder
I[Input] --> E1[Encoder Block 1]
E1 --> E2[Encoder Block 2]
E2 --> E3[Encoder Block 3]
E3 --> E4[Encoder Block 4]
end
subgraph Decoder
E4 --> D4[Decoder Block 4]
D4 --> D3[Decoder Block 3]
D3 --> D2[Decoder Block 2]
D2 --> D1[Decoder Block 1]
end
%% Skip Connections
E1 -.-> D1
E2 -.-> D2
E3 -.-> D3
E4 -.-> D4
D1 --> F[Final Conv]
F --> O[Output]
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
Loading

LinkNet is designed for efficient semantic segmentation:

  • Memory-efficient architecture with strong performance
  • Direct connections between encoder and decoder blocks
  • Residual connections for better gradient flow
  • Lighter computational footprint compared to U-Net
  • Ideal for real-time applications

4. DeepLabV3+

graph TD
subgraph Encoder
I[Input] --> B[Backbone]
B --> ASPP{ASPP Module}
end
subgraph ASPP_Module
ASPP --> A1[1x1 Conv]
ASPP --> A2[3x3 Rate 6]
ASPP --> A3[3x3 Rate 12]
ASPP --> A4[3x3 Rate 18]
ASPP --> A5[Global Pool]
end
subgraph Decoder
A1 & A2 & A3 & A4 & A5 --> C[Concat]
C --> C1[Conv 1x1]
B --> LF[Low-level Features]
LF --> C2[Conv 1x1]
C1 --> U1[Upsample 4x]
U1 --> M[Merge]
C2 --> M
M --> U2[Upsample 4x]
U2 --> O[Output]
end
style I fill:#f9f,stroke:#333
style O fill:#9ff,stroke:#333
Loading

DeepLabV3+ represents the state-of-the-art in semantic segmentation:

  • Atrous Spatial Pyramid Pooling (ASPP) for multi-scale processing
  • Multiple dilation rates (6, 12, 18) for broader receptive fields
  • Encoder-decoder structure with ASPP module
  • Fusion of low-level and high-level features
  • Superior performance on boundary regions

Architecture Comparison

ArchitectureStrengthsBest Use CasesMemory UsageInference Speed
FCNSimple, effective baselineGeneral segmentationMediumFast
U-NetFine detail preservationMedical imaging, detailed segmentationHighMedium
LinkNetEfficiency, good performanceReal-time applicationsLowFast
DeepLabV3+State-of-the-art accuracyHigh-accuracy requirementsHighSlow

Results

Model performance comparison on IDD-Lite dataset:

ArchitectureTraining SetTesting SetMean F1 Score
FCN0.90320.90340.687
UNET0.87840.74060.586
LINKNET0.92310.75790.750
DEEPLABV3+0.80400.77120.787

Model Results

Installation

# Clone the repository
git clone https://github.com/your-username/road-scene-segmentation.git
cd road-scene-segmentation
# Install dependencies
pip install -e .

Requirements

  • Python 3.7+
  • PyTorch >= 1.9.0
  • torchvision >= 0.10.0
  • albumentations >= 1.0.3
  • OpenCV
  • NumPy
  • Matplotlib
  • tqdm

Dataset Setup

The project uses IDD-Lite dataset (~50MB). To set up the dataset:

python setup_data.py

This will download and organize the IDD-Lite dataset in the correct directory structure.

Usage

Training

To train a model:

python train.py --config config.yaml

Configure training parameters in config.yaml:

MODEL_TYPE: 'unet'# Options: 'fcn', 'unet', 'linknet', 'deeplabv3'BACKBONE: 'resnet34'NUM_CLASSES: 8BATCH_SIZE: 16EPOCHS: 100LEARNING_RATE: 0.001

Evaluation

To evaluate a trained model:

python evaluate.py --config config.yaml --model-path checkpoints/final_model.pth

Inference

For inference on a single image:

fromsegmentationimportSegmentationConfig, UNet, Visualizerimportcv2# Initialize model and load weightsconfig=SegmentationConfig(MODEL_TYPE='unet')
model=UNet(config)
model.load_checkpoint('checkpoints/final_model.pth')
# Run inferenceimage=cv2.imread('path/to/image.jpg')
prediction=model.predict(image)

Project Structure

├── segmentation/
│ ├── models/
│ │ ├── fcn.py
│ │ ├── unet.py
│ │ ├── linknet.py
│ │ └── deeplabv3.py
│ ├── config.py
│ ├── dataset.py
│ └── utils/
├── train.py
├── evaluate.py
├── setup_data.py
└── config.yaml

About

The project utilizes convolutional-based network architectures for semantic image segmentation. This project utilizes the Indian Driving Dataset (IDD) Lite to classify various elements in Indian road scenes into 8 predefined categories. This implementation utilizes FCN - VGG backbone, U-Net, LINKNet, and DEEPLABV3+.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages