This is a pytorch implementation of CRNN, which is based on @meijieru's repository here.
The CNN + RNN + CTC model visualisation:
We applied a modified CRNN in this task. CRNN is a conventional scene text recognition method including convolutional layers, bidirectional LSTM layers, and a transcription layer in sequence.
In scanned receipts each text usually contains several words. We add the blank space between words to the alphabet for LSTM prediction and thus improve the network from single word recognition to multiple words recognition. Moreover, we double the input image width to tackle the overlap problem of long texts after max-pooling and stack one more LSTM, enhancing the accuracy per character in the training set from 62% to 83%.
- warp-ctc-pytorch
- lmdb
As is shown in the introduction image, CRNN only accepts image that has single line of word. Therefore, we must provide bounding boxes for the whole reciept image.
-
Put image under folder
./data_test/and bounding box text file under./boundingbox/, the name of image file and text file must correspond. The example test file can be found here -
Download pre-trained model from here and put the weight file under
./expr/folder -
To predict, just run
python main.py. You can change the code inside to visualise output or prepare result for task 3.
example result:
tan chay yee
81750 masai johor
sales persor : fatin
tax invoice
total inclusive gst:
invoice no : pegiv1030765
email: ng@ojcgroup.com
bill to"
date
description
address
total:
cashier
:the peak quarry works
Training a CRNN requires converting data into lmdb format.
-
Divide training data into training and validating dataset, put each portion into
./data_tain/and./data_valid. An example could be found here -
Run
create_dataset.pyto create lmdb dataset. The created dataset could be found inside./dataset -
After preparing dataset, just run:
python train.py --adadelta --trainRoot {train_path} --valRoot {val_path} --cudawith desired options
-
Trained model output will be in
./expr/

