Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
cf4a432e
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
185
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cf4a432e
编写于
4月 24, 2021
作者:
Z
zhangjun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix, remove webservcie for xpu example
上级
3661f972
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
3 addition
and
115 deletion
+3
-115
python/examples/xpu/ernie/README.md
python/examples/xpu/ernie/README.md
+2
-2
python/examples/xpu/ernie/ernie_client.py
python/examples/xpu/ernie/ernie_client.py
+1
-1
python/examples/xpu/fit_a_line_xpu/README.md
python/examples/xpu/fit_a_line_xpu/README.md
+0
-16
python/examples/xpu/fit_a_line_xpu/README_CN.md
python/examples/xpu/fit_a_line_xpu/README_CN.md
+0
-17
python/examples/xpu/fit_a_line_xpu/test_multi_process_client.py
.../examples/xpu/fit_a_line_xpu/test_multi_process_client.py
+0
-42
python/examples/xpu/fit_a_line_xpu/test_server.py
python/examples/xpu/fit_a_line_xpu/test_server.py
+0
-37
未找到文件。
python/examples/xpu/ernie/README.md
浏览文件 @
cf4a432e
...
...
@@ -11,8 +11,8 @@ python3 -m paddle_serving_client.convert --dirname ernie
```
### or, you can get the serving saved model directly
```
wget https://paddle-serving.bj.bcebos.com/models/xpu/
bert
.tar.gz
tar zxvf
bert
.tar.gz
wget https://paddle-serving.bj.bcebos.com/models/xpu/
ernie
.tar.gz
tar zxvf
ernie
.tar.gz
```
### Getting Dict and Sample Dataset
...
...
python/examples/xpu/ernie/ernie_client.py
浏览文件 @
cf4a432e
...
...
@@ -23,7 +23,7 @@ args = benchmark_args()
reader
=
ChineseErnieReader
({
"max_seq_len"
:
128
})
fetch
=
[
"save_infer_model/scale_0"
]
endpoint_list
=
[
'127.0.0.1:
7704
'
]
endpoint_list
=
[
'127.0.0.1:
12000
'
]
client
=
Client
()
client
.
load_client_config
(
args
.
model
)
client
.
connect
(
endpoint_list
)
...
...
python/examples/xpu/fit_a_line_xpu/README.md
浏览文件 @
cf4a432e
...
...
@@ -29,19 +29,3 @@ The `paddlepaddle` package is used in `test_client.py`, and you may need to down
python test_client.py uci_housing_client/serving_client_conf.prototxt
```
## HTTP service
### Start server
Start a web service with default web service hosting modules:
```
shell
python test_server.py
```
### Client prediction
```
shell
curl
-H
"Content-Type:application/json"
-X
POST
-d
'{"feed":[{"x": [0.0137, -0.1136, 0.2553, -0.0692, 0.0582, -0.0727, -0.1583, -0.0584, 0.6283, 0.4919, 0.1856, 0.0795, -0.0332]}], "fetch":["price"]}'
http://127.0.0.1:9292/uci/prediction
```
python/examples/xpu/fit_a_line_xpu/README_CN.md
浏览文件 @
cf4a432e
...
...
@@ -32,20 +32,3 @@ python -m paddle_serving_server.serve --model uci_housing_model --thread 10 --po
python test_client.py uci_housing_client/serving_client_conf.prototxt
```
## HTTP服务
### 开启服务端
通过下面的一行代码开启默认web服务:
```
shell
python test_server.py
```
### 客户端预测
```
shell
curl
-H
"Content-Type:application/json"
-X
POST
-d
'{"feed":[{"x": [0.0137, -0.1136, 0.2553, -0.0692, 0.0582, -0.0727, -0.1583, -0.0584, 0.6283, 0.4919, 0.1856, 0.0795, -0.0332]}], "fetch":["price"]}'
http://127.0.0.1:9292/uci/prediction
```
python/examples/xpu/fit_a_line_xpu/test_multi_process_client.py
已删除
100644 → 0
浏览文件 @
3661f972
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
from
paddle_serving_client
import
Client
from
paddle_serving_client.utils
import
MultiThreadRunner
import
paddle
import
numpy
as
np
def
single_func
(
idx
,
resource
):
client
=
Client
()
client
.
load_client_config
(
"./uci_housing_client/serving_client_conf.prototxt"
)
client
.
connect
([
"127.0.0.1:9293"
,
"127.0.0.1:9292"
])
x
=
[
0.0137
,
-
0.1136
,
0.2553
,
-
0.0692
,
0.0582
,
-
0.0727
,
-
0.1583
,
-
0.0584
,
0.6283
,
0.4919
,
0.1856
,
0.0795
,
-
0.0332
]
x
=
np
.
array
(
x
)
for
i
in
range
(
1000
):
fetch_map
=
client
.
predict
(
feed
=
{
"x"
:
x
},
fetch
=
[
"price"
])
if
fetch_map
is
None
:
return
[[
None
]]
return
[[
0
]]
multi_thread_runner
=
MultiThreadRunner
()
thread_num
=
4
result
=
multi_thread_runner
.
run
(
single_func
,
thread_num
,
{})
if
None
in
result
[
0
]:
exit
(
1
)
python/examples/xpu/fit_a_line_xpu/test_server.py
已删除
100644 → 0
浏览文件 @
3661f972
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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
from
paddle_serving_server.web_service
import
WebService
import
numpy
as
np
class
UciService
(
WebService
):
def
preprocess
(
self
,
feed
=
[],
fetch
=
[]):
feed_batch
=
[]
is_batch
=
True
new_data
=
np
.
zeros
((
len
(
feed
),
1
,
13
)).
astype
(
"float32"
)
for
i
,
ins
in
enumerate
(
feed
):
nums
=
np
.
array
(
ins
[
"x"
]).
reshape
(
1
,
1
,
13
)
new_data
[
i
]
=
nums
feed
=
{
"x"
:
new_data
}
return
feed
,
fetch
,
is_batch
uci_service
=
UciService
(
name
=
"uci"
)
uci_service
.
load_model_config
(
"uci_housing_model"
)
uci_service
.
prepare_server
(
workdir
=
"workdir"
,
port
=
9393
,
use_lite
=
True
,
use_xpu
=
True
,
ir_optim
=
True
)
uci_service
.
run_rpc_service
()
uci_service
.
run_web_service
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录