This software implements the Convolutional Recurrent Neural Network (CRNN) in pytorch.
Origin software could be found in crnn-pytorch
- Ubuntu18.04
- Python3.6.5
- torch==1.5.0
- torchvision==0.6.0
- GTX 1080 - Nvidia
-
Download a pretrained model from Baidu Cloud (extraction code:
9wdt
) -
Run demo
python demo.py -m path/to/model -i data/demo.jpg
-
Expected output
['YY3333AA220011------00---22233---0--0011'] => ['Y3A201023001']
- Variable length
It support variable length.
- Chinese support
I change it to `binary mode` when reading the key and value, so you can use it to do Chinese OCR.
- Change CTCLoss from [warp-ctc](https://github.com/SeanNaren/warp-ctc) to [torch.nn.CTCLoss](https://pytorch.org/docs/stable/nn.html#ctcloss)
I change the loss function to `torch.nn.CTCLoss` .
- Variable image_height
At present, image_height=32, it is fixed.Now it can be set as 64 or lager.
- Bug fixed and no lmdb
Bug has been fixed.
-
Put your images in
./dataset/image_crnn
folder and organize your images in the following format:label_number.jpg
For example
- English
hi_0.jpg hello_1.jpg English_2.jpg English_3.jpg E n g l i s h_4.jpg...
- Chinese
一身转战_0.jpg 三千里_1.jpg 一剑曾当百万师_2.jpg 一剑曾当百万师_3.jpg 一 剑 曾 当 百 万 师_3.jpg ...
So you can see, the number is used to distinguish the same label.
-
Run the
make_list.py
intool
folder bypython tool/make_list.py
It will be create
train.txt
andeval.txt
indataset
folder. -
The advantage of the folder mode is that it's convenient! But due to some illegal character can't be in the path
So the disadvantage of the folder mode is that it's labels are limited.
-
Change parameters
Your can see the
config.py
in detail.
Run train.py
by
python train.py