卷积递归神经网络
此项目使用CNN + RNN + CTCLoss
实现OCR
系统,灵感来自CRNN
网络。
一、用法
python ./train.py --help
二、演示
1、使用TestDataset
数据生成器训练简单的OCR
。训练60-100
次。
python train.py --test-init True --test-epoch 10 --output-dir <path_to_folder_with_snapshots>
2、运行test来训练可视化模型。
python test.py --snapshot <path_to_folder_with_snapshots>/crnn_resnet18_10_best --visualize True
三、训练自定义数据集
1、创建数据集
- 数据集的结构:
<root_dataset_dir>
---- data
-------- <img_filename_0>
...
-------- <img_filename_1>
---- desc.json
- desc.json的结构:
{ "abc": <symbols_in_aphabet>, "train": [ { "text": <text_on_image> "name": <img_filename> }, ... { "text": <text_on_image> "name": <img_filename> } ], "test": [ { "text": <text_on_image> "name": <img_filename> }, ... { "text": <text_on_image> "name": <img_filename> } ] }
2、使用自定义数据集训练简单的OCR。
python train.pt --test-init True --test-epoch 10 --output-dir <path_to_folder_with_snapshots> --data-path <path_to_custom_dataset>
3、运行test来训练可视化模型。
python test.py --snapshot <path_to_folder_with_snapshots>/crnn_resnet18_10_best --visualize True --data-path <path_to_custom_dataset>
四、依赖
- pytorch 0.3.0 +
- warp-ctc
五、相关文章
项目地址:BelBES/crnn-pytorch
prtorch参考手册 https://ptorch.com/docs/8/torch-nn