-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
86 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,61 +32,92 @@ pip install rapidocr_api[openvino] | |
|
||
在`rapidocr_api>=0.1.0`中,可通过环境变量传递模型参数:det_model_path, cls_model_path, rec_model_path;接口中可传入参数,控制是否使用检测、方向分类和识别这三部分的模型;具体调用可参见下面文档。 | ||
|
||
=== "Windows下启动" | ||
#### Windows下使用 | ||
|
||
```bash linenums="1" | ||
set det_model_path=I:\models\图像相关\OCR\RapidOCR\PP-OCRv4\ch_PP-OCRv4_det_server_infer.onnx | ||
set rec_model_path=I:\models\图像相关\OCR\RapidOCR\PP-OCRv4\ch_PP-OCRv4_rec_server_infer.onnx | ||
rapidocr_api | ||
``` | ||
```bash linenums="1" | ||
set det_model_path=I:\models\图像相关\OCR\RapidOCR\PP-OCRv4\ch_PP-OCRv4_det_server_infer.onnx | ||
set rec_model_path=I:\models\图像相关\OCR\RapidOCR\PP-OCRv4\ch_PP-OCRv4_rec_server_infer.onnx | ||
rapidocr_api | ||
``` | ||
|
||
=== "Linux下启动" | ||
#### Linux下使用 | ||
|
||
```bash linenums="1" | ||
# 默认参数启动 | ||
rapidocr_api | ||
```bash linenums="1" | ||
# 默认参数启动 | ||
rapidocr_api | ||
|
||
# 指定参数:端口与进程数量; | ||
rapidocr_api -ip 0.0.0.0 -p 9005 -workers 2 | ||
# 指定参数:端口与进程数量; | ||
rapidocr_api -ip 0.0.0.0 -p 9005 -workers 2 | ||
|
||
# 指定模型 | ||
export det_model_path=/mnt/sda1/models/PP-OCRv4/ch_PP-OCRv4_det_server_infer.onnx | ||
export rec_model_path=/mnt/sda1/models/PP-OCRv4/ch_PP-OCRv4_rec_server_infer.onnx | ||
rapidocr_api -ip 0.0.0.0 -p 9005 -workers 2 | ||
``` | ||
# 指定模型 | ||
export det_model_path=/mnt/sda1/models/PP-OCRv4/ch_PP-OCRv4_det_server_infer.onnx | ||
export rec_model_path=/mnt/sda1/models/PP-OCRv4/ch_PP-OCRv4_rec_server_infer.onnx | ||
rapidocr_api -ip 0.0.0.0 -p 9005 -workers 2 | ||
``` | ||
|
||
=== "Docker下启动" | ||
#### Docker方式使用 | ||
|
||
[Dockerfile源码](https://github.com/RapidAI/RapidOCR/blob/3aa4463ad20bc9dc8d8b08766d0f46d7699efc57/api/Dockerfile) | ||
[Dockerfile源码](https://github.com/RapidAI/RapidOCR/blob/3aa4463ad20bc9dc8d8b08766d0f46d7699efc57/api/Dockerfile) | ||
|
||
```bash linenums="1" | ||
# 构建镜像 | ||
cd api | ||
sudo docker build -t="rapidocr_api:0.1.1" . | ||
Build镜像: | ||
|
||
# 启动镜像 | ||
docker run -p 9003:9003 --name rapidocr_api1 --restart always -d rapidocr_api:0.1.1 | ||
``` | ||
```bash linenums="1" | ||
git clone https://github.com/RapidAI/RapidOCR.git | ||
cd api | ||
|
||
客户端调用说明: | ||
# build方式1:使用宿主机的网络 | ||
docker build -t="rapidocr_api:0.1.4" --network host . | ||
|
||
```bash linenums="1" | ||
cd api | ||
python demo.py | ||
``` | ||
# build方式2:使用宿主机上的代理 | ||
docker build -t rapidocr_api:0.1.4 --network host --build-arg HTTP_PROXY=http://127.0.0.1:8888 --build-arg HTTPS_PROXY=http://127.0.0.1:8888 . | ||
``` | ||
|
||
构建镜像: | ||
调试运行: | ||
|
||
```bash linenums="1" | ||
cd api | ||
sudo docker build -t="rapidocr_api:0.1.1" . | ||
``` | ||
```bash linenums="1" | ||
docker run --rm -p 9003:9003 --name rapidocr_api -e TZ=Asia/Shanghai rapidocr_api:0.1.4 | ||
``` | ||
|
||
启动镜像: | ||
运行: | ||
|
||
```bash linenums="1" | ||
docker run -p 9003:9003 --name rapidocr_api1 --restart always -d rapidocr_api:0.1.1 | ||
``` | ||
```bash linenums="1" | ||
docker run -d -p 9003:9003 --name rapidocr_api -e TZ=Asia/Shanghai rapidocr_api:0.1.4 | ||
``` | ||
|
||
接口web界面: | ||
|
||
```bash linenums="1" | ||
http://<ip>:9003/docs | ||
``` | ||
|
||
#### Docker 临时修改并验证的方法 | ||
|
||
```bash linenums="1" | ||
docker run -p 9003:9003 --name rapidocr_api -e TZ=Asia/Shanghai rapidocr_api:0.1.4 | ||
``` | ||
|
||
进入container修改python源文件,Dockerfile最好加上apt-get install vim安装 | ||
|
||
```bash linenums="1" | ||
docker exec -it rapidocr_api /bin/bash | ||
cd /usr/local/lib/python3.10/site-packages/rapidocr_api | ||
... | ||
# 修改参数文件 | ||
vi /usr/local/lib/python3.10/site-packages/rapidocr_onnxruntime/config.yaml | ||
# 改好后exit退出 | ||
``` | ||
|
||
重启container | ||
|
||
```bash linenums="1" | ||
docker restart rapidocr_api | ||
``` | ||
|
||
查看日志: | ||
|
||
```bash linenums="1" | ||
docker logs -f rapidocr_api | ||
``` | ||
|
||
### 调用 | ||
|
||
|
@@ -135,7 +166,7 @@ curl -F [email protected] http://0.0.0.0:9003/ocr | |
print(response.json()) | ||
``` | ||
|
||
=== "控制是否使用检测、方向分类和识别这三部分的模型" | ||
=== "控制使用检测、方向分类和识别模型" | ||
|
||
```python linenums="1" | ||
import requests | ||
|
@@ -153,20 +184,20 @@ curl -F [email protected] http://0.0.0.0:9003/ocr | |
|
||
如果图像中存在文字,则会输出字典格式,具体介绍如下: | ||
|
||
```json linenums="1" | ||
{ | ||
"0": { | ||
"rec_txt": "香港深圳抽血,", # 识别的文本 | ||
"dt_boxes": [ # 依次为左上角 → 右上角 → 右下角 → 左下角 | ||
[265, 18], | ||
[472, 231], | ||
[431, 271], | ||
[223, 59] | ||
], | ||
"score": "0.8176" # 置信度 | ||
} | ||
} | ||
``` | ||
```json linenums="1" | ||
{ | ||
"0": { | ||
"rec_txt": "香港深圳抽血,", # 识别的文本 | ||
"dt_boxes": [ # 依次为左上角 → 右上角 → 右下角 → 左下角 | ||
[265, 18], | ||
[472, 231], | ||
[431, 271], | ||
[223, 59] | ||
], | ||
"score": "0.8176" # 置信度 | ||
} | ||
} | ||
``` | ||
|
||
如果没有检测到文字,则会输出空字典(`{}`)。 | ||
|
||
|