Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SWHL committed Oct 22, 2023
1 parent 6265743 commit c276874
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 4 deletions.
14 changes: 11 additions & 3 deletions content/docs/install_usage/rapidocr/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,21 @@ description: ""
<a href=""><img src="https://img.shields.io/badge/Python->=3.6,<3.12-aff.svg"></a>
<a href=""><img src="https://img.shields.io/badge/OS-Linux%2C%20Win%2C%20Mac-pink.svg"></a>
<a href="https://pypi.org/project/rapidocr-onnxruntime/"><img alt="PyPI" src="https://img.shields.io/pypi/v/rapidocr-onnxruntime?style=flat-square"></a>
<a href="https://pepy.tech/project/rapidocr_openvino"><img src="https://static.pepy.tech/personalized-badge/rapidocr_openvino?period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=Downloads%20Vino"></a>
<a href="https://pepy.tech/project/rapidocr_onnxruntime"><img src="https://static.pepy.tech/personalized-badge/rapidocr_onnxruntime?period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=Downloads%20Ort"></a>
<a href="https://pepy.tech/project/rapidocr_openvino"><img src="https://static.pepy.tech/personalized-badge/rapidocr_openvino?period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=Downloads%20Vino"></a>
</p>

{{< alert context="info" text="`rapidocr_onnxruntime``rapidocr_openvino`两个包除推理引擎不同之外,其余均相同,后续说明文档均以`rapidocr_onnxruntime`为例<br/>如使用`rapidocr_openvino`,直接更换关键词`rapidocr_onnxruntime``rapidocr_openvino`即可。" />}}

#### 简介
`rapidocr_onnxruntime``rapidocr_openvino`两个包除推理引擎不同之外,其余均相同。后续说明文档均以`rapidocr_onnxruntime`为例

如使用`rapidocr_openvino`,直接更换关键词`rapidocr_onnxruntime``rapidocr_openvino`即可。

两者均是在CPU上推理的,如想在GPU上推理,可以参考[rapidocr_paddle版](../rapidocr_paddle.md)


{{% alert context="info" %}}
#### pypi上各个版本的对应关系:
pypi上各个版本的对应关系:<br/>

|版本|内置模型版本|对应PaddleOCR 分支|
|:---:|:---:|:---:|
Expand All @@ -30,6 +36,8 @@ description: ""

{{% /alert %}}

#### 安装

顺利的话,一行命令即可。包大小约为14M左右,包含了三个模型。因为mobile版模型较小,因此将相关模型都已打到Whl包,可直接pip安装使用。

{{< alert text="请使用Python3.6及以上版本。<br/> `rapidocr`系列库目前仅在CPU上支持较好,GPU上推理很慢,这一点可参考[link](https://rapidai.github.io/RapidOCRDocs/docs/inference_engine/onnxruntime/onnxruntime-gpu/)。因此不建议用onnxruntime-gpu版推理,后续会持续探索GPU上合理的推理方案。" />}}
Expand Down
63 changes: 62 additions & 1 deletion content/docs/install_usage/rapidocr_paddle.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,65 @@ description: "rapidocr_paddle"
icon: menu_book
date: "2023-10-21"
draft: false
---
---

#### 简介
`rapidocr_paddle`系列包是基于PaddlePaddle框架作为推理引擎的,支持CPU和GPU上推理,我推荐GPU上用这个,CPU端还是以`rapidocr_onnxruntime``rapidocr_openvino`为主。毕竟PaddlePaddle的CPU端还是比较重的。

封装这个包的原因是为了弥补GPU端推理的空缺。因为面对成千上万的图像需要提取文字时,CPU端上推理速度还是较慢,不能满足。

#### 安装
1. 根据自己需求,先安装PaddlePaddle框架(CPU/GPU),并验证,参见: [官方教程](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/windows-pip.html),注意验证是否安装成功:
```python {linenos=table}
import paddle

print(paddle.utils.run_check())
# 如果出现PaddlePaddle is installed successfully!,说明您已成功安装。
```
2. 安装`rapidocr_paddle`
```bash {linenos=table}
pip install rapidocr_paddle
```

#### 使用

{{< tabs tabTotal="2">}}
{{% tab tabName="CPU端推理" %}}

前提是安装了CPU版的PaddlePaddle

```python {linenos=table}
import cv2

from rapidocr_paddle import RapidOCR

engine = RapidOCR()
image_path = "tests/test_files/ch_en_num.jpg"
result, elapse_list = engine(image_path)

print(result)
print(elapse_list)
```

{{% /tab %}}
{{% tab tabName="GPU端推理" %}}

前提是安装了GPU版的PaddlePaddle,注意在实例化`RapidOCR`类时,需要通过参数显式指定使用GPU。

```python {linenos=table}
import cv2

from rapidocr_paddle import RapidOCR

engine = RapidOCR(det_use_cuda=True, cls_use_cuda=True, rec_use_cuda=True)

image_path = "tests/test_files/ch_en_num.jpg"
result, elapse_list = engine(image_path)

```

{{% /tab %}}
{{< /tabs >}}


其他详情,同`rapidocor_onnxruntime`系列,参见: [link](./rapidocr/usage.md)

0 comments on commit c276874

Please sign in to comment.