Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
0d56cdb2
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看板
提交
0d56cdb2
编写于
10月 14, 2019
作者:
W
wangguanzhong
提交者:
GitHub
10月 14, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "unify reader to dataloader (#3487)" (#3543)
This reverts commit b591cc133ca04dc1ed50631c8d24031bb97db18b.
上级
a8ae92aa
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
31 addition
and
49 deletion
+31
-49
ppdet/modeling/model_input.py
ppdet/modeling/model_input.py
+9
-7
ppdet/utils/check.py
ppdet/utils/check.py
+2
-16
ppdet/utils/eval_utils.py
ppdet/utils/eval_utils.py
+3
-3
tools/eval.py
tools/eval.py
+4
-6
tools/infer.py
tools/infer.py
+5
-7
tools/train.py
tools/train.py
+8
-10
未找到文件。
ppdet/modeling/model_input.py
浏览文件 @
0d56cdb2
...
...
@@ -38,7 +38,7 @@ feed_var_def = [
# yapf: enable
def
create_feed
(
feed
,
iterable
=
Fals
e
):
def
create_feed
(
feed
,
use_pyreader
=
Tru
e
):
image_shape
=
feed
.
image_shape
feed_var_map
=
{
var
[
'name'
]:
var
for
var
in
feed_var_def
}
feed_var_map
[
'image'
]
=
{
...
...
@@ -66,9 +66,11 @@ def create_feed(feed, iterable=False):
dtype
=
feed_var_map
[
key
][
'dtype'
],
lod_level
=
feed_var_map
[
key
][
'lod_level'
]))
for
key
in
feed
.
fields
])
loader
=
fluid
.
io
.
DataLoader
.
from_generator
(
pyreader
=
None
if
use_pyreader
:
pyreader
=
fluid
.
io
.
PyReader
(
feed_list
=
list
(
feed_vars
.
values
()),
capacity
=
64
,
use_double_buffer
=
True
,
iterable
=
iterabl
e
)
return
lo
ader
,
feed_vars
iterable
=
Fals
e
)
return
pyre
ader
,
feed_vars
ppdet/utils/check.py
浏览文件 @
0d56cdb2
...
...
@@ -15,6 +15,7 @@
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
unicode_literals
import
sys
...
...
@@ -23,7 +24,7 @@ import paddle.fluid as fluid
import
logging
logger
=
logging
.
getLogger
(
__name__
)
__all__
=
[
'check_gpu'
,
'check_version'
]
__all__
=
[
'check_gpu'
]
def
check_gpu
(
use_gpu
):
...
...
@@ -44,18 +45,3 @@ def check_gpu(use_gpu):
except
Exception
as
e
:
pass
def
check_version
():
"""
Log error and exit when the installed version of paddlepaddle is
not satisfied.
"""
err
=
"PaddlePaddle version 1.6 or higher is required, "
\
"or a suitable develop version is satisfied as well.
\n
"
\
"Please make sure the version is good with your code."
\
try
:
fluid
.
require_version
(
'1.6.0'
)
except
Exception
as
e
:
logger
.
error
(
err
)
sys
.
exit
(
1
)
ppdet/utils/eval_utils.py
浏览文件 @
0d56cdb2
...
...
@@ -57,7 +57,7 @@ def parse_fetches(fetches, prog=None, extra_keys=None):
return
keys
,
values
,
cls
def
eval_run
(
exe
,
compile_program
,
lo
ader
,
keys
,
values
,
cls
):
def
eval_run
(
exe
,
compile_program
,
pyre
ader
,
keys
,
values
,
cls
):
"""
Run evaluation program, return program outputs.
"""
...
...
@@ -75,7 +75,7 @@ def eval_run(exe, compile_program, loader, keys, values, cls):
has_bbox
=
'bbox'
in
keys
try
:
lo
ader
.
start
()
pyre
ader
.
start
()
while
True
:
outs
=
exe
.
run
(
compile_program
,
fetch_list
=
values
,
...
...
@@ -90,7 +90,7 @@ def eval_run(exe, compile_program, loader, keys, values, cls):
iter_id
+=
1
images_num
+=
len
(
res
[
'bbox'
][
1
][
0
])
if
has_bbox
else
1
except
(
StopIteration
,
fluid
.
core
.
EOFException
):
lo
ader
.
reset
()
pyre
ader
.
reset
()
logger
.
info
(
'Test finish iter {}'
.
format
(
iter_id
))
end_time
=
time
.
time
()
...
...
tools/eval.py
浏览文件 @
0d56cdb2
...
...
@@ -35,7 +35,7 @@ import paddle.fluid as fluid
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_run
,
eval_results
,
json_eval_results
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.utils.check
import
check_gpu
,
check_version
from
ppdet.utils.check
import
check_gpu
from
ppdet.modeling.model_input
import
create_feed
from
ppdet.data.data_feed
import
create_reader
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
...
...
@@ -62,8 +62,6 @@ def main():
# check if set use_gpu=True in paddlepaddle cpu version
check_gpu
(
cfg
.
use_gpu
)
# check if paddlepaddle version is satisfied
check_version
()
print_total_cfg
(
cfg
)
if
'eval_feed'
not
in
cfg
:
...
...
@@ -81,12 +79,12 @@ def main():
eval_prog
=
fluid
.
Program
()
with
fluid
.
program_guard
(
eval_prog
,
startup_prog
):
with
fluid
.
unique_name
.
guard
():
lo
ader
,
feed_vars
=
create_feed
(
eval_feed
)
pyre
ader
,
feed_vars
=
create_feed
(
eval_feed
)
fetches
=
model
.
eval
(
feed_vars
)
eval_prog
=
eval_prog
.
clone
(
True
)
reader
=
create_reader
(
eval_feed
,
args_path
=
FLAGS
.
dataset_dir
)
loader
.
set
_sample_list_generator
(
reader
,
place
)
pyreader
.
decorate
_sample_list_generator
(
reader
,
place
)
# eval already exists json file
if
FLAGS
.
json_eval
:
...
...
@@ -122,7 +120,7 @@ def main():
callable
(
model
.
is_bbox_normalized
):
is_bbox_normalized
=
model
.
is_bbox_normalized
()
results
=
eval_run
(
exe
,
compile_program
,
lo
ader
,
keys
,
values
,
cls
)
results
=
eval_run
(
exe
,
compile_program
,
pyre
ader
,
keys
,
values
,
cls
)
# evaluation
resolution
=
None
...
...
tools/infer.py
浏览文件 @
0d56cdb2
...
...
@@ -44,7 +44,7 @@ from ppdet.data.data_feed import create_reader
from
ppdet.utils.eval_utils
import
parse_fetches
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
from
ppdet.utils.check
import
check_gpu
from
ppdet.utils.visualizer
import
visualize_results
import
ppdet.utils.checkpoint
as
checkpoint
...
...
@@ -150,8 +150,6 @@ def main():
# check if set use_gpu=True in paddlepaddle cpu version
check_gpu
(
cfg
.
use_gpu
)
# check if paddlepaddle version is satisfied
check_version
()
print_total_cfg
(
cfg
)
if
'test_feed'
not
in
cfg
:
...
...
@@ -171,12 +169,12 @@ def main():
infer_prog
=
fluid
.
Program
()
with
fluid
.
program_guard
(
infer_prog
,
startup_prog
):
with
fluid
.
unique_name
.
guard
():
loader
,
feed_vars
=
create_feed
(
test_feed
,
iterable
=
Tru
e
)
_
,
feed_vars
=
create_feed
(
test_feed
,
use_pyreader
=
Fals
e
)
test_fetches
=
model
.
test
(
feed_vars
)
infer_prog
=
infer_prog
.
clone
(
True
)
reader
=
create_reader
(
test_feed
)
loader
.
set_sample_list_generator
(
reader
,
place
)
feeder
=
fluid
.
DataFeeder
(
place
=
place
,
feed_list
=
feed_vars
.
values
()
)
exe
.
run
(
startup_prog
)
if
cfg
.
weights
:
...
...
@@ -223,9 +221,9 @@ def main():
tb_image_frame
=
0
# each frame can display ten pictures at most.
imid2path
=
reader
.
imid2path
for
iter_id
,
data
in
enumerate
(
lo
ader
()):
for
iter_id
,
data
in
enumerate
(
re
ader
()):
outs
=
exe
.
run
(
infer_prog
,
feed
=
data
,
feed
=
feeder
.
feed
(
data
)
,
fetch_list
=
values
,
return_numpy
=
False
)
res
=
{
...
...
tools/train.py
浏览文件 @
0d56cdb2
...
...
@@ -46,7 +46,7 @@ from ppdet.utils import dist_utils
from
ppdet.utils.eval_utils
import
parse_fetches
,
eval_run
,
eval_results
from
ppdet.utils.stats
import
TrainingStats
from
ppdet.utils.cli
import
ArgsParser
from
ppdet.utils.check
import
check_gpu
,
check_version
from
ppdet.utils.check
import
check_gpu
import
ppdet.utils.checkpoint
as
checkpoint
from
ppdet.modeling.model_input
import
create_feed
...
...
@@ -81,8 +81,6 @@ def main():
# check if set use_gpu=True in paddlepaddle cpu version
check_gpu
(
cfg
.
use_gpu
)
# check if paddlepaddle version is satisfied
check_version
()
if
not
FLAGS
.
dist
or
trainer_id
==
0
:
print_total_cfg
(
cfg
)
...
...
@@ -118,7 +116,7 @@ def main():
with
fluid
.
program_guard
(
train_prog
,
startup_prog
):
with
fluid
.
unique_name
.
guard
():
model
=
create
(
main_arch
)
train_
lo
ader
,
feed_vars
=
create_feed
(
train_feed
)
train_
pyre
ader
,
feed_vars
=
create_feed
(
train_feed
)
with
mixed_precision_context
(
FLAGS
.
loss_scale
,
FLAGS
.
fp16
)
as
ctx
:
train_fetches
=
model
.
train
(
feed_vars
)
...
...
@@ -141,12 +139,12 @@ def main():
with
fluid
.
program_guard
(
eval_prog
,
startup_prog
):
with
fluid
.
unique_name
.
guard
():
model
=
create
(
main_arch
)
eval_
lo
ader
,
feed_vars
=
create_feed
(
eval_feed
)
eval_
pyre
ader
,
feed_vars
=
create_feed
(
eval_feed
)
fetches
=
model
.
eval
(
feed_vars
)
eval_prog
=
eval_prog
.
clone
(
True
)
eval_reader
=
create_reader
(
eval_feed
,
args_path
=
FLAGS
.
dataset_dir
)
eval_
loader
.
set
_sample_list_generator
(
eval_reader
,
place
)
eval_
pyreader
.
decorate
_sample_list_generator
(
eval_reader
,
place
)
# parse eval fetches
extra_keys
=
[]
...
...
@@ -201,7 +199,7 @@ def main():
train_reader
=
create_reader
(
train_feed
,
(
cfg
.
max_iters
-
start_iter
)
*
devices_num
,
FLAGS
.
dataset_dir
)
train_
loader
.
set
_sample_list_generator
(
train_reader
,
place
)
train_
pyreader
.
decorate
_sample_list_generator
(
train_reader
,
place
)
# whether output bbox is normalized in model output layer
is_bbox_normalized
=
False
...
...
@@ -213,7 +211,7 @@ def main():
map_type
=
cfg
.
map_type
if
'map_type'
in
cfg
else
'11point'
train_stats
=
TrainingStats
(
cfg
.
log_smooth_window
,
train_keys
)
train_
lo
ader
.
start
()
train_
pyre
ader
.
start
()
start_time
=
time
.
time
()
end_time
=
time
.
time
()
...
...
@@ -260,7 +258,7 @@ def main():
if
FLAGS
.
eval
:
# evaluation
results
=
eval_run
(
exe
,
compiled_eval_prog
,
eval_
lo
ader
,
results
=
eval_run
(
exe
,
compiled_eval_prog
,
eval_
pyre
ader
,
eval_keys
,
eval_values
,
eval_cls
)
resolution
=
None
if
'mask'
in
results
[
0
]:
...
...
@@ -282,7 +280,7 @@ def main():
logger
.
info
(
"Best test box ap: {}, in iter: {}"
.
format
(
best_box_ap_list
[
0
],
best_box_ap_list
[
1
]))
train_
lo
ader
.
reset
()
train_
pyre
ader
.
reset
()
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录