Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
4dadf17b
Commit
4dadf17b
authored
Jul 31, 2019
by
Maksim Shabunin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15168 from dkurt:dnn_onnx_15120
parents
d3cf0d2c
f9f16040
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
4 deletions
+44
-4
onnx_importer.cpp
modules/dnn/src/onnx/onnx_importer.cpp
+37
-4
test_onnx_importer.cpp
modules/dnn/test/test_onnx_importer.cpp
+7
-0
No files found.
modules/dnn/src/onnx/onnx_importer.cpp
View file @
4dadf17b
...
...
@@ -465,6 +465,20 @@ void ONNXImporter::populateNet(Net dstNet)
}
layerParams
.
set
(
"begin"
,
DictValue
::
arrayInt
(
&
begin
[
0
],
begin
.
size
()));
layerParams
.
set
(
"end"
,
DictValue
::
arrayInt
(
&
end
[
0
],
end
.
size
()));
}
else
if
(
layer_type
==
"Split"
)
{
DictValue
splits
=
layerParams
.
get
(
"split"
);
const
int
numSplits
=
splits
.
size
();
CV_Assert
(
numSplits
>
1
);
std
::
vector
<
int
>
slicePoints
(
numSplits
-
1
,
splits
.
get
<
int
>
(
0
));
for
(
int
i
=
1
;
i
<
splits
.
size
()
-
1
;
++
i
)
{
slicePoints
[
i
]
=
slicePoints
[
i
-
1
]
+
splits
.
get
<
int
>
(
i
-
1
);
}
layerParams
.
set
(
"slice_point"
,
DictValue
::
arrayInt
(
&
slicePoints
[
0
],
slicePoints
.
size
()));
layerParams
.
type
=
"Slice"
;
}
else
if
(
layer_type
==
"Add"
||
layer_type
==
"Sum"
)
{
...
...
@@ -486,6 +500,11 @@ void ONNXImporter::populateNet(Net dstNet)
layerParams
.
type
=
"Eltwise"
;
}
}
else
if
(
layer_type
==
"Max"
)
{
layerParams
.
type
=
"Eltwise"
;
layerParams
.
set
(
"operation"
,
"max"
);
}
else
if
(
layer_type
==
"Sub"
)
{
Mat
blob
=
getBlob
(
node_proto
,
constBlobs
,
1
);
...
...
@@ -741,6 +760,16 @@ void ONNXImporter::populateNet(Net dstNet)
{
layerParams
.
type
=
"Permute"
;
replaceLayerParam
(
layerParams
,
"perm"
,
"order"
);
CV_Assert
(
node_proto
.
input_size
()
==
1
);
if
(
constBlobs
.
find
(
node_proto
.
input
(
0
))
!=
constBlobs
.
end
())
{
std
::
vector
<
Mat
>
inputs
(
1
,
getBlob
(
node_proto
,
constBlobs
,
0
)),
transposed
;
runLayer
(
layerParams
,
inputs
,
transposed
);
CV_Assert
(
transposed
.
size
()
==
1
);
constBlobs
.
insert
(
std
::
make_pair
(
layerParams
.
name
,
transposed
[
0
]));
continue
;
}
}
else
if
(
layer_type
==
"Unsqueeze"
)
{
...
...
@@ -906,8 +935,10 @@ void ONNXImporter::populateNet(Net dstNet)
}
int
id
=
dstNet
.
addLayer
(
layerParams
.
name
,
layerParams
.
type
,
layerParams
);
layer_id
.
insert
(
std
::
make_pair
(
layerParams
.
name
,
LayerInfo
(
id
,
0
)));
for
(
int
i
=
0
;
i
<
node_proto
.
output_size
();
++
i
)
{
layer_id
.
insert
(
std
::
make_pair
(
node_proto
.
output
(
i
),
LayerInfo
(
id
,
i
)));
}
std
::
vector
<
MatShape
>
layerInpShapes
,
layerOutShapes
,
layerInternalShapes
;
for
(
int
j
=
0
;
j
<
node_proto
.
input_size
();
j
++
)
{
...
...
@@ -924,8 +955,10 @@ void ONNXImporter::populateNet(Net dstNet)
// Compute shape of output blob for this layer.
Ptr
<
Layer
>
layer
=
dstNet
.
getLayer
(
id
);
layer
->
getMemoryShapes
(
layerInpShapes
,
0
,
layerOutShapes
,
layerInternalShapes
);
CV_Assert
(
!
layerOutShapes
.
empty
());
outShapes
[
layerParams
.
name
]
=
layerOutShapes
[
0
];
for
(
int
i
=
0
;
i
<
node_proto
.
output_size
()
&&
i
<
(
int
)
layerOutShapes
.
size
();
++
i
)
{
outShapes
[
node_proto
.
output
(
i
)]
=
layerOutShapes
[
i
];
}
}
}
...
...
modules/dnn/test/test_onnx_importer.cpp
View file @
4dadf17b
...
...
@@ -348,6 +348,13 @@ TEST_P(Test_ONNX_layers, Softmax)
testONNXModels
(
"log_softmax"
,
npy
,
0
,
0
,
false
,
false
);
}
TEST_P
(
Test_ONNX_layers
,
Split_EltwiseMax
)
{
if
(
backend
==
DNN_BACKEND_INFERENCE_ENGINE
)
applyTestTag
(
CV_TEST_TAG_DNN_SKIP_IE
);
testONNXModels
(
"split_max"
);
}
INSTANTIATE_TEST_CASE_P
(
/*nothing*/
,
Test_ONNX_layers
,
dnnBackendsAndTargets
());
class
Test_ONNX_nets
:
public
Test_ONNX_layers
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment