By Dev Mehta
Classifies traffic signs into 43 classes using the GTSRB dataset. The project can be used in self driving cars. The project has been implemented using TensorFlow and Keras on Python.
This project classifies different traffic signs into 43 different classes. We have used the GTSRB benchmark dataset which contains around 35,00 images in the training set, 4,500 images in the validation set and around 12,600 images in the test set which totals over 51,000 images in the dataset.
We start off by first installing and then importing all the required dependencies such as the frameworks and libraries.
The data has already been split for us so we just load the data onto our jupyter notebook and then open it.
We shuffle the data and then convert the image to one dimension and apply normalization to get better results.
Now we start building the model:
Our first layer consists of a convolution layer of 20 nodes with a 3x3 filter and use the relu activation and then apply max pooling to it. We also apply dropout with 20%. The reason I added dropout was that when I trained the model earlier, I had seen high variance between the training and validation accuracies and so to reduce this variance, we apply dropout regularization.
Our second layer is similar to the first layer. The only difference I have done is to increase the number of nodes in the Convoluton layer to 30.
For passing on the output of our second layer to the Dense layer that we will add, we first need to flatten the output from the second layer and so we first add a Flatten layer. We now add a Dense layer with 128 nodes and the activation will be relu. In this layer, we also have L1-L2 regularization. We add one more Dense layer with 256 nodes but without regularization and the activation as relu.
For our last layer, we add a softmax layer with 43 nodes since we have 43 classes to differentiate from.
This marks the completion of building the model. We now compile it using the Adam optimizer and the sparse categorical crossentropy loss. For checking our progress, we use the metrics as accuracy so that we can see the accuracy as well as the validation accuracy.
We finally train our model on the training set on a batch size of 32 for 40 epochs. At the end of our training we get an accuracy of 98.9% and a validation accuracy of 96.24%. We then evaluate our model on the test set accuracy and we see a test set accuracy of 95%.
We also plot the graphs to visualize the changes in both the accuracies as well as both the losses. We also visualize a few of our predictions.
Finally we save the weights separately as well as the whole model which also consists of the weights so that it can be loaded and used elsewhere.
The index for the 43 Classes are as listed below:
Submitted by Dev Mehta (devmehta)
Download packets of source code on Coders Packet
Comments