Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
f5aba69c
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看板
未验证
提交
f5aba69c
编写于
3月 29, 2021
作者:
W
wangguanzhong
提交者:
GitHub
3月 29, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update dist api (#2443)
上级
0d14d704
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
16 addition
and
21 deletion
+16
-21
ppdet/engine/callbacks.py
ppdet/engine/callbacks.py
+6
-6
ppdet/engine/env.py
ppdet/engine/env.py
+1
-1
ppdet/engine/trainer.py
ppdet/engine/trainer.py
+4
-3
ppdet/utils/logger.py
ppdet/utils/logger.py
+2
-2
tools/eval.py
tools/eval.py
+1
-3
tools/infer.py
tools/infer.py
+1
-3
tools/train.py
tools/train.py
+1
-3
未找到文件。
ppdet/engine/callbacks.py
浏览文件 @
f5aba69c
...
@@ -23,7 +23,7 @@ import six
...
@@ -23,7 +23,7 @@ import six
import
numpy
as
np
import
numpy
as
np
import
paddle
import
paddle
from
paddle.distributed
import
ParallelEnv
import
paddle.distributed
as
dist
from
ppdet.utils.checkpoint
import
save_model
from
ppdet.utils.checkpoint
import
save_model
from
ppdet.optimizer
import
ModelEMA
from
ppdet.optimizer
import
ModelEMA
...
@@ -81,7 +81,7 @@ class LogPrinter(Callback):
...
@@ -81,7 +81,7 @@ class LogPrinter(Callback):
super
(
LogPrinter
,
self
).
__init__
(
model
)
super
(
LogPrinter
,
self
).
__init__
(
model
)
def
on_step_end
(
self
,
status
):
def
on_step_end
(
self
,
status
):
if
ParallelEnv
().
nranks
<
2
or
ParallelEnv
().
local_rank
==
0
:
if
dist
.
get_world_size
()
<
2
or
dist
.
get_rank
()
==
0
:
mode
=
status
[
'mode'
]
mode
=
status
[
'mode'
]
if
mode
==
'train'
:
if
mode
==
'train'
:
epoch_id
=
status
[
'epoch_id'
]
epoch_id
=
status
[
'epoch_id'
]
...
@@ -129,7 +129,7 @@ class LogPrinter(Callback):
...
@@ -129,7 +129,7 @@ class LogPrinter(Callback):
logger
.
info
(
"Eval iter: {}"
.
format
(
step_id
))
logger
.
info
(
"Eval iter: {}"
.
format
(
step_id
))
def
on_epoch_end
(
self
,
status
):
def
on_epoch_end
(
self
,
status
):
if
ParallelEnv
().
nranks
<
2
or
ParallelEnv
().
local_rank
==
0
:
if
dist
.
get_world_size
()
<
2
or
dist
.
get_rank
()
==
0
:
mode
=
status
[
'mode'
]
mode
=
status
[
'mode'
]
if
mode
==
'eval'
:
if
mode
==
'eval'
:
sample_num
=
status
[
'sample_num'
]
sample_num
=
status
[
'sample_num'
]
...
@@ -160,7 +160,7 @@ class Checkpointer(Callback):
...
@@ -160,7 +160,7 @@ class Checkpointer(Callback):
epoch_id
=
status
[
'epoch_id'
]
epoch_id
=
status
[
'epoch_id'
]
weight
=
None
weight
=
None
save_name
=
None
save_name
=
None
if
ParallelEnv
().
nranks
<
2
or
ParallelEnv
().
local_rank
==
0
:
if
dist
.
get_world_size
()
<
2
or
dist
.
get_rank
()
==
0
:
if
mode
==
'train'
:
if
mode
==
'train'
:
end_epoch
=
self
.
model
.
cfg
.
epoch
end_epoch
=
self
.
model
.
cfg
.
epoch
if
epoch_id
%
self
.
model
.
cfg
.
snapshot_epoch
==
0
or
epoch_id
==
end_epoch
-
1
:
if
epoch_id
%
self
.
model
.
cfg
.
snapshot_epoch
==
0
or
epoch_id
==
end_epoch
-
1
:
...
@@ -224,7 +224,7 @@ class VisualDLWriter(Callback):
...
@@ -224,7 +224,7 @@ class VisualDLWriter(Callback):
def
on_step_end
(
self
,
status
):
def
on_step_end
(
self
,
status
):
mode
=
status
[
'mode'
]
mode
=
status
[
'mode'
]
if
ParallelEnv
().
nranks
<
2
or
ParallelEnv
().
local_rank
==
0
:
if
dist
.
get_world_size
()
<
2
or
dist
.
get_rank
()
==
0
:
if
mode
==
'train'
:
if
mode
==
'train'
:
training_staus
=
status
[
'training_staus'
]
training_staus
=
status
[
'training_staus'
]
for
loss_name
,
loss_value
in
training_staus
.
get
().
items
():
for
loss_name
,
loss_value
in
training_staus
.
get
().
items
():
...
@@ -248,7 +248,7 @@ class VisualDLWriter(Callback):
...
@@ -248,7 +248,7 @@ class VisualDLWriter(Callback):
def
on_epoch_end
(
self
,
status
):
def
on_epoch_end
(
self
,
status
):
mode
=
status
[
'mode'
]
mode
=
status
[
'mode'
]
if
ParallelEnv
().
nranks
<
2
or
ParallelEnv
().
local_rank
==
0
:
if
dist
.
get_world_size
()
<
2
or
dist
.
get_rank
()
==
0
:
if
mode
==
'eval'
:
if
mode
==
'eval'
:
for
metric
in
self
.
model
.
_metrics
:
for
metric
in
self
.
model
.
_metrics
:
for
key
,
map_value
in
metric
.
get_results
().
items
():
for
key
,
map_value
in
metric
.
get_results
().
items
():
...
...
ppdet/engine/env.py
浏览文件 @
f5aba69c
...
@@ -21,7 +21,7 @@ import random
...
@@ -21,7 +21,7 @@ import random
import
numpy
as
np
import
numpy
as
np
import
paddle
import
paddle
from
paddle.distributed
import
ParallelEnv
,
fleet
from
paddle.distributed
import
fleet
__all__
=
[
'init_parallel_env'
,
'set_random_seed'
,
'init_fleet_env'
]
__all__
=
[
'init_parallel_env'
,
'set_random_seed'
,
'init_fleet_env'
]
...
...
ppdet/engine/trainer.py
浏览文件 @
f5aba69c
...
@@ -24,7 +24,8 @@ import numpy as np
...
@@ -24,7 +24,8 @@ import numpy as np
from
PIL
import
Image
from
PIL
import
Image
import
paddle
import
paddle
from
paddle.distributed
import
ParallelEnv
,
fleet
import
paddle.distributed
as
dist
from
paddle.distributed
import
fleet
from
paddle
import
amp
from
paddle
import
amp
from
paddle.static
import
InputSpec
from
paddle.static
import
InputSpec
...
@@ -84,8 +85,8 @@ class Trainer(object):
...
@@ -84,8 +85,8 @@ class Trainer(object):
self
.
optimizer
=
create
(
'OptimizerBuilder'
)(
self
.
lr
,
self
.
optimizer
=
create
(
'OptimizerBuilder'
)(
self
.
lr
,
self
.
model
.
parameters
())
self
.
model
.
parameters
())
self
.
_nranks
=
ParallelEnv
().
nranks
self
.
_nranks
=
dist
.
get_world_size
()
self
.
_local_rank
=
ParallelEnv
().
local_rank
self
.
_local_rank
=
dist
.
get_rank
()
self
.
status
=
{}
self
.
status
=
{}
...
...
ppdet/utils/logger.py
浏览文件 @
f5aba69c
...
@@ -17,7 +17,7 @@ import logging
...
@@ -17,7 +17,7 @@ import logging
import
os
import
os
import
sys
import
sys
from
paddle.distributed
import
ParallelEnv
import
paddle.distributed
as
dist
__all__
=
[
'setup_logger'
]
__all__
=
[
'setup_logger'
]
...
@@ -47,7 +47,7 @@ def setup_logger(name="ppdet", output=None):
...
@@ -47,7 +47,7 @@ def setup_logger(name="ppdet", output=None):
"[%(asctime)s] %(name)s %(levelname)s: %(message)s"
,
"[%(asctime)s] %(name)s %(levelname)s: %(message)s"
,
datefmt
=
"%m/%d %H:%M:%S"
)
datefmt
=
"%m/%d %H:%M:%S"
)
# stdout logging: master only
# stdout logging: master only
local_rank
=
ParallelEnv
().
local_rank
local_rank
=
dist
.
get_rank
()
if
local_rank
==
0
:
if
local_rank
==
0
:
ch
=
logging
.
StreamHandler
(
stream
=
sys
.
stdout
)
ch
=
logging
.
StreamHandler
(
stream
=
sys
.
stdout
)
ch
.
setLevel
(
logging
.
DEBUG
)
ch
.
setLevel
(
logging
.
DEBUG
)
...
...
tools/eval.py
浏览文件 @
f5aba69c
...
@@ -27,7 +27,6 @@ import warnings
...
@@ -27,7 +27,6 @@ import warnings
warnings
.
filterwarnings
(
'ignore'
)
warnings
.
filterwarnings
(
'ignore'
)
import
paddle
import
paddle
from
paddle.distributed
import
ParallelEnv
from
ppdet.core.workspace
import
load_config
,
merge_config
from
ppdet.core.workspace
import
load_config
,
merge_config
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
...
@@ -115,8 +114,7 @@ def main():
...
@@ -115,8 +114,7 @@ def main():
check_gpu
(
cfg
.
use_gpu
)
check_gpu
(
cfg
.
use_gpu
)
check_version
()
check_version
()
place
=
'gpu:{}'
.
format
(
ParallelEnv
().
dev_id
)
if
cfg
.
use_gpu
else
'cpu'
place
=
paddle
.
set_device
(
'gpu'
if
cfg
.
use_gpu
else
'cpu'
)
place
=
paddle
.
set_device
(
place
)
run
(
FLAGS
,
cfg
)
run
(
FLAGS
,
cfg
)
...
...
tools/infer.py
浏览文件 @
f5aba69c
...
@@ -27,7 +27,6 @@ warnings.filterwarnings('ignore')
...
@@ -27,7 +27,6 @@ warnings.filterwarnings('ignore')
import
glob
import
glob
import
paddle
import
paddle
from
paddle.distributed
import
ParallelEnv
from
ppdet.core.workspace
import
load_config
,
merge_config
from
ppdet.core.workspace
import
load_config
,
merge_config
from
ppdet.engine
import
Trainer
from
ppdet.engine
import
Trainer
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
from
ppdet.utils.check
import
check_gpu
,
check_version
,
check_config
...
@@ -140,8 +139,7 @@ def main():
...
@@ -140,8 +139,7 @@ def main():
check_gpu
(
cfg
.
use_gpu
)
check_gpu
(
cfg
.
use_gpu
)
check_version
()
check_version
()
place
=
'gpu:{}'
.
format
(
ParallelEnv
().
dev_id
)
if
cfg
.
use_gpu
else
'cpu'
place
=
paddle
.
set_device
(
'gpu'
if
cfg
.
use_gpu
else
'cpu'
)
place
=
paddle
.
set_device
(
place
)
run
(
FLAGS
,
cfg
)
run
(
FLAGS
,
cfg
)
...
...
tools/train.py
浏览文件 @
f5aba69c
...
@@ -29,7 +29,6 @@ import random
...
@@ -29,7 +29,6 @@ import random
import
numpy
as
np
import
numpy
as
np
import
paddle
import
paddle
from
paddle.distributed
import
ParallelEnv
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.core.workspace
import
load_config
,
merge_config
,
create
from
ppdet.utils.checkpoint
import
load_weight
,
load_pretrain_weight
from
ppdet.utils.checkpoint
import
load_weight
,
load_pretrain_weight
...
@@ -122,8 +121,7 @@ def main():
...
@@ -122,8 +121,7 @@ def main():
check
.
check_gpu
(
cfg
.
use_gpu
)
check
.
check_gpu
(
cfg
.
use_gpu
)
check
.
check_version
()
check
.
check_version
()
place
=
'gpu:{}'
.
format
(
ParallelEnv
().
dev_id
)
if
cfg
.
use_gpu
else
'cpu'
place
=
paddle
.
set_device
(
'gpu'
if
cfg
.
use_gpu
else
'cpu'
)
place
=
paddle
.
set_device
(
place
)
run
(
FLAGS
,
cfg
)
run
(
FLAGS
,
cfg
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录