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
832ca073
Commit
832ca073
authored
Jan 22, 2020
by
Liubov Batanina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring
parent
fada959b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
31 deletions
+29
-31
all_layers.hpp
modules/dnn/include/opencv2/dnn/all_layers.hpp
+1
-1
pooling_layer.cpp
modules/dnn/src/layers/pooling_layer.cpp
+10
-12
human_parsing.py
samples/dnn/human_parsing.py
+18
-18
No files found.
modules/dnn/include/opencv2/dnn/all_layers.hpp
View file @
832ca073
...
...
@@ -250,7 +250,7 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
std
::
vector
<
size_t
>
pads_begin
,
pads_end
;
CV_DEPRECATED_EXTERNAL
Size
kernel
,
stride
,
pad
;
CV_DEPRECATED_EXTERNAL
int
pad_l
,
pad_t
,
pad_r
,
pad_b
;
CV_DEPRECATED_EXTERNAL
bool
globalPooling
;
CV_DEPRECATED_EXTERNAL
bool
globalPooling
;
//!< Flag is true if at least one of the axes is global pooled.
std
::
vector
<
bool
>
isGlobalPooling
;
bool
computeMaxIdx
;
String
padMode
;
...
...
modules/dnn/src/layers/pooling_layer.cpp
View file @
832ca073
...
...
@@ -97,7 +97,7 @@ public:
CV_Error
(
Error
::
StsBadArg
,
"Unknown pooling type
\"
"
+
pool
+
"
\"
"
);
getPoolingKernelParams
(
params
,
kernel_size
,
isGlobalPooling
,
pads_begin
,
pads_end
,
strides
,
padMode
);
globalPooling
=
std
::
accumulate
(
isGlobalPooling
.
begin
(),
isGlobalPooling
.
end
(),
0
)
==
3
;
globalPooling
=
isGlobalPooling
[
0
]
||
isGlobalPooling
[
1
]
||
isGlobalPooling
[
2
]
;
if
(
kernel_size
.
size
()
==
2
)
{
kernel
=
Size
(
kernel_size
[
1
],
kernel_size
[
0
]);
stride
=
Size
(
strides
[
1
],
strides
[
0
]);
...
...
@@ -149,18 +149,16 @@ public:
out
.
push_back
(
outputs
[
0
].
size
[
i
]);
}
if
(
kernel_size
.
size
()
>
inp
.
size
())
{
kernel_size
.
erase
(
kernel_size
.
begin
());
}
kernel_size
.
resize
(
out
.
size
());
if
(
globalPooling
)
{
std
::
vector
<
size_t
>
finalKernel
;
for
(
int
i
=
0
;
i
<
inp
.
size
();
i
++
)
{
int
idx
=
isGlobalPooling
.
size
()
-
inp
.
size
()
+
i
;
finalKernel
.
push_back
(
isGlobalPooling
[
idx
]
?
inp
[
i
]
:
kernel_size
[
idx
]);
}
kernel_size
=
finalKernel
;
kernel
=
Size
(
kernel_size
[
1
],
kernel_size
[
0
]);
}
for
(
int
i
=
0
;
i
<
inp
.
size
();
i
++
)
{
int
idx
=
isGlobalPooling
.
size
()
-
inp
.
size
()
+
i
;
if
(
isGlobalPooling
[
idx
])
kernel_size
[
i
]
=
inp
[
i
];
}
kernel
=
Size
(
kernel_size
.
back
(),
kernel_size
[
kernel_size
.
size
()
-
2
]);
getConvPoolPaddings
(
inp
,
kernel_size
,
strides
,
padMode
,
pads_begin
,
pads_end
);
if
(
pads_begin
.
size
()
==
2
)
{
...
...
samples/dnn/human_parsing.py
View file @
832ca073
...
...
@@ -6,23 +6,6 @@ import argparse
backends
=
(
cv
.
dnn
.
DNN_BACKEND_DEFAULT
,
cv
.
dnn
.
DNN_BACKEND_INFERENCE_ENGINE
,
cv
.
dnn
.
DNN_BACKEND_OPENCV
)
targets
=
(
cv
.
dnn
.
DNN_TARGET_CPU
,
cv
.
dnn
.
DNN_TARGET_OPENCL
,
cv
.
dnn
.
DNN_TARGET_OPENCL_FP16
,
cv
.
dnn
.
DNN_TARGET_MYRIAD
)
parser
=
argparse
.
ArgumentParser
(
description
=
'Use this script to run human parsing using JPPNet'
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
parser
.
add_argument
(
'--input'
,
'-i'
,
help
=
'Path to input image. Skip this argument to capture frames from a camera.'
)
parser
.
add_argument
(
'--model'
,
'-m'
,
required
=
True
,
help
=
'Path to pb model.'
)
parser
.
add_argument
(
'--backend'
,
choices
=
backends
,
default
=
cv
.
dnn
.
DNN_BACKEND_DEFAULT
,
type
=
int
,
help
=
"Choose one of computation backends: "
"
%
d: automatically (by default), "
"
%
d: Intel's Deep Learning Inference Engine (https://software.intel.com/openvino-toolkit), "
"
%
d: OpenCV implementation"
%
backends
)
parser
.
add_argument
(
'--target'
,
choices
=
targets
,
default
=
cv
.
dnn
.
DNN_TARGET_CPU
,
type
=
int
,
help
=
'Choose one of target computation devices: '
'
%
d: CPU target (by default), '
'
%
d: OpenCL, '
'
%
d: OpenCL fp16 (half-float precision), '
'
%
d: VPU'
%
targets
)
args
,
_
=
parser
.
parse_known_args
()
# To get pre-trained model download https://drive.google.com/file/d/1BFVXgeln-bek8TCbRjN6utPAgRE0LJZg/view
# For correct convert .meta to .pb model download original repository https://github.com/Engineering-Course/LIP_JPPNet
# Change script evaluate_parsing_JPPNet-s2.py for human parsing
...
...
@@ -147,7 +130,7 @@ def decode_labels(gray_image):
return
segm
def
parse_human
(
image_path
,
model_path
,
backend
,
target
):
def
parse_human
(
image_path
,
model_path
,
backend
=
cv
.
dnn
.
DNN_BACKEND_OPENCV
,
target
=
cv
.
dnn
.
DNN_TARGET_CPU
):
"""
Prepare input for execution, run net and postprocess output to parse human.
:param image_path: path to input image
...
...
@@ -164,6 +147,23 @@ def parse_human(image_path, model_path, backend, target):
if
__name__
==
'__main__'
:
parser
=
argparse
.
ArgumentParser
(
description
=
'Use this script to run human parsing using JPPNet'
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
parser
.
add_argument
(
'--input'
,
'-i'
,
help
=
'Path to input image. Skip this argument to capture frames from a camera.'
)
parser
.
add_argument
(
'--model'
,
'-m'
,
required
=
True
,
help
=
'Path to pb model.'
)
parser
.
add_argument
(
'--backend'
,
choices
=
backends
,
default
=
cv
.
dnn
.
DNN_BACKEND_DEFAULT
,
type
=
int
,
help
=
"Choose one of computation backends: "
"
%
d: automatically (by default), "
"
%
d: Intel's Deep Learning Inference Engine (https://software.intel.com/openvino-toolkit), "
"
%
d: OpenCV implementation"
%
backends
)
parser
.
add_argument
(
'--target'
,
choices
=
targets
,
default
=
cv
.
dnn
.
DNN_TARGET_CPU
,
type
=
int
,
help
=
'Choose one of target computation devices: '
'
%
d: CPU target (by default), '
'
%
d: OpenCL, '
'
%
d: OpenCL fp16 (half-float precision), '
'
%
d: VPU'
%
targets
)
args
,
_
=
parser
.
parse_known_args
()
output
=
parse_human
(
args
.
input
,
args
.
model
,
args
.
backend
,
args
.
target
)
winName
=
'Deep learning human parsing in OpenCV'
cv
.
namedWindow
(
winName
,
cv
.
WINDOW_AUTOSIZE
)
...
...
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