The Most Detailed Camping Recipes Guide

The Most Detailed Camping Recipes GuideThe number of meals in the field depends largely on the length of the planned hike. The longer the route, the more breakfasts, lunches, and dinners your friends…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




What I did to Build a Traffic Sign Recognition

I recently completed my third project where I have to Build and traine a deep neural network to classify traffic signs, using TensorFlow. Experiment with different network architectures. Performe image pre-processing and validation to guard against overfitting.

Steps of this project are the following:

I used the numpy library to calculate summary statistics of the traffic signs data set:

The size of training set is 34799 The size of test set is 12630 The shape of a traffic sign image is (32, 32, 3) The number of unique classes/labels in the data set is 43

Here is an exploratory visualization of the data set. It pulls in a random set of 8 images and labels them with the correct names in reference with the csv file to their respective id’s.

I also detail the dataset structure by plotting the occurrence of each image class to see how the data is distributed. This can help understand where potential pitfalls could occur if the dataset isn’t uniform in terms of a baseline occurrence.

I decided to convert the images to grayscale. I assume this works better because the excess information might add extra confusion into the learning process. After the grayscale I also normalized the image data because I’ve read it helps in speed of training and performance because of things like resources. Also added additional images to the datasets through randomized modifications.

Here is an example of a traffic sign images that were randomly selected.

Here is a look at the normalized images. Which should look identical, but for some small random alterations such as opencv affine and rotation.

I did a few random alterations to the images and saved multiple copies of them depending on the total images in the dataset class type.

Here is an example of 1 image I changed at random. More can be seen further in the document, but the original is on the right and the randomized opencv affine change is on the left. Small rotations are also visible further along as stated.

I increased the train dataset size to 89860 and also merged and then remade another validation dataset. Now no image class in the train set has less then 1000 images.

Validation set gained 20% of the original total mentioned above. I did this using scikit learns train test split method.

To train the model, I used an ….

| Layer. |. Description |
|: — — — — — — — — — — -:|: — — — — — — — — — — — — — — — — — — — — — — -:|
| Input | 32x32x1 RGB image |
| Convolution 3x3 | 2x2 stride, valid padding, outputs 28x28x6 |
| RELU | |
| Max pooling | 2x2 stride, outputs 14x14x64 |
| Convolution 5x5 | 2x2 stride, valid padding output 10x10x6 |
| RELU | |
| Max Pooling | 2x2 stride, outputs 5x5x16 |
| Convolution 1x1 | 2x2 stride, valid padding, outputs 1x1x412 |
| RELU | |
| Fully connected | input 412, output 122 |
| RELU | |
| Dropout | 50% Keep |
| Fully connected | input 122, output 84 |
| RELU | |
| Dropout | 50% Keep |
| Fully connected | input 84, output 43 |

To train the model, I used an LeNet for the most part that was given, but I did add an additional convolution without a max pooling layer after it like in the udacity lesson. I used the AdamOptimizer with a learning rate of 0.00097. The epochs used was 27 while the batch size was 156. Other important parameters I learned were important was the number and distribution of additional data generated. I played around with various different distributions of image class counts and it had a dramatic effect on the training set accuracy. It didn’t really have much of an effect on the test set accuracy, or real world image accuracy. Even just using the default settings from the Udacity lesson leading up to this point I was able to get 94% accuracy with virtually no changes on the test set. When I finally stopped testing I got 94–95.2% accuracy on the test set though so I think the extra data improved training accuracy, but not a huge help for test set accuracy. Although this did help later on with the images from the internet.

My final model results were:

Training set accuracy of 100.0% validation set accuracy of 99.3% test set accuracy of 95.1% If an iterative approach was chosen:

What were some problems with the initial architecture?

The first issue was lack of data for some images and the last was lack of knowledge of all the parameters. After I fixed those issues the LeNet model given worked pretty well with the defaults. I still couldn’t break 98% very easily until I added another convolution. After that it was much faster at reaching higher accuracy scores.

How was the architecture adjusted and why was it adjusted?

Adding a couple dropouts with a 50% probability.

Which parameters were tuned? How were they adjusted and why?

Epoch, learning rate, batch size, and drop out probability were all parameters tuned along with the number of random modifications to generate more image data was tuned. For Epoch the main reason I tuned this was after I started to get better accuracy early on I lowered the number once I had confidence I could reach my accuracy goals. The batch size I increased only slightly since starting once I increased the dataset size. The learning rate I think could of been left at .001 which is as I am told a normal starting point, but I just wanted to try something different so .00097 was used. I think it mattered little. The dropout probability mattered a lot early on, but after awhile I set it to 50% and just left it. The biggest thing that effected my accuracy was the data images generated with random modifications. This would turn my accuracy from 1–10 epochs from 40% to 60% max to 70% to 90% within the first few evaluations. Increasing the dataset in the correct places really improved the max accuracy as well.

What are some of the important design choices and why were they chosen?

I think the most important thing I learned was having a more uniform dataset along with enough convolutions to capture features will greatly improve speed of training and accuracy.

I used semi-easy images to classify and even modified them slightly. I made them all uniform in size and only had one partially cut off.

Here are the results of the prediction:

The model was able to correctly guess 5 of the 5 traffic signs, which gives an accuracy of 100%. This compares favorably to the accuracy on the test set although I did throw it a softball.

I hope this helped you it as base to start your way!

Add a comment

Related posts:

Korean delegation from KIMST visiting London

After meeting in Busan last month at the World Ocean Forum 2018 where I was invited to give a talk on startup-driven innovation, we were delighted to have a Korean delegation from KIMST — Korea…

SaleHoo Review

This review will just serve as a brief description of what SaleHoo is and why I would recommend it to anyone aspiring to get into dropshipping or start their own e-commerce business. Basically…

Proposal

I have a morbid longing for the picturesque at all costs. I liked to paint myself as an allegory from a novel: white turtleneck under a black blazer, black coffee on rainy mornings, old notebooks and…