TRAFFIC SIGNS RECOGNITION part-1
Traffic signs are an essential part of our day to day lives. They contain critical information that ensures the safety of all the people around us. Without traffic signs, all the drivers would be clueless about what might be ahead to them and roads can become a mess. The annual global roach crash statistics say that over 3,280 people die every day in a road accident. These numbers would be much higher in case if there were no traffic signs.
STEPS TO BUILD THE PROJECT
1. Setup the Project
Firstly Download the dataset into the Traffic sign recognition . We will use the Jupyter notebook which is an interactive development environment.Open up the terminal and traverse to the project folder. To start the jupyter notebook you have to type “jupyter lab” in the terminal and it will open up a web-based interface.Then you can start the jupyter notebook and rename the file as traffic_sign_recognition.
2. Import the necessary modules and initialize variables
import numpy as np
import pandas as pd
import pandas as pd
import matplotlib.pyplot as plt
from keras.models import Sequential
from keras.layers import Dense
from keras.optimizers import Adam
from keras.utils.np_utils import to_categorical
from keras.layers import Dropout, Flatten
from keras.layers.convolutional import Conv2D, MaxPooling2D
from sklearn.model_selection import train_test_split
from keras.preprocessing.image import ImageDataGenerator
path = ("C:\\Users\\KASHISH GUPTA\\Desktop\\goeduhub 1\\myData\\myData")
labelFile = ('C:\\Users\\KASHISH GUPTA\\Desktop\\goeduhub 1\\labels.csv')
batch_size_val=50 # how many to process together
imageDimesions = (32,32,3)
testRatio = 0.2
validationRatio = 0.2
3. import of the Image
count = 0
images = 
classNo = 
myList = os.listdir(path)
print("Total Classes Detected:",len(myList))
for x in range (0,len(myList)):
myPicList = os.listdir(path+"/"+str(count))
for y in myPicList:
curImg = cv2.imread(path+"/"+str(count)+"/"+y)
print(count, end =" ")
images = np.array(images)
classNo = np.array(classNo)
4. SPLIT Data
X_train = Array of the image to train
y_train = Corresponding class id
# Split Data
X_train, X_test, y_train, y_test = train_test_split(images, classNo, test_size=testRatio)
X_train, X_validation, y_train, y_validation = train_test_split(X_train, y_train, test_size=validationRatio)
#check the number of label
print("Train",end = "");print(X_train.shape,y_train.shape)
print("Validation",end = "");print(X_validation.shape,y_validation.shape)
print("Test",end = "");print(X_test.shape,y_test.shape)
assert(X_train.shape==y_train.shape), "The number of images in not equal to the number of lables in training set"
assert(X_validation.shape==y_validation.shape), "The number of images in not equal to the number of lables in validation set"
assert(X_test.shape==y_test.shape), "The number of images in not equal to the number of lables in test set"
assert(X_train.shape[1:]==(imageDimesions))," The dimesions of the Training images are wrong "
assert(X_validation.shape[1:]==(imageDimesions))," The dimesionas of the Validation images are wrong "
assert(X_test.shape[1:]==(imageDimesions))," The dimesionas of the Test images are wrong"
# Read The CSV file and display the sample image of class
num_of_samples = 
cols = 5
num_classes = noOfClasses
fig, axs = plt.subplots(nrows=num_classes, ncols=cols, figsize=(5, 300))
for i in range(cols):
for j,row in data.iterrows():
x_selected = X_train[y_train == j]
axs[j][i].imshow(x_selected[random.randint(0, len(x_selected)- 1), :, :], cmap=plt.get_cmap("gray"))
if i == 2:
These are 42 image groups of taffic sign,.
# DISPLAY A BAR CHART SHOWING NO OF SAMPLES FOR EACH CATEGORY
plt.bar(range(0, num_classes), num_of_samples)
plt.title("Distribution of the training dataset")
plt.ylabel("Number of images")