Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
19b22a59
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看板
提交
19b22a59
编写于
11月 14, 2021
作者:
B
bjjwwang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix save model
上级
1f35ae38
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
822 addition
and
3 deletion
+822
-3
python/paddle_serving_client/io/__init__.py
python/paddle_serving_client/io/__init__.py
+5
-3
python/paddle_serving_client/io/paddle_io.py
python/paddle_serving_client/io/paddle_io.py
+817
-0
未找到文件。
python/paddle_serving_client/io/__init__.py
浏览文件 @
19b22a59
...
...
@@ -19,7 +19,7 @@ from paddle.fluid.framework import core
from
paddle.fluid.framework
import
default_main_program
from
paddle.fluid.framework
import
Program
from
paddle.fluid
import
CPUPlace
from
paddle.fluid.io
import
save_inference_model
from
.paddle_io
import
save_inference_model
,
normalize_program
import
paddle.fluid
as
fluid
from
paddle.fluid.core
import
CipherUtils
from
paddle.fluid.core
import
CipherFactory
...
...
@@ -191,12 +191,14 @@ def save_model(server_model_folder,
executor
=
Executor
(
place
=
CPUPlace
())
feed_var_names
=
[
feed_var_dict
[
x
].
name
for
x
in
feed_var_dict
]
feed_vars
=
[
feed_var_dict
[
x
]
for
x
in
feed_var_dict
]
target_vars
=
[]
target_var_names
=
[]
for
key
in
sorted
(
fetch_var_dict
.
keys
()):
target_vars
.
append
(
fetch_var_dict
[
key
])
target_var_names
.
append
(
key
)
main_program
=
normalize_program
(
main_program
,
feed_vars
,
target_vars
)
if
not
encryption
and
not
show_proto
:
if
not
os
.
path
.
exists
(
server_model_folder
):
os
.
makedirs
(
server_model_folder
)
...
...
@@ -209,7 +211,7 @@ def save_model(server_model_folder,
new_params_path
=
os
.
path
.
join
(
server_model_folder
,
params_filename
)
with
open
(
new_model_path
,
"wb"
)
as
new_model_file
:
new_model_file
.
write
(
main_program
.
desc
.
serialize_to_string
())
new_model_file
.
write
(
main_program
.
_remove_training_info
(
False
).
desc
.
serialize_to_string
())
paddle
.
static
.
save_vars
(
executor
=
executor
,
...
...
@@ -229,7 +231,7 @@ def save_model(server_model_folder,
key
=
CipherUtils
.
gen_key_to_file
(
128
,
"key"
)
params
=
fluid
.
io
.
save_persistables
(
executor
=
executor
,
dirname
=
None
,
main_program
=
main_program
)
model
=
main_program
.
desc
.
serialize_to_string
()
model
=
main_program
.
_remove_training_info
(
False
).
desc
.
serialize_to_string
()
if
not
os
.
path
.
exists
(
server_model_folder
):
os
.
makedirs
(
server_model_folder
)
os
.
chdir
(
server_model_folder
)
...
...
python/paddle_serving_client/io/paddle_io.py
0 → 100644
浏览文件 @
19b22a59
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录