Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
996694b5
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看板
未验证
提交
996694b5
编写于
12月 28, 2022
作者:
M
Minato
提交者:
GitHub
12月 28, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add ips and fps metric to wandb callback (#7542)
上级
f8e21c8f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
36 addition
and
0 deletion
+36
-0
ppdet/engine/callbacks.py
ppdet/engine/callbacks.py
+36
-0
未找到文件。
ppdet/engine/callbacks.py
浏览文件 @
996694b5
...
...
@@ -339,6 +339,7 @@ class WandbCallback(Callback):
self
.
run
.
define_metric
(
"eval/*"
,
step_metric
=
"epoch"
)
self
.
best_ap
=
-
1000.
self
.
fps
=
[]
@
property
def
run
(
self
):
...
...
@@ -360,6 +361,7 @@ class WandbCallback(Callback):
last_epoch
,
ema_model
=
None
,
ap
=
None
,
fps
=
None
,
tags
=
None
):
if
dist
.
get_world_size
()
<
2
or
dist
.
get_rank
()
==
0
:
model_path
=
os
.
path
.
join
(
save_dir
,
save_name
)
...
...
@@ -367,6 +369,10 @@ class WandbCallback(Callback):
metadata
[
"last_epoch"
]
=
last_epoch
if
ap
:
metadata
[
"ap"
]
=
ap
if
fps
:
metadata
[
"fps"
]
=
fps
if
ema_model
is
None
:
ema_artifact
=
self
.
wandb
.
Artifact
(
name
=
"ema_model-{}"
.
format
(
self
.
run
.
id
),
...
...
@@ -398,7 +404,25 @@ class WandbCallback(Callback):
training_status
=
status
[
'training_staus'
].
get
()
for
k
,
v
in
training_status
.
items
():
training_status
[
k
]
=
float
(
v
)
# calculate ips, data_cost, batch_cost
batch_time
=
status
[
'batch_time'
]
data_time
=
status
[
'data_time'
]
batch_size
=
self
.
model
.
cfg
[
'{}Reader'
.
format
(
mode
.
capitalize
(
))][
'batch_size'
]
ips
=
float
(
batch_size
)
/
float
(
batch_time
.
avg
)
data_cost
=
float
(
data_time
.
avg
)
batch_cost
=
f
metrics
=
{
"train/"
+
k
:
v
for
k
,
v
in
training_status
.
items
()}
metrics
[
"train/ips"
]
=
ips
metrics
[
"train/data_cost"
]
=
data_cost
metrics
[
"train/batch_cost"
]
=
batch_cost
self
.
fps
.
append
(
ips
)
self
.
run
.
log
(
metrics
)
def
on_epoch_end
(
self
,
status
):
...
...
@@ -407,6 +431,9 @@ class WandbCallback(Callback):
save_name
=
None
if
dist
.
get_world_size
()
<
2
or
dist
.
get_rank
()
==
0
:
if
mode
==
'train'
:
fps
=
sum
(
self
.
fps
)
/
len
(
self
.
fps
)
self
.
fps
=
[]
end_epoch
=
self
.
model
.
cfg
.
epoch
if
(
epoch_id
+
1
...
...
@@ -420,13 +447,21 @@ class WandbCallback(Callback):
save_name
,
epoch_id
+
1
,
self
.
model
.
use_ema
,
fps
=
fps
,
tags
=
tags
)
if
mode
==
'eval'
:
sample_num
=
status
[
'sample_num'
]
cost_time
=
status
[
'cost_time'
]
fps
=
sample_num
/
cost_time
merged_dict
=
{}
for
metric
in
self
.
model
.
_metrics
:
for
key
,
map_value
in
metric
.
get_results
().
items
():
merged_dict
[
"eval/{}-mAP"
.
format
(
key
)]
=
map_value
[
0
]
merged_dict
[
"epoch"
]
=
status
[
"epoch_id"
]
merged_dict
[
"eval/fps"
]
=
sample_num
/
cost_time
self
.
run
.
log
(
merged_dict
)
if
'save_best_model'
in
status
and
status
[
'save_best_model'
]:
...
...
@@ -457,6 +492,7 @@ class WandbCallback(Callback):
last_epoch
=
epoch_id
+
1
,
ema_model
=
self
.
model
.
use_ema
,
ap
=
abs
(
self
.
best_ap
),
fps
=
fps
,
tags
=
tags
)
def
on_train_end
(
self
,
status
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录