Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
a56d95e6
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看板
未验证
提交
a56d95e6
编写于
7月 26, 2018
作者:
B
baiyf
提交者:
GitHub
7月 26, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add ce run.sh scripts (#1072)
* add ce run.sh
上级
c7625931
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
46 addition
and
5 deletion
+46
-5
fluid/face_detection/.gitignore
fluid/face_detection/.gitignore
+1
-0
fluid/object_detection/.move.sh
fluid/object_detection/.move.sh
+1
-0
fluid/object_detection/.run.sh
fluid/object_detection/.run.sh
+11
-0
fluid/object_detection/train.py
fluid/object_detection/train.py
+33
-5
未找到文件。
fluid/face_detection/.gitignore
浏览文件 @
a56d95e6
...
...
@@ -9,3 +9,4 @@ log*
output*
pred
eval_tools
box*
fluid/object_detection/.move.sh
0 → 100644
浏览文件 @
a56d95e6
cp
-r
./data/pascalvoc/. /home/.cache/paddle/dataset/pascalvoc
fluid/object_detection/.run.sh
0 → 100644
浏览文件 @
a56d95e6
export
MKL_NUM_THREADS
=
1
export
OMP_NUM_THREADS
=
1
cudaid
=
${
object_detection_cudaid
:
=0
}
# use 0-th card as default
export
CUDA_VISIBLE_DEVICES
=
$cudaid
if
[
!
-d
"/root/.cache/paddle/dataset/pascalvoc"
]
;
then
mkdir
-p
/root/.cache/paddle/dataset/pascalvoc
./data/pascalvoc/download.sh
bash ./.move.sh
fi
FLAGS_benchmark
=
true
python train.py
--batch_size
=
64
--num_passes
=
2
--for_model_ce
=
True
--data_dir
=
/root/.cache/paddle/dataset/pascalvoc/
fluid/object_detection/train.py
浏览文件 @
a56d95e6
...
...
@@ -32,6 +32,10 @@ add_arg('mean_value_B', float, 127.5, "Mean value for B channel which will
add_arg
(
'mean_value_G'
,
float
,
127.5
,
"Mean value for G channel which will be subtracted."
)
#116.78
add_arg
(
'mean_value_R'
,
float
,
127.5
,
"Mean value for R channel which will be subtracted."
)
#103.94
add_arg
(
'is_toy'
,
int
,
0
,
"Toy for quick debug, 0 means using all data, while n means using only n sample."
)
add_arg
(
'for_model_ce'
,
bool
,
False
,
"Use CE to evaluate the model"
)
add_arg
(
'data_dir'
,
str
,
'data/pascalvoc'
,
"data directory"
)
add_arg
(
'skip_batch_num'
,
int
,
5
,
"the num of minibatch to skip."
)
add_arg
(
'iterations'
,
int
,
120
,
"mini batchs."
)
#yapf: enable
...
...
@@ -148,13 +152,20 @@ def train(args,
print
(
"Pass {0}, test map {1}"
.
format
(
pass_id
,
test_map
))
return
best_map
train_num
=
0
total_train_time
=
0.0
for
pass_id
in
range
(
num_passes
):
start_time
=
time
.
time
()
prev_start_time
=
start_time
end_time
=
0
# end_time = 0
every_pass_loss
=
[]
iter
=
0
pass_duration
=
0.0
for
batch_id
,
data
in
enumerate
(
train_reader
()):
prev_start_time
=
start_time
start_time
=
time
.
time
()
if
args
.
for_model_ce
and
iter
==
args
.
iterations
:
break
if
len
(
data
)
<
(
devices_num
*
2
):
print
(
"There are too few data to train on all devices."
)
continue
...
...
@@ -165,11 +176,28 @@ def train(args,
loss_v
,
=
exe
.
run
(
fluid
.
default_main_program
(),
feed
=
feeder
.
feed
(
data
),
fetch_list
=
[
loss
])
end_time
=
time
.
time
()
#
end_time = time.time()
loss_v
=
np
.
mean
(
np
.
array
(
loss_v
))
if
batch_id
%
20
==
0
:
print
(
"Pass {0}, batch {1}, loss {2}, time {3}"
.
format
(
pass_id
,
batch_id
,
loss_v
,
start_time
-
prev_start_time
))
if
args
.
for_model_ce
and
iter
>=
args
.
skip_batch_num
or
pass_id
!=
0
:
batch_duration
=
time
.
time
()
-
start_time
pass_duration
+=
batch_duration
train_num
+=
len
(
data
)
every_pass_loss
.
append
(
loss_v
)
iter
+=
1
total_train_time
+=
pass_duration
if
args
.
for_model_ce
and
pass_id
==
num_passes
-
1
:
examples_per_sec
=
train_num
/
total_train_time
cost
=
np
.
mean
(
every_pass_loss
)
with
open
(
"train_speed_factor.txt"
,
'w'
)
as
f
:
f
.
write
(
'{:f}
\n
'
.
format
(
examples_per_sec
))
with
open
(
"train_cost_factor.txt"
,
'a+'
)
as
f
:
f
.
write
(
'{:f}
\n
'
.
format
(
cost
))
best_map
=
test
(
pass_id
,
best_map
)
if
pass_id
%
10
==
0
or
pass_id
==
num_passes
-
1
:
save_model
(
str
(
pass_id
))
...
...
@@ -180,11 +208,11 @@ if __name__ == '__main__':
args
=
parser
.
parse_args
()
print_arguments
(
args
)
data_dir
=
'data/pascalvoc'
train_file_list
=
'trainval.txt'
val_file_list
=
'test.txt'
data_dir
=
args
.
data_dir
label_file
=
'label_list'
model_save_dir
=
args
.
model_save_dir
train_file_list
=
'trainval.txt'
val_file_list
=
'test.txt'
if
'coco'
in
args
.
dataset
:
data_dir
=
'data/coco'
if
'2014'
in
args
.
dataset
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录