Spaces:
Running
Running
Susus
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -1,85 +1,9 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
## 最简单运行方式
|
11 |
-
|
12 |
-
```shell
|
13 |
-
# 安装依赖
|
14 |
-
pip install -r requirements.txt -i https://pypi.douban.com/simple
|
15 |
-
|
16 |
-
# 运行 可选参数如下
|
17 |
-
# --port 9898 指定端口,默认为9898
|
18 |
-
# --ocr 开启ocr模块 默认开启
|
19 |
-
# --old 只有ocr模块开启的情况下生效 默认不开启
|
20 |
-
# --det 开启目标检测模式
|
21 |
-
|
22 |
-
# 最简单运行方式,只开启ocr模块并以新模型计算
|
23 |
-
python ocr_server.py --port 9898 --ocr
|
24 |
-
|
25 |
-
# 开启ocr模块并使用旧模型计算
|
26 |
-
python ocr_server.py --port 9898 --ocr --old
|
27 |
-
|
28 |
-
# 只开启目标检测模块
|
29 |
-
python ocr_server.py --port 9898 --det
|
30 |
-
|
31 |
-
# 同时开启ocr模块以及目标检测模块
|
32 |
-
python ocr_server.py --port 9898 --ocr --det
|
33 |
-
|
34 |
-
# 同时开启ocr模块并使用旧模型计算以及目标检测模块
|
35 |
-
python ocr_server.py --port 9898 --ocr --old --det
|
36 |
-
|
37 |
-
```
|
38 |
-
|
39 |
-
## docker运行方式(目测只能在Linux下部署)
|
40 |
-
|
41 |
-
```shell
|
42 |
-
git clone https://github.com/sml2h3/ocr_api_server.git
|
43 |
-
# docker怎么安装?百度吧
|
44 |
-
|
45 |
-
cd ocr_api_server
|
46 |
-
|
47 |
-
# 修改entrypoint.sh中的参数,具体参数往上翻,默认9898端口,同时开启ocr模块以及目标检测模块
|
48 |
-
|
49 |
-
# 编译镜像
|
50 |
-
docker build -t ocr_server:v1 .
|
51 |
-
|
52 |
-
# 运行镜像
|
53 |
-
docker run -p 9898:9898 -d ocr_server:v1
|
54 |
-
|
55 |
-
```
|
56 |
-
|
57 |
-
# 接口
|
58 |
-
|
59 |
-
**具体请看test_api.py文件**
|
60 |
-
|
61 |
-
```python
|
62 |
-
# 1、测试是否启动成功,可以通过直接GET访问http://{host}:{port}/ping来测试,如果返回pong则启动成功
|
63 |
-
|
64 |
-
# 2、OCR/目标检测请求接口格式:
|
65 |
-
|
66 |
-
# http://{host}:{port}/{opt}/{img_type}/{ret_type}
|
67 |
-
# opt:操作类型 ocr=OCR det=目标检测 slide=滑块(match和compare两种算法,默认为compare)
|
68 |
-
# img_type: 数据类型 file=文件上传方式 b64=base64(imgbyte)方式 默认为file方式
|
69 |
-
# ret_type: 返回类型 json=返回json(识别出错会在msg里返回错误信息) text=返回文本格式(识别出错时回直接返回空文本)
|
70 |
-
|
71 |
-
# 例子:
|
72 |
-
|
73 |
-
# OCR请求
|
74 |
-
# resp = requests.post("http://{host}:{port}/ocr/file", files={'image': image_bytes})
|
75 |
-
# resp = requests.post("http://{host}:{port}/ocr/b64/text", data=base64.b64encode(file).decode())
|
76 |
-
|
77 |
-
# 目标检测请求
|
78 |
-
# resp = requests.post("http://{host}:{port}/det/file", files={'image': image_bytes})
|
79 |
-
# resp = requests.post("http://{host}:{port}/det/b64/json", data=base64.b64encode(file).decode())
|
80 |
-
|
81 |
-
# 滑块识别请求
|
82 |
-
# resp = requests.post("http://{host}:{port}/slide/match/file", files={'target_img': target_bytes, 'bg_img': bg_bytes})
|
83 |
-
# jsonstr = json.dumps({'target_img': target_b64str, 'bg_img': bg_b64str})
|
84 |
-
# resp = requests.post("http://{host}:{port}/slide/compare/b64", files=base64.b64encode(jsonstr.encode()).decode())
|
85 |
-
```
|
|
|
1 |
+
---
|
2 |
+
title: Openlist-ocr
|
3 |
+
emoji: 🏆
|
4 |
+
colorFrom: gray
|
5 |
+
colorTo: red
|
6 |
+
sdk: docker
|
7 |
+
pinned: false
|
8 |
+
---
|
9 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|