Skip to content

Commit 48a4b79

Browse files
committed
docs: update docs
1 parent 7bf67ad commit 48a4b79

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

docs/install_usage/rapidocr/parameters.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,18 @@ PaddlePaddle API 参见:[API 文档](https://www.paddlepaddle.org.cn/documenta
9696

9797
PyTorch API 参见:[PyTorch documentation](https://pytorch.org/docs/stable/index.html)
9898

99+
!!! tip
100+
101+
以下三部分前4个参数基本类似,对应关系如下表:
102+
103+
| YAML 参数 | 对应枚举类 | 可用枚举值(示例) |导入方式 | 备注 |
104+
|-----------------|------------------|------------------|-------------------|-------------------------------------|
105+
| `engine_type` | `EngineType` | `ONNXRUNTIME`(onnxruntime)<br>`OPENVINO`(openvino)<br>`PADDLE`(paddle)<br>`TORCH`(torch) | `from rapidocr import EngineType`|推理引擎类型 |
106+
| `lang_type` | `LangDet`<br> `LangCls`<br> `LangRec` | **检测(Det)**:`CH`/`EN`/`MULTI`<br>**分类(Cls)**:`CH`<br>**识别(Rec)**:`CH`/`CH_DOC`/`EN`/`ARABIC`/... |`from rapidocr import LangDet`<br/> `from rapidocr import LangCls` <br/>`from rapidocr import LangRec`| 根据OCR处理阶段选择不同枚举值 |
107+
| `model_type` | `ModelType` | `MOBILE`(mobile)<br>`SERVER`(server) |`from rapidocr import ModelType`| 模型大小与性能级别 |
108+
| `ocr_version` | `OCRVersion` | `PPOCRV4`(PP-OCRv4)<br>`PPOCRV5`(PP-OCRv5) |`from rapidocr import OCRVersion`| 模型版本 |
109+
110+
99111
#### Det
100112

101113
```yaml linenums="1"

docs/install_usage/rapidocr/usage.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ result.vis("vis_result.jpg")
4545
# The config file has saved in ./default_rapidocr.yaml
4646
```
4747

48-
2. 根据自己的需要更改 **default_rapidocr.yaml** 相应的值。例如使用OpenVINO作为文本检测的推理引擎,更改如下:
48+
2. 根据自己的需要更改 **default_rapidocr.yaml** 相应的值。例如使用OpenVINO作为作为文本检测的推理引擎,同时使用`ch_mobile`,PP-OCRv4版本的模型,更改如下:
4949

5050
```yaml linenums="1" hl_lines="3"
5151
# 该配置文件命名为1.yaml
5252
Det:
53+
# 以下4个值可以查看https://github.com/RapidAI/RapidOCR/blob/123a129c613ca99c3b007f0591a3587cc01a4c32/python/rapidocr/utils/typings.py来查看
5354
engine_type: 'openvino'
5455
lang_type: 'ch'
5556
model_type: 'mobile'
@@ -91,6 +92,10 @@ result.vis("vis_result.jpg")
9192

9293
=== "方法二:直接传入相应参数"
9394

95+
!!! tip
96+
97+
`rapidocr>=3.0.0`版本之后,将`engine_type`、`lang_type`、`model_type`和`ocr_version`三个参数的设置下放到了文本检测、文本行方向分类和文本识别三个阶段中。这样更加灵活。可以为不同阶段中,指定不同的推理引擎, 不同的模型type。
98+
9499
由于rapidocr中涉及可调节的参数众多,为了便于维护,引入[omageconf](https://github.com/omry/omegaconf)库来更新参数。这样带来的代价是传入参数没有1.x系列中直观一些。但是现阶段方式也容易理解和使用。
95100

96101
例如,我想使用OpenVINO作为各个流程的推理引擎,可以通过下面这种方式使用:
@@ -119,7 +124,10 @@ result.vis("vis_result.jpg")
119124

120125
```yaml linenums="1"
121126
Det:
122-
engine_type: 'torch'
127+
engine_type: 'openvino'
128+
lang_type: 'ch'
129+
model_type: 'mobile'
130+
ocr_version: 'PP-OCRv4'
123131

124132
EngineConfig:
125133
torch:
@@ -130,14 +138,17 @@ result.vis("vis_result.jpg")
130138
**对应参数写法**
131139

132140
```python linenums="1" hl_lines="5-7"
133-
from rapidocr import EngineType, RapidOCR
141+
from rapidocr import EngineType, LangDet, ModelType, OCRVersion, RapidOCR
134142

135143
engine = RapidOCR(
136-
params={
137-
"Det.engine_type": EngineType.TORCH,
138-
"EngineConfig.torch.use_cuda": True, # 使用torch GPU版推理
139-
"EngineConfig.torch.gpu_id": 0, # 指定GPU id
140-
}
144+
params={
145+
"Det.engine_type": EngineType.TORCH,
146+
"Det.lang_type": LangDet.CH,
147+
"Det.model_type": ModelType.MOBILE,
148+
"Det.ocr_version": OCRVersion.PPOCRV5,
149+
"EngineConfig.torch.use_cuda": True, # 使用torch GPU版推理
150+
"EngineConfig.torch.gpu_id": 0, # 指定GPU id
151+
}
141152
)
142153
```
143154

0 commit comments

Comments
 (0)