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
f0058bbe
Commit
f0058bbe
authored
Oct 04, 2019
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dnn(test): fix optional test data
parent
53c88f0f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
19 deletions
+25
-19
test_dnn.py
modules/dnn/misc/python/test/test_dnn.py
+17
-11
test_model.cpp
modules/dnn/test/test_model.cpp
+8
-8
No files found.
modules/dnn/misc/python/test/test_dnn.py
View file @
f0058bbe
...
...
@@ -62,6 +62,7 @@ def printParams(backend, target):
}
print
(
'
%
s/
%
s'
%
(
backendNames
[
backend
],
targetNames
[
target
]))
testdata_required
=
bool
(
os
.
environ
.
get
(
'OPENCV_DNN_TEST_REQUIRE_TESTDATA'
,
False
))
class
dnn_test
(
NewOpenCVTests
):
...
...
@@ -87,13 +88,15 @@ class dnn_test(NewOpenCVTests):
self
.
dnnBackendsAndTargets
.
append
([
cv
.
dnn
.
DNN_BACKEND_INFERENCE_ENGINE
,
cv
.
dnn
.
DNN_TARGET_OPENCL_FP16
])
def
find_dnn_file
(
self
,
filename
,
required
=
True
):
if
not
required
:
required
=
testdata_required
return
self
.
find_file
(
filename
,
[
os
.
environ
.
get
(
'OPENCV_DNN_TEST_DATA_PATH'
,
os
.
getcwd
()),
os
.
environ
[
'OPENCV_TEST_DATA_PATH'
]],
required
=
required
)
def
checkIETarget
(
self
,
backend
,
target
):
proto
=
self
.
find_dnn_file
(
'dnn/layers/layer_convolution.prototxt'
,
required
=
True
)
model
=
self
.
find_dnn_file
(
'dnn/layers/layer_convolution.caffemodel'
,
required
=
True
)
proto
=
self
.
find_dnn_file
(
'dnn/layers/layer_convolution.prototxt'
)
model
=
self
.
find_dnn_file
(
'dnn/layers/layer_convolution.caffemodel'
)
net
=
cv
.
dnn
.
readNet
(
proto
,
model
)
net
.
setPreferableBackend
(
backend
)
net
.
setPreferableTarget
(
target
)
...
...
@@ -134,8 +137,11 @@ class dnn_test(NewOpenCVTests):
def
test_model
(
self
):
img_path
=
self
.
find_dnn_file
(
"dnn/street.png"
)
weights
=
self
.
find_dnn_file
(
"dnn/MobileNetSSD_deploy.caffemodel"
)
config
=
self
.
find_dnn_file
(
"dnn/MobileNetSSD_deploy.prototxt"
)
weights
=
self
.
find_dnn_file
(
"dnn/MobileNetSSD_deploy.caffemodel"
,
required
=
False
)
config
=
self
.
find_dnn_file
(
"dnn/MobileNetSSD_deploy.prototxt"
,
required
=
False
)
if
weights
is
None
or
config
is
None
:
raise
unittest
.
SkipTest
(
"Missing DNN test files (dnn/MobileNetSSD_deploy.{prototxt/caffemodel}). Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter."
)
frame
=
cv
.
imread
(
img_path
)
model
=
cv
.
dnn_DetectionModel
(
weights
,
config
)
model
.
setInputParams
(
size
=
(
300
,
300
),
mean
=
(
127.5
,
127.5
,
127.5
),
scale
=
1.0
/
127.5
)
...
...
@@ -163,9 +169,11 @@ class dnn_test(NewOpenCVTests):
def
test_classification_model
(
self
):
img_path
=
self
.
find_dnn_file
(
"dnn/googlenet_0.png"
)
weights
=
self
.
find_dnn_file
(
"dnn/squeezenet_v1.1.caffemodel"
)
weights
=
self
.
find_dnn_file
(
"dnn/squeezenet_v1.1.caffemodel"
,
required
=
False
)
config
=
self
.
find_dnn_file
(
"dnn/squeezenet_v1.1.prototxt"
)
ref
=
np
.
load
(
self
.
find_dnn_file
(
"dnn/squeezenet_v1.1_prob.npy"
))
if
weights
is
None
or
config
is
None
:
raise
unittest
.
SkipTest
(
"Missing DNN test files (dnn/squeezenet_v1.1.{prototxt/caffemodel}). Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter."
)
frame
=
cv
.
imread
(
img_path
)
model
=
cv
.
dnn_ClassificationModel
(
config
,
weights
)
...
...
@@ -177,9 +185,8 @@ class dnn_test(NewOpenCVTests):
def
test_face_detection
(
self
):
testdata_required
=
bool
(
os
.
environ
.
get
(
'OPENCV_DNN_TEST_REQUIRE_TESTDATA'
,
False
))
proto
=
self
.
find_dnn_file
(
'dnn/opencv_face_detector.prototxt'
,
required
=
testdata_required
)
model
=
self
.
find_dnn_file
(
'dnn/opencv_face_detector.caffemodel'
,
required
=
testdata_required
)
proto
=
self
.
find_dnn_file
(
'dnn/opencv_face_detector.prototxt'
)
model
=
self
.
find_dnn_file
(
'dnn/opencv_face_detector.caffemodel'
,
required
=
False
)
if
proto
is
None
or
model
is
None
:
raise
unittest
.
SkipTest
(
"Missing DNN test files (dnn/opencv_face_detector.{prototxt/caffemodel}). Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter."
)
...
...
@@ -216,9 +223,8 @@ class dnn_test(NewOpenCVTests):
def
test_async
(
self
):
timeout
=
10
*
1000
*
10
**
6
# in nanoseconds (10 sec)
testdata_required
=
bool
(
os
.
environ
.
get
(
'OPENCV_DNN_TEST_REQUIRE_TESTDATA'
,
False
))
proto
=
self
.
find_dnn_file
(
'dnn/layers/layer_convolution.prototxt'
,
required
=
testdata_required
)
model
=
self
.
find_dnn_file
(
'dnn/layers/layer_convolution.caffemodel'
,
required
=
testdata_required
)
proto
=
self
.
find_dnn_file
(
'dnn/layers/layer_convolution.prototxt'
)
model
=
self
.
find_dnn_file
(
'dnn/layers/layer_convolution.caffemodel'
)
if
proto
is
None
or
model
is
None
:
raise
unittest
.
SkipTest
(
"Missing DNN test files (dnn/layers/layer_convolution.{prototxt/caffemodel}). Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter."
)
...
...
modules/dnn/test/test_model.cpp
View file @
f0058bbe
...
...
@@ -8,10 +8,10 @@
namespace
opencv_test
{
namespace
{
template
<
typename
TString
>
static
std
::
string
_tf
(
TString
filename
)
static
std
::
string
_tf
(
TString
filename
,
bool
required
=
true
)
{
String
rootFolder
=
"dnn/"
;
return
findDataFile
(
rootFolder
+
filename
);
return
findDataFile
(
rootFolder
+
filename
,
required
);
}
...
...
@@ -96,7 +96,7 @@ TEST_P(Test_Model, Classify)
std
::
string
img_path
=
_tf
(
"grace_hopper_227.png"
);
std
::
string
config_file
=
_tf
(
"bvlc_alexnet.prototxt"
);
std
::
string
weights_file
=
_tf
(
"bvlc_alexnet.caffemodel"
);
std
::
string
weights_file
=
_tf
(
"bvlc_alexnet.caffemodel"
,
false
);
Size
size
{
227
,
227
};
float
norm
=
1e-4
;
...
...
@@ -127,7 +127,7 @@ TEST_P(Test_Model, DetectRegion)
Rect2d
(
58
,
141
,
117
,
249
)};
std
::
string
img_path
=
_tf
(
"dog416.png"
);
std
::
string
weights_file
=
_tf
(
"yolo-voc.weights"
);
std
::
string
weights_file
=
_tf
(
"yolo-voc.weights"
,
false
);
std
::
string
config_file
=
_tf
(
"yolo-voc.cfg"
);
double
scale
=
1.0
/
255.0
;
...
...
@@ -160,7 +160,7 @@ TEST_P(Test_Model, DetectionOutput)
Rect2d
(
132
,
223
,
207
,
344
)};
std
::
string
img_path
=
_tf
(
"dog416.png"
);
std
::
string
weights_file
=
_tf
(
"resnet50_rfcn_final.caffemodel"
);
std
::
string
weights_file
=
_tf
(
"resnet50_rfcn_final.caffemodel"
,
false
);
std
::
string
config_file
=
_tf
(
"rfcn_pascal_voc_resnet50.prototxt"
);
Scalar
mean
=
Scalar
(
102.9801
,
115.9465
,
122.7717
);
...
...
@@ -203,7 +203,7 @@ TEST_P(Test_Model, DetectionMobilenetSSD)
refBoxes
.
emplace_back
(
left
,
top
,
width
,
height
);
}
std
::
string
weights_file
=
_tf
(
"MobileNetSSD_deploy.caffemodel"
);
std
::
string
weights_file
=
_tf
(
"MobileNetSSD_deploy.caffemodel"
,
false
);
std
::
string
config_file
=
_tf
(
"MobileNetSSD_deploy.prototxt"
);
Scalar
mean
=
Scalar
(
127.5
,
127.5
,
127.5
);
...
...
@@ -228,7 +228,7 @@ TEST_P(Test_Model, Detection_normalized)
std
::
vector
<
float
>
refConfidences
=
{
0.999222
f
};
std
::
vector
<
Rect2d
>
refBoxes
=
{
Rect2d
(
0
,
4
,
227
,
222
)};
std
::
string
weights_file
=
_tf
(
"MobileNetSSD_deploy.caffemodel"
);
std
::
string
weights_file
=
_tf
(
"MobileNetSSD_deploy.caffemodel"
,
false
);
std
::
string
config_file
=
_tf
(
"MobileNetSSD_deploy.prototxt"
);
Scalar
mean
=
Scalar
(
127.5
,
127.5
,
127.5
);
...
...
@@ -247,7 +247,7 @@ TEST_P(Test_Model, Segmentation)
{
std
::
string
inp
=
_tf
(
"dog416.png"
);
std
::
string
weights_file
=
_tf
(
"fcn8s-heavy-pascal.prototxt"
);
std
::
string
config_file
=
_tf
(
"fcn8s-heavy-pascal.caffemodel"
);
std
::
string
config_file
=
_tf
(
"fcn8s-heavy-pascal.caffemodel"
,
false
);
std
::
string
exp
=
_tf
(
"segmentation_exp.png"
);
Size
size
{
128
,
128
};
...
...
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