Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
SWHL committed Sep 21, 2023
1 parent 524f6c1 commit 862b205
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 683 deletions.
143 changes: 1 addition & 142 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -1,142 +1 @@
## RapidOCR API

<p>
<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-api/"><img alt="PyPI" src="https://img.shields.io/pypi/v/rapidocr-api"></a>
<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>

- 采用`FastAPI` + `uvicorn`实现。
- 该模块定位是一个快速搭建示例的demo,没有考虑多进程处理并发请求,如果有这需求的小伙伴,可以看看gunicorn等。

### 使用步骤
1. 安装`rapidocr_api`
```bash
$ pip install rapidocr_api

# 源码安装
$ python setup.py bdist_wheel v0.0.1
$ cd dist
$ pip install rapidocr_*.whl
```
2. 运行
- 用法:
```bash
$ rapidocr_api -h
usage: rapidocr_api [-h] [-ip IP] [-p PORT]

optional arguments:
-h, --help show this help message and exit
-ip IP, --ip IP IP Address
-p PORT, --port PORT IP port
```
- 示例:
```bash
$ rapidocr_api -ip 0.0.0.0 -p 9003
```
3. 使用
- ⚠️:本质就是发送一个POST请求,其他语言同理
- curl调用
```bash
$ curl -F [email protected] http://0.0.0.0:9003/ocr
```
- python调用
- 以文件的方式发送请求
```python
import requests
url = 'http://localhost:9003/ocr'
img_path = '../python/tests/test_files/ch_en_num.jpg'
with open(img_path, 'rb') as f:
file_dict = {'image_file': (img_path, f, 'image/png')}
response = requests.post(url, files=file_dict, timeout=60)
print(response.json())
```
- 以`base64`方式发送post请求
```python
import base64
import requests
url = 'http://localhost:9003/ocr'
img_path = '../python/tests/test_files/ch_en_num.jpg'
with open(img_path, 'rb') as fa:
img_str = base64.b64encode(fa.read())
payload = {'image_data': img_str}
resp = requests.post(url, data=payload)
print(resp.json())
```
4. API输出
- 示例结果:
<details>
<summary>详情</summary>

```json
{
"0": {
"rec_txt": "8月26日!",
"dt_boxes": [
[333.0, 72.0],
[545.0, 40.0],
[552.0, 90.0],
[341.0, 122.0]
],
"score": "0.7342076812471662"
},
"1": {
"rec_txt": "澳洲名校招生信息",
"dt_boxes": [
[266.0, 163.0],
[612.0, 116.0],
[619.0, 163.0],
[272.0, 210.0]
],
"score": "0.8261737492349412"
},
"2": {
"rec_txt": "解读!!",
"dt_boxes": [
[341.0, 187.0],
[595.0, 179.0],
[598.0, 288.0],
[344.0, 296.0]
],
"score": "0.6152311325073242"
},
"3": {
"rec_txt": "Rules...",
"dt_boxes": [
[446.0, 321.0],
[560.0, 326.0],
[559.0, 352.0],
[445.0, 347.0]
],
"score": "0.8704230123096042"
}
}
```
</details>

- 输出结果说明:
- 如果图像中存在文字,则会输出字典格式,具体介绍如下:
```python
{
"0": {
"rec_txt": "香港深圳抽血,", # 识别的文本
"dt_boxes": [ # 依次为左上角 → 右上角 → 右下角 → 左下角
[265, 18],
[472, 231],
[431, 271],
[223, 59]
],
"score": "0.8175641223788261" # 置信度
}
}
```
- 如果没有检测到文字,则会输出空json(`{}`)。
5. **!!说明:OCR的输出结果为最原始结果,大家可按需进一步扩展。**
### See [Documentation](https://rapidai.github.io/RapidOCRDocs/docs/install_usage/rapidocr_api/)
136 changes: 1 addition & 135 deletions docs/doc_whl_rapidocr_api.md
Original file line number Diff line number Diff line change
@@ -1,135 +1 @@
## rapidocr-api
<p>
<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-api/"><img alt="PyPI" src="https://img.shields.io/pypi/v/rapidocr-api"></a>
<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>

### Use
1. Install`rapidocr_api`
```bash
$ pip install rapidocr_api
```
2. Run
- Usage:
```bash
$ rapidocr_api -h
usage: rapidocr_api [-h] [-ip IP] [-p PORT]

optional arguments:
-h, --help show this help message and exit
-ip IP, --ip IP IP Address
-p PORT, --port PORT IP port
```
- Example:
```bash
$ rapidocr_api -ip 0.0.0.0 -p 9003
```
3. Use
- with curl
```bash
$ curl -F [email protected] http://0.0.0.0:9003/ocr
```
- with python
- Send image data by file format.
```python
import requests
url = 'http://localhost:9003/ocr'
img_path = '../python/tests/test_files/ch_en_num.jpg'
with open(img_path, 'rb') as f:
file_dict = {'image_file': (img_path, f, 'image/png')}
response = requests.post(url, files=file_dict, timeout=60)
print(response.json())
```
- Send image data by base64 format.
```python
import base64
import requests
url = 'http://localhost:9003/ocr'
img_path = '../python/tests/test_files/ch_en_num.jpg'
with open(img_path, 'rb') as fa:
img_str = base64.b64encode(fa.read())
payload = {'image_data': img_str}
resp = requests.post(url, data=payload)
print(resp.json())
```
4. Output
<details>
<summary>Click to expand</summary>

```json
{
"0": {
"rec_txt": "香港深圳抽血,",
"dt_boxes": [
[265, 18],
[472, 231],
[431, 271],
[223, 59]
],
"score": "0.8175641223788261"
},
"1": {
"rec_txt": "专业查性别",
"dt_boxes": [
[388, 15],
[636, 257],
[587, 307],
[339, 65]
],
"score": "0.8293875356515249"
},
"2": {
"rec_txt": "专业鉴定B超单",
"dt_boxes": [
[215, 84],
[509, 413],
[453, 463],
[159, 134]
],
"score": "0.8626169338822365"
},
"3": {
"rec_txt": "b超仪器查性别",
"dt_boxes": [
[128, 135],
[430, 478],
[366, 534],
[64, 192]
],
"score": "0.8449362441897392"
},
"4": {
"rec_txt": "加微信eee",
"dt_boxes": [
[58, 189],
[268, 450],
[209, 498],
[0, 236]
],
"score": "0.8176911813872201"
},
"5": {
"rec_txt": "可邮寄",
"dt_boxes": [
[493, 261],
[617, 384],
[577, 423],
[454, 300]
],
"score": "0.7494261413812637"
}
}
```
</details>


### See details for [RapidOCR](https://github.com/RapidAI/RapidOCR/tree/main/ocrweb).
### See [Documentation](https://rapidai.github.io/RapidOCRDocs/docs/install_usage/rapidocr_api/)
9 changes: 1 addition & 8 deletions docs/doc_whl_rapidocr_ort.md
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
## rapidocr-onnxruntime
<p>
<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://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>
</p>

### See [Documentation](https://rapidai.github.io/RapidOCRDocs/docs/install_usage/rapidocr/rapidocr_onnxruntime/)
### See [Documentation](https://rapidai.github.io/RapidOCRDocs/docs/install_usage/rapidocr/usage/)
9 changes: 1 addition & 8 deletions docs/doc_whl_rapidocr_vino.md
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
## rapidocr-openvino
<p>
<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://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>

### See [Documentation](https://rapidai.github.io/RapidOCRDocs/docs/install_usage/rapidocr/rapidocr_openvino/)
### See [Documentation](https://rapidai.github.io/RapidOCRDocs/docs/install_usage/rapidocr/usage/)
32 changes: 1 addition & 31 deletions docs/doc_whl_rapidocr_web.md
Original file line number Diff line number Diff line change
@@ -1,31 +1 @@
## rapidocr-web
<p>
<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-web/"><img alt="PyPI" src="https://img.shields.io/pypi/v/rapidocr-web"></a>
<a href="https://pepy.tech/project/rapidocr_web"><img src="https://static.pepy.tech/personalized-badge/rapidocr_web?period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=Downloads"></a>
</p>

### use
1. Install package by pypi.
```bash
$ pip install rapidocr-web
```
2. Run by command line.
- Usage:
```bash
$ rapidocr_web -h
usage: rapidocr_web [-h] [-ip IP] [-p PORT]
optional arguments:
-h, --help show this help message and exit
-ip IP, --ip IP IP Address
-p PORT, --port PORT IP port
```
- Example:
```bash
$ rapidocr_web -ip "0.0.0.0" -p 9003
```
3. Open `http://localhost:9003/` to view, enjoy it.

### See details for [RapidOCR](https://github.com/RapidAI/RapidOCR/tree/main/ocrweb).
### See [Documentation](https://rapidai.github.io/RapidOCRDocs/docs/install_usage/rapidocr_web/rapidocr_web/)
54 changes: 1 addition & 53 deletions ocrweb/README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1 @@
## RapidOCR Web Demo

<p>
<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-web/"><img alt="PyPI" src="https://img.shields.io/pypi/v/rapidocr-web"></a>
<a href="https://pepy.tech/project/rapidocr_web"><img src="https://static.pepy.tech/personalized-badge/rapidocr_web?period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=Downloads"></a>
</p>


- [RapidOCR Web Demo](#rapidocr-web-demo)
- [简要说明](#简要说明)
- [桌面版使用教程](#桌面版使用教程)
- [界面版使用步骤](#界面版使用步骤)


### 简要说明
- 该模块依赖`rapidocr_onnxruntime`库。
- 如果想要离线部署,可以先手动下载[`rapidocr_onnxruntime`](https://pypi.org/project/rapidocr-onnxruntime/#files) whl包,再手动安装[`rapidocr_web`](https://pypi.org/project/rapidocr-web/#files) whl包来使用。
- 所用模型组合(最优组合)为:
```text
ch_PP-OCRv3_det + ch_ppocr_mobile_v2.0_cls + ch_PP-OCRv3_rec
```
- 网页上显示的推理时间具体解释如下:

<div align="center">
<img src="https://github.com/RapidAI/RapidOCR/blob/ae529c2ba79e6cbf04c54caf2d24feb75e947ca4/assets/ocrweb_time.jpg" width="80%" height="80%">
</div>

### [桌面版使用教程](https://github.com/RapidAI/RapidOCR/wiki/%5BRapidOCRWeb%5D-%E6%A1%8C%E9%9D%A2%E7%89%88%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B)

### 界面版使用步骤
1. 安装`rapidocr_web`
```bash
$ pip install rapidocr_web
```
2. 运行
- 用法:
```bash
$ rapidocr_web -h
usage: rapidocr_web [-h] [-ip IP] [-p PORT]

optional arguments:
-h, --help show this help message and exit
-ip IP, --ip IP IP Address
-p PORT, --port PORT IP port
```
- 示例:
```bash
$ rapidocr_web -ip 0.0.0.0 -p 9003
```
3. 使用
- 浏览器打开`http://localhost:9003/`,enjoy it.
### See [Documentation](https://rapidai.github.io/RapidOCRDocs/docs/install_usage/rapidocr_web/rapidocr_web/)
Loading

0 comments on commit 862b205

Please sign in to comment.