Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
f06c44f1
O
Opencv
项目概览
Greenplum
/
Opencv
10 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
f06c44f1
编写于
1月 31, 2018
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10701 from dkurt:tf_ave_pooling
上级
027da35c
a2e9bfba
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
40 addition
and
8 deletion
+40
-8
modules/dnn/src/layers/pooling_layer.cpp
modules/dnn/src/layers/pooling_layer.cpp
+9
-8
modules/dnn/test/test_tf_importer.cpp
modules/dnn/test/test_tf_importer.cpp
+31
-0
未找到文件。
modules/dnn/src/layers/pooling_layer.cpp
浏览文件 @
f06c44f1
...
...
@@ -228,6 +228,7 @@ public:
const
Mat
*
src
,
*
rois
;
Mat
*
dst
,
*
mask
;
Size
kernel
,
stride
,
pad
;
String
padMode
;
int
nstripes
;
bool
computeMaxIdx
;
std
::
vector
<
int
>
ofsbuf
;
...
...
@@ -238,7 +239,7 @@ public:
computeMaxIdx
(
0
),
poolingType
(
MAX
),
spatialScale
(
0
)
{}
static
void
run
(
const
Mat
&
src
,
const
Mat
&
rois
,
Mat
&
dst
,
Mat
&
mask
,
Size
kernel
,
Size
stride
,
Size
pad
,
int
poolingType
,
float
spatialScale
,
Size
stride
,
Size
pad
,
String
padMode
,
int
poolingType
,
float
spatialScale
,
bool
computeMaxIdx
,
int
nstripes
)
{
CV_Assert
(
src
.
isContinuous
(),
dst
.
isContinuous
(),
...
...
@@ -257,6 +258,7 @@ public:
p
.
kernel
=
kernel
;
p
.
stride
=
stride
;
p
.
pad
=
pad
;
p
.
padMode
=
padMode
;
p
.
nstripes
=
nstripes
;
p
.
computeMaxIdx
=
computeMaxIdx
;
p
.
poolingType
=
poolingType
;
...
...
@@ -336,7 +338,6 @@ public:
yend
=
min
(
ystart
+
kernel_h
,
inp_height
+
pad_h
);
srcData
=
src
->
ptr
<
float
>
(
n
,
c
);
}
int
ydelta
=
yend
-
ystart
;
ystart
=
max
(
ystart
,
0
);
yend
=
min
(
yend
,
inp_height
);
float
*
dstData
=
dst
->
ptr
<
float
>
(
n
,
c
,
y0
);
...
...
@@ -500,15 +501,15 @@ public:
}
else
if
(
poolingType
==
AVE
)
{
bool
isSamePad
=
padMode
==
"SAME"
;
for
(
;
x0
<
x1
;
x0
++
)
{
int
xstart
=
x0
*
stride_w
-
pad_w
;
int
xend
=
min
(
xstart
+
kernel_w
,
inp_width
+
pad_w
);
int
xdelta
=
xend
-
xstart
;
xstart
=
max
(
xstart
,
0
);
xend
=
min
(
xend
,
inp_width
);
float
inv_kernel_area
=
1.
f
/
(
ydelta
*
xdelta
);
float
inv_kernel_area
=
isSamePad
?
(
yend
-
ystart
)
*
(
xend
-
xstart
)
:
kernel
.
area
(
);
inv_kernel_area
=
1.0
/
inv_kernel_area
;
#if CV_SIMD128
if
(
xstart
>
0
&&
x0
+
7
<
x1
&&
(
x0
+
7
)
*
stride_w
-
pad_w
+
kernel_w
<
inp_width
)
{
...
...
@@ -619,21 +620,21 @@ public:
{
const
int
nstripes
=
getNumThreads
();
Mat
rois
;
PoolingInvoker
::
run
(
src
,
rois
,
dst
,
mask
,
kernel
,
stride
,
pad
,
type
,
spatialScale
,
computeMaxIdx
,
nstripes
);
PoolingInvoker
::
run
(
src
,
rois
,
dst
,
mask
,
kernel
,
stride
,
pad
,
padMode
,
type
,
spatialScale
,
computeMaxIdx
,
nstripes
);
}
void
avePooling
(
Mat
&
src
,
Mat
&
dst
)
{
const
int
nstripes
=
getNumThreads
();
Mat
rois
,
mask
;
PoolingInvoker
::
run
(
src
,
rois
,
dst
,
mask
,
kernel
,
stride
,
pad
,
type
,
spatialScale
,
computeMaxIdx
,
nstripes
);
PoolingInvoker
::
run
(
src
,
rois
,
dst
,
mask
,
kernel
,
stride
,
pad
,
padMode
,
type
,
spatialScale
,
computeMaxIdx
,
nstripes
);
}
void
roiPooling
(
const
Mat
&
src
,
const
Mat
&
rois
,
Mat
&
dst
)
{
const
int
nstripes
=
getNumThreads
();
Mat
mask
;
PoolingInvoker
::
run
(
src
,
rois
,
dst
,
mask
,
kernel
,
stride
,
pad
,
type
,
spatialScale
,
computeMaxIdx
,
nstripes
);
PoolingInvoker
::
run
(
src
,
rois
,
dst
,
mask
,
kernel
,
stride
,
pad
,
padMode
,
type
,
spatialScale
,
computeMaxIdx
,
nstripes
);
}
virtual
Ptr
<
BackendNode
>
initMaxPoolingHalide
(
const
std
::
vector
<
Ptr
<
BackendWrapper
>
>
&
inputs
)
...
...
modules/dnn/test/test_tf_importer.cpp
浏览文件 @
f06c44f1
...
...
@@ -164,6 +164,7 @@ TEST(Test_TensorFlow, pooling)
runTensorFlowNet
(
"max_pool_even"
);
runTensorFlowNet
(
"max_pool_odd_valid"
);
runTensorFlowNet
(
"max_pool_odd_same"
);
runTensorFlowNet
(
"ave_pool_same"
);
}
TEST
(
Test_TensorFlow
,
deconvolution
)
...
...
@@ -248,6 +249,36 @@ TEST(Test_TensorFlow, MobileNet_SSD)
normAssert
(
target
[
2
].
reshape
(
1
,
1
),
output
[
2
].
reshape
(
1
,
1
),
""
,
4e-5
,
1e-2
);
}
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
.
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
);
}
OCL_TEST
(
Test_TensorFlow
,
MobileNet_SSD
)
{
throw
SkipTestException
(
"TODO: test is failed"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录