View on GitHub

Traffic Sign Classification

Traffic Sign Classification with Convolutional Neural Networks in Python

by Valentyn Sichkar     Academia.edu     YouTube

Traffic Sign Classification with Convolutional Neural Networks in Python

Implementing Traffic Sign Classification in Python for Computer Vision tasks in Autonomous Vehicles.
DOI

Test online here

Content

Short description of the content. Full codes you can find inside the course by link above:


Loading Data

Data used for this task is German Traffic Sign Benchmarks (GTSRB).
Initially datasets consist of images in PPM format with different sizes.

For current task datasets were organized as it was done for CIFAR-10 Image Classification:

Here,
12345 - number of images / labels,
3, 32, 32 - image with 3 channels and size of 32x32 (height and width).

All tensors were put in a dictionary and were written in a pickle file:

d = {'x_train': x_train, 'y_train': y_train,
     'x_validation': x_validation, 'y_validation': y_validation,
     'x_test': x_test, 'y_test': y_test}


Unique Training Examples

Examples of Unique Traffic Signs for every class from training dataset are shown on the figure below.

43 unique examples


Histogram of Training Examples

Histogram of 43 classes for training dataset with their number of examples for Traffic Signs Classification before and after equalization by adding transformated images from original dataset is shown on the figure below. After equalization, training dataset has increased up to 86989 examples.

Histogram of 43 classes


Good Quality Examples

Examples of Good Quality Traffic Signs for every class to show in GUI for driver are shown on the figure below.

43 good quality examples


Table of Labels

Following tabel represents number of class and its corresponding label (description).

Class Description
0 Speed limit (20km/h)
1 Speed limit (30km/h)
2 Speed limit (50km/h)
3 Speed limit (60km/h)
4 Speed limit (70km/h)
5 Speed limit (80km/h)
6 End of speed limit (80km/h)
7 Speed limit (100km/h)
8 Speed limit (120km/h)
9 No passing
10 No passing for vehicles over 3.5 metric tons
11 Right-of-way at the next intersection
12 Priority road
13 Yield
14 Stop
15 No vehicles
16 Vehicles over 3.5 metric tons prohibited
17 No entry
18 General caution
19 Dangerous curve to the left
20 Dangerous curve to the right
21 Double curve
22 Bumpy road
23 Slippery road
24 Road narrows on the right
25 Road work
26 Traffic signals
27 Pedestrians
28 Children crossing
29 Bicycles crossing
30 Beware of ice/snow
31 Wild animals crossing
32 End of all speed and passing limits
33 Turn right ahead
34 Turn left ahead
35 Ahead only
36 Go straight or right
37 Go straight or left
38 Keep right
39 Keep left
40 Roundabout mandatory
41 End of no passing
42 End of no passing by vehicles over 3.5 metric tons


Preprocessing Data

Prepared data is preprocessed in variety of ways and appropriate datasets are written into ‘pickle’ files.
Datasets data0 - data3 have RGB images and datasets data4 - data8 have Gray images.

Shapes of data0 - data3 are as following (RGB):

Shapes of data4 - data8 are as following (Gray):


Examples of some of them (RGB, Gray, Local Histogram Equalization) are shown on the figure below:

Preprocessed_examples


Model 1

For Model 1 architecture will be used as it was done for CIFAR-10 Image Classification:
Input –> Conv –> ReLU –> Pool –> Affine –> ReLU –> Affine –> Softmax


For Model 1 following parameters will be used:

Parameter Description
Weights Initialization HE Normal
Weights Update Policy Adam
Activation Functions ReLU
Regularization L2
Pooling Max
Loss Functions Softmax


Overfitting Small Data for Model 1

For Overfitting Small Data of Model 1 dataset ‘data8.pickle’ was chosen.

Overfitting Small Data with 10 training examples and 100 epochs is shown on the figure below.

Overfitting_Small_Data_for_Model_1_TS.png


Training of Model 1

For training Model 1 dataset ‘data8.pickle’ was chosen as it reached the best accuracy over all datasets.

Model 1 with ‘data8.pickle’ dataset reached 0.989 training accuracy.
Training process of Model 1 with 17 500 iterations is shown on the figure below.

Training_of_Model_1_TS.png


Visualizing Filters

Initialized and Trained filters for CNN Layer are shown on the figure below.

Filters_Initialized_TS.png


Visualizing Feature Maps

Feature maps of trained network for CNN Layer are shown on the figure below.

Feature_Maps_CNN_TS.png


Predicting with image from test dataset

Prediction with image from test dataset ‘data8.pickle’ is shown on the figure below.
Classified as Speed limit (60km/h).

Predicting_with_test_image.png


Predicting with user’s image

Prediction with user’s image is shown on the figure below.
Classified as Keep right.

Predicting_with_users_image.png


Traffic Sign Classification in Real Time

Traffic Sign Classification with Convolutional Neural Network. Left: original frame with detected Sign. Upper Right: cut frame with detected Sign. Lower Right: classified frame by ConvNet according to the detected Sign.

Traffic_Sign_Classification_Small_Small.gif


MIT License

github.com/sichkar-valentyn

Reference to:

Valentyn N Sichkar. Neural Networks for computer vision in autonomous vehicles and robotics // GitHub platform. DOI: 10.5281/zenodo.1317904