Professional Documents
Culture Documents
Assignment No 2 - OCR CNN
Assignment No 2 - OCR CNN
Assignment No 2 - OCR CNN
The OCR can be implemented by using Convolutional Neural Network (CNN), which is a
popular deep neural network architecture.
The traditional CNN classifiers are capable of learning the important 2D features
present in the images and classify them, the classification is performed using
softmax.
Convolution
A convolution sweeps the window through images then calculates its input and filter
dot product pixel values. This allows convolution to emphasize the relevant
features.
Max Pooling
CNN uses max pooling to replace output with a max summary to reduce data size and
processing time.
This allows you to determine features that produce the highest impact and reduces
the risk of overfitting.
Max pooling takes two hyperparameters: stride and size.
The stride will determine the skip of value pools while the size will determine
how big the value pools in every skip.
Finally, we will serve the convolutional and max pooling feature map outputs with
Fully Connected Layer (FCL).
We flatten the feature outputs to column vector and feed-forward it to FCL.
We wrap our features with softmax activation function which assign decimal
probabilities for each possible label which add up to 1.0.
Every node in the previous layer is connected to the last layer and represents
which distinct label to output.
Algorithm
Install required packages( matplotbib, pandas, numpy, keras, sklearn) and
dataset(A_Z hardwritten .cvs) from kaggel
Open the dataset
To get into image format (Drop few column and reshape)
Dictionary for getting characters from index values
Reshaping the training & test dataset so that it can be put in the model
Converting the labels to categorical values
Implementing CNN model using one input, output and convolution layers
Making model predictions
Prediction of external(user written) image.
Displaying some of the test images & their predicted labels
Displaying accuracy , precision, recall and F1 Score using matplolib