Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
d76a168a
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d76a168a
编写于
9月 05, 2019
作者:
Q
qingqing01
提交者:
GitHub
9月 05, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add benchmark (fps) in MODEL_ZOO doc (#3263)
* Add benchmark (fps) in MODEL_ZOO doc
上级
20ca4cc3
变更
5
展开全部
显示空白变更内容
内联
并排
Showing
5 changed file
with
189 addition
and
178 deletion
+189
-178
docs/MODEL_ZOO.md
docs/MODEL_ZOO.md
+77
-74
docs/MODEL_ZOO_cn.md
docs/MODEL_ZOO_cn.md
+75
-74
ppdet/utils/eval_utils.py
ppdet/utils/eval_utils.py
+23
-4
tools/eval.py
tools/eval.py
+4
-16
tools/train.py
tools/train.py
+10
-10
未找到文件。
docs/MODEL_ZOO.md
浏览文件 @
d76a168a
此差异已折叠。
点击以展开。
docs/MODEL_ZOO_cn.md
浏览文件 @
d76a168a
此差异已折叠。
点击以展开。
ppdet/utils/eval_utils.py
浏览文件 @
d76a168a
...
@@ -19,6 +19,7 @@ from __future__ import print_function
...
@@ -19,6 +19,7 @@ from __future__ import print_function
import
logging
import
logging
import
numpy
as
np
import
numpy
as
np
import
os
import
os
import
time
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
...
@@ -69,6 +70,10 @@ def eval_run(exe, compile_program, pyreader, keys, values, cls):
...
@@ -69,6 +70,10 @@ def eval_run(exe, compile_program, pyreader, keys, values, cls):
cls
[
i
].
reset
(
exe
)
cls
[
i
].
reset
(
exe
)
values
.
append
(
accum_map
)
values
.
append
(
accum_map
)
images_num
=
0
start_time
=
time
.
time
()
has_bbox
=
'bbox'
in
keys
try
:
try
:
pyreader
.
start
()
pyreader
.
start
()
while
True
:
while
True
:
...
@@ -83,10 +88,20 @@ def eval_run(exe, compile_program, pyreader, keys, values, cls):
...
@@ -83,10 +88,20 @@ def eval_run(exe, compile_program, pyreader, keys, values, cls):
if
iter_id
%
100
==
0
:
if
iter_id
%
100
==
0
:
logger
.
info
(
'Test iter {}'
.
format
(
iter_id
))
logger
.
info
(
'Test iter {}'
.
format
(
iter_id
))
iter_id
+=
1
iter_id
+=
1
images_num
+=
len
(
res
[
'bbox'
][
1
][
0
])
if
has_bbox
else
1
except
(
StopIteration
,
fluid
.
core
.
EOFException
):
except
(
StopIteration
,
fluid
.
core
.
EOFException
):
pyreader
.
reset
()
pyreader
.
reset
()
logger
.
info
(
'Test finish iter {}'
.
format
(
iter_id
))
logger
.
info
(
'Test finish iter {}'
.
format
(
iter_id
))
end_time
=
time
.
time
()
fps
=
images_num
/
(
end_time
-
start_time
)
if
has_bbox
:
logger
.
info
(
'Total number of images: {}, inference time: {} fps.'
.
format
(
images_num
,
fps
))
else
:
logger
.
info
(
'Total iteration: {}, inference time: {} batch/s.'
.
format
(
images_num
,
fps
))
return
results
return
results
...
@@ -114,7 +129,10 @@ def eval_results(results,
...
@@ -114,7 +129,10 @@ def eval_results(results,
if
output_directory
:
if
output_directory
:
output
=
os
.
path
.
join
(
output_directory
,
'bbox.json'
)
output
=
os
.
path
.
join
(
output_directory
,
'bbox.json'
)
box_ap_stats
=
bbox_eval
(
results
,
anno_file
,
output
,
box_ap_stats
=
bbox_eval
(
results
,
anno_file
,
output
,
with_background
,
with_background
,
is_bbox_normalized
=
is_bbox_normalized
)
is_bbox_normalized
=
is_bbox_normalized
)
...
@@ -130,7 +148,8 @@ def eval_results(results,
...
@@ -130,7 +148,8 @@ def eval_results(results,
box_ap_stats
.
append
(
res
*
100.
)
box_ap_stats
.
append
(
res
*
100.
)
elif
'bbox'
in
results
[
0
]:
elif
'bbox'
in
results
[
0
]:
box_ap
=
voc_bbox_eval
(
box_ap
=
voc_bbox_eval
(
results
,
num_classes
,
results
,
num_classes
,
is_bbox_normalized
=
is_bbox_normalized
,
is_bbox_normalized
=
is_bbox_normalized
,
map_type
=
map_type
)
map_type
=
map_type
)
box_ap_stats
.
append
(
box_ap
)
box_ap_stats
.
append
(
box_ap
)
...
...
tools/eval.py
浏览文件 @
d76a168a
...
@@ -17,7 +17,6 @@ from __future__ import division
...
@@ -17,7 +17,6 @@ from __future__ import division
from
__future__
import
print_function
from
__future__
import
print_function
import
os
import
os
import
multiprocessing
def
set_paddle_flags
(
**
kwargs
):
def
set_paddle_flags
(
**
kwargs
):
...
@@ -63,12 +62,6 @@ def main():
...
@@ -63,12 +62,6 @@ def main():
# check if set use_gpu=True in paddlepaddle cpu version
# check if set use_gpu=True in paddlepaddle cpu version
check_gpu
(
cfg
.
use_gpu
)
check_gpu
(
cfg
.
use_gpu
)
if
cfg
.
use_gpu
:
devices_num
=
fluid
.
core
.
get_cuda_device_count
()
else
:
devices_num
=
int
(
os
.
environ
.
get
(
'CPU_NUM'
,
multiprocessing
.
cpu_count
()))
if
'eval_feed'
not
in
cfg
:
if
'eval_feed'
not
in
cfg
:
eval_feed
=
create
(
main_arch
+
'EvalFeed'
)
eval_feed
=
create
(
main_arch
+
'EvalFeed'
)
else
:
else
:
...
@@ -100,15 +93,9 @@ def main():
...
@@ -100,15 +93,9 @@ def main():
json_eval_results
(
json_eval_results
(
eval_feed
,
cfg
.
metric
,
json_directory
=
FLAGS
.
output_eval
)
eval_feed
,
cfg
.
metric
,
json_directory
=
FLAGS
.
output_eval
)
return
return
# compile program for multi-devices
if
devices_num
<=
1
:
compile_program
=
fluid
.
compiler
.
CompiledProgram
(
eval_prog
)
else
:
build_strategy
=
fluid
.
BuildStrategy
()
build_strategy
.
memory_optimize
=
False
build_strategy
.
enable_inplace
=
False
compile_program
=
fluid
.
compiler
.
CompiledProgram
(
compile_program
=
fluid
.
compiler
.
CompiledProgram
(
eval_prog
).
with_data_parallel
(
build_strategy
=
build_strategy
)
eval_prog
).
with_data_parallel
(
)
# load model
# load model
exe
.
run
(
startup_prog
)
exe
.
run
(
startup_prog
)
...
@@ -132,6 +119,7 @@ def main():
...
@@ -132,6 +119,7 @@ def main():
is_bbox_normalized
=
model
.
is_bbox_normalized
()
is_bbox_normalized
=
model
.
is_bbox_normalized
()
results
=
eval_run
(
exe
,
compile_program
,
pyreader
,
keys
,
values
,
cls
)
results
=
eval_run
(
exe
,
compile_program
,
pyreader
,
keys
,
values
,
cls
)
# evaluation
# evaluation
resolution
=
None
resolution
=
None
if
'mask'
in
results
[
0
]:
if
'mask'
in
results
[
0
]:
...
...
tools/train.py
浏览文件 @
d76a168a
...
@@ -18,16 +18,17 @@ from __future__ import print_function
...
@@ -18,16 +18,17 @@ from __future__ import print_function
import
os
import
os
import
time
import
time
import
multiprocessing
import
numpy
as
np
import
numpy
as
np
import
datetime
import
datetime
from
collections
import
deque
from
collections
import
deque
def
set_paddle_flags
(
**
kwargs
):
def
set_paddle_flags
(
**
kwargs
):
for
key
,
value
in
kwargs
.
items
():
for
key
,
value
in
kwargs
.
items
():
if
os
.
environ
.
get
(
key
,
None
)
is
None
:
if
os
.
environ
.
get
(
key
,
None
)
is
None
:
os
.
environ
[
key
]
=
str
(
value
)
os
.
environ
[
key
]
=
str
(
value
)
# NOTE(paddle-dev): All of these flags should be set before
# NOTE(paddle-dev): All of these flags should be set before
# `import paddle`. Otherwise, it would not take any effect.
# `import paddle`. Otherwise, it would not take any effect.
set_paddle_flags
(
set_paddle_flags
(
...
@@ -69,8 +70,7 @@ def main():
...
@@ -69,8 +70,7 @@ def main():
if
cfg
.
use_gpu
:
if
cfg
.
use_gpu
:
devices_num
=
fluid
.
core
.
get_cuda_device_count
()
devices_num
=
fluid
.
core
.
get_cuda_device_count
()
else
:
else
:
devices_num
=
int
(
devices_num
=
int
(
os
.
environ
.
get
(
'CPU_NUM'
,
1
))
os
.
environ
.
get
(
'CPU_NUM'
,
multiprocessing
.
cpu_count
()))
if
'train_feed'
not
in
cfg
:
if
'train_feed'
not
in
cfg
:
train_feed
=
create
(
main_arch
+
'TrainFeed'
)
train_feed
=
create
(
main_arch
+
'TrainFeed'
)
...
@@ -133,12 +133,10 @@ def main():
...
@@ -133,12 +133,10 @@ def main():
# compile program for multi-devices
# compile program for multi-devices
build_strategy
=
fluid
.
BuildStrategy
()
build_strategy
=
fluid
.
BuildStrategy
()
build_strategy
.
memory_optimize
=
False
build_strategy
.
enable_inplace
=
False
build_strategy
.
enable_inplace
=
False
sync_bn
=
getattr
(
model
.
backbone
,
'norm_type'
,
None
)
==
'sync_bn'
sync_bn
=
getattr
(
model
.
backbone
,
'norm_type'
,
None
)
==
'sync_bn'
# only enable sync_bn in multi GPU devices
# only enable sync_bn in multi GPU devices
build_strategy
.
sync_batch_norm
=
sync_bn
and
devices_num
>
1
\
build_strategy
.
sync_batch_norm
=
sync_bn
and
devices_num
>
1
and
cfg
.
use_gpu
and
cfg
.
use_gpu
train_compile_program
=
fluid
.
compiler
.
CompiledProgram
(
train_compile_program
=
fluid
.
compiler
.
CompiledProgram
(
train_prog
).
with_data_parallel
(
train_prog
).
with_data_parallel
(
loss_name
=
loss
.
name
,
build_strategy
=
build_strategy
)
loss_name
=
loss
.
name
,
build_strategy
=
build_strategy
)
...
@@ -202,14 +200,16 @@ def main():
...
@@ -202,14 +200,16 @@ def main():
resolution
=
None
resolution
=
None
if
'mask'
in
results
[
0
]:
if
'mask'
in
results
[
0
]:
resolution
=
model
.
mask_head
.
resolution
resolution
=
model
.
mask_head
.
resolution
box_ap_stats
=
eval_results
(
results
,
eval_feed
,
cfg
.
metric
,
cfg
.
num_classes
,
box_ap_stats
=
eval_results
(
resolution
,
is_bbox_normalized
,
FLAGS
.
output_eval
,
map_type
)
results
,
eval_feed
,
cfg
.
metric
,
cfg
.
num_classes
,
resolution
,
is_bbox_normalized
,
FLAGS
.
output_eval
,
map_type
)
if
box_ap_stats
[
0
]
>
best_box_ap_list
[
0
]:
if
box_ap_stats
[
0
]
>
best_box_ap_list
[
0
]:
best_box_ap_list
[
0
]
=
box_ap_stats
[
0
]
best_box_ap_list
[
0
]
=
box_ap_stats
[
0
]
best_box_ap_list
[
1
]
=
it
best_box_ap_list
[
1
]
=
it
checkpoint
.
save
(
exe
,
train_prog
,
os
.
path
.
join
(
save_dir
,
"best_model"
))
checkpoint
.
save
(
exe
,
train_prog
,
os
.
path
.
join
(
save_dir
,
"best_model"
))
logger
.
info
(
"Best test box ap: {}, in iter: {}"
.
format
(
logger
.
info
(
"Best test box ap: {}, in iter: {}"
.
format
(
best_box_ap_list
[
0
],
best_box_ap_list
[
1
]))
best_box_ap_list
[
0
],
best_box_ap_list
[
1
]))
train_pyreader
.
reset
()
train_pyreader
.
reset
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录