DEV Community

Cover image for A PROJECT ON TRAFFIC SIGN CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK
Onumaku Chibuike Victory
Onumaku Chibuike Victory

Posted on • Updated on

A PROJECT ON TRAFFIC SIGN CLASSIFICATION USING CONVOLUTIONAL NEURAL NETWORK

In this project, we used a convolutional neural network to build train, and test a traffic sign classification model. We built this model using tensorflow and keras. It is a multiclass classification problem. This model can be used to make smarter cars.
After this project, one can be able to build multiclass classification model using deep learning.

STEPS TAKEN TO SOLVE THE PROBLEMS
1) Finding data on kaggle and loading it into google colab.
2) Preprocessing the image and visualizing them.
3) Finding out the mean of the dimension and resizing all images accordingly.
4) Converting the images into a numpy array and normalize them.
5) Checking class imbalance.
6) Splitting the data and performing one hot encoding.
7) Creating the model architecture, compiling the model and then fitting it.
8) Plotting the accuracy and loss against each Epoch.
9) Preprocessing the test data and make predictions on it.
10) Visualize the original and predicted labels for the test images.

First, we start by connecting to kaggle using kaggle API which can be downloaded from your kaggle account settings and uploading it on your notebook.

Image description

Next we would store the data by making a directory and making it as a current directory.

Image description

We download the data into colab notebook using using references found in search options.

Image description

Also unzip the data which is downloaded and remove irrelevant files.

Image description

We plot 12 images to check dataset.

Image description

For further processing we will require the images of same dimension. So, we will start storing the dimension of all images from training dataset from all 43 classes.

Image description

Now, we will reshape the images into (50,50) and also store their label ids.

Image description

We also check the shape of the images. Here we can see below that there are 39209 images with a shape of (50,50,3).

Image description

The next step was splitting the data into training and validation with 80% of training data and 20% of validation data. Also converting the classes column into categorical using to_categorical() function.

Image description

Next we compile the model using metrics, optimizer and loss as required and printing out the summary of the model.

Image description

Now we fit the model and observe how they are getting trained on each epoch.

Image description

Next we visualize the accuracy and loss per epoch. For this we will store the model history in the pandas dataframe and plot them.

Image description

We create a function to resize the test images converting them into a numpy array and normalize them.

Image description

Now we will use the model to make predictions on our test images and save them in y_pred.

Image description

Next we store the labels according to the image classes.

Image description

Finding out the predicted label for the images above.

Image description

Top comments (0)