Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenCV
opencv
提交
7d114034
O
opencv
项目概览
OpenCV
/
opencv
上一次同步 9 个月
通知
992
Star
71100
Fork
55581
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
7d114034
编写于
6月 29, 2017
作者:
A
Aleksandr Rybnikov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rewrote googlenet tests
上级
6ba22dea
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
52 addition
and
18 deletion
+52
-18
modules/dnn/src/dnn.cpp
modules/dnn/src/dnn.cpp
+9
-2
modules/dnn/src/layers/convolution_layer.cpp
modules/dnn/src/layers/convolution_layer.cpp
+2
-0
modules/dnn/test/imagenet_cls_test_alexnet.py
modules/dnn/test/imagenet_cls_test_alexnet.py
+2
-3
modules/dnn/test/test_googlenet.cpp
modules/dnn/test/test_googlenet.cpp
+37
-13
samples/dnn/torch_enet.cpp
samples/dnn/torch_enet.cpp
+2
-0
未找到文件。
modules/dnn/src/dnn.cpp
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录