Skip to content

yazanmonshed/traffic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Traffic Sign Recognition

A deep learning solution for real-time traffic sign classification using convolutional neural networks. This project demonstrates image classification techniques applied to the German Traffic Sign Recognition Benchmark (GTSRB), a challenging real-world dataset used extensively in autonomous driving research.

Overview

Traffic sign recognition is a critical component of advanced driver assistance systems and autonomous vehicles. This project implements a CNN-based classifier that achieves over 96% accuracy in identifying 43 different categories of German traffic signs.

The model is trained on the GTSRB dataset, which contains over 50,000 images captured under varying lighting conditions, weather, and viewing angles. Images are preprocessed to a uniform 30x30 pixel resolution before being fed through a multi-layer convolutional architecture that progressively extracts hierarchical visual features.

Model Architecture

The final model consists of:

  • Input Layer: 30x30x3 RGB images
  • First Convolutional Block: 32 filters with 3x3 kernel, ReLU activation, followed by 2x2 max pooling
  • Second Convolutional Block: 64 filters with 3x3 kernel, ReLU activation, followed by 2x2 max pooling
  • Flatten Layer: Converts 2D feature maps to 1D vector
  • Dense Layer: 128 neurons with ReLU activation
  • Dropout Layer: 50% dropout rate to prevent overfitting
  • Output Layer: 43 neurons with softmax activation for classification

Experimentation and Learnings

Initial Approach

I initially built the model using a single convolutional layer with 32 filters and max pooling with a 3x3 kernel. The output was flattened and fed into 128 hidden units. I also introduced dropout at a rate of 0.5 to address overfitting. While this model compiled successfully, the accuracy was unacceptable at around 5%.

Improved Architecture

To improve performance, I introduced a second pair of convolutional and max pooling layers. This change led to significantly better results, achieving greater than 96% accuracy with a loss of around 8%.

Why the Improvement Worked

The first convolutional and max pooling block transforms raw pixels into basic visual features such as edges and simple shapes. The second block builds on these features to detect more complex patterns like corners, curves, and specific shapes that are crucial for distinguishing between traffic signs. This hierarchical feature extraction is fundamental to how CNNs learn to recognize images.

The progression from simple to complex features allows the network to understand traffic signs at multiple levels of abstraction. Low-level features capture edges and color gradients, while higher-level features combine these into recognizable symbols and shapes.

Requirements

  • Python 3.8 or higher
  • OpenCV
  • scikit-learn
  • TensorFlow

Setup

1. Clone the Repository

git clone https://github.com/yourusername/traffic.git
cd traffic

2. Create a Virtual Environment (Optional but Recommended)

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Download the Dataset

Download and extract the GTSRB dataset:

curl -O https://cdn.cs50.net/ai/2023/x/projects/5/gtsrb.zip
unzip gtsrb.zip

This will create a gtsrb directory containing 43 subdirectories (numbered 0 through 42), each representing a traffic sign category.

Usage

Training the Model

python traffic.py gtsrb

Training and Saving the Model

python traffic.py gtsrb model.h5

This will train the model and save it to model.h5 for later use.

Dataset

The German Traffic Sign Recognition Benchmark (GTSRB) dataset contains:

  • 43 classes of traffic signs
  • Images of varying sizes (resized to 30x30 for this model)
  • Real-world images captured under different lighting and weather conditions

Results

The final model achieves:

  • Accuracy: Greater than 98%
  • Loss: Approximately 8%

Acknowledgments

  • Institut fur Neuroinformatik for the GTSRB dataset

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages