Hindi Handwriting Recognition

Gunjan Agrawal
6 min readDec 20, 2020

--

Importance of a Handwriting Recognition System: Handwriting recognition in images is a research area that attempts to develop a computer system to transform the text present in the paper format to electronic format. The high variance in handwriting styles across people and poor handwritten text quality compared to printed text poses significant hurdles in converting it to machine-readable text. In offline handwriting recognition, the text is analyzed after being written. Deep learning and Machine Learning has been widely used to recognize handwriting.

In this blog, I would be covering the analysis of different Machine Learning and Deep Learning Technique to select the best technique on Devanagari(Hindi) Handwritten Character Dataset.

Details of the Dataset: The dataset has been taken from Kaggle. It has images of different characters used in the Devanagiri script. The dataset was created by the extraction and manual annotation of thousands of characters from handwritten documents. The dataset has a uniform size.

Sample Image from the Dataset for Hindi Character’ka’

Methodology Followed for Hindi Handwriting Recognition:
1. Uniform input dataset
a. Pre-processed data is used
b. And we have one image per char
2. Problem analysis
a. Char belongs to hindi language
b. Output labels are fixed as hindi char
c. Its a classification problem
3. Multiple Outputs(46 in our case)
a. Possible classifier algorithms need to be tested
4. Machine Learing Algorithms applied and tested on the basis of Accuracy
a. Python library used is sklearn
b. Analysis of different ML Techniques.
5. Deep Learning Techniques used and analysed on the basis of accuracy
6. Best Technique is Obtained based on the results.
a. Different Architectures were tried
7. Testing on specific new sample
8. Conclusion

Since Handwriting Recognition is a Classification problem, the following Machine Learning techniques have been tried, and you can read the description of those ML Techniques in the passage below:

Description of the ML Techniques Used in the Project:
The following ML classification Techniques have
been used:
1.Random Forest: The random forest is a classification algorithm consisting of many decision trees. It uses bagging and feature randomness when building each tree to create an uncorrelated forest of trees whose committee's prediction is more accurate than any individual tree.
2.Decision Tree: The decision tree builds classification or regression models in the form of a tree structure. It breaks down a dataset into smaller and smaller subsets while at the same time an associated decision tree is incrementally developed.
3. ExtraTreeClassifier: is an ensemble learning method fundamentally based on decision trees. ExtraTreesClassifier, like RandomForest, randomizes certain decisions and subsets of data to minimize over-learning from the data and overfitting
4.Linear discriminant analysis, normal discriminant analysis, or discriminant function analysis is a generalization of Fisher’s linear discriminant, a method used in statistics and other fields, to find a linear combination of features that characterizes or separates two or more classes of objects or events. Discriminant analysis is used when groups are known a prior (unlike in cluster analysis).In simple terms, discriminant function analysis is the classification of distributing things into groups, classes, or categories of the same type.
5.Nearest Centroid Classifier: Nearest centroid classifier or nearest prototype classifier is a classification model that assigns to observations the label of the class of training samples whose mean (centroid) is closest to the observation.
6.kNN: In k-NN classification, the output is a class membership. An object is classified by a plurality vote of its neighbors, with the object being assigned to the class most common among its k nearest neighbors (k is a positive integer, typically small). If k = 1, then the object is assigned to that single nearest neighbor's class. k-NN is a type of instance-based learning, or lazy learning, where the function is only approximated locally, and all computation is deferred until function evaluation.
7. Gaussian Naive Bayes: is an algorithm having a Probabilistic Approach. It involves prior and posterior probability calculation of the classes in the dataset and the test data given a class, respectively.
8.Multinomial Naïve Bayes: The multinomial Naive Bayes classifier is suitable for classification with discrete features (e.g., word counts for text classification). The multinomial distribution normally requires integer feature counts.

An Insight to the Data Used for Training the Models:

We are trainining our Models with 300 sample images for each character of Hindi Language.A sample Training Image looks like this:

Sample Training Image

Analysis of Different ML Techniques:
The Accuracy obtained on the validation set is as follows:

Validation Set Accuracy of the ML Techniques Described above
Bar Graph displaying the Validation Accuracy of ML Techniques Used

Details of the Deep Learning Models implemented for the classification task:

A fully connected Deep Neural Network can be used. The architecture of the Neural Network Model used is as follows:

Summary of the Model

Accuracy Obtained with the help of Fully Connected Neural Network is 81.8%.

Plot showing Accuracy and Loss of Neural Network

Further, increasing the size of the Dataset improves Accuracy significantly. For the same neural Network Architecture, accuracy becomes 90.87% on the validation set after increasing the size of the Dataset by 5 times.

Accuracy of Neural Network with Increased Dataset Size

We can use a MultiLayer Perceptron (MLP) classifier as well with the help of sklearn python library but it provides significantly low accuracy than the neural network shown above. The architecture of the MLP classifier is as follows:

The architecture of MLP Classifier

The accuracy obtained with the MLP classifier is: 57.82%

The accuracy obtained with MLP Classifier

Conclusion:

The Best ML Technique for Hindi Handwriting Classification is Random Forest, with an accuracy of 81.52%.

The classification report of Random Forest Classifier is as follows:

Classification Report of Random Forest Classifier

The Neural Network Architecture implemented has performed equally well with an accuracy of 81.81%. Also, increasing the dataset size improves the accuracy of the Model.

Results of Prediction on New Sample:

Prediction by the Model on Unseen Data

The technique used here has the advantage that it can be used for any language; any script provided a good amount of uniform data is provided for training the models.

Contribution Details:

The project has been done individually by Gunjan Agrawal towards fulfilling the course work requirements for Machine Learning @ IIIT Delhi (Monsoon 2020).

Author of the Blog: Gunjan Agrawal

Under the guidance of:

  1. Professor Tanmoy Chakraborty, profile link: linkedin.com/in/tanmoy-chakraborty-89553324,Twitter: @Tanmoy_Chak
  2. Teaching Fellow: Ms. Ishita Bajaj
  3. Teaching Assistants: Vivek Reddy, Shiv Kumar Gehlot, Chhavi Jain, Pragya Srivastava, Shikha Singh, and Nirav Diwan.

References:

  1. Jamshed Memon, Maira Sami, and Rizwan Ahmed Khan, Handwritten Optical Character Recognition (OCR): A Comprehensive Systematic Literature Review (SLR),arXiv:2001.00139v1[cs. CV] 1 Jan 2020.
  2. Vijay Laxmi Sahu, Babita Kubde, OfflineHandwritten Character RecognitionTechniques using Neural Network: A Review(2013), International Journal of Science and Research (IJSR), India Online ISSN: 2319–7064 Volume 2 Issue.
  3. Chayaporn Kaensar, A Comparative Study on Handwriting Digit Recognition Classifier Using Neural Network, Support Vector
    Machine and K-Nearest Neighbor, The 9th International Conference on Computing and Information Technology(IC2IT2013).

--

--