These notebooks have been created by Jonathan Chung, as part of his internship as Applied Scientist @ Amazon AI, in collaboration with Thomas Delteil who built the original prototype.
The pipeline is composed of 3 steps:
- Detecting the handwritten area in a form [blog post], [jupyter notebook], [python script]
- Detecting lines of handwritten texts [blog post], [jupyter notebook], [python script]
- Recognising characters and applying a language model to correct errors. [blog post], [jupyter notebook], [python script]
The entire inference pipeline can be found in this notebook. See the pretrained models section for the pretrained models.
A recorded talk detailing the approach is available on youtube. [video]
The corresponding slides are available on slideshare. [slides]
- {deletion, insertion, substitute}_costs.txt: text files containing matrixes of weights used by the weighted edit distance (in class OcrDistanceMeasure). Files were generated with this notebook.
- handwriting_line_recognition3.params: pre-trained models for CNN-biLSTM for handwriting detection. Model was generated with this file. With the following command:
python handwriting_line_recognition.py --epochs 501 -n handwriting_line.params -g 1 -l 0.0001 -x 0.1 -y 0.1 -j 0.15 -k 0.15 -p 0.75 -o 2 -a 128
- word_segmentation.params generates word crops. It was generated with this file. With the following command:
python line_segmentation.py --min_c 0.01 --overlap_thres 0.10 --topk 150 --epoch 401
- paragraph_segmentation.params generates a region of handwritten text. It was generated with this file with the following commands:
* 1)
python paragraph_segmentation_dcnn.py -r 0.001 -e 301 -n cnn_mse.params
* 2)python paragraph_segmentation_dcnn.py -r 0.0001 -l iou -e 150 -n cnn_iou.params -f cnn_mse.params
- GoogleNews-vectors-negative300.bin.gz: a word2vec model that is used by pycontractions. This was saved here for convenience purposes.
The greedy, lexicon search, and beam search outputs present similar and reasonable predictions for the selected examples. In Figure 6, interesting examples are presented. The first line of Figure 6 show cases where the lexicon search algorithm provided fixes that corrected the words. In the top example, “tovely” (as it was written) was corrected “lovely” and “woved” was corrected to “waved”. In addition, the beam search output corrected “a” into “all”, however it missed a space between “lovely” and “things”. In the second example, “selt” was converted to “salt” with the lexicon search output. However, “selt” was erroneously converted to “self” in the beam search output. Therefore, in this example, beam search performed worse. In the third example, none of the three methods significantly provided comprehensible results. Finally, in the forth example, the lexicon search algorithm incorrectly converted “forhim” into “forum”, however the beam search algorithm correctly identified “for him”.
- To use test_iam_dataset.ipynb, create credentials.json using credentials.json.example and editing the appropriate field. The username and password can be obtained from http://www.fki.inf.unibe.ch/DBs/iamDB/iLogin/index.php.