66
77### 引言
88
9- 在` rapidocr>=3.0.0 ` 版本之后,` rapidocr ` 可以单独为文本检测、文本行方向分类和文本识别单独指定不同的推理引擎。
9+ 在 ` rapidocr>=3.0.0 ` 版本之后,` rapidocr ` 可以单独为文本检测、文本行方向分类和文本识别单独指定不同的推理引擎。
1010
11- 例如:文本检测使用ONNXRuntime ,文本识别使用PaddlePaddle(` params={"Rec.engine_type": EngineType.PADDLE} ` )。同时,不同版本的OCR也可以通过` Det.ocr_version ` 灵活指定。
11+ 例如:文本检测使用 ONNX Runtime ,文本识别使用PaddlePaddle(` params={"Rec.engine_type": EngineType.PADDLE} ` )。同时,不同版本的OCR也可以通过 ` Det.ocr_version ` 灵活指定。
1212
13- ` rapidocr ` 支持5种推理引擎 (** ONNXRuntime / OpenVINO / PaddlePaddle / PyTorch / MNN (` rapidocr>=3.6.0 ` )** ),推荐首先使用 ** ONNXRuntime CPU** 版。默认为ONNXRuntime 。
13+ ` rapidocr ` 支持 5 种推理引擎 (** ONNX Runtime / OpenVINO / PaddlePaddle / PyTorch / MNN (` rapidocr>=3.6.0 ` )** ),推荐首先使用 ** ONNX Runtime CPU** 版。默认为 ONNX Runtime 。
1414
15- ` rapidocr ` 是通过指定不同参数来选择使用不同的推理引擎的。当然,使用不同推理引擎的前提是事先安装好对应的推理引擎库,并确保安装正确。
15+ ` rapidocr ` 是通过指定不同参数来选择使用不同的推理引擎的。当然,使用不同推理引擎的前提是事先安装好对应的推理引擎库,并确保安装正确。
1616
17- ### 使用ONNXRuntime
17+ ### 使用 ONNX Runtime
1818
19- 1 . 安装ONNXRuntime。推荐用CPU版的ONNXRuntime,GPU版不推荐在 ` rapidocr ` 中使用,相关原因参见:[ ONNXRuntime GPU推理 ] ( ../../blog/posts/inference_engine/onnxruntime/onnxruntime-gpu.md ) 。
19+ 1 . 安装 ONNX Runtime。推荐用 CPU 版的 ONNX Runtime,GPU 版不推荐在 ` rapidocr ` 中使用,相关原因参见:[ ONNX Runtime GPU 推理 ] ( ../../blog/posts/inference_engine/onnxruntime/onnxruntime-gpu.md ) 。
2020
2121 ``` bash linenums="1"
2222 pip install onnxruntime
2323 ```
2424
25- 2. ONNXRuntime作为默认推理引擎 ,无需显式指定即可使用。
25+ 2. ONNX Runtime 作为默认推理引擎 ,无需显式指定即可使用。
2626
2727 === " CPU"
2828
4242
4343 !!! tip
4444
45- 仅在` rapidocr> =3.1.0` 中支持。ONNXRuntime官方相关文档 :[link](https://onnxruntime.ai/docs/execution-providers/community-maintained/CANN-ExecutionProvider.html)
45+ 仅在 ` rapidocr> =3.1.0` 中支持。ONNX Runtime 官方相关文档 :[link](https://onnxruntime.ai/docs/execution-providers/community-maintained/CANN-ExecutionProvider.html)
4646
4747 1. 安装
4848
6868
6969 !!! tip
7070
71- DirectML仅能Windows 10 Build 18362及以上使用 。
72- ONNXRuntime官方相关文档 :[link](https://onnxruntime.ai/docs/execution-providers/DirectML-ExecutionProvider.html)
71+ DirectML 仅能 Windows 10 Build 18362 及以上使用 。
72+ ONNX Runtime 官方相关文档 :[link](https://onnxruntime.ai/docs/execution-providers/DirectML-ExecutionProvider.html)
7373
7474 1. 安装
7575
9191 result.vis(" vis_result.jpg" )
9292 ` ` `
9393
94- 3. 查看输出日志。下面日志中打印出了 ** Using engine_name: onnxruntime** ,则证明使用的推理引擎是ONNXRuntime 。
94+ 3. 查看输出日志。下面日志中打印出了 ** Using engine_name: onnxruntime** ,则证明使用的推理引擎是 ONNX Runtime 。
9595
9696 ` ` ` bash linenums=" 1" hl_lines=" 1 3 5"
9797 [INFO] 2025-03-21 09:28:03,457 base.py:30: Using engine_name: onnxruntime
@@ -102,15 +102,15 @@ hide:
102102 [INFO] 2025-03-21 09:28:03,862 utils.py:35: File already exists in /Users/joshuawang/projects/_self/RapidOCR/python/rapidocr/models/ch_PP-OCRv4_rec_infer.onnx
103103 ` ` `
104104
105- # ## 使用OpenVINO
105+ # ## 使用 OpenVINO
106106
107- 1. 安装OpenVINO 。
107+ 1. 安装 OpenVINO 。
108108
109109 ` ` ` bash linenums=" 1"
110110 pip install openvino
111111 ` ` `
112112
113- 2. 指定OpenVINO作为推理引擎 。
113+ 2. 指定 OpenVINO 作为推理引擎 。
114114
115115 ` ` ` python linenums=" 1" hl_lines=" 5-7"
116116 from rapidocr import RapidOCR, EngineType
@@ -130,7 +130,7 @@ hide:
130130 result.vis(' vis_result.jpg' )
131131 ` ` `
132132
133- 3. 查看输出日志。下面日志中打印出了 ** Using engine_name: openvino** ,则证明使用的推理引擎是OpenVINO 。
133+ 3. 查看输出日志。下面日志中打印出了 ** Using engine_name: openvino** ,则证明使用的推理引擎是 OpenVINO 。
134134
135135 ` ` ` bash linenums=" 1" hl_lines=" 1 3 5"
136136 [INFO] 2025-03-21 09:28:03,457 base.py:30: Using engine_name: openvino
@@ -141,19 +141,19 @@ hide:
141141 [INFO] 2025-03-21 09:28:03,862 utils.py:35: File already exists in /Users/joshuawang/projects/_self/RapidOCR/python/rapidocr/models/ch_PP-OCRv4_rec_infer.onnx
142142 ` ` `
143143
144- # ## 使用MNN
144+ # ## 使用 MNN
145145
146146!!! tip
147147
148148 ` rapidocr> =3.6.0` 支持。
149149
150- 1. 安装MNN
150+ 1. 安装 MNN
151151
152152 ` ` ` bash linenums=" 1"
153153 pip install MNN
154154 ` ` `
155155
156- 2. 指定MNN作为推理引擎 。
156+ 2. 指定 MNN 作为推理引擎 。
157157
158158 === " CPU"
159159
@@ -179,7 +179,7 @@ hide:
179179
180180 敬请期待!
181181
182- 3. 查看输出日志。下面日志中打印出了 ** Using engine_name: mnn** ,则证明使用的推理引擎是MNN 。
182+ 3. 查看输出日志。下面日志中打印出了 ** Using engine_name: mnn** ,则证明使用的推理引擎是 MNN 。
183183
184184 ` ` ` bash linenums=" 1" hl_lines=" 1 3 5"
185185 [INFO] 2025-03-21 09:28:03,457 base.py:30: Using engine_name: mnn
@@ -190,15 +190,15 @@ hide:
190190 [INFO] 2025-03-21 09:28:03,862 utils.py:35: File already exists in /Users/joshuawang/projects/_self/RapidOCR/python/rapidocr/models/ch_PP-OCRv4_rec_infer.mnn
191191 ` ` `
192192
193- # ## 使用PaddlePaddle
193+ # ## 使用 PaddlePaddle
194194
195- 1. 安装PaddlePaddle 。
195+ 1. 安装 PaddlePaddle 。
196196
197- 参见PaddlePaddle官方安装文档 → [快速安装](https://www.paddlepaddle.org.cn/install/quick? docurl=undefined)
197+ 参见 PaddlePaddle 官方安装文档 → [快速安装](https://www.paddlepaddle.org.cn/install/quick? docurl=undefined)
198198
199199 大家可以根据实际情况,选择安装需要的版本。
200200
201- 2. 指定PaddlePaddle作为推理引擎 。
201+ 2. 指定 PaddlePaddle 作为推理引擎 。
202202
203203 === " CPU"
204204
@@ -264,7 +264,7 @@ hide:
264264 result.vis(' vis_result.jpg' )
265265 ` ` `
266266
267- 3. 查看输出日志。下面日志中打印出了 ** Using engine_name: paddle** ,则证明使用的推理引擎是PaddlePaddle 。
267+ 3. 查看输出日志。下面日志中打印出了 ** Using engine_name: paddle** ,则证明使用的推理引擎是 PaddlePaddle 。
268268
269269 ` ` ` bash linenums=" 1" hl_lines=" 3 6"
270270 [INFO] 2025-03-22 15:20:45,528 utils.py:35: File already exists in /Users/jiahuawang/projects/RapidOCR/python/rapidocr/models/ch_PP-OCRv4_det_infer/inference.pdmodel
@@ -277,15 +277,15 @@ hide:
277277 [INFO] 2025-03-22 15:20:45,904 utils.py:35: File already exists in /Users/jiahuawang/projects/RapidOCR/python/rapidocr/models/ch_PP-OCRv4_rec_infer/inference.pdiparams
278278 ` ` `
279279
280- # ## 使用PyTorch
280+ # ## 使用 PyTorch
281281
282- 1. 安装PyTorch 。
282+ 1. 安装 PyTorch 。
283283
284- 参见PyTorch官方安装文档 → [Install PyTorch](https://pytorch.org/# :~:text=and%20easy%20scaling.-,INSTALL%20PYTORCH,-Select%20your%20preferences)。
284+ 参见 PyTorch 官方安装文档 → [Install PyTorch](https://pytorch.org/# :~:text=and%20easy%20scaling.-,INSTALL%20PYTORCH,-Select%20your%20preferences)。
285285
286286 大家可以根据实际情况,选择安装需要的版本。
287287
288- 2. 指定PyTorch作为推理引擎 。
288+ 2. 指定 PyTorch 作为推理引擎 。
289289
290290 === " CPU"
291291
@@ -317,7 +317,7 @@ hide:
317317 " Det.engine_type" : EngineType.TORCH,
318318 " Cls.engine_type" : EngineType.TORCH,
319319 " Rec.engine_type" : EngineType.TORCH,
320- " EngineConfig.torch.use_cuda" : True, # 使用torch GPU版推理
320+ " EngineConfig.torch.use_cuda" : True, # 使用 torch GPU 版推理
321321 " EngineConfig.torch.cuda_ep_cfg.device_id" : 0, # 指定GPU id
322322 }
323323 )
@@ -333,9 +333,9 @@ hide:
333333
334334 !!! tip
335335
336- 仅在` rapidocr> =3.4.2` 中支持。` torch_npu` 官方相关文档:[link](https://github.com/Ascend/pytorch)
336+ 仅在 ` rapidocr> =3.4.2` 中支持。` torch_npu` 官方相关文档:[link](https://github.com/Ascend/pytorch)
337337
338- 1. 安装` torch_npu` ,参见:[docs](https://github.com/Ascend/pytorch#installation)。
338+ 1. 安装 ` torch_npu` ,参见:[docs](https://github.com/Ascend/pytorch#installation)。
339339
340340 2. 使用
341341
@@ -359,7 +359,7 @@ hide:
359359 result.vis(' vis_result.jpg' )
360360 ` ` `
361361
362- 3. 查看输出日志。下面日志中打印出了 ** Using engine_name: torch** ,则证明使用的推理引擎是PyTorch 。
362+ 3. 查看输出日志。下面日志中打印出了 ** Using engine_name: torch** ,则证明使用的推理引擎是 PyTorch 。
363363
364364 ` ` ` bash linenums=" 1" hl_lines=" 1 3 5"
365365 [INFO] 2025-03-22 15:39:13,241 base.py:30: Using engine_name: torch
0 commit comments