Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
1e8f4146
P
PaddleOCR
项目概览
weixin_41840029
/
PaddleOCR
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleOCR
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
1e8f4146
编写于
8月 10, 2020
作者:
M
MissPenguin
提交者:
GitHub
8月 10, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #510 from wangjiawei04/pdserving_cpu
pdserving deploy增加CPU支持
上级
ec903eb5
841ff3c6
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
77 addition
and
23 deletion
+77
-23
deploy/pdserving/det_local_server.py
deploy/pdserving/det_local_server.py
+9
-3
deploy/pdserving/det_web_server.py
deploy/pdserving/det_web_server.py
+9
-3
deploy/pdserving/ocr_local_server.py
deploy/pdserving/ocr_local_server.py
+14
-4
deploy/pdserving/ocr_web_server.py
deploy/pdserving/ocr_web_server.py
+9
-3
deploy/pdserving/readme.md
deploy/pdserving/readme.md
+27
-7
deploy/pdserving/rec_web_server.py
deploy/pdserving/rec_web_server.py
+9
-3
未找到文件。
deploy/pdserving/det_local_server.py
浏览文件 @
1e8f4146
...
...
@@ -21,7 +21,10 @@ from paddle_serving_client import Client
from
paddle_serving_app.reader
import
Sequential
,
ResizeByFactor
from
paddle_serving_app.reader
import
Div
,
Normalize
,
Transpose
from
paddle_serving_app.reader
import
DBPostProcess
,
FilterBoxes
from
paddle_serving_server_gpu.web_service
import
WebService
if
sys
.
argv
[
1
]
==
'gpu'
:
from
paddle_serving_server_gpu.web_service
import
WebService
elif
sys
.
argv
[
1
]
==
'cpu'
from
paddle_serving_server.web_service
import
WebService
import
time
import
re
import
base64
...
...
@@ -64,8 +67,11 @@ class OCRService(WebService):
ocr_service
=
OCRService
(
name
=
"ocr"
)
ocr_service
.
load_model_config
(
"ocr_det_model"
)
ocr_service
.
set_gpus
(
"0"
)
ocr_service
.
prepare_server
(
workdir
=
"workdir"
,
port
=
9292
,
device
=
"gpu"
,
gpuid
=
0
)
if
sys
.
argv
[
1
]
==
'gpu'
:
ocr_service
.
set_gpus
(
"0"
)
ocr_service
.
prepare_server
(
workdir
=
"workdir"
,
port
=
9292
,
device
=
"gpu"
,
gpuid
=
0
)
elif
sys
.
argv
[
1
]
==
'cpu'
:
ocr_service
.
prepare_server
(
workdir
=
"workdir"
,
port
=
9292
)
ocr_service
.
init_det
()
ocr_service
.
run_debugger_service
()
ocr_service
.
run_web_service
()
deploy/pdserving/det_web_server.py
浏览文件 @
1e8f4146
...
...
@@ -21,7 +21,10 @@ from paddle_serving_client import Client
from
paddle_serving_app.reader
import
Sequential
,
ResizeByFactor
from
paddle_serving_app.reader
import
Div
,
Normalize
,
Transpose
from
paddle_serving_app.reader
import
DBPostProcess
,
FilterBoxes
from
paddle_serving_server_gpu.web_service
import
WebService
if
sys
.
argv
[
1
]
==
'gpu'
:
from
paddle_serving_server_gpu.web_service
import
WebService
elif
sys
.
argv
[
1
]
==
'cpu'
:
from
paddle_serving_server.web_service
import
WebService
import
time
import
re
import
base64
...
...
@@ -65,8 +68,11 @@ class OCRService(WebService):
ocr_service
=
OCRService
(
name
=
"ocr"
)
ocr_service
.
load_model_config
(
"ocr_det_model"
)
ocr_service
.
set_gpus
(
"0"
)
ocr_service
.
prepare_server
(
workdir
=
"workdir"
,
port
=
9292
,
device
=
"gpu"
,
gpuid
=
0
)
if
sys
.
argv
[
1
]
==
'gpu'
:
ocr_service
.
set_gpus
(
"0"
)
ocr_service
.
prepare_server
(
workdir
=
"workdir"
,
port
=
9292
,
device
=
"gpu"
,
gpuid
=
0
)
elif
sys
.
argv
[
1
]
==
'cpu'
:
ocr_service
.
prepare_server
(
workdir
=
"workdir"
,
port
=
9292
,
device
=
"cpu"
)
ocr_service
.
init_det
()
ocr_service
.
run_rpc_service
()
ocr_service
.
run_web_service
()
deploy/pdserving/ocr_local_server.py
浏览文件 @
1e8f4146
...
...
@@ -22,7 +22,10 @@ from paddle_serving_client import Client
from
paddle_serving_app.reader
import
Sequential
,
URL2Image
,
ResizeByFactor
from
paddle_serving_app.reader
import
Div
,
Normalize
,
Transpose
from
paddle_serving_app.reader
import
DBPostProcess
,
FilterBoxes
,
GetRotateCropImage
,
SortedBoxes
from
paddle_serving_server_gpu.web_service
import
WebService
if
sys
.
argv
[
1
]
==
'gpu'
:
from
paddle_serving_server_gpu.web_service
import
WebService
elif
sys
.
argv
[
1
]
==
'cpu'
:
from
paddle_serving_server.web_service
import
WebService
from
paddle_serving_app.local_predict
import
Debugger
import
time
import
re
...
...
@@ -37,8 +40,12 @@ class OCRService(WebService):
(
2
,
0
,
1
))
])
self
.
det_client
=
Debugger
()
self
.
det_client
.
load_model_config
(
det_model_config
,
gpu
=
True
,
profile
=
False
)
if
sys
.
argv
[
1
]
==
'gpu'
:
self
.
det_client
.
load_model_config
(
det_model_config
,
gpu
=
True
,
profile
=
False
)
elif
sys
.
argv
[
1
]
==
'cpu'
:
self
.
det_client
.
load_model_config
(
det_model_config
,
gpu
=
False
,
profile
=
False
)
self
.
ocr_reader
=
OCRReader
()
def
preprocess
(
self
,
feed
=
[],
fetch
=
[]):
...
...
@@ -99,5 +106,8 @@ ocr_service = OCRService(name="ocr")
ocr_service
.
load_model_config
(
"ocr_rec_model"
)
ocr_service
.
prepare_server
(
workdir
=
"workdir"
,
port
=
9292
)
ocr_service
.
init_det_debugger
(
det_model_config
=
"ocr_det_model"
)
ocr_service
.
run_debugger_service
(
gpu
=
True
)
if
sys
.
argv
[
1
]
==
'gpu'
:
ocr_service
.
run_debugger_service
(
gpu
=
True
)
elif
sys
.
argv
[
1
]
==
'cpu'
:
ocr_service
.
run_debugger_service
()
ocr_service
.
run_web_service
()
deploy/pdserving/ocr_web_server.py
浏览文件 @
1e8f4146
...
...
@@ -22,7 +22,10 @@ from paddle_serving_client import Client
from
paddle_serving_app.reader
import
Sequential
,
URL2Image
,
ResizeByFactor
from
paddle_serving_app.reader
import
Div
,
Normalize
,
Transpose
from
paddle_serving_app.reader
import
DBPostProcess
,
FilterBoxes
,
GetRotateCropImage
,
SortedBoxes
from
paddle_serving_server_gpu.web_service
import
WebService
if
sys
.
argv
[
1
]
==
'gpu'
:
from
paddle_serving_server_gpu.web_service
import
WebService
elif
sys
.
argv
[
1
]
==
'cpu'
:
from
paddle_serving_server.web_service
import
WebService
import
time
import
re
import
base64
...
...
@@ -90,8 +93,11 @@ class OCRService(WebService):
ocr_service
=
OCRService
(
name
=
"ocr"
)
ocr_service
.
load_model_config
(
"ocr_rec_model"
)
ocr_service
.
set_gpus
(
"0"
)
ocr_service
.
prepare_server
(
workdir
=
"workdir"
,
port
=
9292
,
device
=
"gpu"
,
gpuid
=
0
)
if
sys
.
argv
[
1
]
==
'gpu'
:
ocr_service
.
set_gpus
(
"0"
)
ocr_service
.
prepare_server
(
workdir
=
"workdir"
,
port
=
9292
,
device
=
"gpu"
,
gpuid
=
0
)
elif
sys
.
argv
[
1
]
==
'cpu'
:
ocr_service
.
prepare_server
(
workdir
=
"workdir"
,
port
=
9292
)
ocr_service
.
init_det_client
(
det_port
=
9293
,
det_client_config
=
"ocr_det_client/serving_client_conf.prototxt"
)
...
...
deploy/pdserving/readme.md
浏览文件 @
1e8f4146
...
...
@@ -16,20 +16,33 @@
**Python3操作指南:**
```
#以下提供beta版本的paddle serving whl包,欢迎试用,正式版会在7月底正式上线
#以下提供beta版本的paddle serving whl包,欢迎试用,正式版会在8月中正式上线
#GPU用户下载server包使用这个链接
wget --no-check-certificate https://paddle-serving.bj.bcebos.com/others/paddle_serving_server_gpu-0.3.2-py3-none-any.whl
python -m pip install paddle_serving_server_gpu-0.3.2-py3-none-any.whl
#CPU版本使用这个链接
wget --no-check-certificate https://paddle-serving.bj.bcebos.com/others/paddle_serving_server-0.3.2-py3-none-any.whl
python -m pip install paddle_serving_server-0.3.2-py3-none-any.whl
#客户端和App包使用以下链接(CPU,GPU通用)
wget --no-check-certificate https://paddle-serving.bj.bcebos.com/others/paddle_serving_client-0.3.2-cp36-none-any.whl
wget --no-check-certificate https://paddle-serving.bj.bcebos.com/others/paddle_serving_app-0.1.2-py3-none-any.whl
python -m pip install paddle_serving_app-0.1.2-py3-none-any.whl paddle_serving_
server_gpu-0.3.2-py3-none-any.whl paddle_serving_
client-0.3.2-cp36-none-any.whl
python -m pip install paddle_serving_app-0.1.2-py3-none-any.whl paddle_serving_client-0.3.2-cp36-none-any.whl
```
**Python2操作指南:**
```
#以下提供beta版本的paddle serving whl包,欢迎试用,正式版会在7月底正式上线
#以下提供beta版本的paddle serving whl包,欢迎试用,正式版会在8月中正式上线
#GPU用户下载server包使用这个链接
wget --no-check-certificate https://paddle-serving.bj.bcebos.com/others/paddle_serving_server_gpu-0.3.2-py2-none-any.whl
python -m pip install paddle_serving_server_gpu-0.3.2-py2-none-any.whl
#CPU版本使用这个链接
wget --no-check-certificate https://paddle-serving.bj.bcebos.com/others/paddle_serving_server-0.3.2-py2-none-any.whl
python -m pip install paddle_serving_server-0.3.2-py2-none-any.whl
#客户端和App包使用以下链接(CPU,GPU通用)
wget --no-check-certificate https://paddle-serving.bj.bcebos.com/others/paddle_serving_app-0.1.2-py2-none-any.whl
wget --no-check-certificate https://paddle-serving.bj.bcebos.com/others/paddle_serving_client-0.3.2-cp27-none-any.whl
python -m pip install paddle_serving_app-0.1.2-py2-none-any.whl paddle_serving_
server_gpu-0.3.2-py2-none-any.whl paddle_serving_
client-0.3.2-cp27-none-any.whl
python -m pip install paddle_serving_app-0.1.2-py2-none-any.whl paddle_serving_client-0.3.2-cp27-none-any.whl
```
### 2. 模型转换
...
...
@@ -53,14 +66,21 @@ tar -xzvf ocr_det.tar.gz
#### 方式1. 启动标准版服务
```
# cpu,gpu启动二选一,以下是cpu启动
python -m paddle_serving_server.serve --model ocr_det_model --port 9293
python ocr_web_server.py cpu
# gpu启动
python -m paddle_serving_server_gpu.serve --model ocr_det_model --port 9293 --gpu_id 0
python ocr_web_server.py
python ocr_web_server.py
gpu
```
#### 方式2. 启动快速版服务
```
python ocr_local_server.py
# cpu,gpu启动二选一,以下是cpu启动
python ocr_local_server.py cpu
# gpu启动
python ocr_local_server.py gpu
```
## 发送预测请求
...
...
@@ -85,7 +105,7 @@ python ocr_web_client.py
在
`ocr_web_server.py`
或是
`ocr_local_server.py`
当中的
`preprocess`
函数里面做了检测服务和识别服务的前处理,
`postprocess`
函数里面做了识别的后处理服务,可以在相应的函数中做修改。调用了
`paddle_serving_app`
库提供的常见CV模型的前处理/后处理库。
如果想要单独启动Paddle Serving的检测服务和识别服务,参见下列表格, 执行对应的脚本即可。
如果想要单独启动Paddle Serving的检测服务和识别服务,参见下列表格, 执行对应的脚本即可
,并且在命令行参数注明用的CPU或是GPU来提供服务
。
| 模型 | 标准版 | 快速版 |
| ---- | ----------------- | ------------------- |
...
...
deploy/pdserving/rec_web_server.py
浏览文件 @
1e8f4146
...
...
@@ -22,7 +22,10 @@ from paddle_serving_client import Client
from
paddle_serving_app.reader
import
Sequential
,
URL2Image
,
ResizeByFactor
from
paddle_serving_app.reader
import
Div
,
Normalize
,
Transpose
from
paddle_serving_app.reader
import
DBPostProcess
,
FilterBoxes
,
GetRotateCropImage
,
SortedBoxes
from
paddle_serving_server_gpu.web_service
import
WebService
if
sys
.
argv
[
1
]
==
'gpu'
:
from
paddle_serving_server_gpu.web_service
import
WebService
elif
sys
.
argv
[
1
]
==
'cpu'
:
from
paddle_serving_server.web_service
import
WebService
import
time
import
re
import
base64
...
...
@@ -64,8 +67,11 @@ class OCRService(WebService):
ocr_service
=
OCRService
(
name
=
"ocr"
)
ocr_service
.
load_model_config
(
"ocr_rec_model"
)
ocr_service
.
set_gpus
(
"0"
)
ocr_service
.
init_rec
()
ocr_service
.
prepare_server
(
workdir
=
"workdir"
,
port
=
9292
,
device
=
"gpu"
,
gpuid
=
0
)
if
sys
.
argv
[
1
]
==
'gpu'
:
ocr_service
.
set_gpus
(
"0"
)
ocr_service
.
prepare_server
(
workdir
=
"workdir"
,
port
=
9292
,
device
=
"gpu"
,
gpuid
=
0
)
elif
sys
.
argv
[
1
]
==
'cpu'
:
ocr_service
.
prepare_server
(
workdir
=
"workdir"
,
port
=
9292
,
device
=
"cpu"
)
ocr_service
.
run_rpc_service
()
ocr_service
.
run_web_service
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录