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
d65fead3
Commit
d65fead3
authored
Oct 24, 2019
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15752 from dkurt:fix_15750
parents
5e8d8df8
dfe03688
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
46 deletions
+58
-46
dnn.cpp
modules/dnn/src/dnn.cpp
+36
-30
test_darknet_importer.cpp
modules/dnn/test/test_darknet_importer.cpp
+22
-16
No files found.
modules/dnn/src/dnn.cpp
View file @
d65fead3
...
@@ -97,6 +97,37 @@ public:
...
@@ -97,6 +97,37 @@ public:
static
BackendRegistry
impl
;
static
BackendRegistry
impl
;
return
impl
;
return
impl
;
}
}
static
inline
bool
checkIETarget
(
int
target
)
{
#ifndef HAVE_INF_ENGINE
return
false
;
#else
cv
::
dnn
::
Net
net
;
cv
::
dnn
::
LayerParams
lp
;
lp
.
set
(
"kernel_size"
,
1
);
lp
.
set
(
"num_output"
,
1
);
lp
.
set
(
"bias_term"
,
false
);
lp
.
type
=
"Convolution"
;
lp
.
name
=
"testLayer"
;
lp
.
blobs
.
push_back
(
Mat
({
1
,
2
,
1
,
1
},
CV_32F
,
Scalar
(
1
)));
net
.
addLayerToPrev
(
lp
.
name
,
lp
.
type
,
lp
);
net
.
setPreferableBackend
(
cv
::
dnn
::
DNN_BACKEND_INFERENCE_ENGINE
);
net
.
setPreferableTarget
(
target
);
static
int
inpDims
[]
=
{
1
,
2
,
3
,
4
};
net
.
setInput
(
cv
::
Mat
(
4
,
&
inpDims
[
0
],
CV_32FC1
,
cv
::
Scalar
(
0
)));
try
{
net
.
forward
();
}
catch
(...)
{
return
false
;
}
return
true
;
#endif
}
private
:
private
:
BackendRegistry
()
BackendRegistry
()
{
{
...
@@ -136,35 +167,6 @@ private:
...
@@ -136,35 +167,6 @@ private:
backends
.
push_back
(
std
::
make_pair
(
DNN_BACKEND_OPENCV
,
DNN_TARGET_CPU
));
backends
.
push_back
(
std
::
make_pair
(
DNN_BACKEND_OPENCV
,
DNN_TARGET_CPU
));
}
}
static
inline
bool
checkIETarget
(
int
target
)
{
#ifndef HAVE_INF_ENGINE
return
false
;
#else
cv
::
dnn
::
Net
net
;
cv
::
dnn
::
LayerParams
lp
;
lp
.
set
(
"kernel_size"
,
1
);
lp
.
set
(
"num_output"
,
1
);
lp
.
set
(
"bias_term"
,
false
);
lp
.
type
=
"Convolution"
;
lp
.
name
=
"testLayer"
;
lp
.
blobs
.
push_back
(
Mat
({
1
,
2
,
1
,
1
},
CV_32F
,
Scalar
(
1
)));
net
.
addLayerToPrev
(
lp
.
name
,
lp
.
type
,
lp
);
net
.
setPreferableBackend
(
cv
::
dnn
::
DNN_BACKEND_INFERENCE_ENGINE
);
net
.
setPreferableTarget
(
target
);
static
int
inpDims
[]
=
{
1
,
2
,
3
,
4
};
net
.
setInput
(
cv
::
Mat
(
4
,
&
inpDims
[
0
],
CV_32FC1
,
cv
::
Scalar
(
0
)));
try
{
net
.
forward
();
}
catch
(...)
{
return
false
;
}
return
true
;
#endif
}
BackendsList
backends
;
BackendsList
backends
;
};
};
...
@@ -1544,6 +1546,9 @@ struct Net::Impl
...
@@ -1544,6 +1546,9 @@ struct Net::Impl
// backend. Split a whole model on several Inference Engine networks if
// backend. Split a whole model on several Inference Engine networks if
// some of layers are not implemented.
// some of layers are not implemented.
bool
supportsCPUFallback
=
preferableTarget
==
DNN_TARGET_CPU
||
BackendRegistry
::
checkIETarget
(
DNN_TARGET_CPU
);
// Set of all input and output blobs wrappers for current network.
// Set of all input and output blobs wrappers for current network.
std
::
map
<
LayerPin
,
Ptr
<
BackendWrapper
>
>
netBlobsWrappers
;
std
::
map
<
LayerPin
,
Ptr
<
BackendWrapper
>
>
netBlobsWrappers
;
for
(
it
=
layers
.
begin
();
it
!=
layers
.
end
();
++
it
)
for
(
it
=
layers
.
begin
();
it
!=
layers
.
end
();
++
it
)
...
@@ -1557,7 +1562,8 @@ struct Net::Impl
...
@@ -1557,7 +1562,8 @@ struct Net::Impl
if
(
!
fused
&&
!
layer
->
supportBackend
(
preferableBackend
))
if
(
!
fused
&&
!
layer
->
supportBackend
(
preferableBackend
))
{
{
bool
customizable
=
ld
.
id
!=
0
&&
ld
.
outputBlobs
.
size
()
==
1
&&
bool
customizable
=
ld
.
id
!=
0
&&
ld
.
outputBlobs
.
size
()
==
1
&&
INF_ENGINE_VER_MAJOR_GE
(
INF_ENGINE_RELEASE_2019R2
);
INF_ENGINE_VER_MAJOR_GE
(
INF_ENGINE_RELEASE_2019R2
)
&&
supportsCPUFallback
;
// TODO: there is a bug in Myriad plugin with custom layers shape infer.
// TODO: there is a bug in Myriad plugin with custom layers shape infer.
if
(
preferableTarget
==
DNN_TARGET_MYRIAD
)
if
(
preferableTarget
==
DNN_TARGET_MYRIAD
)
{
{
...
...
modules/dnn/test/test_darknet_importer.cpp
View file @
d65fead3
...
@@ -390,12 +390,6 @@ TEST_P(Test_Darknet_nets, YOLOv3)
...
@@ -390,12 +390,6 @@ TEST_P(Test_Darknet_nets, YOLOv3)
{
{
applyTestTag
(
CV_TEST_TAG_LONG
,
(
target
==
DNN_TARGET_CPU
?
CV_TEST_TAG_MEMORY_1GB
:
CV_TEST_TAG_MEMORY_2GB
));
applyTestTag
(
CV_TEST_TAG_LONG
,
(
target
==
DNN_TARGET_CPU
?
CV_TEST_TAG_MEMORY_1GB
:
CV_TEST_TAG_MEMORY_2GB
));
#if defined(INF_ENGINE_RELEASE)
if
(
backend
==
DNN_BACKEND_INFERENCE_ENGINE
&&
target
==
DNN_TARGET_MYRIAD
&&
getInferenceEngineVPUType
()
==
CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X
)
applyTestTag
(
CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X
);
#endif
// batchId, classId, confidence, left, top, right, bottom
// batchId, classId, confidence, left, top, right, bottom
Mat
ref
=
(
Mat_
<
float
>
(
9
,
7
)
<<
0
,
7
,
0.952983
f
,
0.614622
f
,
0.150257
f
,
0.901369
f
,
0.289251
f
,
// a truck
Mat
ref
=
(
Mat_
<
float
>
(
9
,
7
)
<<
0
,
7
,
0.952983
f
,
0.614622
f
,
0.150257
f
,
0.901369
f
,
0.289251
f
,
// a truck
0
,
1
,
0.987908
f
,
0.150913
f
,
0.221933
f
,
0.742255
f
,
0.74626
f
,
// a bicycle
0
,
1
,
0.987908
f
,
0.150913
f
,
0.221933
f
,
0.742255
f
,
0.74626
f
,
// a bicycle
...
@@ -413,23 +407,35 @@ TEST_P(Test_Darknet_nets, YOLOv3)
...
@@ -413,23 +407,35 @@ TEST_P(Test_Darknet_nets, YOLOv3)
std
::
string
config_file
=
"yolov3.cfg"
;
std
::
string
config_file
=
"yolov3.cfg"
;
std
::
string
weights_file
=
"yolov3.weights"
;
std
::
string
weights_file
=
"yolov3.weights"
;
#if defined(INF_ENGINE_RELEASE)
if
(
backend
==
DNN_BACKEND_INFERENCE_ENGINE
&&
target
==
DNN_TARGET_MYRIAD
&&
getInferenceEngineVPUType
()
==
CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X
)
{
scoreDiff
=
0.04
;
iouDiff
=
0.2
;
}
#endif
{
{
SCOPED_TRACE
(
"batch size 1"
);
SCOPED_TRACE
(
"batch size 1"
);
testDarknetModel
(
config_file
,
weights_file
,
ref
.
rowRange
(
0
,
3
),
scoreDiff
,
iouDiff
);
testDarknetModel
(
config_file
,
weights_file
,
ref
.
rowRange
(
0
,
3
),
scoreDiff
,
iouDiff
);
}
}
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LE(2018050000)
#if defined(INF_ENGINE_RELEASE)
if
(
backend
==
DNN_BACKEND_INFERENCE_ENGINE
&&
target
==
DNN_TARGET_OPENCL
)
applyTestTag
(
CV_TEST_TAG_DNN_SKIP_IE_OPENCL
)
// Test with 'batch size 2' is disabled for DLIE/OpenCL target
#endif
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019020000)
if
(
backend
==
DNN_BACKEND_INFERENCE_ENGINE
)
if
(
backend
==
DNN_BACKEND_INFERENCE_ENGINE
)
{
{
if
(
target
==
DNN_TARGET_OPENCL
)
if
(
INF_ENGINE_VER_MAJOR_LE
(
2018050000
)
&&
target
==
DNN_TARGET_OPENCL
)
applyTestTag
(
CV_TEST_TAG_DNN_SKIP_IE_OPENCL
,
CV_TEST_TAG_DNN_SKIP_IE_2019R2
);
applyTestTag
(
CV_TEST_TAG_DNN_SKIP_IE_OPENCL
,
CV_TEST_TAG_DNN_SKIP_IE_2018R5
);
if
(
target
==
DNN_TARGET_OPENCL_FP16
)
else
if
(
INF_ENGINE_VER_MAJOR_EQ
(
2019020000
))
applyTestTag
(
CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16
,
CV_TEST_TAG_DNN_SKIP_IE_2019R2
);
{
if
(
target
==
DNN_TARGET_OPENCL
)
applyTestTag
(
CV_TEST_TAG_DNN_SKIP_IE_OPENCL
,
CV_TEST_TAG_DNN_SKIP_IE_2019R2
);
if
(
target
==
DNN_TARGET_OPENCL_FP16
)
applyTestTag
(
CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16
,
CV_TEST_TAG_DNN_SKIP_IE_2019R2
);
}
else
if
(
target
==
DNN_TARGET_MYRIAD
&&
getInferenceEngineVPUType
()
==
CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X
)
applyTestTag
(
CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X
);
}
}
#endif
#endif
...
...
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