Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
752653c7
Commit
752653c7
authored
Dec 28, 2019
by
Liubov Batanina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update global pooling
parent
cf477f7e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
8 deletions
+25
-8
all_layers.hpp
modules/dnn/include/opencv2/dnn/all_layers.hpp
+1
-1
pooling_layer.cpp
modules/dnn/src/layers/pooling_layer.cpp
+22
-6
tf_importer.cpp
modules/dnn/src/tensorflow/tf_importer.cpp
+2
-1
No files found.
modules/dnn/include/opencv2/dnn/all_layers.hpp
View file @
752653c7
...
@@ -251,7 +251,7 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
...
@@ -251,7 +251,7 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
CV_DEPRECATED_EXTERNAL
Size
kernel
,
stride
,
pad
;
CV_DEPRECATED_EXTERNAL
Size
kernel
,
stride
,
pad
;
CV_DEPRECATED_EXTERNAL
int
pad_l
,
pad_t
,
pad_r
,
pad_b
;
CV_DEPRECATED_EXTERNAL
int
pad_l
,
pad_t
,
pad_r
,
pad_b
;
bool
globalPooling
;
bool
globalPooling
;
int
global_axis
;
std
::
vector
<
bool
>
isGlobalPooling
;
bool
computeMaxIdx
;
bool
computeMaxIdx
;
String
padMode
;
String
padMode
;
bool
ceilMode
;
bool
ceilMode
;
...
...
modules/dnn/src/layers/pooling_layer.cpp
View file @
752653c7
...
@@ -122,9 +122,17 @@ public:
...
@@ -122,9 +122,17 @@ public:
}
}
else
else
CV_Error
(
Error
::
StsBadArg
,
"Cannot determine pooling type"
);
CV_Error
(
Error
::
StsBadArg
,
"Cannot determine pooling type"
);
setParamsFrom
(
params
);
setParamsFrom
(
params
);
ceilMode
=
params
.
get
<
bool
>
(
"ceil_mode"
,
true
);
ceilMode
=
params
.
get
<
bool
>
(
"ceil_mode"
,
true
);
global_axis
=
params
.
get
<
int
>
(
"global_axis"
,
-
1
);
if
(
params
.
has
(
"is_global_pooling"
))
{
const
DictValue
&
global_axis
=
params
.
get
(
"is_global_pooling"
);
int
size
=
global_axis
.
size
();
isGlobalPooling
.
resize
(
size
);
for
(
int
i
=
0
;
i
<
size
;
i
++
)
isGlobalPooling
[
i
]
=
global_axis
.
get
<
bool
>
(
i
);
}
spatialScale
=
params
.
get
<
float
>
(
"spatial_scale"
,
1
);
spatialScale
=
params
.
get
<
float
>
(
"spatial_scale"
,
1
);
avePoolPaddedArea
=
params
.
get
<
bool
>
(
"ave_pool_padded_area"
,
true
);
avePoolPaddedArea
=
params
.
get
<
bool
>
(
"ave_pool_padded_area"
,
true
);
}
}
...
@@ -150,8 +158,12 @@ public:
...
@@ -150,8 +158,12 @@ public:
if
(
globalPooling
)
{
if
(
globalPooling
)
{
kernel
=
Size
(
inp
[
1
],
inp
[
0
]);
kernel
=
Size
(
inp
[
1
],
inp
[
0
]);
kernel_size
=
std
::
vector
<
size_t
>
(
inp
.
begin
(),
inp
.
end
());
kernel_size
=
std
::
vector
<
size_t
>
(
inp
.
begin
(),
inp
.
end
());
}
else
if
(
global_axis
!=
-
1
)
{
}
else
if
(
!
isGlobalPooling
.
empty
())
{
kernel_size
[
global_axis
]
=
inp
[
global_axis
];
for
(
int
i
=
0
;
i
<
isGlobalPooling
.
size
();
i
++
)
{
if
(
isGlobalPooling
[
i
])
kernel_size
[
i
]
=
inp
[
i
];
}
kernel
=
Size
(
kernel_size
[
1
],
kernel_size
[
0
]);
kernel
=
Size
(
kernel_size
[
1
],
kernel_size
[
0
]);
}
}
...
@@ -1041,10 +1053,14 @@ virtual Ptr<BackendNode> initNgraph(const std::vector<Ptr<BackendWrapper> >& inp
...
@@ -1041,10 +1053,14 @@ virtual Ptr<BackendNode> initNgraph(const std::vector<Ptr<BackendWrapper> >& inp
outShape
[
0
]
=
inputs
[
1
][
0
];
// Number of proposals;
outShape
[
0
]
=
inputs
[
1
][
0
];
// Number of proposals;
outShape
[
1
]
=
psRoiOutChannels
;
outShape
[
1
]
=
psRoiOutChannels
;
}
}
else
if
(
global_axis
!=
-
1
)
else
if
(
!
isGlobalPooling
.
empty
())
{
CV_Assert
(
isGlobalPooling
.
size
()
==
inpShape
.
size
());
for
(
int
i
=
0
;
i
<
isGlobalPooling
.
size
();
i
++
)
{
{
CV_Assert
(
global_axis
>=
0
&&
global_axis
<
inpShape
.
size
());
if
(
isGlobalPooling
[
i
])
outShape
[
2
+
global_axis
]
=
1
;
outShape
[
2
+
i
]
=
1
;
}
}
}
int
numOutputs
=
requiredOutputs
?
requiredOutputs
:
(
type
==
MAX
?
2
:
1
);
int
numOutputs
=
requiredOutputs
?
requiredOutputs
:
(
type
==
MAX
?
2
:
1
);
...
...
modules/dnn/src/tensorflow/tf_importer.cpp
View file @
752653c7
...
@@ -1961,7 +1961,8 @@ void TFImporter::populateNet(Net dstNet)
...
@@ -1961,7 +1961,8 @@ void TFImporter::populateNet(Net dstNet)
CV_Assert
(
layer_id
.
find
(
avgName
)
==
layer_id
.
end
());
CV_Assert
(
layer_id
.
find
(
avgName
)
==
layer_id
.
end
());
avgLp
.
set
(
"pool"
,
"ave"
);
avgLp
.
set
(
"pool"
,
"ave"
);
// pooling kernel H x 1
// pooling kernel H x 1
avgLp
.
set
(
"global_axis"
,
0
);
bool
isGlobalPooling
[]
=
{
true
,
false
};
avgLp
.
set
(
"is_global_pooling"
,
DictValue
::
arrayInt
(
&
isGlobalPooling
[
0
],
2
));
avgLp
.
set
(
"kernel_size"
,
1
);
avgLp
.
set
(
"kernel_size"
,
1
);
int
avgId
=
dstNet
.
addLayer
(
avgName
,
"Pooling"
,
avgLp
);
int
avgId
=
dstNet
.
addLayer
(
avgName
,
"Pooling"
,
avgLp
);
layer_id
[
avgName
]
=
avgId
;
layer_id
[
avgName
]
=
avgId
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment