Skip to content

Commit 13d503c

Browse files
horchamhorcham
andauthored
* Add Doc * Add Doc * update index.md --------- Co-authored-by: horcham <zhanghongquan15@huawei.com>
1 parent e42dae0 commit 13d503c

File tree

5 files changed

+14
-563
lines changed

5 files changed

+14
-563
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ You can do MindSpore Lite inference in MindOCR using **MindOCR models** or **Thi
151151
- Inference with MindSpore Lite
152152
- [Python/C++ Inference on Ascend 310](docs/en/inference/inference_tutorial.md)
153153
- [MindOCR Models Offline Inference - Quick Start](docs/en/inference/inference_quickstart.md)
154-
- [Third-party Models Offline Inference - Quick Start](docs/en/inference/inference_thirdparty_quickstart.md).
154+
- [Third-party Models Offline Inference - Quick Start](docs/en/inference/inference_thirdparty_quickstart.md)
155+
- [Model Conversion](docs/en/inference/convert_tutorial.md)
155156
- Developer Guides
156157
- [Customize Dataset](mindocr/data/README.md)
157158
- [Customize Data Transformation](mindocr/data/transforms/README.md)

docs/cn/index.md

Lines changed: 2 additions & 276 deletions
Original file line numberDiff line numberDiff line change
@@ -1,282 +1,8 @@
11
---
22
hide:
33
- navigation
4+
- toc
45
---
56

6-
<div align="center" markdown>
77

8-
# MindOCR
9-
10-
[![CI](https://github.com/mindspore-lab/mindocr/actions/workflows/ci.yml/badge.svg)](https://github.com/mindspore-lab/mindocr/actions/workflows/ci.yml)
11-
[![license](https://img.shields.io/github/license/mindspore-lab/mindocr.svg)](https://github.com/mindspore-lab/mindocr/blob/main/LICENSE)
12-
[![open issues](https://img.shields.io/github/issues/mindspore-lab/mindocr)](https://github.com/mindspore-lab/mindocr/issues)
13-
[![PRs](https://img.shields.io/badge/PRs-welcome-pink.svg)](https://github.com/mindspore-lab/mindocr/pulls)
14-
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
15-
16-
</div>
17-
18-
## 简介
19-
MindOCR是一个基于[MindSpore](https://www.mindspore.cn/en) 框架开发的OCR开源工具箱,集成系列主流文字检测识别的算法、模型,并提供易用的训练和推理工具,可以帮助用户快速开发和应用业界SoTA文本检测、文本识别模型,如DBNet/DBNet++和CRNN/SVTR,满足图像文档理解的需求。
20-
21-
22-
<details open markdown>
23-
<summary> 主要特性 </summary>
24-
25-
- **模块化设计**: MindOCR将OCR任务解耦成多个可配置模块,用户只需修改几行代码,就可以轻松地在定制化的数据和模型上配置训练、评估的全流程;
26-
- **高性能**: MindOCR提供的预训练权重和训练方法可以使其达到OCR任务上具有竞争力的表现;
27-
- **易用性**: MindOCR提供易用工具帮助在真实世界数据中进行文本的检测和识别。
28-
</details>
29-
30-
31-
## 安装教程
32-
33-
#### MindSpore相关环境准备
34-
35-
MindOCR基于MindSpore AI框架(支持CPU/GPU/NPU)开发,并适配以下框架版本。安装方式请参见下方的安装链接。
36-
37-
- mindspore >= 1.9 (ABINet 需要 mindspore >= 2.0) [[安装](https://www.mindspore.cn/install)]
38-
- python >= 3.7
39-
- openmpi 4.0.3 (for distributed training/evaluation) [[安装](https://www.open-mpi.org/software/ompi/v4.0/)]
40-
- mindspore lite (for inference) [[安装](inference/environment.md)]
41-
42-
#### 包依赖
43-
44-
```shell
45-
pip install -r requirements.txt
46-
```
47-
**提示:**
48-
49-
#### 通过源文件安装(推荐)
50-
51-
```shell
52-
git clone https://github.com/mindspore-lab/mindocr.git
53-
cd mindocr
54-
pip install -e .
55-
```
56-
> 使用 `-e` 代表可编辑模式,可以帮助解决潜在的模块导入问题。
57-
58-
#### 通过PyPI安装
59-
```shell
60-
pip install mindocr
61-
```
62-
63-
>由于此项目正在积极开发中,从PyPI安装的版本目前已过期,我们将很快更新,敬请期待。
64-
65-
## 快速开始
66-
67-
### 1. 文字检测和识别示例
68-
69-
安装完MindOCR后,我们就很方便地进行任意图像的文本检测和识别,如下。
70-
71-
```shell
72-
python tools/infer/text/predict_system.py --image_dir {path_to_img or dir_to_imgs} \
73-
--det_algorithm DB++ \
74-
--rec_algorithm CRNN
75-
```
76-
77-
运行结束后,结果将被默认保存在`./inference_results`路径,可视化结果如下:
78-
<p align="center">
79-
<img src="https://github.com/SamitHuang/mindocr-1/assets/8156835/c1f53970-8618-4039-994f-9f6dc1eee1dd" width=600 />
80-
</p>
81-
<p align="center">
82-
<em> 文本检测、识别结果可视化 </em>
83-
</p>
84-
85-
可以看到图像中的文字块均被检测出来并正确识别。更详细的用法介绍,请参考推理[教程](#_7)
86-
87-
### 2. 模型训练与评估-快速指南
88-
89-
使用`tools/train.py`脚本可以很容易地训练OCR模型,该脚本可支持文本检测和识别模型训练。
90-
```shell
91-
python tools/train.py --config {path/to/model_config.yaml}
92-
```
93-
`--config` 参数用于指定yaml文件的路径,该文件定义要训练的模型和训练策略,包括数据处理流程、优化器、学习率调度器等。
94-
95-
MindOCR在`configs`文件夹中提供系列SoTA的OCR模型及其训练策略,用户可以快速将其适配到自己的任务或数据集上,参考例子如下
96-
97-
```shell
98-
# train text detection model DBNet++ on icdar15 dataset
99-
python tools/train.py --config configs/det/dbnet/db++_r50_icdar15.yaml
100-
```
101-
```shell
102-
# train text recognition model CRNN on icdar15 dataset
103-
python tools/train.py --config configs/rec/crnn/crnn_icdar15.yaml
104-
```
105-
106-
类似的,使用`tools/eval.py` 脚本可以很容易地评估已训练好的模型,如下所示:
107-
```shell
108-
python tools/eval.py \
109-
--config {path/to/model_config.yaml} \
110-
--opt eval.dataset_root={path/to/your_dataset} eval.ckpt_load_path={path/to/ckpt_file}
111-
```
112-
113-
更多使用方法,请参考[使用教程](#_7)中的模型训练章节。
114-
115-
### 3. 模型推理-快速指南
116-
117-
你可以在MindOCR中使用MindSpore Lite对MindOCR原生模型或第三方模型(如PaddleOCR、MMOCR等)进行推理。
118-
请见[MindOCR原生模型推理-快速开始](inference/inference_quickstart.md)[第三方模型推理-快速开始](inference/inference_thirdparty_quickstart.md)
119-
120-
## 使用教程
121-
122-
- 数据集
123-
- [数据集准备](datasets/converters.md)
124-
- [数据增强策略](tutorials/transform_tutorial.md)
125-
- 模型训练
126-
- [Yaml配置文件](tutorials/yaml_configuration.md)
127-
- [文本检测](tutorials/training_detection_custom_dataset.md)
128-
- [文本识别](tutorials/training_recognition_custom_dataset.md)
129-
- [分布式训练](tutorials/distribute_train.md)
130-
- [进阶技巧:梯度累积,EMA,断点续训等](tutorials/advanced_train.md)
131-
- 推理与部署
132-
- [基于Python/C++和昇腾310的OCR推理](inference/inference_tutorial.md)
133-
- [基于Python的OCR在线推理](mkdocs/online_inference.md)
134-
- 开发者指南
135-
- [如何自定义数据集](mkdocs/customize_dataset.md)
136-
- [如何自定义数据增强方法](mkdocs/customize_data_transform.md)
137-
- [如何创建新的OCR模型](mkdocs/customize_model.md)
138-
- [如何自定义后处理方法](mkdocs/customize_postprocess.md)
139-
140-
## 模型列表
141-
142-
<details open markdown>
143-
<summary>文本检测</summary>
144-
145-
- [x] [DBNet](https://github.com/mindspore-lab/mindocr/blob/main/configs/det/dbnet/README_CN.md) (AAAI'2020)
146-
- [x] [DBNet++](https://github.com/mindspore-lab/mindocr/blob/main/configs/det/dbnet/README_CN.md) (TPAMI'2022)
147-
- [x] [PSENet](https://github.com/mindspore-lab/mindocr/blob/main/configs/det/psenet/README_CN.md) (CVPR'2019)
148-
- [x] [EAST](https://github.com/mindspore-lab/mindocr/blob/main/configs/det/east/README_CN.md)(CVPR'2017)
149-
- [x] [FCENet](https://github.com/mindspore-lab/mindocr/blob/main/configs/det/fcenet/README_CN.md) (CVPR'2021)
150-
</details>
151-
152-
<details open markdown>
153-
<summary>文本识别</summary>
154-
155-
- [x] [CRNN](https://github.com/mindspore-lab/mindocr/blob/main/configs/rec/crnn/README_CN.md) (TPAMI'2016)
156-
- [x] [CRNN-Seq2Seq/RARE](https://github.com/mindspore-lab/mindocr/blob/main/configs/rec/rare/README_CN.md) (CVPR'2016)
157-
- [x] [SVTR](https://github.com/mindspore-lab/mindocr/blob/main/configs/rec/svtr/README_CN.md) (IJCAI'2022)
158-
- [x] [MASTER](https://github.com/mindspore-lab/mindocr/blob/main/configs/rec/master/README_CN.md) (PR'2019)
159-
- [x] [VISIONLAN](https://github.com/mindspore-lab/mindocr/blob/main/configs/rec/visionlan/README_CN.md) (ICCV'2021)
160-
- [x] [RobustScanner](https://github.com/mindspore-lab/mindocr/blob/main/configs/rec/robustscanner/README_CN.md) (ECCV'2020)
161-
- [x] [ABINet](https://github.com/mindspore-lab/mindocr/blob/main/configs/rec/abinet/README_CN.md) (CVPR'2021)
162-
</details>
163-
164-
关于以上模型的具体训练方法和结果,请参见[configs](https://github.com/mindspore-lab/mindocr/blob/main/configs)下各模型子目录的readme文档。
165-
166-
关于[MindSpore Lite](https://www.mindspore.cn/lite)[ACL](https://www.hiascend.com/document/detail/zh/canncommercial/63RC1/inferapplicationdev/aclcppdevg/aclcppdevg_000004.html)模型推理的支持列表,
167-
请参见[MindOCR支持模型列表](inference/inference_quickstart.md)[第三方模型推理支持列表](inference/inference_thirdparty_quickstart.md)(如PaddleOCR、MMOCR等)。
168-
169-
## 数据集列表
170-
171-
MindOCR提供了[数据格式转换工具](datasets/converters.md) ,以支持不同格式的OCR数据集,支持用户自定义的数据集。
172-
当前已在模型训练评估中验证过的公开OCR数据集如下。
173-
174-
<details open markdown>
175-
<summary>通用OCR数据集</summary>
176-
177-
- [Born-Digital Images](https://rrc.cvc.uab.es/?ch=1) [[download](datasets/borndigital.md)]
178-
- [CASIA-10K](http://www.nlpr.ia.ac.cn/pal/CASIA10K.html) [[download](datasets/casia10k.md)]
179-
- [CCPD](https://github.com/detectRecog/CCPD) [[download](datasets/ccpd.md)]
180-
- [Chinese Text Recognition Benchmark](https://github.com/FudanVI/benchmarking-chinese-text-recognition) [[paper](https://arxiv.org/abs/2112.15093)] [[download](datasets/chinese_text_recognition.md)]
181-
- [COCO-Text](https://rrc.cvc.uab.es/?ch=5) [[download](datasets/cocotext.md)]
182-
- [CTW](https://ctwdataset.github.io/) [[download](datasets/ctw.md)]
183-
- [ICDAR2015](https://rrc.cvc.uab.es/?ch=4) [[paper](https://rrc.cvc.uab.es/files/short_rrc_2015.pdf)] [[download](datasets/icdar2015.md)]
184-
- [ICDAR2019 ArT](https://rrc.cvc.uab.es/?ch=14) [[download](datasets/ic19_art.md)]
185-
- [LSVT](https://rrc.cvc.uab.es/?ch=16) [[download](datasets/lsvt.md)]
186-
- [MLT2017](https://rrc.cvc.uab.es/?ch=8) [[paper](https://ieeexplore.ieee.org/abstract/document/8270168)] [[download](datasets/mlt2017.md)]
187-
- [MSRA-TD500](http://www.iapr-tc11.org/mediawiki/index.php/MSRA_Text_Detection_500_Database_(MSRA-TD500)) [[paper](https://ieeexplore.ieee.org/abstract/document/6247787)] [[download](datasets/td500.md)]
188-
- [MTWI-2018](https://tianchi.aliyun.com/competition/entrance/231651/introduction) [[download](datasets/mtwi2018.md)]
189-
- [RCTW-17](https://rctw.vlrlab.net/) [[download](datasets/rctw17.md)]
190-
- [ReCTS](https://rrc.cvc.uab.es/?ch=12) [[download](datasets/rects.md)]
191-
- [SCUT-CTW1500](https://github.com/Yuliang-Liu/Curve-Text-Detector) [[paper](https://www.sciencedirect.com/science/article/pii/S0031320319300664)] [[download](datasets/ctw1500.md)]
192-
- [SROIE](https://rrc.cvc.uab.es/?ch=13) [[download](datasets/sroie.md)]
193-
- [SVT](http://www.iapr-tc11.org/mediawiki/index.php/The_Street_View_Text_Dataset) [[download](datasets/svt.md)]
194-
- [SynText150k](https://github.com/aim-uofa/AdelaiDet) [[paper](https://arxiv.org/abs/2002.10200)] [[download](datasets/syntext150k.md)]
195-
- [SynthText](https://www.robots.ox.ac.uk/~vgg/data/scenetext/) [[paper](https://www.robots.ox.ac.uk/~vgg/publications/2016/Gupta16/)] [[download](datasets/synthtext.md)]
196-
- [TextOCR](https://textvqa.org/textocr/) [[download](datasets/textocr.md)]
197-
- [Total-Text](https://github.com/cs-chan/Total-Text-Dataset/tree/master/Dataset) [[paper](https://arxiv.org/abs/1710.10400)] [[download](datasets/totaltext.md)]
198-
</details>
199-
200-
我们会在更多的数据集上进行模型训练和验证。该列表将持续更新。
201-
202-
## 重要信息
203-
204-
### 更新日志
205-
206-
- 2023/06/07
207-
1. 增加新模型
208-
- 文本检测[PSENet](https://github.com/mindspore-lab/mindocr/blob/main/configs/det/psenet)
209-
- 文本检测[EAST](https://github.com/mindspore-lab/mindocr/blob/main/configs/det/east)
210-
- 文本识别[SVTR](https://github.com/mindspore-lab/mindocr/blob/main/configs/rec/svtr)
211-
2. 添加更多基准数据集及其结果
212-
- [totaltext](datasets/totaltext.md)
213-
- [mlt2017](datasets/mlt2017.md)
214-
- [chinese_text_recognition](datasets/chinese_text_recognition.md)
215-
3. 增加断点续训(resume training)功能,可在训练意外中断时使用。如需使用,请在配置文件中`model`字段下增加`resume`参数,允许传入具体路径`resume: /path/to/train_resume.ckpt`或者通过设置`resume: True`来加载在ckpt_save_dir下保存的trian_resume.ckpt
216-
4. 改进检测模块的后处理部分:默认情况下,将检测到的文本多边形重新缩放到原始图像空间,可以通过在`eval.dataset.output_columns`列表中增加"shape_list"实现。
217-
5. 重构在线推理以支持更多模型,详情请参见[README.md](mkdocs/online_inference.md)
218-
219-
- 2023/05/15
220-
1. 增加新模型
221-
- 文本检测[DBNet++](https://github.com/mindspore-lab/mindocr/blob/main/configs/det/dbnet)
222-
- 文本识别[CRNN-Seq2Seq](https://github.com/mindspore-lab/mindocr/blob/main/configs/rec/rare)
223-
- 在SynthText数据集上预训练的[DBNet](https://download.mindspore.cn/toolkits/mindocr/dbnet/dbnet_resnet50_synthtext-40655acb.ckpt)
224-
2. 添加更多基准数据集及其结果
225-
- [SynthText](datasets/synthtext.md), [MSRA-TD500](datasets/td500.md), [CTW1500](datasets/ctw1500.md)
226-
- DBNet的更多基准结果可以[在此找到](https://github.com/mindspore-lab/mindocr/blob/main/configs/det/dbnet/README_CN.md).
227-
3. 添加用于保存前k个checkpoint的checkpoint manager并改进日志。
228-
4. Python推理代码重构。
229-
5. Bug修复:对大型数据集使用平均损失meter,在AMP训练中对ctcloss禁用`pred_cast_fp32`,修复存在无效多边形的错误。
230-
231-
- 2023/05/04
232-
1. 支持加载自定义的预训练checkpoint, 通过在yaml配置中将`model-pretrained`设置为checkpoint url或本地路径来使用。
233-
2. 支持设置执行包括旋转和翻转在内的数据增强操作的概率。
234-
3. 为模型训练添加EMA功能,可以通过在yaml配置中设置`train-ema`(默认值:False)和`train-ema_decay`来启用。
235-
4. 参数修改:`num_columns_to_net` -> `net_input_column_index`: 输入网络的columns数量改为输入网络的columns索引
236-
5. 参数修改:`num_columns_of_labels` -> `label_column_index`: 用索引替换数量,以表示lebel的位置。
237-
238-
- 2023/04/21
239-
1. 添加参数分组以支持训练中的正则化。用法:在yaml config中添加`grouping_strategy`参数以选择预定义的分组策略,或使用`no_weight_decay_params`参数选择要从权重衰减中排除的层(例如,bias、norm)。示例可参考`configs/rec/crn/crnn_icdar15.yaml`
240-
2. 添加梯度累积,支持大批量训练。用法:在yaml配置中添加`gradient_accumulation_steps`,全局批量大小=batch_size * devices * gradient_aaccumulation_steps。示例可参考`configs/rec/crn/crnn_icdar15.yaml`
241-
3. 添加梯度裁剪,支持训练稳定。通过在yaml配置中将`grad_clip`设置为True来启用。
242-
243-
- 2023/03/23
244-
1. 增加dynamic loss scaler支持, 且与drop overflow update兼容。如需使用, 请在配置文件中增加`loss_scale`字段并将`type`参数设为`dynamic`,参考例子请见`configs/rec/crnn/crnn_icdar15.yaml`
245-
246-
- 2023/03/20
247-
1. 参数名修改:`output_keys` -> `output_columns``num_keys_to_net` -> `num_columns_to_net`
248-
2. 更新数据流程。
249-
250-
- 2023/03/13
251-
1. 增加系统测试和CI工作流;
252-
2. 增加modelarts平台适配器,使得支持在OpenI平台上训练,在OpenI平台上训练需要以下步骤:
253-
```text
254-
i) 在OpenI云平台上创建一个训练任务;
255-
ii) 在网页上关联数据集,如ic15_mindocr;
256-
iii) 增加 `config` 参数,在网页的UI界面配置yaml文件路径,如'/home/work/user-job-dir/V0001/configs/rec/test.yaml';
257-
iv) 在网页的UI界面增加运行参数`enable_modelarts`并将其设置为True;
258-
v) 填写其他项并启动训练任务。
259-
```
260-
261-
### 如何贡献
262-
263-
我们欢迎包括问题单和PR在内的所有贡献,来让MindOCR变得更好。
264-
265-
请参考[CONTRIBUTING.md](mkdocs/contributing.md)作为贡献指南,请按照[Model Template and Guideline](mkdocs/customize_model.md)的指引贡献一个适配所有接口的模型,多谢合作。
266-
267-
### 许可
268-
269-
本项目遵从[Apache License 2.0](mkdocs/license.md)开源许可。
270-
271-
### 引用
272-
273-
如果本项目对您的研究有帮助,请考虑引用:
274-
275-
```latex
276-
@misc{MindSpore OCR 2023,
277-
title={{MindSpore OCR }:MindSpore OCR Toolbox},
278-
author={MindSpore Team},
279-
howpublished = {\url{https://github.com/mindspore-lab/mindocr/}},
280-
year={2023}
281-
}
282-
```
8+
{% include-markdown "../../README_CN.md" %}

docs/cn/inference/inference_thirdparty_quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ python deploy/eval_utils/eval_rec.py \
359359
--gt_path=/path/to/mlt17_ch/chinese_gt.txt \
360360
--pred_path=/path/to/en_rec_infer_results/rec_results.txt
361361
```
362-
关于数据集准备请参考[数据集转换](/docs/cn/datasets/converters.md)
362+
关于数据集准备请参考[数据集转换](../../docs/cn/datasets/converters.md)
363363

364364
### 3.3 文本方向分类
365365
下面主要以[第三方模型支持列表](#13-文本方向识别)中的`ch_pp_mobile_cls_v2`为例介绍推理方法

0 commit comments

Comments
 (0)