/ocr_pytorch

A pytorch-lightning implementation of CTPN for text detection and recognition

Primary LanguagePythonMIT LicenseMIT

lightning_text_detection

Applying pytorch-lightning to CTPN and CRNN Code heavily borrowed from courao

Text detection is based CTPN and text recognition is based CRNN.
More detection and recognition methods will be supported!

Working on implementing CRAFT And Transformer_STR

Pull requests welcome!

Prerequisite

  • python-3.6+
  • pytorch-lightning-1.4.1
  • opencv-4.5.2.52
  • numpy-1.21.1
  • Pillow-8.2.0
  • pathed-1.1.00

Detection

Detection is based on CTPN, some codes are borrowed from pytorch_ctpn

Recognition

Recognition is based on CRNN, some codes are borrowed from crnn.pytorch

Test

Download pretrained models from Baidu Netdisk (extract code: u2ff) or Google Driver and put these files into checkpoints. Then run

python3 demo.py

The image files in ./test_images will be tested for text detection and recognition, the results will be stored in ./test_result.

If you want to test a single image, run

python3 test_one.py [filename]

Train

Training codes are placed into train_code directory.
Train CTPN
Train CRNN

Licence

MIT License