Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
d1e5d0e8
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看板
提交
d1e5d0e8
编写于
6月 20, 2018
作者:
B
baiyfbupt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine pyramidbox config for inference
上级
6b92e294
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
19 addition
and
19 deletion
+19
-19
fluid/face_detection/.gitignore
fluid/face_detection/.gitignore
+0
-9
fluid/face_detection/infer.py
fluid/face_detection/infer.py
+4
-2
fluid/face_detection/train.py
fluid/face_detection/train.py
+15
-8
未找到文件。
fluid/face_detection/.gitignore
浏览文件 @
d1e5d0e8
# saved model
model/
# pretrained model
pretrained/
# used data and label
data/
label/
# log and swap files
*.swp
*.log
# infer
infer_results/
fluid/face_detection/infer.py
浏览文件 @
d1e5d0e8
...
...
@@ -181,9 +181,10 @@ def detect_face(image, shrink):
def
flip_test
(
image
,
shrink
):
im
age
=
image
.
transpose
(
Image
.
FLIP_LEFT_RIGHT
)
det_f
=
detect_face
(
im
age
,
shrink
)
im
g
=
image
.
transpose
(
Image
.
FLIP_LEFT_RIGHT
)
det_f
=
detect_face
(
im
g
,
shrink
)
det_t
=
np
.
zeros
(
det_f
.
shape
)
# image.size: [width, height]
det_t
[:,
0
]
=
image
.
size
[
0
]
-
det_f
[:,
2
]
det_t
[:,
1
]
=
det_f
[:,
1
]
det_t
[:,
2
]
=
image
.
size
[
0
]
-
det_f
[:,
0
]
...
...
@@ -263,6 +264,7 @@ def infer(args, batch_size, data_args):
image
=
img
[
0
][
0
]
image_path
=
img
[
0
][
1
]
# image.size: [width, height]
image_shape
=
[
3
,
image
.
size
[
1
],
image
.
size
[
0
]]
shrink
,
max_shrink
=
get_im_shrink
(
image_shape
)
...
...
fluid/face_detection/train.py
浏览文件 @
d1e5d0e8
...
...
@@ -16,11 +16,11 @@ add_arg = functools.partial(add_arguments, argparser=parser)
# yapf: disable
add_arg
(
'parallel'
,
bool
,
True
,
"parallel"
)
add_arg
(
'learning_rate'
,
float
,
0.00
0
1
,
"Learning rate."
)
add_arg
(
'batch_size'
,
int
,
1
6
,
"Minibatch size."
)
add_arg
(
'learning_rate'
,
float
,
0.001
,
"Learning rate."
)
add_arg
(
'batch_size'
,
int
,
1
2
,
"Minibatch size."
)
add_arg
(
'num_passes'
,
int
,
120
,
"Epoch number."
)
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
(
'dataset'
,
str
,
'WIDERFACE'
,
"coco2014, coco2017, and pascalvoc."
)
add_arg
(
'model_save_dir'
,
str
,
'model'
,
"The path to save model."
)
add_arg
(
'pretrained_model'
,
str
,
'./pretrained/'
,
"The init model path."
)
...
...
@@ -50,10 +50,10 @@ def train(args, data_args, learning_rate, batch_size, pretrained_model,
fetches
=
[
loss
]
epocs
=
12880
/
batch_size
boundaries
=
[
epocs
*
100
,
epocs
*
125
,
epocs
*
15
0
]
boundaries
=
[
epocs
*
40
,
epocs
*
60
,
epocs
*
80
,
epocs
*
10
0
]
values
=
[
learning_rate
,
learning_rate
*
0.
1
,
learning_rate
*
0.01
,
learning_rate
*
0.
0
01
learning_rate
,
learning_rate
*
0.
5
,
learning_rate
*
0.25
,
learning_rate
*
0.
1
,
learning_rate
*
0.
01
]
if
optimizer_method
==
"momentum"
:
...
...
@@ -70,12 +70,19 @@ def train(args, data_args, learning_rate, batch_size, pretrained_model,
)
optimizer
.
minimize
(
loss
)
# fluid.memory_optimize(fluid.default_main_program())
place
=
fluid
.
CUDAPlace
(
0
)
if
args
.
use_gpu
else
fluid
.
CPUPlace
()
exe
=
fluid
.
Executor
(
place
)
exe
.
run
(
fluid
.
default_startup_program
())
start_pass
=
0
if
pretrained_model
:
if
pretrained_model
.
isdigit
():
start_pass
=
int
(
pretrained_model
)
+
1
pretrained_model
=
os
.
path
.
join
(
args
.
model_save_dir
,
pretrained_model
)
print
(
"Resume from %s "
%
(
pretrained_model
))
if
not
os
.
path
.
exists
(
pretrained_model
):
raise
ValueError
(
"The pre-trained model path [%s] does not exist."
%
(
pretrained_model
))
...
...
@@ -98,14 +105,14 @@ def train(args, data_args, learning_rate, batch_size, pretrained_model,
print
'save models to %s'
%
(
model_path
)
fluid
.
io
.
save_persistables
(
exe
,
model_path
)
for
pass_id
in
range
(
num_passes
):
for
pass_id
in
range
(
start_pass
,
num_passes
):
start_time
=
time
.
time
()
prev_start_time
=
start_time
end_time
=
0
for
batch_id
,
data
in
enumerate
(
train_reader
()):
prev_start_time
=
start_time
start_time
=
time
.
time
()
if
len
(
data
)
<
devices_num
:
continue
if
len
(
data
)
<
2
*
devices_num
:
continue
if
args
.
parallel
:
fetch_vars
=
train_exe
.
run
(
fetch_list
=
[
v
.
name
for
v
in
fetches
],
feed
=
feeder
.
feed
(
data
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录