/lstm_ctc_ocr

Use CTC + tensorflow to OCR

Primary LanguagePython

How to use

  1. run python genImg.py to generate the train images in train/, validation set in test/and the file name shall has the format of 00000001_name.png, the number of process is set to 16.
  2. cd standard or cd warpCTC
  3. run python lstm_ocr.py to training

Notice that,

Dependency

Some details

The training data:
data

Notice that, sufficient amount of data is a must, otherwise, the network cannot converge.
Some tools and parameters can be found in utils_*.py
some parameters need to be fined tune:

  • learning rate
  • decay step & decay rate (notice that, uncomment the learing rate decay part of code if it is commented)
  • image_width
  • image_height

if you want to use your own data and use pipline to read data, the height of the image shall be the same, besides, the suffix of the image shall be png or you can modify the code in utils_*.py fromtf.image.decode_png to anything you need. However, if you read all your images at one time using OpenCV(default in my code), then this is not a problem.

Result

After adding more training data The accurary can be more than 95%
accuracy
Read this blog for more details and this blog for how to use tf.nn.ctc_loss or warpCTC