Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
64b6656e
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看板
提交
64b6656e
编写于
1月 14, 2020
作者:
G
guru4elephant
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add server save_model
上级
c30b3e01
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
41 addition
and
16 deletion
+41
-16
python/examples/imdb/get_data.sh
python/examples/imdb/get_data.sh
+2
-0
python/examples/imdb/inference.conf
python/examples/imdb/inference.conf
+0
-6
python/examples/imdb/local_train.py
python/examples/imdb/local_train.py
+4
-4
python/paddle_serving/__init__.py
python/paddle_serving/__init__.py
+1
-0
python/paddle_serving/io/__init__.py
python/paddle_serving/io/__init__.py
+29
-4
python/setup.py.in
python/setup.py.in
+5
-2
未找到文件。
python/examples/imdb/get_data.sh
0 → 100644
浏览文件 @
64b6656e
wget 10.86.69.44:/home/work/incubate/text_classification_data.tar.gz
tar
-zxvf
text_classification_data.tar.gz
python/examples/imdb/inference.conf
已删除
100644 → 0
浏览文件 @
c30b3e01
2
3
words
1
-
1
0
label
1
1
0
cost
mean_0
.
tmp_0
acc
accuracy_0
.
tmp_0
prediction
fc_1
.
tmp_2
python/examples/imdb/local_train.py
浏览文件 @
64b6656e
...
...
@@ -56,13 +56,13 @@ if __name__ == "__main__":
exe
.
run
(
fluid
.
default_startup_program
())
epochs
=
30
save_dirname
=
"cnn_model"
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
.
io
.
save_model
(
"%s/epoch%d.model"
%
(
save_dirname
,
i
),
[
"words"
,
"label"
],
{
"acc"
:
acc
},
exe
)
serving
.
save_model
(
"%s/epoch%d.model"
%
(
save_dirname
,
i
),
"client_config{}"
.
format
(
i
),
{
"words"
:
data
,
"label"
:
label
},
{
"acc"
:
acc
,
"cost"
:
avg_cost
,
"prediction"
:
prediction
})
python/paddle_serving/__init__.py
浏览文件 @
64b6656e
...
...
@@ -12,3 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from
.serving_client
import
Client
from
.io
import
save_model
python/paddle_serving/io/__init__.py
浏览文件 @
64b6656e
...
...
@@ -12,9 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from
paddle.fluid
import
Executor
from
paddle.fluid.compiler
import
CompiledProgram
from
paddle.fluid.framework
import
Program
from
paddle.fluid.framework
import
default_main_program
from
paddle.fluid
import
CPUPlace
from
paddle.fluid.io
import
save_persistables
import
os
def
save_model
(
server_model_folder
,
client_config_folder
,
...
...
@@ -30,10 +35,30 @@ def save_model(server_model_folder,
if
not
isinstance
(
main_program
,
Program
):
raise
TypeError
(
"program should be as Program type or None"
)
executor
=
Executor
(
place
=
paddle
.
fluid
.
CPUPlace
())
paddle
.
fluid
.
io
.
save_persistables
(
executor
,
server_model_folder
,
main_program
)
executor
=
Executor
(
place
=
CPUPlace
())
save_persistables
(
executor
,
server_model_folder
,
main_program
)
cmd
=
"mkdir -p {}"
.
format
(
client_config_folder
)
os
.
system
(
cmd
)
with
open
(
"{}/client.conf"
.
format
(
client_config_folder
),
"w"
)
as
fout
:
fout
.
write
(
"{} {}
\n
"
.
format
(
len
(
feed_var_dict
),
len
(
fetch_var_dict
)))
for
key
in
feed_var_dict
:
fout
.
write
(
"{}"
.
format
(
key
))
if
feed_var_dict
[
key
].
lod_level
==
1
:
fout
.
write
(
" 1 -1
\n
"
)
elif
feed_var_dict
[
key
].
lod_level
==
0
:
fout
.
write
(
" {}"
.
format
(
len
(
feed_var_dict
[
key
].
shape
)))
for
dim
in
feed_var_dict
[
key
].
shape
:
fout
.
write
(
" {}"
.
format
(
dim
))
fout
.
write
(
"
\n
"
)
for
key
in
fetch_var_dict
:
fout
.
write
(
"{} {}
\n
"
.
format
(
key
,
fetch_var_dict
[
key
].
name
))
cmd
=
"cp {}/client.conf {}/server.conf"
.
format
(
client_config_folder
,
server_model_folder
)
os
.
system
(
cmd
)
python/setup.py.in
浏览文件 @
64b6656e
...
...
@@ -34,12 +34,15 @@ REQUIRED_PACKAGES = [
packages=['paddle_serving',
'paddle_serving.serving_client',
'paddle_serving.proto']
'paddle_serving.proto',
'paddle_serving.io']
package_data={'paddle_serving.serving_client': ['serving_client.so']}
package_dir={'paddle_serving.serving_client':
'${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving/serving_client',
'paddle_serving.proto':
'${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving/proto'}
'${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving/proto',
'paddle_serving.io':
'${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving/io'}
setup(
name='paddle-serving-client',
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录