Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
a6f9170f
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a6f9170f
编写于
10月 31, 2018
作者:
D
Dmitry Kurtaev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add ONNX's padding import
上级
850053f9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
5 deletion
+36
-5
modules/dnn/src/onnx/onnx_importer.cpp
modules/dnn/src/onnx/onnx_importer.cpp
+31
-5
modules/dnn/test/test_onnx_importer.cpp
modules/dnn/test/test_onnx_importer.cpp
+5
-0
未找到文件。
modules/dnn/src/onnx/onnx_importer.cpp
浏览文件 @
a6f9170f
...
@@ -96,6 +96,8 @@ Mat getMatFromTensor(opencv_onnx::TensorProto& tensor_proto)
...
@@ -96,6 +96,8 @@ Mat getMatFromTensor(opencv_onnx::TensorProto& tensor_proto)
for
(
int
i
=
0
;
i
<
tensor_proto
.
dims_size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
tensor_proto
.
dims_size
();
i
++
)
{
sizes
.
push_back
(
tensor_proto
.
dims
(
i
));
sizes
.
push_back
(
tensor_proto
.
dims
(
i
));
}
}
if
(
sizes
.
empty
())
sizes
.
assign
(
1
,
1
);
if
(
datatype
==
opencv_onnx
::
TensorProto_DataType_FLOAT
)
{
if
(
datatype
==
opencv_onnx
::
TensorProto_DataType_FLOAT
)
{
if
(
!
tensor_proto
.
float_data
().
empty
())
{
if
(
!
tensor_proto
.
float_data
().
empty
())
{
...
@@ -173,11 +175,31 @@ LayerParams ONNXImporter::getLayerParams(const opencv_onnx::NodeProto& node_prot
...
@@ -173,11 +175,31 @@ LayerParams ONNXImporter::getLayerParams(const opencv_onnx::NodeProto& node_prot
}
}
else
if
(
attribute_name
==
"pads"
)
else
if
(
attribute_name
==
"pads"
)
{
{
CV_Assert
(
attribute_proto
.
ints_size
()
==
4
);
if
(
node_proto
.
op_type
()
==
"Pad"
)
lp
.
set
(
"pad_t"
,
saturate_cast
<
int32_t
>
(
attribute_proto
.
ints
(
0
)));
{
lp
.
set
(
"pad_l"
,
saturate_cast
<
int32_t
>
(
attribute_proto
.
ints
(
1
)));
// Padding layer.
lp
.
set
(
"pad_b"
,
saturate_cast
<
int32_t
>
(
attribute_proto
.
ints
(
2
)));
// Paddings are in order begin0, begin1, .. beginN, end0, end1, ..., endN.
lp
.
set
(
"pad_r"
,
saturate_cast
<
int32_t
>
(
attribute_proto
.
ints
(
3
)));
// We need to shuffle it to begin0, end0, begin1, end1, ...
CV_Assert
(
attribute_proto
.
ints_size
()
%
2
==
0
);
const
int
dims
=
attribute_proto
.
ints_size
()
/
2
;
std
::
vector
<
int32_t
>
paddings
;
paddings
.
reserve
(
attribute_proto
.
ints_size
());
for
(
int
i
=
0
;
i
<
dims
;
++
i
)
{
paddings
.
push_back
(
attribute_proto
.
ints
(
i
));
paddings
.
push_back
(
attribute_proto
.
ints
(
dims
+
i
));
}
lp
.
set
(
"paddings"
,
DictValue
::
arrayInt
(
&
paddings
[
0
],
paddings
.
size
()));
}
else
{
// Convolution or pooling.
CV_Assert
(
attribute_proto
.
ints_size
()
==
4
);
lp
.
set
(
"pad_t"
,
saturate_cast
<
int32_t
>
(
attribute_proto
.
ints
(
0
)));
lp
.
set
(
"pad_l"
,
saturate_cast
<
int32_t
>
(
attribute_proto
.
ints
(
1
)));
lp
.
set
(
"pad_b"
,
saturate_cast
<
int32_t
>
(
attribute_proto
.
ints
(
2
)));
lp
.
set
(
"pad_r"
,
saturate_cast
<
int32_t
>
(
attribute_proto
.
ints
(
3
)));
}
}
}
else
if
(
attribute_name
==
"auto_pad"
)
else
if
(
attribute_name
==
"auto_pad"
)
{
{
...
@@ -543,6 +565,10 @@ void ONNXImporter::populateNet(Net dstNet)
...
@@ -543,6 +565,10 @@ void ONNXImporter::populateNet(Net dstNet)
replaceLayerParam
(
layerParams
,
"shape"
,
"dim"
);
replaceLayerParam
(
layerParams
,
"shape"
,
"dim"
);
}
}
}
}
else
if
(
layer_type
==
"Pad"
)
{
layerParams
.
type
=
"Padding"
;
}
else
else
{
{
for
(
int
j
=
0
;
j
<
node_proto
.
input_size
();
j
++
)
{
for
(
int
j
=
0
;
j
<
node_proto
.
input_size
();
j
++
)
{
...
...
modules/dnn/test/test_onnx_importer.cpp
浏览文件 @
a6f9170f
...
@@ -129,6 +129,11 @@ TEST_P(Test_ONNX_layers, Constant)
...
@@ -129,6 +129,11 @@ TEST_P(Test_ONNX_layers, Constant)
testONNXModels
(
"constant"
);
testONNXModels
(
"constant"
);
}
}
TEST_P
(
Test_ONNX_layers
,
Padding
)
{
testONNXModels
(
"padding"
);
}
TEST_P
(
Test_ONNX_layers
,
MultyInputs
)
TEST_P
(
Test_ONNX_layers
,
MultyInputs
)
{
{
const
String
model
=
_tf
(
"models/multy_inputs.onnx"
);
const
String
model
=
_tf
(
"models/multy_inputs.onnx"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录