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
26e426ad
Commit
26e426ad
authored
6 years ago
by
Dmitry Kurtaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
StridedSlice from TensorFlow
parent
190467b6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
2 deletions
+47
-2
dnn.hpp
modules/dnn/include/opencv2/dnn/dnn.hpp
+1
-0
tf_importer.cpp
modules/dnn/src/tensorflow/tf_importer.cpp
+37
-0
test_onnx_importer.cpp
modules/dnn/test/test_onnx_importer.cpp
+1
-1
test_tf_importer.cpp
modules/dnn/test/test_tf_importer.cpp
+1
-0
tf_text_graph_faster_rcnn.py
samples/dnn/tf_text_graph_faster_rcnn.py
+7
-1
No files found.
modules/dnn/include/opencv2/dnn/dnn.hpp
View file @
26e426ad
...
...
@@ -820,6 +820,7 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
* * `*.t7` | `*.net` (Torch, http://torch.ch/)
* * `*.weights` (Darknet, https://pjreddie.com/darknet/)
* * `*.bin` (DLDT, https://software.intel.com/openvino-toolkit)
* * `*.onnx` (ONNX, https://onnx.ai/)
* @param[in] config Text file contains network configuration. It could be a
* file with the following extensions:
* * `*.prototxt` (Caffe, http://caffe.berkeleyvision.org/)
...
...
This diff is collapsed.
Click to expand it.
modules/dnn/src/tensorflow/tf_importer.cpp
View file @
26e426ad
...
...
@@ -1423,6 +1423,43 @@ void TFImporter::populateNet(Net dstNet)
connect
(
layer_id
,
dstNet
,
parsePin
(
layer
.
input
(
0
)),
id
,
0
);
}
else
if
(
type
==
"StridedSlice"
)
{
CV_Assert
(
layer
.
input_size
()
==
4
);
Mat
begins
=
getTensorContent
(
getConstBlob
(
layer
,
value_id
,
1
));
Mat
ends
=
getTensorContent
(
getConstBlob
(
layer
,
value_id
,
2
));
Mat
strides
=
getTensorContent
(
getConstBlob
(
layer
,
value_id
,
3
));
CV_CheckTypeEQ
(
begins
.
type
(),
CV_32SC1
,
""
);
CV_CheckTypeEQ
(
ends
.
type
(),
CV_32SC1
,
""
);
CV_CheckTypeEQ
(
strides
.
type
(),
CV_32SC1
,
""
);
const
int
num
=
begins
.
total
();
CV_Assert_N
(
num
==
ends
.
total
(),
num
==
strides
.
total
());
int
end_mask
=
getLayerAttr
(
layer
,
"end_mask"
).
i
();
for
(
int
i
=
0
;
i
<
num
;
++
i
)
{
if
(
end_mask
&
(
1
<<
i
))
ends
.
at
<
int
>
(
i
)
=
-
1
;
if
(
strides
.
at
<
int
>
(
i
)
!=
1
)
CV_Error
(
Error
::
StsNotImplemented
,
format
(
"StridedSlice with stride %d"
,
strides
.
at
<
int
>
(
i
)));
}
if
(
begins
.
total
()
==
4
&&
getDataLayout
(
name
,
data_layouts
)
==
DATA_LAYOUT_NHWC
)
{
// Swap NHWC parameters' order to NCHW.
std
::
swap
(
begins
.
at
<
int
>
(
2
),
begins
.
at
<
int
>
(
3
));
std
::
swap
(
begins
.
at
<
int
>
(
1
),
begins
.
at
<
int
>
(
2
));
std
::
swap
(
ends
.
at
<
int
>
(
2
),
ends
.
at
<
int
>
(
3
));
std
::
swap
(
ends
.
at
<
int
>
(
1
),
ends
.
at
<
int
>
(
2
));
}
layerParams
.
set
(
"begin"
,
DictValue
::
arrayInt
((
int
*
)
begins
.
data
,
begins
.
total
()));
layerParams
.
set
(
"end"
,
DictValue
::
arrayInt
((
int
*
)
ends
.
data
,
ends
.
total
()));
int
id
=
dstNet
.
addLayer
(
name
,
"Slice"
,
layerParams
);
layer_id
[
name
]
=
id
;
connect
(
layer_id
,
dstNet
,
parsePin
(
layer
.
input
(
0
)),
id
,
0
);
}
else
if
(
type
==
"Mul"
)
{
bool
haveConst
=
false
;
...
...
This diff is collapsed.
Click to expand it.
modules/dnn/test/test_onnx_importer.cpp
View file @
26e426ad
...
...
@@ -248,7 +248,7 @@ TEST_P(Test_ONNX_layers, Reshape)
TEST_P
(
Test_ONNX_layers
,
Softmax
)
{
testONNXModels
(
"softmax"
);
testONNXModels
(
"log_softmax"
);
testONNXModels
(
"log_softmax"
,
npy
,
0
,
0
,
false
,
false
);
}
INSTANTIATE_TEST_CASE_P
(
/*nothing*/
,
Test_ONNX_layers
,
dnnBackendsAndTargets
());
...
...
This diff is collapsed.
Click to expand it.
modules/dnn/test/test_tf_importer.cpp
View file @
26e426ad
...
...
@@ -663,6 +663,7 @@ TEST_P(Test_TensorFlow_layers, slice)
(
target
==
DNN_TARGET_OPENCL
||
target
==
DNN_TARGET_OPENCL_FP16
))
throw
SkipTestException
(
""
);
runTensorFlowNet
(
"slice_4d"
);
runTensorFlowNet
(
"strided_slice"
);
}
TEST_P
(
Test_TensorFlow_layers
,
softmax
)
...
...
This diff is collapsed.
Click to expand it.
samples/dnn/tf_text_graph_faster_rcnn.py
View file @
26e426ad
...
...
@@ -31,7 +31,13 @@ def createFasterRCNNGraph(modelPath, configPath, outputPath):
aspect_ratios
=
[
float
(
ar
)
for
ar
in
grid_anchor_generator
[
'aspect_ratios'
]]
width_stride
=
float
(
grid_anchor_generator
[
'width_stride'
][
0
])
height_stride
=
float
(
grid_anchor_generator
[
'height_stride'
][
0
])
features_stride
=
float
(
config
[
'feature_extractor'
][
0
][
'first_stage_features_stride'
][
0
])
feature_extractor
=
config
[
'feature_extractor'
][
0
]
if
'type'
in
feature_extractor
and
feature_extractor
[
'type'
][
0
]
==
'faster_rcnn_nas'
:
features_stride
=
16.0
else
:
features_stride
=
float
(
feature_extractor
[
'first_stage_features_stride'
][
0
])
first_stage_nms_iou_threshold
=
float
(
config
[
'first_stage_nms_iou_threshold'
][
0
])
first_stage_max_proposals
=
int
(
config
[
'first_stage_max_proposals'
][
0
])
...
...
This diff is collapsed.
Click to expand it.
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