CoolFace
Apppublic

Sandeep2803/traffic-segmentation-alexnet

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
App README

Python PyTorch Dataset Task

πŸš— Traffic Scene Semantic Segmentation using a Custom AlexNet-based Encoder–Decoder Architecture

A PyTorch implementation of semantic segmentation using a custom AlexNet-based encoder–decoder architecture trained on the BDD100K dataset.

πŸ“Œ Project Overview

This project implements a Semantic Segmentation model using a custom AlexNet-based Encoder–Decoder Architecture in PyTorch. The model is trained on the BDD100K dataset to perform pixel-wise classification of traffic scene images.

Unlike image classification, semantic segmentation predicts a class label for every pixel in an image. The model identifies different objects such as roads, vehicles, buildings, vegetation, sky, pedestrians, traffic signs, and other traffic scene elements.

The objective of this project is to understand and implement the complete semantic segmentation pipeline, including dataset preprocessing, model development, training, evaluation, visualization, and performance analysis.


✨ Features

  • β€”Custom AlexNet Encoder
  • β€”Custom Decoder for Semantic Segmentation
  • β€”Pixel-wise Image Segmentation
  • β€”BDD100K Dataset Support
  • β€”Custom Dataset and DataLoader
  • β€”Training Pipeline
  • β€”Evaluation Pipeline
  • β€”Visualization of Predictions
  • β€”Color Segmentation Masks
  • β€”Pixel Accuracy Evaluation
  • β€”Mean Intersection over Union (mIoU)
  • β€”Training Loss Visualization

πŸ—‚ Dataset

Dataset Name: BDD100K (Berkeley DeepDrive)

BDD100K is a large-scale autonomous driving dataset containing real-world road scenes with pixel-level semantic segmentation annotations.

Classes

The model predicts 19 semantic classes, including:

  • β€”Road
  • β€”Sidewalk
  • β€”Building
  • β€”Wall
  • β€”Fence
  • β€”Pole
  • β€”Traffic Light
  • β€”Traffic Sign
  • β€”Vegetation
  • β€”Terrain
  • β€”Sky
  • β€”Person
  • β€”Rider
  • β€”Car
  • β€”Truck
  • β€”Bus
  • β€”Train
  • β€”Motorcycle
  • β€”Bicycle

πŸ— Model Architecture

The semantic segmentation model uses a custom AlexNet-based Encoder–Decoder architecture.

[image]

πŸ“‚ Project Structure

Traffic-Segmentation-AlexNet/

β”‚
β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ encoder.py
β”‚   β”œβ”€β”€ decoder.py
β”‚   └── segmentation_model.py
β”‚
β”œβ”€β”€ preprocessing/
β”‚   β”œβ”€β”€ dataset.py
β”‚   β”œβ”€β”€ dataloader.py
β”‚   └── transforms.py
β”‚
β”œβ”€β”€ outputs/
β”‚   β”œβ”€β”€ predictions/
β”‚   β”œβ”€β”€ plots/
β”‚   └── metrics.txt
β”‚
β”œβ”€β”€ config.py
β”œβ”€β”€ train.py
β”œβ”€β”€ test.py
β”œβ”€β”€ evaluate.py
β”œβ”€β”€ metrics.py
β”œβ”€β”€ visualize.py
β”œβ”€β”€ plot_loss.py
β”œβ”€β”€ utils.py
β”œβ”€β”€ requirements.txt
└── README.md

βš™ Training Configuration

ParameterValue
FrameworkPyTorch
DatasetBDD100K
Epochs20
Batch Size4
OptimizerAdam
Loss FunctionCrossEntropyLoss
DeviceCPU

πŸ“Š Final Results

MetricValue
Validation Loss0.7282
Pixel Accuracy77.90%
Mean IoU (mIoU)0.2564

πŸ–Ό Sample Prediction

Example 1

[image]

Example 2

[image]

Example 3

[image]

Example 4

[image]

Example 5

[image]

πŸš€ Installation

Clone the repository

bash
git clone https://github.com/Sandeepkumarreddy-7/Traffic-Segmentation-AlexNet.git

Move into the project

bash
cd Traffic-Segmentation-AlexNet

Create Virtual Environment

bash
python -m venv venv

Activate Virtual Environment

Linux

bash
source venv/bin/activate

Windows

bash
venv\Scripts\activate

Install Dependencies

bash
pip install -r requirements.txt

β–Ά Training

bash
python train.py

πŸ“ˆ Evaluation

bash
python evaluate.py

πŸ–Ό Testing

bash
python test.py

πŸ“‰ Plot Training Loss

The following graph shows the decrease in training loss during model training.

[image] ---

πŸ›  Technologies Used

  • β€”Python
  • β€”PyTorch
  • β€”TorchVision
  • β€”NumPy
  • β€”Matplotlib
  • β€”Pillow
  • β€”Git
  • β€”GitHub

πŸ“ˆ Future Improvements

  • β€”Use Pretrained AlexNet Weights
  • β€”Add Skip Connections
  • β€”Implement Data Augmentation
  • β€”Train for More Epochs
  • β€”Use Dice Loss or Focal Loss
  • β€”Improve Decoder Architecture
  • β€”Deploy with Gradio or Streamlit
  • β€”Experiment with U-Net and DeepLabV3+

πŸ‘¨β€πŸ’» Author

Dammuru Sandeep Kumar Reddy

B.Tech – Computer Science and Engineering

Srinivasa Ramanujan Institute of Technology

GitHub: https://github.com/Sandeepkumarreddy-7


⭐ Acknowledgements

  • β€”Berkeley DeepDrive (BDD100K)
  • β€”PyTorch
  • β€”TorchVision
  • β€”OpenAI ChatGPT