An implementation of CRNN algorithm using Pytorch framework
The most typical CTC algorithm is CRNN (Convolutional Recurrent Neural Network), which introduces the bidirectional LSTM (Long Short-Term Memory) to enhance the context modeling. Experiments have proved that the bidirectional LSTM module can effectively extract the contextual information of the picture, finally enter the output feature sequence into the CTC module, and decode the sequence result.
Environment The dependencies are listed in `requirements.txt`. Please install and follow the command below:pip install -r requirements.txtYou can download and use ICDAR2015 or MJSynth dataset for the training model.
After that,
- Put the data folder under the
datasetsdirectory - Setup config file for each dataset in
src/__init__.py: replaceCFG_PATHaugment bysrc/config/rec_lmdb.ymlorsrc/config/rec_icdar15.yml
Before training, please modify configurations in src/config/rec_lmdb.yml or src/config/rec_icdar15.yml
python -m src.trainTo train the model with PyTorch lightning
python -m src.pl_modules.pl_trainpython -m src.evalpython -m src.exports.exporter --export_format <torchscript/onnx/paddle/tensorrt> --device cudapython -m src.predict --img_path <path_to_image_file> --export_format <torchscript/onnx/paddle/tensorrt> --device cudaExample:
python -m src.predict --image_path images/tuongan.png --export_format pt --device cuda
>> tuongantensorboard --logdir debugs/tensorboard| Train Loss | Valid Loss | Valid Acc |
|---|---|---|
| Export format | Inference time | ACC with CTCLoss | ACC with Focal CTCLoss |
|---|---|---|---|
| Pytorch | 0.0008s | 95.47 | 96 |
| TorchScript | 0.0007s | - | - |
| ONNX | 0.001s | - | - |
| TensorRT | 0.0001s | - | - |
| Paddle | 0.01s | - | - |




