Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
f2422ace
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,发现更多精彩内容 >>
提交
f2422ace
编写于
12月 10, 2020
作者:
A
Anastasia Murzova
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added TF nearest neighbour resize behaviour alignment
Relates to OpenCV issue #18721
上级
8286d84f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
62 addition
and
1 deletion
+62
-1
modules/dnn/src/layers/resize_layer.cpp
modules/dnn/src/layers/resize_layer.cpp
+49
-1
modules/dnn/test/test_tf_importer.cpp
modules/dnn/test/test_tf_importer.cpp
+13
-0
未找到文件。
modules/dnn/src/layers/resize_layer.cpp
浏览文件 @
f2422ace
...
@@ -115,7 +115,7 @@ public:
...
@@ -115,7 +115,7 @@ public:
Mat
&
inp
=
inputs
[
0
];
Mat
&
inp
=
inputs
[
0
];
Mat
&
out
=
outputs
[
0
];
Mat
&
out
=
outputs
[
0
];
if
(
interpolation
==
"nearest"
||
interpolation
==
"opencv_linear"
||
(
interpolation
==
"bilinear"
&&
halfPixelCenters
))
if
(
(
interpolation
==
"nearest"
&&
!
alignCorners
&&
!
halfPixelCenters
)
||
interpolation
==
"opencv_linear"
||
(
interpolation
==
"bilinear"
&&
halfPixelCenters
))
{
{
InterpolationFlags
mode
=
interpolation
==
"nearest"
?
INTER_NEAREST
:
INTER_LINEAR
;
InterpolationFlags
mode
=
interpolation
==
"nearest"
?
INTER_NEAREST
:
INTER_LINEAR
;
for
(
size_t
n
=
0
;
n
<
inputs
[
0
].
size
[
0
];
++
n
)
for
(
size_t
n
=
0
;
n
<
inputs
[
0
].
size
[
0
];
++
n
)
...
@@ -127,6 +127,54 @@ public:
...
@@ -127,6 +127,54 @@ public:
}
}
}
}
}
}
else
if
(
interpolation
==
"nearest"
)
{
const
int
inpHeight
=
inp
.
size
[
2
];
const
int
inpWidth
=
inp
.
size
[
3
];
const
int
inpSpatialSize
=
inpHeight
*
inpWidth
;
const
int
outSpatialSize
=
outHeight
*
outWidth
;
const
int
numPlanes
=
inp
.
size
[
0
]
*
inp
.
size
[
1
];
CV_Assert_N
(
inp
.
isContinuous
(),
out
.
isContinuous
());
Mat
inpPlanes
=
inp
.
reshape
(
1
,
numPlanes
*
inpHeight
);
Mat
outPlanes
=
out
.
reshape
(
1
,
numPlanes
*
outHeight
);
float
heightOffset
=
0.0
f
;
float
widthOffset
=
0.0
f
;
if
(
halfPixelCenters
)
{
heightOffset
=
0.5
f
*
scaleHeight
;
widthOffset
=
0.5
f
*
scaleWidth
;
}
for
(
int
y
=
0
;
y
<
outHeight
;
++
y
)
{
float
input_y
=
y
*
scaleHeight
+
heightOffset
;
int
y0
=
halfPixelCenters
?
std
::
floor
(
input_y
)
:
lroundf
(
input_y
);
y0
=
std
::
min
(
y0
,
inpHeight
-
1
);
const
float
*
inpData_row
=
inpPlanes
.
ptr
<
float
>
(
y0
);
for
(
int
x
=
0
;
x
<
outWidth
;
++
x
)
{
float
input_x
=
x
*
scaleWidth
+
widthOffset
;
int
x0
=
halfPixelCenters
?
std
::
floor
(
input_x
)
:
lroundf
(
input_x
);
x0
=
std
::
min
(
x0
,
inpWidth
-
1
);
float
*
outData
=
outPlanes
.
ptr
<
float
>
(
y
,
x
);
const
float
*
inpData_row_c
=
inpData_row
;
for
(
int
c
=
0
;
c
<
numPlanes
;
++
c
)
{
*
outData
=
inpData_row_c
[
x0
];
inpData_row_c
+=
inpSpatialSize
;
outData
+=
outSpatialSize
;
}
}
}
}
else
if
(
interpolation
==
"bilinear"
)
else
if
(
interpolation
==
"bilinear"
)
{
{
const
int
inpHeight
=
inp
.
size
[
2
];
const
int
inpHeight
=
inp
.
size
[
2
];
...
...
modules/dnn/test/test_tf_importer.cpp
浏览文件 @
f2422ace
...
@@ -920,6 +920,19 @@ TEST_P(Test_TensorFlow_layers, resize_nearest_neighbor)
...
@@ -920,6 +920,19 @@ TEST_P(Test_TensorFlow_layers, resize_nearest_neighbor)
runTensorFlowNet
(
"keras_upsampling2d"
);
runTensorFlowNet
(
"keras_upsampling2d"
);
}
}
TEST_P
(
Test_TensorFlow_layers
,
resize_nearest_neighbor_align_corners
)
{
runTensorFlowNet
(
"resize_nearest_neighbor"
,
false
,
0.0
,
0.0
,
false
,
"_align_corners"
);
}
TEST_P
(
Test_TensorFlow_layers
,
resize_nearest_neighbor_half_pixel
)
{
if
(
backend
==
DNN_BACKEND_INFERENCE_ENGINE_NGRAPH
)
applyTestTag
(
CV_TEST_TAG_DNN_SKIP_IE_NGRAPH
);
runTensorFlowNet
(
"resize_nearest_neighbor"
,
false
,
0.0
,
0.0
,
false
,
"_half_pixel"
);
}
TEST_P
(
Test_TensorFlow_layers
,
fused_resize_conv
)
TEST_P
(
Test_TensorFlow_layers
,
fused_resize_conv
)
{
{
runTensorFlowNet
(
"fused_resize_conv"
);
runTensorFlowNet
(
"fused_resize_conv"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录