Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
9d3a4835
X
X2Paddle
项目概览
PaddlePaddle
/
X2Paddle
大约 1 年 前同步成功
通知
328
Star
698
Fork
167
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
26
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
X2Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
26
Issue
26
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9d3a4835
编写于
8月 03, 2020
作者:
C
Channingss
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update user prompt
上级
1472f8d5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
21 addition
and
24 deletion
+21
-24
x2paddle/op_mapper/paddle2onnx/opset11/paddle_custom_layer/multiclass_nms.py
...paddle2onnx/opset11/paddle_custom_layer/multiclass_nms.py
+4
-4
x2paddle/op_mapper/paddle2onnx/opset11/paddle_custom_layer/yolo_box.py
...apper/paddle2onnx/opset11/paddle_custom_layer/yolo_box.py
+5
-16
x2paddle/op_mapper/paddle2onnx/opset9/paddle_custom_layer/multiclass_nms.py
.../paddle2onnx/opset9/paddle_custom_layer/multiclass_nms.py
+4
-4
x2paddle/op_mapper/paddle2onnx/opset9/paddle_custom_layer/yolo_box.py
...mapper/paddle2onnx/opset9/paddle_custom_layer/yolo_box.py
+8
-0
未找到文件。
x2paddle/op_mapper/paddle2onnx/opset11/paddle_custom_layer/multiclass_nms.py
浏览文件 @
9d3a4835
...
@@ -19,7 +19,7 @@ import numpy as np
...
@@ -19,7 +19,7 @@ import numpy as np
import
paddle.fluid.core
as
core
import
paddle.fluid.core
as
core
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
import
onnx
import
onnx
import
warnings
import
logging
from
onnx
import
helper
,
onnx_pb
from
onnx
import
helper
,
onnx_pb
...
@@ -42,9 +42,9 @@ def multiclass_nms(op, block):
...
@@ -42,9 +42,9 @@ def multiclass_nms(op, block):
background
=
attrs
[
'background_label'
]
background
=
attrs
[
'background_label'
]
normalized
=
attrs
[
'normalized'
]
normalized
=
attrs
[
'normalized'
]
if
normalized
==
False
:
if
normalized
==
False
:
warnings
.
warn
(
logging
.
warn
(
'The parameter normalized of multiclass_nms OP of Paddle is False, which has diff with ONNX.
\
"The parameter normalized of multiclass_nms OP of Paddle is False, which has diff with ONNX."
\
Please set normalized=True in multiclass_nms of Paddle'
)
" Please set normalized=True in multiclass_nms of Paddle, see doc Q4 in https://github.com/PaddlePaddle/X2Paddle/blob/develop/FAQ.md"
)
#convert the paddle attribute to onnx tensor
#convert the paddle attribute to onnx tensor
name_score_threshold
=
[
outputs
[
'Out'
][
0
]
+
"@score_threshold"
]
name_score_threshold
=
[
outputs
[
'Out'
][
0
]
+
"@score_threshold"
]
...
...
x2paddle/op_mapper/paddle2onnx/opset11/paddle_custom_layer/yolo_box.py
浏览文件 @
9d3a4835
...
@@ -15,21 +15,9 @@
...
@@ -15,21 +15,9 @@
import
onnx
import
onnx
import
numpy
as
np
import
numpy
as
np
from
onnx
import
onnx_pb
,
helper
from
onnx
import
onnx_pb
,
helper
from
x2paddle.op_mapper.paddle2onnx.opset9.paddle_custom_layer.yolo_box
import
is_static_shape
MAX_FLOAT
=
np
.
asarray
([
255
,
255
,
127
,
127
],
dtype
=
np
.
uint8
).
view
(
np
.
float32
)[
0
]
from
x2paddle.op_mapper.paddle2onnx.opset9.paddle_custom_layer.yolo_box
import
get_old_name
from
x2paddle.op_mapper.paddle2onnx.opset9.paddle_custom_layer.yolo_box
import
MAX_FLOAT32
def
get_old_name
(
arg
,
name_prefix
=
''
):
prefix_index
=
arg
.
find
(
name_prefix
)
if
prefix_index
!=
-
1
:
last_prefix
=
arg
[
len
(
name_prefix
):]
else
:
last_prefix
=
arg
idx
=
last_prefix
.
find
(
'@'
)
if
idx
!=
-
1
:
last_prefix
=
last_prefix
[:
idx
]
return
name_prefix
+
last_prefix
def
yolo_box
(
op
,
block
):
def
yolo_box
(
op
,
block
):
...
@@ -44,6 +32,7 @@ def yolo_box(op, block):
...
@@ -44,6 +32,7 @@ def yolo_box(op, block):
attrs
[
name
]
=
op
.
attr
(
name
)
attrs
[
name
]
=
op
.
attr
(
name
)
model_name
=
outputs
[
'Boxes'
][
0
]
model_name
=
outputs
[
'Boxes'
][
0
]
input_shape
=
block
.
vars
[
get_old_name
(
inputs
[
'X'
][
0
])].
shape
input_shape
=
block
.
vars
[
get_old_name
(
inputs
[
'X'
][
0
])].
shape
is_static_shape
(
input_shape
)
image_size
=
inputs
[
'ImgSize'
]
image_size
=
inputs
[
'ImgSize'
]
input_height
=
input_shape
[
2
]
input_height
=
input_shape
[
2
]
input_width
=
input_shape
[
3
]
input_width
=
input_shape
[
3
]
...
@@ -785,7 +774,7 @@ def yolo_box(op, block):
...
@@ -785,7 +774,7 @@ def yolo_box(op, block):
name
=
max_const_name
,
name
=
max_const_name
,
data_type
=
onnx
.
TensorProto
.
FLOAT
,
data_type
=
onnx
.
TensorProto
.
FLOAT
,
dims
=
(),
dims
=
(),
vals
=
[
MAX_FLOAT
]))
vals
=
[
MAX_FLOAT
32
]))
node_list
.
append
(
max_const
)
node_list
.
append
(
max_const
)
node_pred_box_x1_clip
=
onnx
.
helper
.
make_node
(
node_pred_box_x1_clip
=
onnx
.
helper
.
make_node
(
...
...
x2paddle/op_mapper/paddle2onnx/opset9/paddle_custom_layer/multiclass_nms.py
浏览文件 @
9d3a4835
...
@@ -19,7 +19,7 @@ import numpy as np
...
@@ -19,7 +19,7 @@ import numpy as np
import
paddle.fluid.core
as
core
import
paddle.fluid.core
as
core
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
import
onnx
import
onnx
import
warnings
import
logging
from
onnx
import
helper
,
onnx_pb
from
onnx
import
helper
,
onnx_pb
...
@@ -42,9 +42,9 @@ def multiclass_nms(op, block):
...
@@ -42,9 +42,9 @@ def multiclass_nms(op, block):
background
=
attrs
[
'background_label'
]
background
=
attrs
[
'background_label'
]
normalized
=
attrs
[
'normalized'
]
normalized
=
attrs
[
'normalized'
]
if
normalized
==
False
:
if
normalized
==
False
:
warnings
.
warn
(
logging
.
warn
(
'The parameter normalized of multiclass_nms OP of Paddle is False, which has diff with ONNX.
\
"The parameter normalized of multiclass_nms OP of Paddle is False, which has diff with ONNX."
\
Please set normalized=True in multiclass_nms of Paddle'
)
" Please set normalized=True in multiclass_nms of Paddle, see doc Q4 in https://github.com/PaddlePaddle/X2Paddle/blob/develop/FAQ.md"
)
#convert the paddle attribute to onnx tensor
#convert the paddle attribute to onnx tensor
name_score_threshold
=
[
outputs
[
'Out'
][
0
]
+
"@score_threshold"
]
name_score_threshold
=
[
outputs
[
'Out'
][
0
]
+
"@score_threshold"
]
...
...
x2paddle/op_mapper/paddle2onnx/opset9/paddle_custom_layer/yolo_box.py
浏览文件 @
9d3a4835
...
@@ -33,6 +33,13 @@ def get_old_name(arg, name_prefix=''):
...
@@ -33,6 +33,13 @@ def get_old_name(arg, name_prefix=''):
return
name_prefix
+
last_prefix
return
name_prefix
+
last_prefix
def
is_static_shape
(
shape
):
if
len
(
shape
)
>
1
and
shape
.
count
(
-
1
)
>
1
:
raise
Exception
(
"Converting this model to ONNX need with static input shape, please converting with --fixed_input_shape [H,W]."
)
def
yolo_box
(
op
,
block
):
def
yolo_box
(
op
,
block
):
inputs
=
dict
()
inputs
=
dict
()
outputs
=
dict
()
outputs
=
dict
()
...
@@ -45,6 +52,7 @@ def yolo_box(op, block):
...
@@ -45,6 +52,7 @@ def yolo_box(op, block):
attrs
[
name
]
=
op
.
attr
(
name
)
attrs
[
name
]
=
op
.
attr
(
name
)
model_name
=
outputs
[
'Boxes'
][
0
]
model_name
=
outputs
[
'Boxes'
][
0
]
input_shape
=
block
.
vars
[
get_old_name
(
inputs
[
'X'
][
0
])].
shape
input_shape
=
block
.
vars
[
get_old_name
(
inputs
[
'X'
][
0
])].
shape
is_static_shape
(
input_shape
)
image_size
=
inputs
[
'ImgSize'
]
image_size
=
inputs
[
'ImgSize'
]
input_height
=
input_shape
[
2
]
input_height
=
input_shape
[
2
]
input_width
=
input_shape
[
3
]
input_width
=
input_shape
[
3
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录