Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
872a6eff
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
872a6eff
编写于
9月 10, 2018
作者:
B
Bai Yifan
提交者:
GitHub
9月 10, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix cpm and interp_mode (#1187)
* refine cpm and interp_mode
上级
258ae207
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
67 addition
and
13 deletion
+67
-13
fluid/face_detection/pyramidbox.py
fluid/face_detection/pyramidbox.py
+54
-6
fluid/face_detection/reader.py
fluid/face_detection/reader.py
+9
-3
fluid/face_detection/train.py
fluid/face_detection/train.py
+4
-4
未找到文件。
fluid/face_detection/pyramidbox.py
浏览文件 @
872a6eff
...
...
@@ -13,6 +13,8 @@ from paddle.fluid.regularizer import L2Decay
def
conv_bn
(
input
,
filter
,
ksize
,
stride
,
padding
,
act
=
'relu'
,
bias_attr
=
False
):
p_attr
=
ParamAttr
(
learning_rate
=
1.
,
regularizer
=
L2Decay
(
0.
))
b_attr
=
ParamAttr
(
learning_rate
=
0.
,
regularizer
=
L2Decay
(
0.
))
conv
=
fluid
.
layers
.
conv2d
(
input
=
input
,
filter_size
=
ksize
,
...
...
@@ -21,7 +23,13 @@ def conv_bn(input, filter, ksize, stride, padding, act='relu', bias_attr=False):
padding
=
padding
,
act
=
None
,
bias_attr
=
bias_attr
)
return
fluid
.
layers
.
batch_norm
(
input
=
conv
,
act
=
act
)
return
fluid
.
layers
.
batch_norm
(
input
=
conv
,
act
=
act
,
epsilon
=
0.001
,
momentum
=
0.999
,
param_attr
=
p_attr
,
bias_attr
=
b_attr
)
def
conv_block
(
input
,
groups
,
filters
,
ksizes
,
strides
=
None
,
with_pool
=
True
):
...
...
@@ -234,11 +242,51 @@ class PyramidBox(object):
face_locs
,
face_confs
=
[],
[]
head_locs
,
head_confs
=
[],
[]
boxes
,
vars
=
[],
[]
b_attr
=
ParamAttr
(
learning_rate
=
2.
,
regularizer
=
L2Decay
(
0.
))
mbox_loc
=
fluid
.
layers
.
conv2d
(
self
.
ssh_conv3_norm
,
8
,
3
,
1
,
1
,
bias_attr
=
b_attr
)
face_loc
,
head_loc
=
fluid
.
layers
.
split
(
mbox_loc
,
num_or_sections
=
2
,
dim
=
1
)
face_loc
=
permute_and_reshape
(
face_loc
,
4
)
head_loc
=
permute_and_reshape
(
head_loc
,
4
)
mbox_conf
=
fluid
.
layers
.
conv2d
(
self
.
ssh_conv3_norm
,
8
,
3
,
1
,
1
,
bias_attr
=
b_attr
)
face_conf3
,
face_conf1
,
head_conf3
,
head_conf1
=
fluid
.
layers
.
split
(
mbox_conf
,
num_or_sections
=
[
3
,
1
,
3
,
1
],
dim
=
1
)
face_conf3_maxin
=
fluid
.
layers
.
reduce_max
(
face_conf3
,
dim
=
1
,
keep_dim
=
True
)
face_conf
=
fluid
.
layers
.
concat
([
face_conf3_maxin
,
face_conf1
],
axis
=
1
)
head_conf3_maxin
=
fluid
.
layers
.
reduce_max
(
head_conf3
,
dim
=
1
,
keep_dim
=
True
)
head_conf
=
fluid
.
layers
.
concat
([
head_conf3_maxin
,
head_conf1
],
axis
=
1
)
face_conf
=
permute_and_reshape
(
face_conf
,
2
)
head_conf
=
permute_and_reshape
(
head_conf
,
2
)
face_locs
.
append
(
face_loc
)
face_confs
.
append
(
face_conf
)
head_locs
.
append
(
head_loc
)
head_confs
.
append
(
head_conf
)
box
,
var
=
fluid
.
layers
.
prior_box
(
self
.
ssh_conv3_norm
,
self
.
image
,
min_sizes
=
[
16.
],
steps
=
[
4.
]
*
2
,
aspect_ratios
=
[
1.
],
clip
=
False
,
flip
=
True
,
offset
=
0.5
)
box
=
fluid
.
layers
.
reshape
(
box
,
shape
=
[
-
1
,
4
])
var
=
fluid
.
layers
.
reshape
(
var
,
shape
=
[
-
1
,
4
])
boxes
.
append
(
box
)
vars
.
append
(
var
)
inputs
=
[
self
.
ssh_conv
3_norm
,
self
.
ssh_conv4_norm
,
self
.
ssh_conv5_norm
,
self
.
ssh_conv
6
,
self
.
ssh_conv
7
,
self
.
ssh_conv8
self
.
ssh_conv
4_norm
,
self
.
ssh_conv5_norm
,
self
.
ssh_conv6
,
self
.
ssh_conv7
,
self
.
ssh_conv8
]
b_attr
=
ParamAttr
(
learning_rate
=
2.
,
regularizer
=
L2Decay
(
0.
))
for
i
,
input
in
enumerate
(
inputs
):
mbox_loc
=
fluid
.
layers
.
conv2d
(
input
,
8
,
3
,
1
,
1
,
bias_attr
=
b_attr
)
face_loc
,
head_loc
=
fluid
.
layers
.
split
(
...
...
@@ -266,8 +314,8 @@ class PyramidBox(object):
box
,
var
=
fluid
.
layers
.
prior_box
(
input
,
self
.
image
,
min_sizes
=
[
self
.
min_sizes
[
i
]],
steps
=
[
self
.
steps
[
i
]]
*
2
,
min_sizes
=
[
self
.
min_sizes
[
i
+
1
]],
steps
=
[
self
.
steps
[
i
+
1
]]
*
2
,
aspect_ratios
=
[
1.
],
clip
=
False
,
flip
=
True
,
...
...
fluid/face_detection/reader.py
浏览文件 @
872a6eff
...
...
@@ -146,9 +146,15 @@ def preprocess(img, bbox_labels, mode, settings, image_path):
settings
.
min_face_size
)
img
=
Image
.
fromarray
(
img
)
img
=
img
.
resize
((
settings
.
resize_width
,
settings
.
resize_height
),
Image
.
ANTIALIAS
)
interp_mode
=
[
Image
.
BILINEAR
,
Image
.
HAMMING
,
Image
.
NEAREST
,
Image
.
BICUBIC
,
Image
.
LANCZOS
]
interp_indx
=
np
.
random
.
randint
(
0
,
5
)
img
=
img
.
resize
(
(
settings
.
resize_width
,
settings
.
resize_height
),
resample
=
interp_mode
[
interp_indx
])
img
=
np
.
array
(
img
)
if
mode
==
'train'
:
...
...
fluid/face_detection/train.py
浏览文件 @
872a6eff
...
...
@@ -62,11 +62,11 @@ def train(args, config, train_file_list, optimizer_method):
fetches
=
[
loss
]
steps_per_pass
=
12880
//
batch_size
boundaries
=
[
steps_per_pass
*
50
,
steps_per_pass
*
80
,
steps_per_pass
*
1
20
,
steps_per_pass
*
140
]
boundaries
=
[
steps_per_pass
*
99
,
steps_per_pass
*
124
,
steps_per_pass
*
1
49
]
values
=
[
learning_rate
,
learning_rate
*
0.
5
,
learning_rate
*
0.25
,
learning_rate
*
0.
1
,
learning_rate
*
0.
01
learning_rate
,
learning_rate
*
0.
1
,
learning_rate
*
0.
01
,
learning_rate
*
0.0
01
]
if
optimizer_method
==
"momentum"
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录