Skip to content

Commit db5cc29

Browse files
committed
docs: add CPU / GPU docs
1 parent 770429f commit db5cc29

File tree

1 file changed

+31
-17
lines changed

1 file changed

+31
-17
lines changed

docs/install_usage/rapidocr/usage.md

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -645,27 +645,41 @@ RapidOCR输出包括4种类型:`Union[TextDetOutput, TextClsOutput, TextRecOut
645645

646646
2. 指定PaddlePaddle作为推理引擎
647647

648-
```python linenums="1" hl_lines="4"
649-
from rapidocr import RapidOCR
648+
=== CPU版
650649

651-
# CPU版直接使用
652-
engine = RapidOCR(params={"Global.with_paddle": True})
650+
```python linenums="1" hl_lines="4"
651+
from rapidocr import RapidOCR
653652

654-
# GPU版,指定GPU id
655-
engine = RapidOCR(
656-
params={
657-
"Global.with_paddle": True,
658-
"EngineConfig.paddlepaddle.use_cuda": True, # 使用torch GPU版推理
659-
"EngineConfig.paddlepaddle.gpu_id": 0, # 指定GPU id
660-
}
661-
)
653+
# CPU版直接使用
654+
engine = RapidOCR(params={"Global.with_paddle": True})
662655

663-
img_url = "https://github.com/RapidAI/RapidOCR/blob/main/python/tests/test_files/ch_en_num.jpg?raw=true"
664-
result = engine(img_url)
665-
print(result)
656+
img_url = "https://github.com/RapidAI/RapidOCR/blob/main/python/tests/test_files/ch_en_num.jpg?raw=true"
657+
result = engine(img_url)
658+
print(result)
666659

667-
result.vis('vis_result.jpg')
668-
```
660+
result.vis('vis_result.jpg')
661+
```
662+
663+
=== GPU版
664+
665+
```python linenums="1" hl_lines="4"
666+
from rapidocr import RapidOCR
667+
668+
# GPU版,指定GPU id
669+
engine = RapidOCR(
670+
params={
671+
"Global.with_paddle": True,
672+
"EngineConfig.paddlepaddle.use_cuda": True, # 使用torch GPU版推理
673+
"EngineConfig.paddlepaddle.gpu_id": 0, # 指定GPU id
674+
}
675+
)
676+
677+
img_url = "https://github.com/RapidAI/RapidOCR/blob/main/python/tests/test_files/ch_en_num.jpg?raw=true"
678+
result = engine(img_url)
679+
print(result)
680+
681+
result.vis('vis_result.jpg')
682+
```
669683

670684
3. 查看输出日志。下面日志中打印出了**Using engine_name: paddle**,则证明使用的推理引擎是PaddlePaddle。
671685

0 commit comments

Comments
 (0)