This repository provides a complete implementation of a Traffic Signs Classification model using Convolutional Neural Networks (CNN). The goal is to classify various types of traffic signs for use in applications such as autonomous driving.
- Introduction
- Dataset
- Model Architecture
- Installation and Setup
- Training and Evaluation
- Results and Visualizations
- Live Testing
- Android App
- Web App
Traffic sign recognition is crucial for the development of self-driving cars and other intelligent road systems. This project employs a CNN model to classify images of traffic signs into 43 distinct classes. Using image processing and data augmentation techniques, the model achieves robust performance, making it suitable for real-world applications.
The project uses the German Traffic Sign Recognition Benchmark (GTSRB) dataset, which contains over 35,000 images of 43 different traffic sign classes. The images are of varying sizes, lighting conditions, and angles, making this a challenging classification task.
- Training Set: 80% of the dataset
- Validation Set: 20% of the training data
- Test Set: 20% of the total dataset
The CNN model has been built using the Keras framework. The architecture includes:
- Convolutional Layers: Extract features from the input images.
- MaxPooling Layers: Reduce the spatial dimensions of feature maps.
- Dropout Layers: Prevent overfitting by dropping nodes during training.
- Dense Layers: Perform final classification using a softmax activation function.
The network includes:
- Two sets of Convolutional and MaxPooling layers.
- Dropout layers with a 50% drop rate to enhance generalization.
- A fully connected layer followed by a softmax output layer.
Make sure you have the following packages installed:
- Python (>= 3.6)
- TensorFlow
- Keras
- NumPy
- OpenCV
- Matplotlib
- Scikit-learn
-
Clone the repository:
git clone https://github.com/nishatrhythm/Traffic-Signs-Classification-Using-Convolution-Neural-Networks.git cd Traffic-Signs-Classification-Using-Convolution-Neural-Networks
-
Install the required dependencies:
pip install -r requirements.txt
Images are preprocessed using OpenCV:
- Grayscale Conversion: Simplifies the image by reducing color channels.
- Histogram Equalization: Normalizes the lighting conditions.
- Normalization: Scales pixel values to the [0, 1] range.
To improve model generalization, data augmentation techniques such as width/height shifts, zoom, shear, and rotations are applied.
To train the model, run:
python TrafficSigns_main.py
The model is trained using the Adam optimizer and categorical cross-entropy loss function. The training history, including accuracy and loss curves, is plotted for analysis.
The model is evaluated on the test set to measure performance. The final model is saved as model_trained.p
for later use.
You can test the model in real-time using a webcam. The model detects and classifies traffic signs with a specified probability threshold.
python TrafficSigns_test.py
- Press
q
to quit the live demo. - The
TrafficSigns_test.py
script captures images from the webcam, preprocesses them, and classifies the traffic signs using the trained model.
Below are some sample screenshots from the live testing:
In addition to the Python implementation, an Android app has been developed based on this project. The app uses the trained CNN model to classify traffic signs in real-time, making it suitable for mobile and on-the-go applications.
You can find the Android app and more details in the dedicated repository: Android App of Traffic Signs Classification using CNN.
A web application has been developed alongside the Python implementation to classify traffic signs directly from a browser. Built using Python, Flask, and Tailwind CSS, this app offers a simple and efficient way to upload images and receive classification results in real-time using the trained CNN model.
You can find the web app and more details in the dedicated repository: Traffic Signs Classification Web Application.