Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
8761ab3d
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
8761ab3d
编写于
6月 28, 2018
作者:
B
baiyf
提交者:
GitHub
6月 28, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add more pyramid in face detection inference (#1014)
* add more pyramid
上级
6fc865e1
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
33 addition
and
2 deletion
+33
-2
fluid/face_detection/infer.py
fluid/face_detection/infer.py
+33
-2
未找到文件。
fluid/face_detection/infer.py
浏览文件 @
8761ab3d
...
...
@@ -15,7 +15,7 @@ parser = argparse.ArgumentParser(description=__doc__)
add_arg
=
functools
.
partial
(
add_arguments
,
argparser
=
parser
)
# yapf: disable
add_arg
(
'use_gpu'
,
bool
,
True
,
"Whether use GPU."
)
add_arg
(
'use_pyramidbox'
,
bool
,
Fals
e
,
"Whether use PyramidBox model."
)
add_arg
(
'use_pyramidbox'
,
bool
,
Tru
e
,
"Whether use PyramidBox model."
)
add_arg
(
'confs_threshold'
,
float
,
0.25
,
"Confidence threshold to draw bbox."
)
add_arg
(
'image_path'
,
str
,
''
,
"The data root path."
)
add_arg
(
'model_dir'
,
str
,
''
,
"The model path."
)
...
...
@@ -168,6 +168,9 @@ def detect_face(image, shrink):
return_numpy
=
False
)
detection
=
np
.
array
(
detection
)
# layout: xmin, ymin, xmax. ymax, score
if
detection
.
shape
==
(
1
,
):
print
(
"No face detected"
)
return
np
.
array
([[
0
,
0
,
0
,
0
,
0
]])
det_conf
=
detection
[:,
1
]
det_xmin
=
image_shape
[
2
]
*
detection
[:,
2
]
/
shrink
det_ymin
=
image_shape
[
1
]
*
detection
[:,
3
]
/
shrink
...
...
@@ -227,6 +230,33 @@ def multi_scale_test(image, max_shrink):
return
det_s
,
det_b
def
multi_scale_test_pyramid
(
image
,
max_shrink
):
# shrink detecting and shrink only detect big face
det_b
=
detect_face
(
image
,
0.25
)
index
=
np
.
where
(
np
.
maximum
(
det_b
[:,
2
]
-
det_b
[:,
0
]
+
1
,
det_b
[:,
3
]
-
det_b
[:,
1
]
+
1
)
>
30
)[
0
]
det_b
=
det_b
[
index
,
:]
st
=
[
0.5
,
0.75
,
1.25
,
1.5
,
1.75
,
2.25
]
for
i
in
range
(
len
(
st
)):
if
(
st
[
i
]
<=
max_shrink
):
det_temp
=
detect_face
(
image
,
st
[
i
])
# enlarge only detect small face
if
st
[
i
]
>
1
:
index
=
np
.
where
(
np
.
minimum
(
det_temp
[:,
2
]
-
det_temp
[:,
0
]
+
1
,
det_temp
[:,
3
]
-
det_temp
[:,
1
]
+
1
)
<
100
)[
0
]
det_temp
=
det_temp
[
index
,
:]
else
:
index
=
np
.
where
(
np
.
maximum
(
det_temp
[:,
2
]
-
det_temp
[:,
0
]
+
1
,
det_temp
[:,
3
]
-
det_temp
[:,
1
]
+
1
)
>
30
)[
0
]
det_temp
=
det_temp
[
index
,
:]
det_b
=
np
.
row_stack
((
det_b
,
det_temp
))
return
det_b
def
get_im_shrink
(
image_shape
):
max_shrink_v1
=
(
0x7fffffff
/
577.0
/
(
image_shape
[
1
]
*
image_shape
[
2
]))
**
0.5
...
...
@@ -272,7 +302,8 @@ def infer(args, batch_size, data_args):
det0
=
detect_face
(
image
,
shrink
)
det1
=
flip_test
(
image
,
shrink
)
[
det2
,
det3
]
=
multi_scale_test
(
image
,
max_shrink
)
det
=
np
.
row_stack
((
det0
,
det1
,
det2
,
det3
))
det4
=
multi_scale_test_pyramid
(
image
,
max_shrink
)
det
=
np
.
row_stack
((
det0
,
det1
,
det2
,
det3
,
det4
))
dets
=
bbox_vote
(
det
)
image_name
=
image_path
.
split
(
'/'
)[
-
1
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录