Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenCV
opencv
提交
8574a757
O
opencv
项目概览
OpenCV
/
opencv
上一次同步 9 个月
通知
992
Star
71100
Fork
55581
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
8574a757
编写于
3月 22, 2020
作者:
D
Dmitry Kurtaev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Case sensitive dnn layers types
上级
7b82ad29
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
22 addition
and
20 deletion
+22
-20
modules/dnn/src/dnn.cpp
modules/dnn/src/dnn.cpp
+5
-8
modules/dnn/src/init.cpp
modules/dnn/src/init.cpp
+1
-0
modules/dnn/src/onnx/onnx_importer.cpp
modules/dnn/src/onnx/onnx_importer.cpp
+11
-2
modules/dnn/src/torch/torch_importer.cpp
modules/dnn/src/torch/torch_importer.cpp
+3
-8
modules/dnn/test/test_halide_layers.cpp
modules/dnn/test/test_halide_layers.cpp
+1
-1
modules/dnn/test/test_onnx_importer.cpp
modules/dnn/test/test_onnx_importer.cpp
+1
-1
未找到文件。
modules/dnn/src/dnn.cpp
浏览文件 @
8574a757
...
...
@@ -4626,16 +4626,15 @@ void LayerFactory::registerLayer(const String &type, Constructor constructor)
CV_TRACE_ARG_VALUE
(
type
,
"type"
,
type
.
c_str
());
cv
::
AutoLock
lock
(
getLayerFactoryMutex
());
String
type_
=
type
.
toLowerCase
();
LayerFactory_Impl
::
iterator
it
=
getLayerFactoryImpl
().
find
(
type_
);
LayerFactory_Impl
::
iterator
it
=
getLayerFactoryImpl
().
find
(
type
);
if
(
it
!=
getLayerFactoryImpl
().
end
())
{
if
(
it
->
second
.
back
()
==
constructor
)
CV_Error
(
cv
::
Error
::
StsBadArg
,
"Layer
\"
"
+
type
_
+
"
\"
already was registered"
);
CV_Error
(
cv
::
Error
::
StsBadArg
,
"Layer
\"
"
+
type
+
"
\"
already was registered"
);
it
->
second
.
push_back
(
constructor
);
}
getLayerFactoryImpl
().
insert
(
std
::
make_pair
(
type
_
,
std
::
vector
<
Constructor
>
(
1
,
constructor
)));
getLayerFactoryImpl
().
insert
(
std
::
make_pair
(
type
,
std
::
vector
<
Constructor
>
(
1
,
constructor
)));
}
void
LayerFactory
::
unregisterLayer
(
const
String
&
type
)
...
...
@@ -4644,9 +4643,8 @@ void LayerFactory::unregisterLayer(const String &type)
CV_TRACE_ARG_VALUE
(
type
,
"type"
,
type
.
c_str
());
cv
::
AutoLock
lock
(
getLayerFactoryMutex
());
String
type_
=
type
.
toLowerCase
();
LayerFactory_Impl
::
iterator
it
=
getLayerFactoryImpl
().
find
(
type
_
);
LayerFactory_Impl
::
iterator
it
=
getLayerFactoryImpl
().
find
(
type
);
if
(
it
!=
getLayerFactoryImpl
().
end
())
{
if
(
it
->
second
.
size
()
>
1
)
...
...
@@ -4662,8 +4660,7 @@ Ptr<Layer> LayerFactory::createLayerInstance(const String &type, LayerParams& pa
CV_TRACE_ARG_VALUE
(
type
,
"type"
,
type
.
c_str
());
cv
::
AutoLock
lock
(
getLayerFactoryMutex
());
String
type_
=
type
.
toLowerCase
();
LayerFactory_Impl
::
const_iterator
it
=
getLayerFactoryImpl
().
find
(
type_
);
LayerFactory_Impl
::
const_iterator
it
=
getLayerFactoryImpl
().
find
(
type
);
if
(
it
!=
getLayerFactoryImpl
().
end
())
{
...
...
modules/dnn/src/init.cpp
浏览文件 @
8574a757
...
...
@@ -95,6 +95,7 @@ void initializeLayerFactory()
CV_DNN_REGISTER_LAYER_CLASS
(
LRN
,
LRNLayer
);
CV_DNN_REGISTER_LAYER_CLASS
(
InnerProduct
,
InnerProductLayer
);
CV_DNN_REGISTER_LAYER_CLASS
(
Softmax
,
SoftmaxLayer
);
CV_DNN_REGISTER_LAYER_CLASS
(
SoftMax
,
SoftmaxLayer
);
// For compatibility. See https://github.com/opencv/opencv/issues/16877
CV_DNN_REGISTER_LAYER_CLASS
(
MVN
,
MVNLayer
);
CV_DNN_REGISTER_LAYER_CLASS
(
ReLU
,
ReLULayer
);
...
...
modules/dnn/src/onnx/onnx_importer.cpp
浏览文件 @
8574a757
...
...
@@ -615,6 +615,15 @@ void ONNXImporter::populateNet(Net dstNet)
layerParams
.
type
=
"ReLU"
;
replaceLayerParam
(
layerParams
,
"alpha"
,
"negative_slope"
);
}
else
if
(
layer_type
==
"Relu"
)
{
layerParams
.
type
=
"ReLU"
;
}
else
if
(
layer_type
==
"PRelu"
)
{
layerParams
.
type
=
"PReLU"
;
layerParams
.
blobs
.
push_back
(
getBlob
(
node_proto
,
constBlobs
,
1
));
}
else
if
(
layer_type
==
"LRN"
)
{
replaceLayerParam
(
layerParams
,
"size"
,
"local_size"
);
...
...
@@ -1133,10 +1142,10 @@ void ONNXImporter::populateNet(Net dstNet)
layerParams
.
set
(
"zoom_factor_x"
,
scales
.
at
<
float
>
(
3
));
}
}
else
if
(
layer_type
==
"LogSoftmax"
)
else
if
(
layer_type
==
"
SoftMax"
||
layer_type
==
"
LogSoftmax"
)
{
layerParams
.
type
=
"Softmax"
;
layerParams
.
set
(
"log_softmax"
,
true
);
layerParams
.
set
(
"log_softmax"
,
layer_type
==
"LogSoftmax"
);
}
else
{
...
...
modules/dnn/src/torch/torch_importer.cpp
浏览文件 @
8574a757
...
...
@@ -865,15 +865,10 @@ struct TorchImporter
layerParams
.
set
(
"indices_blob_id"
,
tensorParams
[
"indices"
].
first
);
curModule
->
modules
.
push_back
(
newModule
);
}
else
if
(
nnName
==
"SoftMax"
)
else
if
(
nnName
==
"
LogSoftMax"
||
nnName
==
"
SoftMax"
)
{
newModule
->
apiType
=
"SoftMax"
;
curModule
->
modules
.
push_back
(
newModule
);
}
else
if
(
nnName
==
"LogSoftMax"
)
{
newModule
->
apiType
=
"SoftMax"
;
layerParams
.
set
(
"log_softmax"
,
true
);
newModule
->
apiType
=
"Softmax"
;
layerParams
.
set
(
"log_softmax"
,
nnName
==
"LogSoftMax"
);
curModule
->
modules
.
push_back
(
newModule
);
}
else
if
(
nnName
==
"SpatialCrossMapLRN"
)
...
...
modules/dnn/test/test_halide_layers.cpp
浏览文件 @
8574a757
...
...
@@ -431,7 +431,7 @@ TEST_P(SoftMax, Accuracy)
Backend
backendId
=
get
<
0
>
(
get
<
1
>
(
GetParam
()));
Target
targetId
=
get
<
1
>
(
get
<
1
>
(
GetParam
()));
LayerParams
lp
;
lp
.
type
=
"Soft
M
ax"
;
lp
.
type
=
"Soft
m
ax"
;
lp
.
name
=
"testLayer"
;
int
sz
[]
=
{
1
,
inChannels
,
1
,
1
};
...
...
modules/dnn/test/test_onnx_importer.cpp
浏览文件 @
8574a757
...
...
@@ -70,7 +70,7 @@ public:
{
LayerParams
lp
;
Net
netSoftmax
;
netSoftmax
.
addLayerToPrev
(
"softmaxLayer"
,
"Soft
M
ax"
,
lp
);
netSoftmax
.
addLayerToPrev
(
"softmaxLayer"
,
"Soft
m
ax"
,
lp
);
netSoftmax
.
setPreferableBackend
(
DNN_BACKEND_OPENCV
);
netSoftmax
.
setInput
(
out
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录