|
1 |
| -# PaddleOCR2Pytorch |
2 |
| -Converted from [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR) |
| 1 | +# [PaddleOCR2Pytorch](https://github.com/frotms/PaddleOCR2Pytorch) |
| 2 | + |
| 3 | +## 简介 |
| 4 | + |
| 5 | +**”真·白嫖“**[PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR) |
| 6 | + |
| 7 | +## 注意 |
| 8 | + |
| 9 | +`PytorchOCR`由`PaddleOCR-2.0rc1+`动态图版本移植。 |
| 10 | + |
| 11 | +## 特性 |
| 12 | + |
| 13 | +高质量推理模型,准确的识别效果 |
| 14 | + |
| 15 | +- 超轻量ptocr_mobile移动端系列 |
| 16 | +- 通用ptocr_server系列 |
| 17 | +- 支持中英文数字组合识别、竖排文本识别、长文本识别 |
| 18 | + |
| 19 | +## 模型列表 |
| 20 | + |
| 21 | +`.pth`模型下载链接:https://pan.baidu.com/s/1r1DELT8BlgxeOP2RqREJEg 提取码:6clx |
| 22 | + |
| 23 | +### 检测模型 |
| 24 | + |
| 25 | +| 模型名称 | PaddleOCR对应模型 | |
| 26 | +| ------------------------------------ | ------------------------------------------------------------ | |
| 27 | +| `ch_ptocr_mobile_v2.0_det_infer.pth` | ch_ppocr_mobile_v2.0_det: [推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_infer.tar) / [训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_train.tar) | |
| 28 | +| `ch_ptocr_server_v2.0_det_infer.pth` | ch_ppocr_server_v2.0_det: [推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_det_infer.tar) / [训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_det_train.tar) | |
| 29 | + |
| 30 | +### 识别模型 |
| 31 | + |
| 32 | +| 模型名称 | PaddleOCR对应模型 | |
| 33 | +| ------------------------------------ | ------------------------------------------------------------ | |
| 34 | +| `ch_ptocr_mobile_v2.0_rec_infer.pth` | ch_ppocr_mobile_v2.0_rec: [推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_infer.tar) / [训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_train.tar) | |
| 35 | +| `ch_ptocr_server_v2.0_rec_infer.pth` | ch_ppocr_server_v2.0_rec: [推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_rec_infer.tar) / [训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_server_v2.0_rec_train.tar) | |
| 36 | + |
| 37 | +### 分类模型 |
| 38 | + |
| 39 | +| 模型名称 | PaddleOCR对应模型 | |
| 40 | +| ------------------------------------ | ------------------------------------------------------------ | |
| 41 | +| `ch_ptocr_mobile_v2.0_cls_infer.pth` | [推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_infer.tar) / [训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_train.tar) | |
| 42 | + |
| 43 | +## 效果展示 |
| 44 | + |
| 45 | +- 中文模型 |
| 46 | + |
| 47 | +<div align="center"> |
| 48 | + <img src="./doc/imgs_results/ch_ptocr_mobile_v2.0/11.jpg" width="800"> |
| 49 | + <img src="./doc/imgs_results/ch_ptocr_mobile_v2.0/00015504.jpg" width="800"> |
| 50 | + <img src="./doc/imgs_results/ch_ptocr_mobile_v2.0/00056221.jpg" width="800"> |
| 51 | + <img src="./doc/imgs_results/ch_ptocr_mobile_v2.0/1.jpg" width="800"> |
| 52 | +</div> |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | +## Pipeline |
| 57 | + |
| 58 | +<div align="center"> |
| 59 | + <img src="./doc/framework.png" width="800"> |
| 60 | +</div> |
| 61 | + |
| 62 | +PP-OCR是一个实用的超轻量OCR系统。主要由DB文本检测、检测框矫正和CRNN文本识别三部分组成。该系统从骨干网络选择和调整、预测头部的设计、数据增强、学习率变换策略、正则化参数选择、预训练模型使用以及模型自动裁剪量化8个方面,采用19个有效策略,对各个模块的模型进行效果调优和瘦身,最终得到整体大小为3.5M的超轻量中英文OCR和2.8M的英文数字OCR。更多细节请参考PP-OCR技术方案 https://arxiv.org/abs/2009.09941 。其中FPGM裁剪器和PACT量化的实现可以参考[PaddleSlim](https://github.com/PaddlePaddle/PaddleSlim)。 |
| 63 | + |
| 64 | +## 推理 |
| 65 | + |
| 66 | +### 环境 |
| 67 | + |
| 68 | +``` |
| 69 | +shapely |
| 70 | +numpy |
| 71 | +pillow |
| 72 | +pyclipper |
| 73 | +opencv-python <= 4.2.0.32 |
| 74 | +pytorch |
| 75 | +``` |
| 76 | + |
| 77 | +### 中文检测模型推理 |
| 78 | + |
| 79 | +``` |
| 80 | +python3 ./tools/infer/predict_det.py --image_dir ./doc/imgs --model_path your_det_pth_path.pth |
| 81 | +``` |
| 82 | + |
| 83 | +### 中文识别模型推理 |
| 84 | + |
| 85 | +``` |
| 86 | +python3 ./tools/infer/predict_rec.py --image_dir ./doc/imgs_words --model_path your_rec_pth_path.pth |
| 87 | +``` |
| 88 | + |
| 89 | +### 中文方向分类模型推理 |
| 90 | + |
| 91 | +``` |
| 92 | +python3 ./tools/infer/predict_cls.py --image_dir ./doc/imgs_words --model_path your_cls_pth_path.pth |
| 93 | +``` |
| 94 | + |
| 95 | +### 文本检测、方向分类和文字识别串联推理 |
| 96 | + |
| 97 | +#### 使用方向分类器 |
| 98 | + |
| 99 | +``` |
| 100 | +python3 ./tools/infer/predict_system.py --image_dir ./doc/imgs --det_model_path your_det_pth_path.pth --rec_model_path your_rec_pth_path.pth --use_angle_cls --cls_model_path your_cls_pth_path.pth |
| 101 | +``` |
| 102 | + |
| 103 | +#### 不适用方向分类器 |
| 104 | + |
| 105 | +``` |
| 106 | +python3 ./tools/infer/predict_system.py --image_dir ./doc/imgs --det_model_path your_det_pth_path.pth --rec_model_path your_rec_pth_path.pth |
| 107 | +``` |
| 108 | + |
| 109 | +## PaddleOCR2Pytorch |
| 110 | + |
| 111 | +### 环境 |
| 112 | + |
| 113 | +``` |
| 114 | +shapely |
| 115 | +numpy |
| 116 | +pillow |
| 117 | +pyclipper |
| 118 | +opencv-python <= 4.2.0.32 |
| 119 | +pytorch |
| 120 | +paddlepaddle==2.0rc1 |
| 121 | +``` |
| 122 | + |
| 123 | +### 模型转换 |
| 124 | + |
| 125 | +模型路径详见**PaddleOCR对应模型**或者**百度网盘链接**:https://pan.baidu.com/s/1getAprT2l_JqwhjwML0g9g |
| 126 | +提取码:lmv7 |
| 127 | + |
| 128 | +``` |
| 129 | +python3 ./converter/ch_ppocr_mobile_v2.0_det_converter.py --src_model_path paddle_ch_ppocr_mobile_v2.0_det_dir |
| 130 | +
|
| 131 | +python3 ./converter/ch_ppocr_server_v2.0_det_converter.py --src_model_path paddle_ch_ppocr_server_v2.0_det_dir |
| 132 | +
|
| 133 | +python3 ./converter/ch_ppocr_mobile_v2.0_rec_converter.py --src_model_path paddle_ch_ppocr_mobile_v2.0_rec_dir |
| 134 | +
|
| 135 | +python3 ./converter/ch_ppocr_server_v2.0_rec_converter.py --src_model_path paddle_ch_ppocr_server_v2.0_rec_dir |
| 136 | +
|
| 137 | +python3 ./converter/ch_ppocr_mobile_v2.0_cls_converter.py --src_model_path paddle_ch_ppocr_mobile_v2.0_cls_dir |
| 138 | +``` |
| 139 | + |
| 140 | +## [FAQ](https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.0-rc1-0/doc/doc_ch/FAQ.md) |
| 141 | + |
| 142 | +## 参考 |
| 143 | + |
| 144 | +- [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR) |
| 145 | +- [PytorchOCR](https://github.com/WenmuZhou/PytorchOCR) |
| 146 | +- [Paddle](https://github.com/PaddlePaddle) |
| 147 | +- [Pytorch](https://pytorch.org/) |
| 148 | +- [https://github.com/frotms/image_classification_pytorch](https://github.com/frotms/image_classification_pytorch) |
| 149 | +- [https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.0-rc1-0/doc/doc_ch/models_list.md](https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.0-rc1-0/doc/doc_ch/models_list.md) |
0 commit comments