Python scripts for segmentation of cursive handwritten image, and recognizing the characters using a CNN based model
Handwriting recognition is one of the challenging and difficult problems. A number of papers have been published with research detailing new techniques for the classification of handwritten numerals and words. In most of the research, the text recognition is carried out by passing each small part of segmented text directly to a neural network based model. This technique relies on the accuracy of model and confidence values for verification of correctness which is very slow & difficult to implement. The technique proposed here is a simple and unique set of algorithms for text recognition which primarily focuses on the character segmentation. The algorithm involves the preprocessing, segmentation, model building and recognition steps.
All the python scripts can be independently executed. The following order needs to be maintained.
-
image-straighten.py
(optional) This module is used for slant-correction of the images. If the image is already straightened, no need to execute this. -
segmentation.py
: This takes in the desired image from the foldersample_image
, and performs segmentation operation. This includes word and character segmentation, stored in theresult/characters
folder.
center-align.py
: This takes in the segmented character images, adds padding, resizes and center aligns the images, ready to be fed to the model for prediction. The standardized images are stored inresult/image
folder.
model_build.py
: This module builds the CNN model using Keras. The training and testing data is taken fromgzip
. The model is saved in the same folder. If the model exists, it is used for future recognition. If not, a new model is built.
recognition.py
: This uses the model built to recognise the characters in the images. The images and their predicted output from the model is displayed together.
- Few characters missing in segmentation, needs fixes.
- The accuracy of the model is low as of now. Needs more training.
- Use of transfer learning using models like Resnet, or ensemble methods, may give better results.