Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
a3737406
P
PaddleOCR
项目概览
weixin_41840029
/
PaddleOCR
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleOCR
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
a3737406
编写于
6月 28, 2022
作者:
A
andyjpaddle
提交者:
GitHub
6月 28, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6726 from andyjpaddle/fix_amp_vqa
fix amp train vqa
上级
91600fcc
adeb8a17
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
22 addition
and
9 deletion
+22
-9
tools/program.py
tools/program.py
+22
-9
未找到文件。
tools/program.py
浏览文件 @
a3737406
...
@@ -255,6 +255,8 @@ def train(config,
...
@@ -255,6 +255,8 @@ def train(config,
with
paddle
.
amp
.
auto_cast
():
with
paddle
.
amp
.
auto_cast
():
if
model_type
==
'table'
or
extra_input
:
if
model_type
==
'table'
or
extra_input
:
preds
=
model
(
images
,
data
=
batch
[
1
:])
preds
=
model
(
images
,
data
=
batch
[
1
:])
elif
model_type
in
[
"kie"
,
'vqa'
]:
preds
=
model
(
batch
)
else
:
else
:
preds
=
model
(
images
)
preds
=
model
(
images
)
else
:
else
:
...
@@ -307,7 +309,8 @@ def train(config,
...
@@ -307,7 +309,8 @@ def train(config,
train_stats
.
update
(
stats
)
train_stats
.
update
(
stats
)
if
log_writer
is
not
None
and
dist
.
get_rank
()
==
0
:
if
log_writer
is
not
None
and
dist
.
get_rank
()
==
0
:
log_writer
.
log_metrics
(
metrics
=
train_stats
.
get
(),
prefix
=
"TRAIN"
,
step
=
global_step
)
log_writer
.
log_metrics
(
metrics
=
train_stats
.
get
(),
prefix
=
"TRAIN"
,
step
=
global_step
)
if
dist
.
get_rank
()
==
0
and
(
if
dist
.
get_rank
()
==
0
and
(
(
global_step
>
0
and
global_step
%
print_batch_step
==
0
)
or
(
global_step
>
0
and
global_step
%
print_batch_step
==
0
)
or
...
@@ -354,7 +357,8 @@ def train(config,
...
@@ -354,7 +357,8 @@ def train(config,
# logger metric
# logger metric
if
log_writer
is
not
None
:
if
log_writer
is
not
None
:
log_writer
.
log_metrics
(
metrics
=
cur_metric
,
prefix
=
"EVAL"
,
step
=
global_step
)
log_writer
.
log_metrics
(
metrics
=
cur_metric
,
prefix
=
"EVAL"
,
step
=
global_step
)
if
cur_metric
[
main_indicator
]
>=
best_model_dict
[
if
cur_metric
[
main_indicator
]
>=
best_model_dict
[
main_indicator
]:
main_indicator
]:
...
@@ -377,11 +381,18 @@ def train(config,
...
@@ -377,11 +381,18 @@ def train(config,
logger
.
info
(
best_str
)
logger
.
info
(
best_str
)
# logger best metric
# logger best metric
if
log_writer
is
not
None
:
if
log_writer
is
not
None
:
log_writer
.
log_metrics
(
metrics
=
{
log_writer
.
log_metrics
(
"best_{}"
.
format
(
main_indicator
):
best_model_dict
[
main_indicator
]
metrics
=
{
},
prefix
=
"EVAL"
,
step
=
global_step
)
"best_{}"
.
format
(
main_indicator
):
best_model_dict
[
main_indicator
]
log_writer
.
log_model
(
is_best
=
True
,
prefix
=
"best_accuracy"
,
metadata
=
best_model_dict
)
},
prefix
=
"EVAL"
,
step
=
global_step
)
log_writer
.
log_model
(
is_best
=
True
,
prefix
=
"best_accuracy"
,
metadata
=
best_model_dict
)
reader_start
=
time
.
time
()
reader_start
=
time
.
time
()
if
dist
.
get_rank
()
==
0
:
if
dist
.
get_rank
()
==
0
:
...
@@ -413,7 +424,8 @@ def train(config,
...
@@ -413,7 +424,8 @@ def train(config,
epoch
=
epoch
,
epoch
=
epoch
,
global_step
=
global_step
)
global_step
=
global_step
)
if
log_writer
is
not
None
:
if
log_writer
is
not
None
:
log_writer
.
log_model
(
is_best
=
False
,
prefix
=
'iter_epoch_{}'
.
format
(
epoch
))
log_writer
.
log_model
(
is_best
=
False
,
prefix
=
'iter_epoch_{}'
.
format
(
epoch
))
best_str
=
'best metric, {}'
.
format
(
', '
.
join
(
best_str
=
'best metric, {}'
.
format
(
', '
.
join
(
[
'{}: {}'
.
format
(
k
,
v
)
for
k
,
v
in
best_model_dict
.
items
()]))
[
'{}: {}'
.
format
(
k
,
v
)
for
k
,
v
in
best_model_dict
.
items
()]))
...
@@ -585,7 +597,8 @@ def preprocess(is_train=False):
...
@@ -585,7 +597,8 @@ def preprocess(is_train=False):
vdl_writer_path
=
'{}/vdl/'
.
format
(
save_model_dir
)
vdl_writer_path
=
'{}/vdl/'
.
format
(
save_model_dir
)
log_writer
=
VDLLogger
(
save_model_dir
)
log_writer
=
VDLLogger
(
save_model_dir
)
loggers
.
append
(
log_writer
)
loggers
.
append
(
log_writer
)
if
(
'use_wandb'
in
config
[
'Global'
]
and
config
[
'Global'
][
'use_wandb'
])
or
'wandb'
in
config
:
if
(
'use_wandb'
in
config
[
'Global'
]
and
config
[
'Global'
][
'use_wandb'
])
or
'wandb'
in
config
:
save_dir
=
config
[
'Global'
][
'save_model_dir'
]
save_dir
=
config
[
'Global'
][
'save_model_dir'
]
wandb_writer_path
=
"{}/wandb"
.
format
(
save_dir
)
wandb_writer_path
=
"{}/wandb"
.
format
(
save_dir
)
if
"wandb"
in
config
:
if
"wandb"
in
config
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录