Sandeep2803/traffic-segmentation-alexnet
π 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.
π 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
π Final Results
πΌ Sample Prediction
Example 1
Example 2
Example 3
Example 4
Example 5
π Installation
Clone the repository
git clone https://github.com/Sandeepkumarreddy-7/Traffic-Segmentation-AlexNet.gitMove into the project
cd Traffic-Segmentation-AlexNetCreate Virtual Environment
python -m venv venvActivate Virtual Environment
Linux
source venv/bin/activateWindows
venv\Scripts\activateInstall Dependencies
pip install -r requirements.txtβΆ Training
python train.pyπ Evaluation
python evaluate.pyπΌ Testing
python test.pyπ Plot Training Loss
The following graph shows the decrease in training loss during model training.
---
π 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
