Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
a4b89dc5
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看板
提交
a4b89dc5
编写于
3月 23, 2020
作者:
B
barrierye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update the usage of Client in python examples
上级
392c85a7
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
47 addition
and
22 deletion
+47
-22
python/examples/bert/benchmark.py
python/examples/bert/benchmark.py
+3
-1
python/examples/bert/benchmark_batch.py
python/examples/bert/benchmark_batch.py
+3
-1
python/examples/bert/bert_client.py
python/examples/bert/bert_client.py
+2
-1
python/examples/criteo_ctr/benchmark.py
python/examples/criteo_ctr/benchmark.py
+3
-1
python/examples/criteo_ctr/benchmark_batch.py
python/examples/criteo_ctr/benchmark_batch.py
+3
-1
python/examples/criteo_ctr/test_client.py
python/examples/criteo_ctr/test_client.py
+2
-1
python/examples/criteo_ctr_with_cube/benchmark.py
python/examples/criteo_ctr_with_cube/benchmark.py
+2
-1
python/examples/criteo_ctr_with_cube/benchmark_batch.py
python/examples/criteo_ctr_with_cube/benchmark_batch.py
+2
-1
python/examples/criteo_ctr_with_cube/test_client.py
python/examples/criteo_ctr_with_cube/test_client.py
+2
-1
python/examples/fit_a_line/benchmark.py
python/examples/fit_a_line/benchmark.py
+2
-1
python/examples/fit_a_line/test_client.py
python/examples/fit_a_line/test_client.py
+2
-3
python/examples/imagenet/benchmark.py
python/examples/imagenet/benchmark.py
+4
-1
python/examples/imagenet/benchmark_batch.py
python/examples/imagenet/benchmark_batch.py
+3
-1
python/examples/imagenet/image_rpc_client.py
python/examples/imagenet/image_rpc_client.py
+2
-1
python/examples/imdb/benchmark.py
python/examples/imdb/benchmark.py
+2
-1
python/examples/imdb/benchmark_batch.py
python/examples/imdb/benchmark_batch.py
+2
-1
python/examples/imdb/test_client.py
python/examples/imdb/test_client.py
+2
-1
python/examples/imdb/test_client_batch.py
python/examples/imdb/test_client_batch.py
+2
-1
python/examples/lac/benchmark.py
python/examples/lac/benchmark.py
+2
-1
python/examples/lac/lac_client.py
python/examples/lac/lac_client.py
+2
-1
未找到文件。
python/examples/bert/benchmark.py
浏览文件 @
a4b89dc5
...
...
@@ -41,7 +41,9 @@ def single_func(idx, resource):
fetch
=
[
"pooled_output"
]
client
=
Client
()
client
.
load_client_config
(
args
.
model
)
client
.
connect
([
resource
[
"endpoint"
][
idx
%
len
(
resource
[
"endpoint"
])]])
client
.
add_variant
(
"var1"
,
[
resource
[
"endpoint"
][
idx
%
len
(
resource
[
"endpoint"
])]],
50
)
client
.
connect
()
start
=
time
.
time
()
for
i
in
range
(
1000
):
...
...
python/examples/bert/benchmark_batch.py
浏览文件 @
a4b89dc5
...
...
@@ -40,7 +40,9 @@ def single_func(idx, resource):
fetch
=
[
"pooled_output"
]
client
=
Client
()
client
.
load_client_config
(
args
.
model
)
client
.
connect
([
resource
[
"endpoint"
][
idx
%
len
(
resource
[
"endpoint"
])]])
client
.
add_variant
(
"var1"
,
[
resource
[
"endpoint"
][
idx
%
len
(
resource
[
"endpoint"
])]],
50
)
client
.
connect
()
feed_batch
=
[]
for
bi
in
range
(
args
.
batch_size
):
feed_batch
.
append
(
reader
.
process
(
dataset
[
bi
]))
...
...
python/examples/bert/bert_client.py
浏览文件 @
a4b89dc5
...
...
@@ -33,7 +33,8 @@ fetch = ["pooled_output"]
endpoint_list
=
[
"127.0.0.1:9494"
]
client
=
Client
()
client
.
load_client_config
(
args
.
model
)
client
.
connect
(
endpoint_list
)
client
.
add_variant
(
"var1"
,
endpoint_list
,
50
)
client
.
connect
()
for
line
in
fin
:
feed_dict
=
reader
.
process
(
line
)
...
...
python/examples/criteo_ctr/benchmark.py
浏览文件 @
a4b89dc5
...
...
@@ -43,7 +43,9 @@ def single_func(idx, resource):
fetch
=
[
"prob"
]
client
=
Client
()
client
.
load_client_config
(
args
.
model
)
client
.
connect
([
resource
[
"endpoint"
][
idx
%
len
(
resource
[
"endpoint"
])]])
client
.
add_variant
(
"var1"
,
[
resource
[
"endpoint"
][
idx
%
len
(
resource
[
"endpoint"
])]],
50
)
client
.
connect
()
start
=
time
.
time
()
for
i
in
range
(
1000
):
...
...
python/examples/criteo_ctr/benchmark_batch.py
浏览文件 @
a4b89dc5
...
...
@@ -43,7 +43,9 @@ def single_func(idx, resource):
fetch
=
[
"prob"
]
client
=
Client
()
client
.
load_client_config
(
args
.
model
)
client
.
connect
([
resource
[
"endpoint"
][
idx
%
len
(
resource
[
"endpoint"
])]])
client
.
add_variant
(
"var1"
,
[
resource
[
"endpoint"
][
idx
%
len
(
resource
[
"endpoint"
])]],
50
)
client
.
connect
()
start
=
time
.
time
()
for
i
in
range
(
1000
):
...
...
python/examples/criteo_ctr/test_client.py
浏览文件 @
a4b89dc5
...
...
@@ -23,7 +23,8 @@ from paddle_serving_client.metric import auc
client
=
Client
()
client
.
load_client_config
(
sys
.
argv
[
1
])
client
.
connect
([
"127.0.0.1:9292"
])
client
.
add_variant
(
"var1"
,
[
"127.0.0.1:9292"
],
50
)
client
.
connect
()
batch
=
1
buf_size
=
100
...
...
python/examples/criteo_ctr_with_cube/benchmark.py
浏览文件 @
a4b89dc5
...
...
@@ -30,7 +30,8 @@ args = benchmark_args()
def
single_func
(
idx
,
resource
):
client
=
Client
()
client
.
load_client_config
(
'ctr_client_conf/serving_client_conf.prototxt'
)
client
.
connect
([
'127.0.0.1:9292'
])
client
.
add_variant
(
"var1"
,
[
'127.0.0.1:9292'
],
50
)
client
.
connect
()
batch
=
1
buf_size
=
100
dataset
=
criteo
.
CriteoDataset
()
...
...
python/examples/criteo_ctr_with_cube/benchmark_batch.py
浏览文件 @
a4b89dc5
...
...
@@ -31,7 +31,8 @@ def single_func(idx, resource):
client
=
Client
()
print
([
resource
[
"endpoint"
][
idx
%
len
(
resource
[
"endpoint"
])]])
client
.
load_client_config
(
'ctr_client_conf/serving_client_conf.prototxt'
)
client
.
connect
([
'127.0.0.1:9292'
])
client
.
add_variant
(
"var1"
,
[
'127.0.0.1:9292'
],
50
)
client
.
connect
()
batch
=
1
buf_size
=
100
dataset
=
criteo
.
CriteoDataset
()
...
...
python/examples/criteo_ctr_with_cube/test_client.py
浏览文件 @
a4b89dc5
...
...
@@ -22,7 +22,8 @@ from paddle_serving_client.metric import auc
client
=
Client
()
client
.
load_client_config
(
sys
.
argv
[
1
])
client
.
connect
([
"127.0.0.1:9292"
])
client
.
add_variant
(
"var1"
,
[
'127.0.0.1:9292'
],
50
)
client
.
connect
()
batch
=
1
buf_size
=
100
...
...
python/examples/fit_a_line/benchmark.py
浏览文件 @
a4b89dc5
...
...
@@ -28,7 +28,8 @@ def single_func(idx, resource):
if
args
.
request
==
"rpc"
:
client
=
Client
()
client
.
load_client_config
(
args
.
model
)
client
.
connect
([
args
.
endpoint
])
client
.
add_variant
(
"var1"
,
[
args
.
endpoint
],
50
)
client
.
connect
()
train_reader
=
paddle
.
batch
(
paddle
.
reader
.
shuffle
(
paddle
.
dataset
.
uci_housing
.
train
(),
buf_size
=
500
),
...
...
python/examples/fit_a_line/test_client.py
浏览文件 @
a4b89dc5
...
...
@@ -28,6 +28,5 @@ test_reader = paddle.batch(
batch_size
=
1
)
for
data
in
test_reader
():
[
fetch_map
,
server_pid
]
=
client
.
predict
(
feed
=
{
"x"
:
data
[
0
][
0
]},
fetch
=
[
"price"
],
need_server_pid
=
True
)
print
(
"[{}] {} {}"
.
format
(
server_pid
,
fetch_map
[
"price"
][
0
],
data
[
0
][
1
][
0
]))
fetch_map
=
client
.
predict
(
feed
=
{
"x"
:
data
[
0
][
0
]},
fetch
=
[
"price"
])
print
(
"{} {}"
.
format
(
fetch_map
[
"price"
][
0
],
data
[
0
][
1
][
0
]))
python/examples/imagenet/benchmark.py
浏览文件 @
a4b89dc5
...
...
@@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# pylint: disable=doc-string-missing
import
sys
from
image_reader
import
ImageReader
...
...
@@ -35,7 +36,9 @@ def single_func(idx, resource):
fetch
=
[
"score"
]
client
=
Client
()
client
.
load_client_config
(
args
.
model
)
client
.
connect
([
resource
[
"endpoint"
][
idx
%
len
(
resource
[
"endpoint"
])]])
client
.
add_variant
(
"var1"
,
[
resource
[
"endpoint"
][
idx
%
len
(
resource
[
"endpoint"
])]],
50
)
client
.
connect
()
start
=
time
.
time
()
for
i
in
range
(
1000
):
...
...
python/examples/imagenet/benchmark_batch.py
浏览文件 @
a4b89dc5
...
...
@@ -41,7 +41,9 @@ def single_func(idx, resource):
fetch
=
[
"score"
]
client
=
Client
()
client
.
load_client_config
(
args
.
model
)
client
.
connect
([
resource
[
"endpoint"
][
idx
%
len
(
resource
[
"endpoint"
])]])
client
.
add_variant
(
"var1"
,
[
resource
[
"endpoint"
][
idx
%
len
(
resource
[
"endpoint"
])]],
50
)
client
.
connect
()
start
=
time
.
time
()
for
i
in
range
(
1000
):
if
args
.
batch_size
>=
1
:
...
...
python/examples/imagenet/image_rpc_client.py
浏览文件 @
a4b89dc5
...
...
@@ -19,7 +19,8 @@ import time
client
=
Client
()
client
.
load_client_config
(
sys
.
argv
[
1
])
client
.
connect
([
"127.0.0.1:9295"
])
client
.
add_variant
(
"var1"
,
[
"127.0.0.1:9295"
],
50
)
client
.
connect
()
reader
=
ImageReader
()
start
=
time
.
time
()
...
...
python/examples/imdb/benchmark.py
浏览文件 @
a4b89dc5
...
...
@@ -35,7 +35,8 @@ def single_func(idx, resource):
if
args
.
request
==
"rpc"
:
client
=
Client
()
client
.
load_client_config
(
args
.
model
)
client
.
connect
([
args
.
endpoint
])
client
.
add_variant
(
"var1"
,
[
args
.
endpoint
],
50
)
client
.
connect
()
for
i
in
range
(
1000
):
if
args
.
batch_size
==
1
:
word_ids
,
label
=
imdb_dataset
.
get_words_and_label
(
line
)
...
...
python/examples/imdb/benchmark_batch.py
浏览文件 @
a4b89dc5
...
...
@@ -35,7 +35,8 @@ def single_func(idx, resource):
if
args
.
request
==
"rpc"
:
client
=
Client
()
client
.
load_client_config
(
args
.
model
)
client
.
connect
([
args
.
endpoint
])
client
.
add_variant
(
"var1"
,
[
args
.
endpoint
],
50
)
client
.
connect
()
for
i
in
range
(
1000
):
if
args
.
batch_size
>=
1
:
feed_batch
=
[]
...
...
python/examples/imdb/test_client.py
浏览文件 @
a4b89dc5
...
...
@@ -18,7 +18,8 @@ import sys
client
=
Client
()
client
.
load_client_config
(
sys
.
argv
[
1
])
client
.
connect
([
"127.0.0.1:9292"
])
client
.
add_variant
(
"var1"
,
[
"127.0.0.1:9292"
],
50
)
client
.
connect
()
# you can define any english sentence or dataset here
# This example reuses imdb reader in training, you
...
...
python/examples/imdb/test_client_batch.py
浏览文件 @
a4b89dc5
...
...
@@ -23,7 +23,8 @@ import time
def
batch_predict
(
batch_size
=
4
):
client
=
Client
()
client
.
load_client_config
(
conf_file
)
client
.
connect
([
"127.0.0.1:9292"
])
client
.
add_variant
(
"var1"
,
[
"127.0.0.1:9292"
],
50
)
client
.
connect
()
fetch
=
[
"acc"
,
"cost"
,
"prediction"
]
feed_batch
=
[]
for
line
in
sys
.
stdin
:
...
...
python/examples/lac/benchmark.py
浏览文件 @
a4b89dc5
...
...
@@ -30,7 +30,8 @@ def single_func(idx, resource):
if
args
.
request
==
"rpc"
:
client
=
Client
()
client
.
load_client_config
(
args
.
model
)
client
.
connect
([
args
.
endpoint
])
client
.
add_variant
(
"var1"
,
[
args
.
endpoint
],
50
)
client
.
connect
()
fin
=
open
(
"jieba_test.txt"
)
for
line
in
fin
:
feed_data
=
reader
.
process
(
line
)
...
...
python/examples/lac/lac_client.py
浏览文件 @
a4b89dc5
...
...
@@ -22,7 +22,8 @@ import io
client
=
Client
()
client
.
load_client_config
(
sys
.
argv
[
1
])
client
.
connect
([
"127.0.0.1:9280"
])
client
.
add_variant
(
"var1"
,
[
"127.0.0.1:9280"
],
50
)
client
.
connect
()
reader
=
LACReader
(
sys
.
argv
[
2
])
for
line
in
sys
.
stdin
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录