Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
未来在这儿
X2Paddle
提交
1c79e067
X
X2Paddle
项目概览
未来在这儿
/
X2Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / X2Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
X2Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1c79e067
编写于
7月 03, 2020
作者:
C
Channingss
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
set asymmetric as defalut mode of Resize
上级
853731b8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
6 deletion
+13
-6
x2paddle/convert.py
x2paddle/convert.py
+9
-3
x2paddle/op_mapper/paddle_op_mapper.py
x2paddle/op_mapper/paddle_op_mapper.py
+4
-3
未找到文件。
x2paddle/convert.py
浏览文件 @
1c79e067
...
...
@@ -75,6 +75,12 @@ def arg_parser():
action
=
"store_true"
,
default
=
False
,
help
=
"define input shape for tf model"
)
parser
.
add_argument
(
"--onnx_opset"
,
"-oo"
,
type
=
int
,
default
=
10
,
help
=
"when paddle2onnx set onnx opset version to export"
)
parser
.
add_argument
(
"--params_merge"
,
"-pm"
,
...
...
@@ -186,12 +192,12 @@ def onnx2paddle(model_path, save_dir, params_merge=False):
print
(
"Paddle model and code generated."
)
def
paddle2onnx
(
model_path
,
save_dir
):
def
paddle2onnx
(
model_path
,
save_dir
,
opset
):
from
x2paddle.decoder.paddle_decoder
import
PaddleDecoder
from
x2paddle.op_mapper.paddle_op_mapper
import
PaddleOpMapper
model
=
PaddleDecoder
(
model_path
,
'__model__'
,
'__params__'
)
mapper
=
PaddleOpMapper
()
mapper
.
convert
(
model
.
program
,
save_dir
)
mapper
.
convert
(
model
.
program
,
save_dir
,
opset
)
def
main
():
...
...
@@ -258,7 +264,7 @@ def main():
elif
args
.
framework
==
"paddle2onnx"
:
assert
args
.
model
is
not
None
,
"--model should be defined while translating paddle model to onnx"
paddle2onnx
(
args
.
model
,
args
.
save_dir
)
paddle2onnx
(
args
.
model
,
args
.
save_dir
,
args
.
onnx_opset
)
else
:
raise
Exception
(
...
...
x2paddle/op_mapper/paddle_op_mapper.py
浏览文件 @
1c79e067
...
...
@@ -37,12 +37,11 @@ class PaddleOpMapper(object):
self
.
name_counter
=
dict
()
def
convert
(
self
,
program
,
save_dir
):
def
convert
(
self
,
program
,
save_dir
,
opset
=
10
):
weight_nodes
=
self
.
convert_weights
(
program
)
op_nodes
=
list
()
input_nodes
=
list
()
output_nodes
=
list
()
unsupported_ops
=
set
()
print
(
"Translating PaddlePaddle to ONNX...
\n
"
)
...
...
@@ -81,7 +80,9 @@ class PaddleOpMapper(object):
initializer
=
[],
inputs
=
input_nodes
,
outputs
=
output_nodes
)
model
=
helper
.
make_model
(
graph
,
producer_name
=
'X2Paddle'
)
opset_imports
=
[
helper
.
make_opsetid
(
""
,
opset
)]
model
=
helper
.
make_model
(
graph
,
producer_name
=
'X2Paddle'
,
opset_imports
=
opset_imports
)
onnx
.
checker
.
check_model
(
model
)
if
not
os
.
path
.
isdir
(
save_dir
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录