Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
e6062532
O
Opencv
项目概览
Greenplum
/
Opencv
11 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e6062532
编写于
2月 22, 2018
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10918 from pengli:dnn
上级
203ac0f8
e7d35d51
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
67 addition
and
22 deletion
+67
-22
modules/dnn/src/layers/convolution_layer.cpp
modules/dnn/src/layers/convolution_layer.cpp
+2
-8
modules/dnn/src/layers/normalize_bbox_layer.cpp
modules/dnn/src/layers/normalize_bbox_layer.cpp
+12
-0
modules/dnn/src/layers/pooling_layer.cpp
modules/dnn/src/layers/pooling_layer.cpp
+3
-0
modules/dnn/test/test_backends.cpp
modules/dnn/test/test_backends.cpp
+2
-6
modules/dnn/test/test_caffe_importer.cpp
modules/dnn/test/test_caffe_importer.cpp
+14
-7
modules/dnn/test/test_tf_importer.cpp
modules/dnn/test/test_tf_importer.cpp
+34
-1
未找到文件。
modules/dnn/src/layers/convolution_layer.cpp
浏览文件 @
e6062532
...
...
@@ -824,15 +824,9 @@ public:
for
(
int
i
=
0
;
i
<
inputs
.
size
();
++
i
)
CV_Assert
(
inputs
[
i
].
u
!=
outputs
[
0
].
u
);
int
inpH
=
inputs
[
0
].
size
[
2
];
int
inpW
=
inputs
[
0
].
size
[
3
];
int
out_h
=
(
inpH
+
2
*
pad
.
height
-
(
dilation
.
height
*
(
kernel
.
height
-
1
)
+
1
))
/
stride
.
height
+
1
;
int
out_w
=
(
inpW
+
2
*
pad
.
width
-
(
dilation
.
width
*
(
kernel
.
width
-
1
)
+
1
))
/
stride
.
width
+
1
;
if
(
out_h
!=
outputs
[
0
].
size
[
2
]
||
out_w
!=
outputs
[
0
].
size
[
3
])
if
(
padMode
==
"SAME"
)
return
false
;
int
group
=
inputs
[
0
].
size
[
1
]
/
umat_blobs
[
0
].
size
[
1
];
if
(
convolutionOp
.
empty
())
{
OCL4DNNConvConfig
config
;
...
...
@@ -842,7 +836,7 @@ public:
config
.
pad
=
pad
;
config
.
stride
=
stride
;
config
.
dilation
=
dilation
;
config
.
group
=
group
;
config
.
group
=
inputs
[
0
].
size
[
1
]
/
umat_blobs
[
0
].
size
[
1
]
;
config
.
bias_term
=
(
hasBias
())
?
true
:
false
;
convolutionOp
=
Ptr
<
OCL4DNNConvSpatial
<
float
>
>
(
new
OCL4DNNConvSpatial
<
float
>
(
config
));
...
...
modules/dnn/src/layers/normalize_bbox_layer.cpp
浏览文件 @
e6062532
...
...
@@ -105,6 +105,18 @@ public:
float
norm
=
pow
(
absSum
,
1.0
f
/
pnorm
);
multiply
(
src
,
1.0
f
/
norm
,
dst
);
}
else
{
Mat
norm
;
reduce
(
buffer
,
norm
,
0
,
REDUCE_SUM
);
norm
+=
epsilon
;
// compute inverted norm to call multiply instead divide
cv
::
pow
(
norm
,
-
1.0
f
/
pnorm
,
norm
);
repeat
(
norm
,
channels
,
1
,
buffer
);
multiply
(
src
,
buffer
,
dst
);
}
if
(
!
blobs
.
empty
())
{
...
...
modules/dnn/src/layers/pooling_layer.cpp
浏览文件 @
e6062532
...
...
@@ -145,6 +145,9 @@ public:
inps
.
getUMatVector
(
inputs
);
outs
.
getUMatVector
(
outputs
);
if
(
type
==
AVE
&&
padMode
==
"SAME"
)
return
false
;
if
(
poolOp
.
empty
())
{
OCL4DNNPoolConfig
config
;
...
...
modules/dnn/test/test_backends.cpp
浏览文件 @
e6062532
...
...
@@ -222,9 +222,7 @@ TEST_P(DNNTestNetwork, OpenFace)
TEST_P
(
DNNTestNetwork
,
opencv_face_detector
)
{
if
(
backend
==
DNN_BACKEND_HALIDE
||
backend
==
DNN_BACKEND_DEFAULT
&&
target
==
DNN_TARGET_OPENCL
)
throw
SkipTestException
(
""
);
if
(
backend
==
DNN_BACKEND_HALIDE
)
throw
SkipTestException
(
""
);
Mat
img
=
imread
(
findDataFile
(
"gpu/lbpcascade/er.png"
,
false
));
Mat
inp
=
blobFromImage
(
img
,
1.0
,
Size
(),
Scalar
(
104.0
,
177.0
,
123.0
),
false
,
false
);
processNet
(
"dnn/opencv_face_detector.caffemodel"
,
"dnn/opencv_face_detector.prototxt"
,
...
...
@@ -233,9 +231,7 @@ TEST_P(DNNTestNetwork, opencv_face_detector)
TEST_P
(
DNNTestNetwork
,
Inception_v2_SSD_TensorFlow
)
{
if
(
backend
==
DNN_BACKEND_DEFAULT
&&
target
==
DNN_TARGET_OPENCL
||
backend
==
DNN_BACKEND_HALIDE
)
throw
SkipTestException
(
""
);
if
(
backend
==
DNN_BACKEND_HALIDE
)
throw
SkipTestException
(
""
);
Mat
sample
=
imread
(
findDataFile
(
"dnn/street.png"
,
false
));
Mat
inp
=
blobFromImage
(
sample
,
1.0
f
/
127.5
,
Size
(
300
,
300
),
Scalar
(
127.5
,
127.5
,
127.5
),
false
);
processNet
(
"dnn/ssd_inception_v2_coco_2017_11_17.pb"
,
"dnn/ssd_inception_v2_coco_2017_11_17.pbtxt"
,
...
...
modules/dnn/test/test_caffe_importer.cpp
浏览文件 @
e6062532
...
...
@@ -456,16 +456,21 @@ TEST(Test_Caffe, multiple_inputs)
normAssert
(
out
,
first_image
+
second_image
);
}
typedef
testing
::
TestWithParam
<
std
::
string
>
opencv_face_detector
;
CV_ENUM
(
DNNTarget
,
DNN_TARGET_CPU
,
DNN_TARGET_OPENCL
)
typedef
testing
::
TestWithParam
<
tuple
<
std
::
string
,
DNNTarget
>
>
opencv_face_detector
;
TEST_P
(
opencv_face_detector
,
Accuracy
)
{
std
::
string
proto
=
findDataFile
(
"dnn/opencv_face_detector.prototxt"
,
false
);
std
::
string
model
=
findDataFile
(
GetParam
(),
false
);
std
::
string
model
=
findDataFile
(
get
<
0
>
(
GetParam
()),
false
);
dnn
::
Target
targetId
=
(
dnn
::
Target
)(
int
)
get
<
1
>
(
GetParam
());
Net
net
=
readNetFromCaffe
(
proto
,
model
);
Mat
img
=
imread
(
findDataFile
(
"gpu/lbpcascade/er.png"
,
false
));
Mat
blob
=
blobFromImage
(
img
,
1.0
,
Size
(),
Scalar
(
104.0
,
177.0
,
123.0
),
false
,
false
);
net
.
setPreferableBackend
(
DNN_BACKEND_DEFAULT
);
net
.
setPreferableTarget
(
targetId
);
net
.
setInput
(
blob
);
// Output has shape 1x1xNx7 where N - number of detections.
// An every detection is a vector of values [id, classId, confidence, left, top, right, bottom]
...
...
@@ -479,11 +484,13 @@ TEST_P(opencv_face_detector, Accuracy)
0.95097077
,
0.51901293
,
0.45863652
,
0.5777427
,
0.5347801
);
normAssert
(
out
.
reshape
(
1
,
out
.
total
()
/
7
).
rowRange
(
0
,
6
).
colRange
(
2
,
7
),
ref
);
}
INSTANTIATE_TEST_CASE_P
(
Test_Caffe
,
opencv_face_detector
,
Values
(
"dnn/opencv_face_detector.caffemodel"
,
"dnn/opencv_face_detector_fp16.caffemodel"
));
INSTANTIATE_TEST_CASE_P
(
Test_Caffe
,
opencv_face_detector
,
Combine
(
Values
(
"dnn/opencv_face_detector.caffemodel"
,
"dnn/opencv_face_detector_fp16.caffemodel"
),
Values
(
DNN_TARGET_CPU
,
DNN_TARGET_OPENCL
)
)
);
TEST
(
Test_Caffe
,
FasterRCNN_and_RFCN
)
{
...
...
modules/dnn/test/test_tf_importer.cpp
浏览文件 @
e6062532
...
...
@@ -317,11 +317,44 @@ OCL_TEST(Test_TensorFlow, MobileNet_SSD)
std
::
vector
<
Mat
>
output
;
net
.
forward
(
output
,
outNames
);
normAssert
(
target
[
0
].
reshape
(
1
,
1
),
output
[
0
].
reshape
(
1
,
1
)
,
""
,
1e-5
,
1.5e-4
);
normAssert
(
target
[
0
].
reshape
(
1
,
1
),
output
[
0
].
reshape
(
1
,
1
));
normAssert
(
target
[
1
].
reshape
(
1
,
1
),
output
[
1
].
reshape
(
1
,
1
),
""
,
1e-5
,
3e-4
);
normAssert
(
target
[
2
].
reshape
(
1
,
1
),
output
[
2
].
reshape
(
1
,
1
),
""
,
4e-5
,
1e-2
);
}
OCL_TEST
(
Test_TensorFlow
,
Inception_v2_SSD
)
{
std
::
string
proto
=
findDataFile
(
"dnn/ssd_inception_v2_coco_2017_11_17.pbtxt"
,
false
);
std
::
string
model
=
findDataFile
(
"dnn/ssd_inception_v2_coco_2017_11_17.pb"
,
false
);
Net
net
=
readNetFromTensorflow
(
model
,
proto
);
Mat
img
=
imread
(
findDataFile
(
"dnn/street.png"
,
false
));
Mat
blob
=
blobFromImage
(
img
,
1.0
f
/
127.5
,
Size
(
300
,
300
),
Scalar
(
127.5
,
127.5
,
127.5
),
true
,
false
);
net
.
setPreferableBackend
(
DNN_BACKEND_DEFAULT
);
net
.
setPreferableTarget
(
DNN_TARGET_OPENCL
);
net
.
setInput
(
blob
);
// Output has shape 1x1xNx7 where N - number of detections.
// An every detection is a vector of values [id, classId, confidence, left, top, right, bottom]
Mat
out
=
net
.
forward
();
out
=
out
.
reshape
(
1
,
out
.
total
()
/
7
);
Mat
detections
;
for
(
int
i
=
0
;
i
<
out
.
rows
;
++
i
)
{
if
(
out
.
at
<
float
>
(
i
,
2
)
>
0.5
)
detections
.
push_back
(
out
.
row
(
i
).
colRange
(
1
,
7
));
}
Mat
ref
=
(
Mat_
<
float
>
(
5
,
6
)
<<
1
,
0.90176028
,
0.19872092
,
0.36311883
,
0.26461923
,
0.63498729
,
3
,
0.93569964
,
0.64865261
,
0.45906419
,
0.80675775
,
0.65708131
,
3
,
0.75838411
,
0.44668293
,
0.45907149
,
0.49459291
,
0.52197015
,
10
,
0.95932811
,
0.38349164
,
0.32528657
,
0.40387636
,
0.39165527
,
10
,
0.93973452
,
0.66561931
,
0.37841269
,
0.68074018
,
0.42907384
);
normAssert
(
detections
,
ref
);
}
TEST
(
Test_TensorFlow
,
lstm
)
{
runTensorFlowNet
(
"lstm"
,
DNN_TARGET_CPU
,
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录