https://github.com/mnj-tothetop/english-handwritten-characters-recognizer
A handwritten english character recognizer [0-9, A-Z, a-z] made by using a Dataset of 3409 images. Tensorflow, Keras, Scikit-learn, and OpenCV was used to implement the Convolution Neural Network (CNN). Matplotlib and Seaborn were used to visualize the data.
https://github.com/mnj-tothetop/english-handwritten-characters-recognizer
artificial-intelligence convolutional-neural-networks keras matplotlib opencv-python scikit-learn seaborn tensorflow
Last synced: 3 months ago
JSON representation
A handwritten english character recognizer [0-9, A-Z, a-z] made by using a Dataset of 3409 images. Tensorflow, Keras, Scikit-learn, and OpenCV was used to implement the Convolution Neural Network (CNN). Matplotlib and Seaborn were used to visualize the data.
- Host: GitHub
- URL: https://github.com/mnj-tothetop/english-handwritten-characters-recognizer
- Owner: Mnj-ToTheTop
- License: mit
- Created: 2024-06-18T05:41:12.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-06-18T12:59:37.000Z (12 months ago)
- Last Synced: 2025-01-21T14:13:28.807Z (5 months ago)
- Topics: artificial-intelligence, convolutional-neural-networks, keras, matplotlib, opencv-python, scikit-learn, seaborn, tensorflow
- Language: Jupyter Notebook
- Homepage:
- Size: 355 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# English-Handwritten-Characters-Recognizer
## STEP - 1: Loading the Dataset
First step I took was to download the dataset.
The labels and the images names were stored in a CSV (Comma Separated Value) file. I used the `read_csv()` fuction of the Pandas library to achieve this.

Looking at the data it can be noted that the first column contains the Image path while the 2nd contains the True Label of the image. There are a total 3409 images.
I then created a Python list `labels` and `filenames` to store the image path of each image along with its corresponding label.
## STEP 2: Preprocessing
To make sure all the images are of the same type and that all the images have the proper input size for our model, I used the `imread()` function of OpenCV library to read the image and the `resize()` function of the same to resize the image to the correct size.Then I converted both the labels list and filenames list to Numpy arrays. I also used the `LabelEncoder` from the scikit-learn library to encode the the labels to integers (as some of the labels are characters)
## STEP 3: Separating the Train set and Test set
To split the dataset into train and test set, I have used the `train_test_split()` of the scikit-learn library. Once the the train set and test set were obtained, the labels were One-Hot-Encoded using the `to_categorical()` function of Keras.## STEP 4: Model Building
The model contains 3 Convolution Layers and Classification Layer.### *LAYER - 1*
This layer contains two `Conv2D()` layers one with 64 filters and the other with 32 filters, with the kernel size = 3 (i.e. 3x3). Following this, a Max Poooling layer is in place, which gives the output shape of `32x32x32`.### *LAYER - 2*
This layer contains two `Conv2D()` layer each with 64 Filters and a kernel size of 3 (i.e. 3x3). This is followed by Max Pooling with a size of 2x2 which results in an output size of `8x8x64`.### *LAYER - 3*
This layer is identical to Layer - 2 and results in an output size of `8x8x64`.`NOTE: I have used padding to avoid shrinking of the data.`
`NOTE 2: The activation function used is Rectified Linear (ReLu)`### CLASSIFICATION LAYERS:
#### *FLATTEN*
This layer is used to flatten the matrix to a vector. On flattening the matrix the total elements we got: `8 * 8 * 64 = 4096`
#### *DROPOUT LAYER - 1*
To reduce overfitting, we are dropping 0.25 of the neurons.
#### *DENSE LAYER - 1*
A fully connected layer of nuerons with output of shape of `512`
#### *DROPOUT LAYER - 2*
Dropping 0.50 of the nuerons
#### *DENSE LAYER - 2*
Since we have 62 classes to classify, we have kept the the number of nuerons to `62`## STEP 5: Training and Testing the model
The model was trained using the `model.fit()` function. 30 Epoches were used.
On evaluating the model using the test set, and the function `model.evaluate()` we can see the model has an accuracy of 75.806%## IMPROVEMENTS THAT CAN BE MADE :
1. A larger data set can be used to train the model more.
2. A larger number of epoch can be used.
3. Changes in the model can also be done to improve the model.Dataset Taken from:
@InProceedings {deCampos09,
author = "de Campos, T.~E. and Babu, B.~R. and Varma, M.",
title = "Character recognition in natural images",
booktitle = "Proceedings of the International Conference on Computer
Vision Theory and Applications, Lisbon, Portugal",
month = "February",
year = "2009",
}Kaggel Link: https://www.kaggle.com/datasets/dhruvildave/english-handwritten-characters-dataset