Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
dc5c9786
S
Serving
项目概览
PaddlePaddle
/
Serving
1 年多 前同步成功
通知
186
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
dc5c9786
编写于
1月 19, 2021
作者:
J
Jiawei Wang
提交者:
wangjiawei04
1月 19, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merge pull request #967 from wangjiawei04/autoshape
Auto shape for Web Service
上级
f10e820d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
5 deletion
+23
-5
python/paddle_serving_server/web_service.py
python/paddle_serving_server/web_service.py
+12
-3
python/paddle_serving_server_gpu/web_service.py
python/paddle_serving_server_gpu/web_service.py
+11
-2
未找到文件。
python/paddle_serving_server/web_service.py
浏览文件 @
dc5c9786
...
...
@@ -20,7 +20,7 @@ from paddle_serving_server import OpMaker, OpSeqMaker, Server
from
paddle_serving_client
import
Client
from
contextlib
import
closing
import
socket
import
numpy
as
np
from
paddle_serving_server
import
pipeline
from
paddle_serving_server.pipeline
import
Op
...
...
@@ -64,8 +64,8 @@ class WebService(object):
f
=
open
(
client_config
,
'r'
)
model_conf
=
google
.
protobuf
.
text_format
.
Merge
(
str
(
f
.
read
()),
model_conf
)
self
.
feed_
names
=
[
var
.
alias_name
for
var
in
model_conf
.
feed_var
]
self
.
fetch_
names
=
[
var
.
alias_name
for
var
in
model_conf
.
fetch_var
]
self
.
feed_
vars
=
{
var
.
name
:
var
for
var
in
model_conf
.
feed_var
}
self
.
fetch_
vars
=
{
var
.
name
:
var
for
var
in
model_conf
.
fetch_var
}
def
_launch_rpc_service
(
self
):
op_maker
=
OpMaker
()
...
...
@@ -201,6 +201,15 @@ class WebService(object):
def
preprocess
(
self
,
feed
=
[],
fetch
=
[]):
print
(
"This API will be deprecated later. Please do not use it"
)
is_batch
=
True
feed_dict
=
{}
for
var_name
in
self
.
feed_vars
.
keys
():
feed_dict
[
var_name
]
=
[]
for
feed_ins
in
feed
:
for
key
in
feed_ins
:
feed_dict
[
key
].
append
(
np
.
array
(
feed_ins
[
key
]).
reshape
(
list
(
self
.
feed_vars
[
key
].
shape
))[
np
.
newaxis
,:])
feed
=
{}
for
key
in
feed_dict
:
feed
[
key
]
=
np
.
concatenate
(
feed_dict
[
key
],
axis
=
0
)
return
feed
,
fetch
,
is_batch
def
postprocess
(
self
,
feed
=
[],
fetch
=
[],
fetch_map
=
None
):
...
...
python/paddle_serving_server_gpu/web_service.py
浏览文件 @
dc5c9786
...
...
@@ -70,8 +70,8 @@ class WebService(object):
f
=
open
(
client_config
,
'r'
)
model_conf
=
google
.
protobuf
.
text_format
.
Merge
(
str
(
f
.
read
()),
model_conf
)
self
.
feed_
names
=
[
var
.
alias_name
for
var
in
model_conf
.
feed_var
]
self
.
fetch_
names
=
[
var
.
alias_name
for
var
in
model_conf
.
fetch_var
]
self
.
feed_
vars
=
{
var
.
name
:
var
for
var
in
model_conf
.
feed_var
}
self
.
fetch_
vars
=
{
var
.
name
:
var
for
var
in
model_conf
.
fetch_var
}
def
set_gpus
(
self
,
gpus
):
print
(
"This API will be deprecated later. Please do not use it"
)
...
...
@@ -278,6 +278,15 @@ class WebService(object):
def
preprocess
(
self
,
feed
=
[],
fetch
=
[]):
print
(
"This API will be deprecated later. Please do not use it"
)
is_batch
=
True
feed_dict
=
{}
for
var_name
in
self
.
feed_vars
.
keys
():
feed_dict
[
var_name
]
=
[]
for
feed_ins
in
feed
:
for
key
in
feed_ins
:
feed_dict
[
key
].
append
(
np
.
array
(
feed_ins
[
key
]).
reshape
(
list
(
self
.
feed_vars
[
key
].
shape
))[
np
.
newaxis
,:])
feed
=
{}
for
key
in
feed_dict
:
feed
[
key
]
=
np
.
concatenate
(
feed_dict
[
key
],
axis
=
0
)
return
feed
,
fetch
,
is_batch
def
postprocess
(
self
,
feed
=
[],
fetch
=
[],
fetch_map
=
None
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录