PaddleOCR/README.md

232 lines
15 KiB
Markdown
Raw Normal View History

2020-07-17 15:49:30 +08:00
English | [简体中文](README_cn.md)
2020-07-21 15:47:14 +08:00
## Introduction
PaddleOCR aims to create rich, leading, and practical OCR tools that help users train better models and apply them into practice.
2020-07-20 20:26:02 +08:00
2020-07-17 15:49:30 +08:00
**Recent updates**
2020-08-24 20:59:52 +08:00
- 2020.8.24 Support the use of PaddleOCR through whl package installationpelease refer [PaddleOCR Package](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/doc/doc_en/whl_en.md)
2020-08-16 20:07:01 +08:00
- 2020.8.16, Release text detection algorithm [SAST](https://arxiv.org/abs/1908.05498) and text recognition algorithm [SRN](https://arxiv.org/abs/2003.12294)
2020-07-23 10:11:45 +08:00
- 2020.7.23, Release the playback and PPT of live class on BiliBili station, PaddleOCR Introduction, [address](https://aistudio.baidu.com/aistudio/course/introduce/1519)
2020-07-17 15:49:30 +08:00
- 2020.7.15, Add mobile App demo , support both iOS and Android ( based on easyedge and Paddle Lite)
2020-08-19 20:45:32 +08:00
- 2020.7.15, Improve the deployment ability, add the C + + inference , serving deployment. In addition, the benchmarks of the ultra-lightweight OCR model are provided.
2020-07-17 15:49:30 +08:00
- 2020.7.15, Add several related datasets, data annotation and synthesis tools.
- [more](./doc/doc_en/update_en.md)
2020-07-16 13:58:39 +08:00
2020-07-17 16:03:36 +08:00
## Features
2020-07-17 16:52:14 +08:00
- Ultra-lightweight OCR model, total model size is only 8.6M
2020-07-17 16:53:13 +08:00
- Single model supports Chinese/English numbers combination recognition, vertical text recognition, long text recognition
2020-07-17 15:49:30 +08:00
- Detection model DB (4.1M) + recognition model CRNN (4.5M)
- Various text detection algorithms: EAST, DB
- Various text recognition algorithms: Rosetta, CRNN, STAR-Net, RARE
2020-08-19 20:45:32 +08:00
- Support Linux, Windows, macOS and other systems.
2020-05-14 11:05:33 +08:00
2020-07-17 15:49:30 +08:00
## Visualization
2020-05-14 00:01:00 +08:00
2020-07-17 15:49:30 +08:00
![](doc/imgs_results/11.jpg)
2020-05-14 01:51:17 +08:00
2020-07-17 17:04:31 +08:00
![](doc/imgs_results/img_10.jpg)
2020-07-17 17:03:11 +08:00
2020-07-17 15:49:30 +08:00
[More visualization](./doc/doc_en/visualization_en.md)
2020-05-14 11:05:33 +08:00
2020-07-17 16:52:14 +08:00
You can also quickly experience the ultra-lightweight OCR : [Online Experience](https://www.paddlepaddle.org.cn/hub/scene/ocr)
2020-07-14 20:27:31 +08:00
2020-08-19 20:45:32 +08:00
Mobile DEMO experience (based on EasyEdge and Paddle-Lite, supports iOS and Android systems): [Sign in to the website to obtain the QR code for installing the App](https://ai.baidu.com/easyedge/app/openSource?from=paddlelite)
2020-07-17 15:49:30 +08:00
2020-08-19 20:45:32 +08:00
Also, you can scan the QR code below to install the App (**Android support only**)
2020-07-14 20:27:31 +08:00
<div align="center">
<img src="./doc/ocr-android-easyedge.png" width = "200" height = "200" />
</div>
2020-07-17 15:49:30 +08:00
- [**OCR Quick Start**](./doc/doc_en/quickstart_en.md)
2020-07-13 22:19:42 +08:00
2020-07-17 15:49:30 +08:00
<a name="Supported-Chinese-model-list"></a>
2020-07-13 22:19:42 +08:00
2020-07-17 16:52:14 +08:00
### Supported Models:
2020-05-15 22:07:18 +08:00
2020-07-17 15:49:30 +08:00
|Model Name|Description |Detection Model link|Recognition Model link| Support for space Recognition Model link|
2020-07-10 23:22:32 +08:00
|-|-|-|-|-|
2020-07-17 16:54:13 +08:00
|db_crnn_mobile|ultra-lightweight OCR model|[inference model](https://paddleocr.bj.bcebos.com/ch_models/ch_det_mv3_db_infer.tar) / [pre-trained model](https://paddleocr.bj.bcebos.com/ch_models/ch_det_mv3_db.tar)|[inference model](https://paddleocr.bj.bcebos.com/ch_models/ch_rec_mv3_crnn_infer.tar) / [pre-trained model](https://paddleocr.bj.bcebos.com/ch_models/ch_rec_mv3_crnn.tar)|[inference model](https://paddleocr.bj.bcebos.com/ch_models/ch_rec_mv3_crnn_enhance_infer.tar) / [pre-train model](https://paddleocr.bj.bcebos.com/ch_models/ch_rec_mv3_crnn_enhance.tar)
|db_crnn_server|General OCR model|[inference model](https://paddleocr.bj.bcebos.com/ch_models/ch_det_r50_vd_db_infer.tar) / [pre-trained model](https://paddleocr.bj.bcebos.com/ch_models/ch_det_r50_vd_db.tar)|[inference model](https://paddleocr.bj.bcebos.com/ch_models/ch_rec_r34_vd_crnn_infer.tar) / [pre-trained model](https://paddleocr.bj.bcebos.com/ch_models/ch_rec_r34_vd_crnn.tar)|[inference model](https://paddleocr.bj.bcebos.com/ch_models/ch_rec_r34_vd_crnn_enhance_infer.tar) / [pre-train model](https://paddleocr.bj.bcebos.com/ch_models/ch_rec_r34_vd_crnn_enhance.tar)
2020-07-17 15:49:30 +08:00
## Tutorials
- [Installation](./doc/doc_en/installation_en.md)
- [Quick Start](./doc/doc_en/quickstart_en.md)
- Algorithm introduction
- [Text Detection Algorithm](#TEXTDETECTIONALGORITHM)
- [Text Recognition Algorithm](#TEXTRECOGNITIONALGORITHM)
- [END-TO-END OCR Algorithm](#ENDENDOCRALGORITHM)
- Model training/evaluation
- [Text Detection](./doc/doc_en/detection_en.md)
- [Text Recognition](./doc/doc_en/recognition_en.md)
- [Yml Configuration](./doc/doc_en/config_en.md)
- [Tricks](./doc/doc_en/tricks_en.md)
2020-07-17 15:53:14 +08:00
- Deployment
2020-07-17 15:49:30 +08:00
- [Python Inference](./doc/doc_en/inference_en.md)
- [C++ Inference](./deploy/cpp_infer/readme_en.md)
- [Serving](./doc/doc_en/serving_en.md)
- [Mobile](./deploy/lite/readme_en.md)
- Model Quantization and Compression (coming soon)
- [Benchmark](./doc/doc_en/benchmark_en.md)
2020-07-17 15:53:14 +08:00
- Datasets
2020-07-17 15:49:30 +08:00
- [General OCR Datasets(Chinese/English)](./doc/doc_en/datasets_en.md)
- [HandWritten_OCR_Datasets(Chinese)](./doc/doc_en/handwritten_datasets_en.md)
- [Various OCR Datasets(multilingual)](./doc/doc_en/vertical_and_multilingual_datasets_en.md)
- [Data Annotation Tools](./doc/doc_en/data_annotation_en.md)
- [Data Synthesis Tools](./doc/doc_en/data_synthesis_en.md)
2020-07-12 09:20:21 +08:00
- [FAQ](#FAQ)
2020-07-17 15:49:30 +08:00
- Visualization
- [Ultra-lightweight Chinese/English OCR Visualization](#UCOCRVIS)
- [General Chinese/English OCR Visualization](#GeOCRVIS)
2020-08-19 20:45:32 +08:00
- [Chinese/English OCR Visualization (Support Space Recognition )](#SpaceOCRVIS)
2020-07-17 16:03:36 +08:00
- [Community](#Community)
- [References](./doc/doc_en/reference_en.md)
- [License](#LICENSE)
- [Contribution](#CONTRIBUTION)
2020-07-17 15:49:30 +08:00
<a name="TEXTDETECTIONALGORITHM"></a>
## Text Detection Algorithm
PaddleOCR open source text detection algorithms list:
2020-05-14 12:04:43 +08:00
- [x] EAST([paper](https://arxiv.org/abs/1704.03155))
2020-05-14 12:07:22 +08:00
- [x] DB([paper](https://arxiv.org/abs/1911.08947))
2020-08-16 19:44:07 +08:00
- [x] SAST([paper](https://arxiv.org/abs/1908.05498))(Baidu Self-Research)
2020-05-14 00:01:00 +08:00
2020-07-17 15:49:30 +08:00
On the ICDAR2015 dataset, the text detection result is as follows:
2020-05-14 00:01:00 +08:00
2020-07-17 15:49:30 +08:00
|Model|Backbone|precision|recall|Hmean|Download link|
2020-05-25 18:14:13 +08:00
|-|-|-|-|-|-|
2020-07-17 15:49:30 +08:00
|EAST|ResNet50_vd|88.18%|85.51%|86.82%|[Download link](https://paddleocr.bj.bcebos.com/det_r50_vd_east.tar)|
|EAST|MobileNetV3|81.67%|79.83%|80.74%|[Download link](https://paddleocr.bj.bcebos.com/det_mv3_east.tar)|
|DB|ResNet50_vd|83.79%|80.65%|82.19%|[Download link](https://paddleocr.bj.bcebos.com/det_r50_vd_db.tar)|
|DB|MobileNetV3|75.92%|73.18%|74.53%|[Download link](https://paddleocr.bj.bcebos.com/det_mv3_db.tar)|
2020-08-16 19:44:07 +08:00
|SAST|ResNet50_vd|92.18%|82.96%|87.33%|[Download link](https://paddleocr.bj.bcebos.com/SAST/sast_r50_vd_icdar2015.tar)|
2020-05-25 16:29:20 +08:00
2020-08-16 20:07:01 +08:00
On Total-Text dataset, the text detection result is as follows:
|Model|Backbone|precision|recall|Hmean|Download link|
|-|-|-|-|-|-|
|SAST|ResNet50_vd|88.74%|79.80%|84.03%|[Download link](https://paddleocr.bj.bcebos.com/SAST/sast_r50_vd_total_text.tar)|
**Note** Additional data, like icdar2013, icdar2017, COCO-Text, ArT, was added to the model training of SAST. Download English public dataset in organized format used by PaddleOCR from [Baidu Drive](https://pan.baidu.com/s/12cPnZcVuV1zn5DOd4mqjVw) (download code: 2bpi).
For use of [LSVT](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/doc/doc_en/datasets_en.md#1-icdar2019-lsvt) street view dataset with a total of 3w training datathe related configuration and pre-trained models for text detection task are as follows:
2020-07-17 15:49:30 +08:00
|Model|Backbone|Configuration file|Pre-trained model|
2020-06-08 16:51:05 +08:00
|-|-|-|-|
2020-07-17 16:52:14 +08:00
|ultra-lightweight OCR model|MobileNetV3|det_mv3_db.yml|[Download link](https://paddleocr.bj.bcebos.com/ch_models/ch_det_mv3_db.tar)|
|General OCR model|ResNet50_vd|det_r50_vd_db.yml|[Download link](https://paddleocr.bj.bcebos.com/ch_models/ch_det_r50_vd_db.tar)|
2020-06-08 16:51:05 +08:00
2020-07-17 15:49:30 +08:00
* Note: For the training and evaluation of the above DB model, post-processing parameters box_thresh=0.6 and unclip_ratio=1.5 need to be set. If using different datasets and different models for training, these two parameters can be adjusted for better result.
2020-05-14 00:01:00 +08:00
2020-07-17 15:49:30 +08:00
For the training guide and use of PaddleOCR text detection algorithms, please refer to the document [Text detection model training/evaluation/prediction](./doc/doc_en/detection_en.md)
2020-05-14 00:01:00 +08:00
2020-07-17 15:49:30 +08:00
<a name="TEXTRECOGNITIONALGORITHM"></a>
## Text Recognition Algorithm
2020-05-14 00:01:00 +08:00
2020-07-17 15:49:30 +08:00
PaddleOCR open-source text recognition algorithms list:
2020-05-14 12:04:43 +08:00
- [x] CRNN([paper](https://arxiv.org/abs/1507.05717))
- [x] Rosetta([paper](https://arxiv.org/abs/1910.05085))
- [x] STAR-Net([paper](http://www.bmva.org/bmvc/2016/papers/paper043/index.html))
- [x] RARE([paper](https://arxiv.org/abs/1603.03915v1))
2020-08-16 19:44:07 +08:00
- [x] SRN([paper](https://arxiv.org/abs/2003.12294))(Baidu Self-Research)
2020-05-14 00:01:00 +08:00
2020-07-17 15:49:30 +08:00
Refer to [DTRB](https://arxiv.org/abs/1904.01906), the training and evaluation result of these above text recognition (using MJSynth and SynthText for training, evaluate on IIIT, SVT, IC03, IC13, IC15, SVTP, CUTE) is as follow:
2020-05-14 00:01:00 +08:00
2020-07-17 15:49:30 +08:00
|Model|Backbone|Avg Accuracy|Module combination|Download link|
2020-05-15 19:51:49 +08:00
|-|-|-|-|-|
2020-07-17 15:49:30 +08:00
|Rosetta|Resnet34_vd|80.24%|rec_r34_vd_none_none_ctc|[Download link](https://paddleocr.bj.bcebos.com/rec_r34_vd_none_none_ctc.tar)|
|Rosetta|MobileNetV3|78.16%|rec_mv3_none_none_ctc|[Download link](https://paddleocr.bj.bcebos.com/rec_mv3_none_none_ctc.tar)|
|CRNN|Resnet34_vd|82.20%|rec_r34_vd_none_bilstm_ctc|[Download link](https://paddleocr.bj.bcebos.com/rec_r34_vd_none_bilstm_ctc.tar)|
|CRNN|MobileNetV3|79.37%|rec_mv3_none_bilstm_ctc|[Download link](https://paddleocr.bj.bcebos.com/rec_mv3_none_bilstm_ctc.tar)|
|STAR-Net|Resnet34_vd|83.93%|rec_r34_vd_tps_bilstm_ctc|[Download link](https://paddleocr.bj.bcebos.com/rec_r34_vd_tps_bilstm_ctc.tar)|
|STAR-Net|MobileNetV3|81.56%|rec_mv3_tps_bilstm_ctc|[Download link](https://paddleocr.bj.bcebos.com/rec_mv3_tps_bilstm_ctc.tar)|
|RARE|Resnet34_vd|84.90%|rec_r34_vd_tps_bilstm_attn|[Download link](https://paddleocr.bj.bcebos.com/rec_r34_vd_tps_bilstm_attn.tar)|
|RARE|MobileNetV3|83.32%|rec_mv3_tps_bilstm_attn|[Download link](https://paddleocr.bj.bcebos.com/rec_mv3_tps_bilstm_attn.tar)|
2020-08-16 19:44:07 +08:00
|SRN|Resnet50_vd_fpn|88.33%|rec_r50fpn_vd_none_srn|[Download link](https://paddleocr.bj.bcebos.com/SRN/rec_r50fpn_vd_none_srn.tar)|
**Note** SRN model uses data expansion method to expand the two training sets mentioned above, and the expanded data can be downloaded from [Baidu Drive](https://pan.baidu.com/s/1-HSZ-ZVdqBF2HaBZ5pRAKA) (download code: y3ry).
2020-08-16 19:44:07 +08:00
The average accuracy of the two-stage training in the original paper is 89.74%, and that of one stage training in paddleocr is 88.33%. Both pre-trained weights can be downloaded [here](https://paddleocr.bj.bcebos.com/SRN/rec_r50fpn_vd_none_srn.tar).
2020-07-17 15:49:30 +08:00
2020-08-19 20:45:32 +08:00
We use [LSVT](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/doc/doc_en/datasets_en.md#1-icdar2019-lsvt) dataset and cropout 30w training data from original photos by using position groundtruth and make some calibration needed. In addition, based on the LSVT corpus, 500w synthetic data is generated to train the model. The related configuration and pre-trained models are as follows:
2020-08-16 19:44:07 +08:00
2020-07-17 15:49:30 +08:00
|Model|Backbone|Configuration file|Pre-trained model|
2020-06-08 16:51:05 +08:00
|-|-|-|-|
2020-07-17 16:52:14 +08:00
|ultra-lightweight OCR model|MobileNetV3|rec_chinese_lite_train.yml|[Download link](https://paddleocr.bj.bcebos.com/ch_models/ch_rec_mv3_crnn.tar)|[inference model](https://paddleocr.bj.bcebos.com/ch_models/ch_rec_mv3_crnn_enhance_infer.tar) & [pre-trained model](https://paddleocr.bj.bcebos.com/ch_models/ch_rec_mv3_crnn_enhance.tar)|
|General OCR model|Resnet34_vd|rec_chinese_common_train.yml|[Download link](https://paddleocr.bj.bcebos.com/ch_models/ch_rec_r34_vd_crnn.tar)|[inference model](https://paddleocr.bj.bcebos.com/ch_models/ch_rec_r34_vd_crnn_enhance_infer.tar) & [pre-trained model](https://paddleocr.bj.bcebos.com/ch_models/ch_rec_r34_vd_crnn_enhance.tar)|
2020-06-08 16:51:05 +08:00
2020-07-17 15:49:30 +08:00
Please refer to the document for training guide and use of PaddleOCR text recognition algorithms [Text recognition model training/evaluation/prediction](./doc/doc_en/recognition_en.md)
2020-05-14 00:01:00 +08:00
2020-07-17 15:49:30 +08:00
<a name="ENDENDOCRALGORITHM"></a>
## END-TO-END OCR Algorithm
2020-08-19 20:45:32 +08:00
- [ ] [End2End-PSL](https://arxiv.org/abs/1909.07808)(Baidu Self-Research, coming soon)
2020-05-14 00:01:00 +08:00
2020-07-17 15:49:30 +08:00
## Visualization
2020-07-10 23:22:32 +08:00
2020-07-17 15:49:30 +08:00
<a name="UCOCRVIS"></a>
### 1.Ultra-lightweight Chinese/English OCR Visualization [more](./doc/doc_en/visualization_en.md)
2020-07-08 14:39:48 +08:00
2020-07-12 14:45:03 +08:00
<div align="center">
2020-07-15 10:37:40 +08:00
<img src="doc/imgs_results/1.jpg" width="800">
2020-07-12 14:45:03 +08:00
</div>
2020-05-14 00:01:00 +08:00
2020-07-17 15:49:30 +08:00
<a name="GeOCRVIS"></a>
### 2. General Chinese/English OCR Visualization [more](./doc/doc_en/visualization_en.md)
2020-07-12 14:45:03 +08:00
<div align="center">
<img src="doc/imgs_results/chinese_db_crnn_server/11.jpg" width="800">
</div>
2020-07-17 15:49:30 +08:00
<a name="SpaceOCRVIS"></a>
### 3.Chinese/English OCR Visualization (Space_support) [more](./doc/doc_en/visualization_en.md)
2020-07-06 21:10:49 +08:00
2020-07-12 14:45:03 +08:00
<div align="center">
<img src="doc/imgs_results/chinese_db_crnn_server/en_paper.jpg" width="800">
</div>
2020-07-06 21:10:49 +08:00
2020-06-23 19:59:35 +08:00
<a name="FAQ"></a>
2020-07-17 15:49:30 +08:00
2020-06-02 20:33:26 +08:00
## FAQ
2020-07-17 15:49:30 +08:00
1. Error when using attention-based recognition model: KeyError: 'predict'
The inference of recognition model based on attention loss is still being debugged. For Chinese text recognition, it is recommended to choose the recognition model based on CTC loss first. In practice, it is also found that the recognition model based on attention loss is not as effective as the one based on CTC loss.
2. About inference speed
When there are a lot of texts in the picture, the prediction time will increase. You can use `--rec_batch_num` to set a smaller prediction batch size. The default value is 30, which can be changed to 10 or other values.
3. Service deployment and mobile deployment
2020-06-05 13:21:56 +08:00
2020-07-17 15:49:30 +08:00
It is expected that the service deployment based on Serving and the mobile deployment based on Paddle Lite will be released successively in mid-to-late June. Stay tuned for more updates.
2020-06-03 11:23:55 +08:00
2020-07-17 15:49:30 +08:00
4. Release time of self-developed algorithm
2020-06-05 13:21:56 +08:00
2020-07-17 15:49:30 +08:00
Baidu Self-developed algorithms such as SAST, SRN and end2end PSL will be released in June or July. Please be patient.
2020-06-03 11:23:55 +08:00
2020-07-17 15:49:30 +08:00
[more](./doc/doc_en/FAQ_en.md)
2020-06-02 20:33:26 +08:00
2020-07-17 15:49:30 +08:00
<a name="Community"></a>
2020-07-17 16:03:36 +08:00
## Community
2020-07-17 15:49:30 +08:00
Scan the QR code below with your wechat and completing the questionnaire, you can access to offical technical exchange group.
2020-07-14 11:40:31 +08:00
2020-07-14 10:21:23 +08:00
<div align="center">
<img src="./doc/joinus.jpg" width = "200" height = "200" />
</div>
2020-06-23 17:39:50 +08:00
2020-07-17 15:49:30 +08:00
<a name="LICENSE"></a>
2020-07-17 16:03:36 +08:00
## License
2020-07-17 15:49:30 +08:00
This project is released under <a href="https://github.com/PaddlePaddle/PaddleOCR/blob/master/LICENSE">Apache 2.0 license</a>
2020-05-14 01:58:00 +08:00
2020-07-17 15:49:30 +08:00
<a name="CONTRIBUTION"></a>
2020-07-17 16:03:36 +08:00
## Contribution
2020-07-17 15:49:30 +08:00
We welcome all the contributions to PaddleOCR and appreciate for your feedback very much.
2020-06-10 13:23:58 +08:00
2020-08-20 10:35:41 +08:00
- Many thanks to [Khanh Tran](https://github.com/xxxpsyduck) and [Karl Horky](https://github.com/karlhorky) for contributing and revising the English documentation.
2020-07-17 15:49:30 +08:00
- Many thanks to [zhangxin](https://github.com/ZhangXinNan) for contributing the new visualize function、add .gitgnore and discard set PYTHONPATH manually.
- Many thanks to [lyl120117](https://github.com/lyl120117) for contributing the code for printing the network structure.
- Thanks [xiangyubo](https://github.com/xiangyubo) for contributing the handwritten Chinese OCR datasets.
- Thanks [authorfu](https://github.com/authorfu) for contributing Android demo and [xiadeye](https://github.com/xiadeye) contributing iOS demo, respectively.
2020-07-29 23:03:37 +08:00
- Thanks [BeyondYourself](https://github.com/BeyondYourself) for contributing many great suggestions and simplifying part of the code style.
2020-08-17 19:09:13 +08:00
- Thanks [tangmq](https://gitee.com/tangmq) for contributing Dockerized deployment services to PaddleOCR and supporting the rapid release of callable Restful API services.