Pytorch使用CRNN+CTCLoss实现OCR系统

Song2887 次浏览0个评论2019年02月02日

卷积递归神经网络

此项目使用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>

四、依赖

五、相关文章

项目地址:BelBES/crnn-pytorch

提交评论

请登录后评论

用户评论

  • Song Song 2019-03-21 09:09:01
    123
    0 赞 0 条评论 回复
    评论
    查看更多评论!

更多相关好文

    当前暂无更多相关好文推荐...