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
7d114034
Commit
7d114034
authored
Jun 29, 2017
by
Aleksandr Rybnikov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewrote googlenet tests
parent
6ba22dea
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
18 deletions
+52
-18
dnn.cpp
modules/dnn/src/dnn.cpp
+9
-2
convolution_layer.cpp
modules/dnn/src/layers/convolution_layer.cpp
+2
-0
imagenet_cls_test_alexnet.py
modules/dnn/test/imagenet_cls_test_alexnet.py
+2
-3
test_googlenet.cpp
modules/dnn/test/test_googlenet.cpp
+37
-13
torch_enet.cpp
samples/dnn/torch_enet.cpp
+2
-0
No files found.
modules/dnn/src/dnn.cpp
View file @
7d114034
...
...
@@ -694,6 +694,7 @@ struct Net::Impl
for
(
it
=
layers
.
begin
();
it
!=
layers
.
end
();
it
++
)
{
if
(
it
->
second
.
id
!=
0
)
{
it
->
second
.
inputBlobs
.
clear
();
it
->
second
.
outputBlobs
.
clear
();
it
->
second
.
internals
.
clear
();
}
...
...
@@ -1106,8 +1107,10 @@ struct Net::Impl
bnormData
->
skipFlags
[
DNN_BACKEND_DEFAULT
]
=
true
;
ld
.
outputBlobs
=
layers
[
lpNext
.
lid
].
outputBlobs
;
if
(
bnormData
->
consumers
.
size
()
==
1
)
{
nextData
=
&
layers
[
bnormData
->
consumers
[
0
].
lid
];
lpNext
=
LayerPin
(
bnormData
->
consumers
[
0
].
lid
,
0
);
lpNext
=
LayerPin
(
bnormData
->
consumers
[
0
].
lid
,
0
);
}
}
}
...
...
@@ -1124,7 +1127,10 @@ struct Net::Impl
scaleData
->
skipFlags
[
DNN_BACKEND_DEFAULT
]
=
true
;
ld
.
outputBlobs
=
layers
[
lpNext
.
lid
].
outputBlobs
;
if
(
scaleData
->
consumers
.
size
()
==
1
)
{
nextData
=
&
layers
[
scaleData
->
consumers
[
0
].
lid
];
lpNext
=
LayerPin
(
scaleData
->
consumers
[
0
].
lid
,
0
);
}
}
}
...
...
@@ -1132,7 +1138,8 @@ struct Net::Impl
if
(
nextData
)
nextActivLayer
=
nextData
->
layerInstance
.
dynamicCast
<
ActivationLayer
>
();
if
(
!
nextActivLayer
.
empty
()
&&
currLayer
->
setActivation
(
nextActivLayer
)
)
if
(
!
nextActivLayer
.
empty
()
&&
pinsToKeep
.
count
(
lpNext
)
==
0
&&
currLayer
->
setActivation
(
nextActivLayer
)
)
{
printf_
((
"
\t
fused with %s
\n
"
,
nextActivLayer
->
name
.
c_str
()));
nextData
->
skipFlags
[
DNN_BACKEND_DEFAULT
]
=
true
;
...
...
modules/dnn/src/layers/convolution_layer.cpp
View file @
7d114034
...
...
@@ -198,6 +198,8 @@ public:
bool
setActivation
(
const
Ptr
<
ActivationLayer
>&
layer
)
{
activ
=
layer
;
if
(
activ
.
empty
())
reluslope
.
clear
();
return
!
activ
.
empty
();
}
...
...
modules/dnn/test/imagenet_cls_test_alexnet.py
View file @
7d114034
...
...
@@ -146,9 +146,8 @@ class DnnCaffeModel(Framework):
return
'DNN'
def
get_output
(
self
,
input_blob
):
self
.
net
.
setBlob
(
self
.
in_blob_name
,
input_blob
)
self
.
net
.
forward
()
return
self
.
net
.
getBlob
(
self
.
out_blob_name
)
self
.
net
.
setInput
(
input_blob
,
self
.
in_blob_name
)
return
self
.
net
.
forward
(
self
.
out_blob_name
)
class
ClsAccEvaluation
:
...
...
modules/dnn/test/test_googlenet.cpp
View file @
7d114034
...
...
@@ -56,16 +56,10 @@ static std::string _tf(TString filename)
return
(
getOpenCVExtraDir
()
+
"/dnn/"
)
+
filename
;
}
static
void
launchGoogleNetTest
(
)
TEST
(
Reproducibility_GoogLeNet
,
Accuracy
)
{
Net
net
;
{
const
string
proto
=
findDataFile
(
"dnn/bvlc_googlenet.prototxt"
,
false
);
const
string
model
=
findDataFile
(
"dnn/bvlc_googlenet.caffemodel"
,
false
);
Ptr
<
Importer
>
importer
=
createCaffeImporter
(
proto
,
model
);
ASSERT_TRUE
(
importer
!=
NULL
);
importer
->
populateNet
(
net
);
}
Net
net
=
readNetFromCaffe
(
findDataFile
(
"dnn/bvlc_googlenet.prototxt"
,
false
),
findDataFile
(
"dnn/bvlc_googlenet.caffemodel"
,
false
));
std
::
vector
<
Mat
>
inpMats
;
inpMats
.
push_back
(
imread
(
_tf
(
"googlenet_0.png"
))
);
...
...
@@ -77,6 +71,12 @@ static void launchGoogleNetTest()
Mat
ref
=
blobFromNPY
(
_tf
(
"googlenet_prob.npy"
));
normAssert
(
out
,
ref
);
}
TEST
(
IntermediateBlobs_GoogLeNet
,
Accuracy
)
{
Net
net
=
readNetFromCaffe
(
findDataFile
(
"dnn/bvlc_googlenet.prototxt"
,
false
),
findDataFile
(
"dnn/bvlc_googlenet.caffemodel"
,
false
));
std
::
vector
<
String
>
blobsNames
;
blobsNames
.
push_back
(
"conv1/7x7_s2"
);
...
...
@@ -84,7 +84,7 @@ static void launchGoogleNetTest()
blobsNames
.
push_back
(
"inception_4c/1x1"
);
blobsNames
.
push_back
(
"inception_4c/relu_1x1"
);
std
::
vector
<
Mat
>
outs
;
Mat
in
=
blobFromImage
(
i
npMats
[
0
]
);
Mat
in
=
blobFromImage
(
i
mread
(
_tf
(
"googlenet_0.png"
))
);
net
.
setInput
(
in
,
"data"
);
net
.
forward
(
outs
,
blobsNames
);
CV_Assert
(
outs
.
size
()
==
blobsNames
.
size
());
...
...
@@ -95,13 +95,37 @@ static void launchGoogleNetTest()
std
::
replace
(
filename
.
begin
(),
filename
.
end
(),
'/'
,
'#'
);
Mat
ref
=
blobFromNPY
(
_tf
(
"googlenet_"
+
filename
+
".npy"
));
//
normAssert(outs[i], ref, "", 1E-4, 1E-2);
normAssert
(
outs
[
i
],
ref
,
""
,
1E-4
,
1E-2
);
}
}
TEST
(
Reproducibility
_GoogLeNet
,
Accuracy
)
TEST
(
SeveralCalls
_GoogLeNet
,
Accuracy
)
{
launchGoogleNetTest
();
Net
net
=
readNetFromCaffe
(
findDataFile
(
"dnn/bvlc_googlenet.prototxt"
,
false
),
findDataFile
(
"dnn/bvlc_googlenet.caffemodel"
,
false
));
std
::
vector
<
Mat
>
inpMats
;
inpMats
.
push_back
(
imread
(
_tf
(
"googlenet_0.png"
))
);
inpMats
.
push_back
(
imread
(
_tf
(
"googlenet_1.png"
))
);
ASSERT_TRUE
(
!
inpMats
[
0
].
empty
()
&&
!
inpMats
[
1
].
empty
());
net
.
setInput
(
blobFromImages
(
inpMats
),
"data"
);
Mat
out
=
net
.
forward
();
Mat
ref
=
blobFromNPY
(
_tf
(
"googlenet_prob.npy"
));
normAssert
(
out
,
ref
);
std
::
vector
<
String
>
blobsNames
;
blobsNames
.
push_back
(
"conv1/7x7_s2"
);
std
::
vector
<
Mat
>
outs
;
Mat
in
=
blobFromImage
(
inpMats
[
0
]);
net
.
setInput
(
in
,
"data"
);
net
.
forward
(
outs
,
blobsNames
);
CV_Assert
(
outs
.
size
()
==
blobsNames
.
size
());
ref
=
blobFromNPY
(
_tf
(
"googlenet_conv1#7x7_s2.npy"
));
normAssert
(
outs
[
0
],
ref
,
""
,
1E-4
,
1E-2
);
}
}
samples/dnn/torch_enet.cpp
View file @
7d114034
...
...
@@ -85,7 +85,9 @@ int main(int argc, char **argv)
}
//! [Make forward pass]
tm
.
start
();
Mat
result
=
net
.
forward
(
oBlob
);
tm
.
stop
();
if
(
!
resultFile
.
empty
())
{
CV_Assert
(
result
.
isContinuous
());
...
...
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