Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
ff2ebc27
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看板
提交
ff2ebc27
编写于
2月 06, 2020
作者:
D
Dong Daxiang
提交者:
GitHub
2月 06, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update README.md
上级
dbef5e5f
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
39 addition
and
21 deletion
+39
-21
README.md
README.md
+39
-21
未找到文件。
README.md
浏览文件 @
ff2ebc27
...
...
@@ -17,11 +17,6 @@ import sys
import
paddle
import
logging
import
paddle.fluid
as
fluid
import
paddle_serving
as
serving
logging
.
basicConfig
(
format
=
'%(asctime)s - %(levelname)s - %(message)s'
)
logger
=
logging
.
getLogger
(
"fluid"
)
logger
.
setLevel
(
logging
.
INFO
)
def
load_vocab
(
filename
):
vocab
=
{}
...
...
@@ -56,46 +51,69 @@ if __name__ == "__main__":
exe
=
fluid
.
Executor
(
fluid
.
CPUPlace
())
exe
.
run
(
fluid
.
default_startup_program
())
epochs
=
30
save_dirname
=
"cnn_model"
import
paddle_serving_client.io
as
serving_io
for
i
in
range
(
epochs
):
exe
.
train_from_dataset
(
program
=
fluid
.
default_main_program
(),
dataset
=
dataset
,
debug
=
False
)
logger
.
info
(
"TRAIN --> pass: {}"
.
format
(
i
))
fluid
.
io
.
save_inference_model
(
"%s/epoch%d.model"
%
(
save_dirname
,
i
),
[
data
.
name
,
label
.
name
],
[
acc
],
exe
)
serving
.
save_model
(
"%s/epoch%d.model"
%
(
save_dirname
,
i
),
"client_config{}"
.
format
(
i
)
,
if
i
==
20
:
serving_io
.
save_model
(
"serving_server_model"
,
"serving_client_conf"
,
{
"words"
:
data
,
"label"
:
label
},
{
"acc"
:
acc
,
"cost"
:
avg_cost
,
"prediction"
:
prediction
})
{
"cost"
:
avg_cost
,
"acc"
:
acc
,
"prediction"
:
prediction
},
fluid
.
default_main_program
())
```
#### 本地服务启动
TBA
#### 服务器端代码
```
python
import
sys
from
paddle_serving.serving_server
import
OpMaker
from
paddle_serving.serving_server
import
OpSeqMaker
from
paddle_serving.serving_server
import
Server
op_maker
=
OpMaker
()
read_op
=
op_maker
.
create
(
'general_reader'
)
general_infer_op
=
op_maker
.
create
(
'general_infer'
)
op_seq_maker
=
OpSeqMaker
()
op_seq_maker
.
add_op
(
read_op
)
op_seq_maker
.
add_op
(
general_infer_op
)
server
=
Server
()
server
.
set_op_sequence
(
op_seq_maker
.
get_op_sequence
())
server
.
load_model_config
(
sys
.
argv
[
1
])
server
.
prepare_server
(
workdir
=
"work_dir1"
,
port
=
9393
,
device
=
"cpu"
)
server
.
run_server
()
```
#### 服务器端启动
```
shell
python test_server.py serving_server_model
```
#### 客户端预测
```
python
from
paddle_serving
import
Client
from
paddle_serving
_client
import
Client
import
sys
client
=
Client
()
client
.
load_client_config
(
sys
.
argv
[
1
])
client
.
connect
([
"127.0.0.1:9
292
"
])
client
.
connect
([
"127.0.0.1:9
393
"
])
for
line
in
sys
.
stdin
:
group
=
line
.
strip
().
split
()
words
=
[
int
(
x
)
for
x
in
group
[
1
:
int
(
group
[
0
])]]
words
=
[
int
(
x
)
for
x
in
group
[
1
:
int
(
group
[
0
])
+
1
]]
label
=
[
int
(
group
[
-
1
])]
feed
=
{
"words"
:
words
,
"label"
:
label
}
fetch
=
[
"
acc"
,
"cost
"
,
"prediction"
]
fetch
=
[
"
cost"
,
"acc
"
,
"prediction"
]
fetch_map
=
client
.
predict
(
feed
=
feed
,
fetch
=
fetch
)
print
(
"{} {}"
.
format
(
fetch_map
[
"prediction"
][
1
],
label
[
0
]))
```
#### 完成操作截屏
TBA
### 文档
[
设计文档
](
doc/DESIGN.md
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录