Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
d37180a2
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,发现更多精彩内容 >>
提交
d37180a2
编写于
4月 10, 2020
作者:
A
AshihsKrShrivastava
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modification for upsample node fused from unfused Resize subgraph
上级
245b2fec
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
8 deletion
+23
-8
modules/dnn/src/onnx/onnx_importer.cpp
modules/dnn/src/onnx/onnx_importer.cpp
+22
-8
modules/dnn/test/test_onnx_importer.cpp
modules/dnn/test/test_onnx_importer.cpp
+1
-0
未找到文件。
modules/dnn/src/onnx/onnx_importer.cpp
浏览文件 @
d37180a2
...
...
@@ -1397,8 +1397,7 @@ void ONNXImporter::populateNet(Net dstNet)
CV_Assert
(
layer_id
.
find
(
node_proto
.
input
(
i
))
==
layer_id
.
end
());
String
interp_mode
=
layerParams
.
get
<
String
>
(
"coordinate_transformation_mode"
);
CV_Assert_N
(
interp_mode
!=
"tf_crop_and_resize"
,
interp_mode
!=
"asymmetric"
,
interp_mode
!=
"tf_half_pixel_for_nn"
);
CV_Assert_N
(
interp_mode
!=
"tf_crop_and_resize"
,
interp_mode
!=
"tf_half_pixel_for_nn"
);
layerParams
.
set
(
"align_corners"
,
interp_mode
==
"align_corners"
);
Mat
shapes
=
getBlob
(
node_proto
,
constBlobs
,
node_proto
.
input_size
()
-
1
);
...
...
@@ -1426,6 +1425,22 @@ void ONNXImporter::populateNet(Net dstNet)
}
else
if
(
layer_type
==
"Upsample"
)
{
//fused from Resize Subgraph
if
(
layerParams
.
has
(
"coordinate_transformation_mode"
))
{
String
interp_mode
=
layerParams
.
get
<
String
>
(
"coordinate_transformation_mode"
);
CV_Assert_N
(
interp_mode
!=
"tf_crop_and_resize"
,
interp_mode
!=
"tf_half_pixel_for_nn"
);
layerParams
.
set
(
"align_corners"
,
interp_mode
==
"align_corners"
);
if
(
layerParams
.
get
<
String
>
(
"mode"
)
==
"linear"
)
{
layerParams
.
set
(
"mode"
,
interp_mode
==
"pytorch_half_pixel"
?
"opencv_linear"
:
"bilinear"
);
}
}
if
(
layerParams
.
get
<
String
>
(
"mode"
)
==
"linear"
&&
framework_name
==
"pytorch"
)
layerParams
.
set
(
"mode"
,
"opencv_linear"
);
layerParams
.
type
=
"Resize"
;
if
(
layerParams
.
has
(
"scales"
))
{
...
...
@@ -1435,22 +1450,21 @@ void ONNXImporter::populateNet(Net dstNet)
layerParams
.
set
(
"zoom_factor_y"
,
scales
.
getIntValue
(
2
));
layerParams
.
set
(
"zoom_factor_x"
,
scales
.
getIntValue
(
3
));
}
else
else
if
(
layerParams
.
has
(
"height_scale"
)
&&
layerParams
.
has
(
"width_scale"
))
{
// Caffe2 layer
replaceLayerParam
(
layerParams
,
"height_scale"
,
"zoom_factor_y"
);
replaceLayerParam
(
layerParams
,
"width_scale"
,
"zoom_factor_x"
);
}
replaceLayerParam
(
layerParams
,
"mode"
,
"interpolation"
);
if
(
layerParams
.
get
<
String
>
(
"interpolation"
)
==
"linear"
&&
framework_name
==
"pytorch"
)
{
layerParams
.
type
=
"Resize"
;
else
{
// scales as input
Mat
scales
=
getBlob
(
node_proto
,
constBlobs
,
1
);
CV_Assert
(
scales
.
total
()
==
4
);
layerParams
.
set
(
"interpolation"
,
"opencv_linear"
);
layerParams
.
set
(
"zoom_factor_y"
,
scales
.
at
<
float
>
(
2
));
layerParams
.
set
(
"zoom_factor_x"
,
scales
.
at
<
float
>
(
3
));
}
replaceLayerParam
(
layerParams
,
"mode"
,
"interpolation"
);
}
else
if
(
layer_type
==
"SoftMax"
||
layer_type
==
"LogSoftmax"
)
{
...
...
modules/dnn/test/test_onnx_importer.cpp
浏览文件 @
d37180a2
...
...
@@ -369,6 +369,7 @@ TEST_P(Test_ONNX_layers, ResizeUnfused)
testONNXModels
(
"upsample_unfused_opset9_torch1.4"
);
testONNXModels
(
"resize_nearest_unfused_opset11_torch1.4"
);
testONNXModels
(
"resize_nearest_unfused_opset11_torch1.3"
);
testONNXModels
(
"resize_bilinear_unfused_opset11_torch1.4"
);
}
TEST_P
(
Test_ONNX_layers
,
MultyInputs
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录