Skip to content

Commit

Permalink
docs(rapidocr_api): Update changelog and usage
Browse files Browse the repository at this point in the history
  • Loading branch information
SWHL committed Jul 11, 2024
1 parent 253ee91 commit 5cb5e4f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
12 changes: 8 additions & 4 deletions docs/install_usage/rapidocr_api/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ comments: true
<a href="https://pepy.tech/project/rapidocr_api"><img src="https://static.pepy.tech/personalized-badge/rapidocr_api?period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=Downloads"></a>
</p>

#### 🥥2024-03-04 v0.0.6 update:
#### 2024-07-11 v0.0.7 update

- Merge PR [#200](https://github.com/RapidAI/RapidOCR/pull/200)

#### 🥥2024-03-04 v0.0.6 update

- 优化图像读取部分,与`rapidocr_onnxruntime>=1.3.13`版本保持一致
- 统一接口返回值类型为字典

#### 🍜2023-05-22 api update:
#### 🍜2023-05-22 api update

- 将API从ocrweb中解耦出来,作为单独模块维护,详情参见[API](https://github.com/RapidAI/RapidOCR/tree/main/api)
- `rapidocr_web>0.1.6`之后,将不支持`pip install rapidocr_web[api]`方式安装,可直接`pip install rapidocr_api`安装使用。


33 changes: 21 additions & 12 deletions docs/install_usage/rapidocr_api/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ comments: true
OCR API的输出结果为最原始结果,大家可按需进一步扩展。

### 简介

- 该包是将[rapidocr_onnxruntime](./rapidocr/install.md)库做了API封装,采用[FastAPI](https://fastapi.tiangolo.com/) + [uvicorn](https://www.uvicorn.org/)实现。
- 定位是一个快速调用`rapidocr_onnxruntime`的API接口,没有考虑多进程处理并发请求,如果有这需求的小伙伴,可以看看[gunicorn](https://gunicorn.org/)等。

### 安装

```bash linenums="1"
pip install rapidocr_api
```

### 启动服务端

- 用法:

```bash linenums="1"
$ rapidocr_api -h
usage: rapidocr_api [-h] [-ip IP] [-p PORT]
Expand All @@ -33,22 +37,27 @@ pip install rapidocr_api
-ip IP, --ip IP IP Address
-p PORT, --port PORT IP port
```

- 启动:

```bash linenums="1"
rapidocr_api -ip 0.0.0.0 -p 9003
```

### 调用

!!! info

调用本质就是发送一个POST请求,以下给出Curl和Python的调用示例,其他编程语言同理。

#### Curl调用

```bash linenums="1"
curl -F [email protected] http://0.0.0.0:9003/ocr
```

#### Python调用

=== "以文件方式发送POST请求"

```python linenums="1"
Expand Down Expand Up @@ -77,15 +86,16 @@ curl -F [email protected] http://0.0.0.0:9003/ocr
img_str = base64.b64encode(fa.read())
payload = {'image_data': img_str}
response = requests.post(url, data=payload)
response = requests.post(url, data=payload, timeout=60)
print(response.json())
```


### API输出

- 输出结果说明:
- 如果图像中存在文字,则会输出字典格式,具体介绍如下:
- 如果图像中存在文字,则会输出字典格式,具体介绍如下:

```python linenums="1"
{
"0": {
Expand All @@ -96,12 +106,14 @@ curl -F [email protected] http://0.0.0.0:9003/ocr
[431, 271],
[223, 59]
],
"score": "0.8175641223788261" # 置信度
"score": "0.8176" # 置信度
}
}
```
- 如果没有检测到文字,则会输出空字典(`{}`)。

- 如果没有检测到文字,则会输出空字典(`{}`)。
- 示例结果:

```json linenums="1"
{
"0": {
Expand All @@ -112,7 +124,7 @@ curl -F [email protected] http://0.0.0.0:9003/ocr
[552.0, 90.0],
[341.0, 122.0]
],
"score": "0.7342076812471662"
"score": "0.7342"
},
"1": {
"rec_txt": "澳洲名校招生信息",
Expand All @@ -122,7 +134,7 @@ curl -F [email protected] http://0.0.0.0:9003/ocr
[619.0, 163.0],
[272.0, 210.0]
],
"score": "0.8261737492349412"
"score": "0.8262"
},
"2": {
"rec_txt": "解读!!",
Expand All @@ -132,7 +144,7 @@ curl -F [email protected] http://0.0.0.0:9003/ocr
[598.0, 288.0],
[344.0, 296.0]
],
"score": "0.6152311325073242"
"score": "0.6152"
},
"3": {
"rec_txt": "Rules...",
Expand All @@ -142,10 +154,7 @@ curl -F [email protected] http://0.0.0.0:9003/ocr
[559.0, 352.0],
[445.0, 347.0]
],
"score": "0.8704230123096042"
"score": "0.8704"
}
}
```



0 comments on commit 5cb5e4f

Please sign in to comment.