Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
665de4a3
M
models
项目概览
PaddlePaddle
/
models
接近 2 年 前同步成功
通知
230
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看板
提交
665de4a3
编写于
1月 07, 2019
作者:
Z
zhengya01
提交者:
qingqing01
1月 07, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Face detection ce (#1596)
* Add CE for face detection.
上级
2e86916f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
124 addition
and
0 deletion
+124
-0
fluid/PaddleCV/face_detection/.run_ce.sh
fluid/PaddleCV/face_detection/.run_ce.sh
+17
-0
fluid/PaddleCV/face_detection/__init__.py
fluid/PaddleCV/face_detection/__init__.py
+0
-0
fluid/PaddleCV/face_detection/_ce.py
fluid/PaddleCV/face_detection/_ce.py
+65
-0
fluid/PaddleCV/face_detection/train.py
fluid/PaddleCV/face_detection/train.py
+42
-0
未找到文件。
fluid/PaddleCV/face_detection/.run_ce.sh
0 → 100755
浏览文件 @
665de4a3
#!/bin/bash
export
MKL_NUM_THREADS
=
1
export
OMP_NUM_THREADS
=
1
cudaid
=
${
face_detection
:
=0
}
# use 0-th card as default
export
CUDA_VISIBLE_DEVICES
=
$cudaid
FLAGS_benchmark
=
true
python train.py
--batch_size
=
2
--epoc_num
=
1
--batch_num
=
200
--parallel
=
False
--enable_ce
| python _ce.py
cudaid
=
${
face_detection_m
:
=0,1,2,3
}
# use 0,1,2,3 card as default
export
CUDA_VISIBLE_DEVICES
=
$cudaid
FLAGS_benchmark
=
true
python train.py
--batch_size
=
8
--epoc_num
=
1
--batch_num
=
200
--parallel
=
False
--enable_ce
| python _ce.py
fluid/PaddleCV/face_detection/__init__.py
0 → 100644
浏览文件 @
665de4a3
fluid/PaddleCV/face_detection/_ce.py
0 → 100644
浏览文件 @
665de4a3
# this file is only used for continuous evaluation test!
import
os
import
sys
sys
.
path
.
append
(
os
.
environ
[
'ceroot'
])
from
kpi
import
CostKpi
from
kpi
import
DurationKpi
each_pass_duration_card1_kpi
=
DurationKpi
(
'each_pass_duration_card1'
,
0.08
,
0
,
actived
=
True
)
train_face_loss_card1_kpi
=
CostKpi
(
'train_face_loss_card1'
,
0.08
,
0
)
train_head_loss_card1_kpi
=
CostKpi
(
'train_head_loss_card1'
,
0.08
,
0
)
each_pass_duration_card4_kpi
=
DurationKpi
(
'each_pass_duration_card4'
,
0.08
,
0
,
actived
=
True
)
train_face_loss_card4_kpi
=
CostKpi
(
'train_face_loss_card4'
,
0.08
,
0
)
train_head_loss_card4_kpi
=
CostKpi
(
'train_head_loss_card4'
,
0.08
,
0
)
tracking_kpis
=
[
each_pass_duration_card1_kpi
,
train_face_loss_card1_kpi
,
train_head_loss_card1_kpi
,
each_pass_duration_card4_kpi
,
train_face_loss_card4_kpi
,
train_head_loss_card4_kpi
,
]
def
parse_log
(
log
):
'''
This method should be implemented by model developers.
The suggestion:
each line in the log should be key, value, for example:
"
train_cost
\t
1.0
test_cost
\t
1.0
train_cost
\t
1.0
train_cost
\t
1.0
train_acc
\t
1.2
"
'''
for
line
in
log
.
split
(
'
\n
'
):
fs
=
line
.
strip
().
split
(
'
\t
'
)
print
(
fs
)
if
len
(
fs
)
==
3
and
fs
[
0
]
==
'kpis'
:
kpi_name
=
fs
[
1
]
kpi_value
=
float
(
fs
[
2
])
yield
kpi_name
,
kpi_value
def
log_to_ce
(
log
):
kpi_tracker
=
{}
for
kpi
in
tracking_kpis
:
kpi_tracker
[
kpi
.
name
]
=
kpi
for
(
kpi_name
,
kpi_value
)
in
parse_log
(
log
):
print
(
kpi_name
,
kpi_value
)
kpi_tracker
[
kpi_name
].
add_record
(
kpi_value
)
kpi_tracker
[
kpi_name
].
persist
()
if
__name__
==
'__main__'
:
log
=
sys
.
stdin
.
read
()
log_to_ce
(
log
)
fluid/PaddleCV/face_detection/train.py
浏览文件 @
665de4a3
...
@@ -32,6 +32,9 @@ add_arg('mean_BGR', str, '104., 117., 123.', "Mean value for B,G,R cha
...
@@ -32,6 +32,9 @@ add_arg('mean_BGR', str, '104., 117., 123.', "Mean value for B,G,R cha
add_arg
(
'with_mem_opt'
,
bool
,
True
,
"Whether to use memory optimization or not."
)
add_arg
(
'with_mem_opt'
,
bool
,
True
,
"Whether to use memory optimization or not."
)
add_arg
(
'pretrained_model'
,
str
,
'./vgg_ilsvrc_16_fc_reduced/'
,
"The init model path."
)
add_arg
(
'pretrained_model'
,
str
,
'./vgg_ilsvrc_16_fc_reduced/'
,
"The init model path."
)
add_arg
(
'data_dir'
,
str
,
'data'
,
"The base dir of dataset"
)
add_arg
(
'data_dir'
,
str
,
'data'
,
"The base dir of dataset"
)
parser
.
add_argument
(
'--enable_ce'
,
action
=
'store_true'
,
help
=
'If set, run the task with continuous evaluation logs.'
)
parser
.
add_argument
(
'--batch_num'
,
type
=
int
,
help
=
"batch num for ce"
)
parser
.
add_argument
(
'--num_devices'
,
type
=
int
,
default
=
1
,
help
=
'Number of GPU devices'
)
#yapf: enable
#yapf: enable
train_parameters
=
{
train_parameters
=
{
...
@@ -119,6 +122,16 @@ def train(args, config, train_params, train_file_list):
...
@@ -119,6 +122,16 @@ def train(args, config, train_params, train_file_list):
startup_prog
=
fluid
.
Program
()
startup_prog
=
fluid
.
Program
()
train_prog
=
fluid
.
Program
()
train_prog
=
fluid
.
Program
()
#only for ce
if
args
.
enable_ce
:
SEED
=
102
startup_prog
.
random_seed
=
SEED
train_prog
.
random_seed
=
SEED
num_workers
=
1
pretrained_model
=
""
if
args
.
batch_num
!=
None
:
iters_per_epoc
=
args
.
batch_num
train_py_reader
,
fetches
,
loss
=
build_program
(
train_py_reader
,
fetches
,
loss
=
build_program
(
train_params
=
train_params
,
train_params
=
train_params
,
main_prog
=
train_prog
,
main_prog
=
train_prog
,
...
@@ -171,7 +184,12 @@ def train(args, config, train_params, train_file_list):
...
@@ -171,7 +184,12 @@ def train(args, config, train_params, train_file_list):
train_py_reader
.
start
()
train_py_reader
.
start
()
try
:
try
:
total_time
=
0.0
epoch_idx
=
0
face_loss
=
0
head_loss
=
0
for
pass_id
in
range
(
start_epoc
,
epoc_num
):
for
pass_id
in
range
(
start_epoc
,
epoc_num
):
epoch_idx
+=
1
start_time
=
time
.
time
()
start_time
=
time
.
time
()
prev_start_time
=
start_time
prev_start_time
=
start_time
end_time
=
0
end_time
=
0
...
@@ -198,14 +216,38 @@ def train(args, config, train_params, train_file_list):
...
@@ -198,14 +216,38 @@ def train(args, config, train_params, train_file_list):
"time {:.5f}"
.
format
(
pass_id
,
"time {:.5f}"
.
format
(
pass_id
,
batch_id
,
fetch_vars
[
0
],
fetch_vars
[
1
],
batch_id
,
fetch_vars
[
0
],
fetch_vars
[
1
],
start_time
-
prev_start_time
))
start_time
-
prev_start_time
))
face_loss
=
fetch_vars
[
0
]
head_loss
=
fetch_vars
[
1
]
epoch_end_time
=
time
.
time
()
total_time
+=
epoch_end_time
-
start_time
if
pass_id
%
1
==
0
or
pass_id
==
epoc_num
-
1
:
if
pass_id
%
1
==
0
or
pass_id
==
epoc_num
-
1
:
save_model
(
str
(
pass_id
),
train_prog
)
save_model
(
str
(
pass_id
),
train_prog
)
# only for ce
if
args
.
enable_ce
:
gpu_num
=
get_cards
(
args
)
print
(
"kpis
\t
each_pass_duration_card%s
\t
%s"
%
(
gpu_num
,
total_time
/
epoch_idx
))
print
(
"kpis
\t
train_face_loss_card%s
\t
%s"
%
(
gpu_num
,
face_loss
))
print
(
"kpis
\t
train_head_loss_card%s
\t
%s"
%
(
gpu_num
,
head_loss
))
except
fluid
.
core
.
EOFException
:
except
fluid
.
core
.
EOFException
:
train_py_reader
.
reset
()
train_py_reader
.
reset
()
except
StopIteration
:
except
StopIteration
:
train_py_reader
.
reset
()
train_py_reader
.
reset
()
train_py_reader
.
reset
()
train_py_reader
.
reset
()
def
get_cards
(
args
):
if
args
.
enable_ce
:
cards
=
os
.
environ
.
get
(
'CUDA_VISIBLE_DEVICES'
)
num
=
len
(
cards
.
split
(
","
))
return
num
else
:
return
args
.
num_devices
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
print_arguments
(
args
)
print_arguments
(
args
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录