Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
d8107a51
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,发现更多精彩内容 >>
提交
d8107a51
编写于
12月 08, 2020
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18996 from LupusSanctus:am/dnn_bilinear_resize
上级
e8348e5f
a82c50ea
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
53 addition
and
5 deletion
+53
-5
modules/dnn/src/layers/resize_layer.cpp
modules/dnn/src/layers/resize_layer.cpp
+3
-1
modules/dnn/src/tensorflow/tf_importer.cpp
modules/dnn/src/tensorflow/tf_importer.cpp
+3
-0
modules/dnn/test/test_tf_importer.cpp
modules/dnn/test/test_tf_importer.cpp
+47
-4
未找到文件。
modules/dnn/src/layers/resize_layer.cpp
浏览文件 @
d8107a51
...
...
@@ -42,6 +42,7 @@ public:
CV_Check
(
interpolation
,
interpolation
==
"nearest"
||
interpolation
==
"opencv_linear"
||
interpolation
==
"bilinear"
,
""
);
alignCorners
=
params
.
get
<
bool
>
(
"align_corners"
,
false
);
halfPixelCenters
=
params
.
get
<
bool
>
(
"half_pixel_centers"
,
false
);
}
bool
getMemoryShapes
(
const
std
::
vector
<
MatShape
>
&
inputs
,
...
...
@@ -114,7 +115,7 @@ public:
Mat
&
inp
=
inputs
[
0
];
Mat
&
out
=
outputs
[
0
];
if
(
interpolation
==
"nearest"
||
interpolation
==
"opencv_linear"
)
if
(
interpolation
==
"nearest"
||
interpolation
==
"opencv_linear"
||
(
interpolation
==
"bilinear"
&&
halfPixelCenters
)
)
{
InterpolationFlags
mode
=
interpolation
==
"nearest"
?
INTER_NEAREST
:
INTER_LINEAR
;
for
(
size_t
n
=
0
;
n
<
inputs
[
0
].
size
[
0
];
++
n
)
...
...
@@ -236,6 +237,7 @@ protected:
String
interpolation
;
float
scaleWidth
,
scaleHeight
;
bool
alignCorners
;
bool
halfPixelCenters
;
};
...
...
modules/dnn/src/tensorflow/tf_importer.cpp
浏览文件 @
d8107a51
...
...
@@ -1962,6 +1962,9 @@ void TFImporter::populateNet(Net dstNet)
if
(
hasLayerAttr
(
layer
,
"align_corners"
))
layerParams
.
set
(
"align_corners"
,
getLayerAttr
(
layer
,
"align_corners"
).
b
());
if
(
hasLayerAttr
(
layer
,
"half_pixel_centers"
))
layerParams
.
set
(
"half_pixel_centers"
,
getLayerAttr
(
layer
,
"half_pixel_centers"
).
b
());
int
id
=
dstNet
.
addLayer
(
name
,
"Resize"
,
layerParams
);
layer_id
[
name
]
=
id
;
...
...
modules/dnn/test/test_tf_importer.cpp
浏览文件 @
d8107a51
...
...
@@ -81,12 +81,12 @@ class Test_TensorFlow_layers : public DNNTestLayer
{
public:
void
runTensorFlowNet
(
const
std
::
string
&
prefix
,
bool
hasText
=
false
,
double
l1
=
0.0
,
double
lInf
=
0.0
,
bool
memoryLoad
=
false
)
double
l1
=
0.0
,
double
lInf
=
0.0
,
bool
memoryLoad
=
false
,
const
std
::
string
&
groupPrefix
=
""
)
{
std
::
string
netPath
=
path
(
prefix
+
"_net.pb"
);
std
::
string
netConfig
=
(
hasText
?
path
(
prefix
+
"_net.pbtxt"
)
:
""
);
std
::
string
netPath
=
path
(
prefix
+
groupPrefix
+
"_net.pb"
);
std
::
string
netConfig
=
(
hasText
?
path
(
prefix
+
groupPrefix
+
"_net.pbtxt"
)
:
""
);
std
::
string
inpPath
=
path
(
prefix
+
"_in.npy"
);
std
::
string
outPath
=
path
(
prefix
+
"_out.npy"
);
std
::
string
outPath
=
path
(
prefix
+
groupPrefix
+
"_out.npy"
);
cv
::
Mat
input
=
blobFromNPY
(
inpPath
);
cv
::
Mat
ref
=
blobFromNPY
(
outPath
);
...
...
@@ -975,10 +975,53 @@ TEST_P(Test_TensorFlow_layers, keras_mobilenet_head)
runTensorFlowNet
(
"keras_learning_phase"
);
}
// TF case: align_corners=False, half_pixel_centers=False
TEST_P
(
Test_TensorFlow_layers
,
resize_bilinear
)
{
runTensorFlowNet
(
"resize_bilinear"
);
}
// TF case: align_corners=True, half_pixel_centers=False
TEST_P
(
Test_TensorFlow_layers
,
resize_bilinear_align_corners
)
{
runTensorFlowNet
(
"resize_bilinear"
,
false
,
0.0
,
0.0
,
false
,
// default parameters
"_align_corners"
);
}
// TF case: align_corners=False, half_pixel_centers=True
TEST_P
(
Test_TensorFlow_layers
,
resize_bilinear_half_pixel
)
{
if
(
backend
==
DNN_BACKEND_INFERENCE_ENGINE_NGRAPH
)
applyTestTag
(
CV_TEST_TAG_DNN_SKIP_IE_NGRAPH
);
runTensorFlowNet
(
"resize_bilinear"
,
false
,
0.0
,
0.0
,
false
,
"_half_pixel"
);
}
// TF case: align_corners=False, half_pixel_centers=False
TEST_P
(
Test_TensorFlow_layers
,
resize_bilinear_factor
)
{
runTensorFlowNet
(
"resize_bilinear_factor"
);
}
// TF case: align_corners=False, half_pixel_centers=True
TEST_P
(
Test_TensorFlow_layers
,
resize_bilinear_factor_half_pixel
)
{
if
(
backend
==
DNN_BACKEND_INFERENCE_ENGINE_NGRAPH
)
applyTestTag
(
CV_TEST_TAG_DNN_SKIP_IE_NGRAPH
);
runTensorFlowNet
(
"resize_bilinear_factor"
,
false
,
0.0
,
0.0
,
false
,
"_half_pixel"
);
}
// TF case: align_corners=True, half_pixel_centers=False
TEST_P
(
Test_TensorFlow_layers
,
resize_bilinear_factor_align_corners
)
{
runTensorFlowNet
(
"resize_bilinear_factor"
,
false
,
0.0
,
0.0
,
false
,
"_align_corners"
);
}
// TF case: align_corners=False, half_pixel_centers=False
TEST_P
(
Test_TensorFlow_layers
,
resize_bilinear_down
)
{
runTensorFlowNet
(
"resize_bilinear_down"
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录