Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleOCR
提交
c2702229
P
PaddleOCR
项目概览
s920243400
/
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看板
未验证
提交
c2702229
编写于
4月 26, 2021
作者:
Z
zhoujun
提交者:
GitHub
4月 27, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add global_step to .states files (#2566)
Co-authored-by:
N
littletomatodonkey
<
2120160898@bit.edu.cn
>
上级
8e4b2138
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
5 deletion
+10
-5
ppocr/utils/save_load.py
ppocr/utils/save_load.py
+2
-2
tools/program.py
tools/program.py
+8
-3
未找到文件。
ppocr/utils/save_load.py
浏览文件 @
c2702229
...
@@ -121,7 +121,7 @@ def init_model(config, model, logger, optimizer=None, lr_scheduler=None):
...
@@ -121,7 +121,7 @@ def init_model(config, model, logger, optimizer=None, lr_scheduler=None):
return
best_model_dict
return
best_model_dict
def
save_model
(
net
,
def
save_model
(
model
,
optimizer
,
optimizer
,
model_path
,
model_path
,
logger
,
logger
,
...
@@ -133,7 +133,7 @@ def save_model(net,
...
@@ -133,7 +133,7 @@ def save_model(net,
"""
"""
_mkdir_if_not_exist
(
model_path
,
logger
)
_mkdir_if_not_exist
(
model_path
,
logger
)
model_prefix
=
os
.
path
.
join
(
model_path
,
prefix
)
model_prefix
=
os
.
path
.
join
(
model_path
,
prefix
)
paddle
.
save
(
net
.
state_dict
(),
model_prefix
+
'.pdparams'
)
paddle
.
save
(
model
.
state_dict
(),
model_prefix
+
'.pdparams'
)
paddle
.
save
(
optimizer
.
state_dict
(),
model_prefix
+
'.pdopt'
)
paddle
.
save
(
optimizer
.
state_dict
(),
model_prefix
+
'.pdopt'
)
# save metric and config
# save metric and config
...
...
tools/program.py
浏览文件 @
c2702229
...
@@ -159,6 +159,8 @@ def train(config,
...
@@ -159,6 +159,8 @@ def train(config,
eval_batch_step
=
config
[
'Global'
][
'eval_batch_step'
]
eval_batch_step
=
config
[
'Global'
][
'eval_batch_step'
]
global_step
=
0
global_step
=
0
if
'global_step'
in
pre_best_model_dict
:
global_step
=
pre_best_model_dict
[
'global_step'
]
start_eval_step
=
0
start_eval_step
=
0
if
type
(
eval_batch_step
)
==
list
and
len
(
eval_batch_step
)
>=
2
:
if
type
(
eval_batch_step
)
==
list
and
len
(
eval_batch_step
)
>=
2
:
start_eval_step
=
eval_batch_step
[
0
]
start_eval_step
=
eval_batch_step
[
0
]
...
@@ -285,7 +287,8 @@ def train(config,
...
@@ -285,7 +287,8 @@ def train(config,
is_best
=
True
,
is_best
=
True
,
prefix
=
'best_accuracy'
,
prefix
=
'best_accuracy'
,
best_model_dict
=
best_model_dict
,
best_model_dict
=
best_model_dict
,
epoch
=
epoch
)
epoch
=
epoch
,
global_step
=
global_step
)
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
()
]))
]))
...
@@ -307,7 +310,8 @@ def train(config,
...
@@ -307,7 +310,8 @@ def train(config,
is_best
=
False
,
is_best
=
False
,
prefix
=
'latest'
,
prefix
=
'latest'
,
best_model_dict
=
best_model_dict
,
best_model_dict
=
best_model_dict
,
epoch
=
epoch
)
epoch
=
epoch
,
global_step
=
global_step
)
if
dist
.
get_rank
()
==
0
and
epoch
>
0
and
epoch
%
save_epoch_step
==
0
:
if
dist
.
get_rank
()
==
0
and
epoch
>
0
and
epoch
%
save_epoch_step
==
0
:
save_model
(
save_model
(
model
,
model
,
...
@@ -317,7 +321,8 @@ def train(config,
...
@@ -317,7 +321,8 @@ def train(config,
is_best
=
False
,
is_best
=
False
,
prefix
=
'iter_epoch_{}'
.
format
(
epoch
),
prefix
=
'iter_epoch_{}'
.
format
(
epoch
),
best_model_dict
=
best_model_dict
,
best_model_dict
=
best_model_dict
,
epoch
=
epoch
)
epoch
=
epoch
,
global_step
=
global_step
)
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
()]))
logger
.
info
(
best_str
)
logger
.
info
(
best_str
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录