Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
09fd94e7
P
PaddleOCR
项目概览
PaddlePaddle
/
PaddleOCR
大约 1 年 前同步成功
通知
1528
Star
32962
Fork
6643
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
108
列表
看板
标记
里程碑
合并请求
7
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
108
Issue
108
列表
看板
标记
里程碑
合并请求
7
合并请求
7
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
09fd94e7
编写于
1月 26, 2021
作者:
L
LDOUBLEV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix typo
上级
5a5d627d
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
15 addition
and
15 deletion
+15
-15
tools/program.py
tools/program.py
+15
-15
未找到文件。
tools/program.py
浏览文件 @
09fd94e7
...
@@ -212,7 +212,7 @@ def train(config,
...
@@ -212,7 +212,7 @@ def train(config,
stats
[
'lr'
]
=
lr
stats
[
'lr'
]
=
lr
train_stats
.
update
(
stats
)
train_stats
.
update
(
stats
)
if
cal_metric_during_train
:
# onl
t
rec and cls need
if
cal_metric_during_train
:
# onl
y
rec and cls need
batch
=
[
item
.
numpy
()
for
item
in
batch
]
batch
=
[
item
.
numpy
()
for
item
in
batch
]
post_result
=
post_process_class
(
preds
,
batch
[
1
])
post_result
=
post_process_class
(
preds
,
batch
[
1
])
eval_class
(
post_result
,
batch
)
eval_class
(
post_result
,
batch
)
...
@@ -238,21 +238,21 @@ def train(config,
...
@@ -238,21 +238,21 @@ def train(config,
# eval
# eval
if
global_step
>
start_eval_step
and
\
if
global_step
>
start_eval_step
and
\
(
global_step
-
start_eval_step
)
%
eval_batch_step
==
0
and
dist
.
get_rank
()
==
0
:
(
global_step
-
start_eval_step
)
%
eval_batch_step
==
0
and
dist
.
get_rank
()
==
0
:
cur_met
ir
c
=
eval
(
model
,
valid_dataloader
,
post_process_class
,
cur_met
ri
c
=
eval
(
model
,
valid_dataloader
,
post_process_class
,
eval_class
)
eval_class
)
cur_met
irc_str
=
'cur metir
c, {}'
.
format
(
', '
.
join
(
cur_met
ric_str
=
'cur metri
c, {}'
.
format
(
', '
.
join
(
[
'{}: {}'
.
format
(
k
,
v
)
for
k
,
v
in
cur_met
ir
c
.
items
()]))
[
'{}: {}'
.
format
(
k
,
v
)
for
k
,
v
in
cur_met
ri
c
.
items
()]))
logger
.
info
(
cur_met
ir
c_str
)
logger
.
info
(
cur_met
ri
c_str
)
# logger metric
# logger metric
if
vdl_writer
is
not
None
:
if
vdl_writer
is
not
None
:
for
k
,
v
in
cur_met
ir
c
.
items
():
for
k
,
v
in
cur_met
ri
c
.
items
():
if
isinstance
(
v
,
(
float
,
int
)):
if
isinstance
(
v
,
(
float
,
int
)):
vdl_writer
.
add_scalar
(
'EVAL/{}'
.
format
(
k
),
vdl_writer
.
add_scalar
(
'EVAL/{}'
.
format
(
k
),
cur_met
ir
c
[
k
],
global_step
)
cur_met
ri
c
[
k
],
global_step
)
if
cur_met
ir
c
[
main_indicator
]
>=
best_model_dict
[
if
cur_met
ri
c
[
main_indicator
]
>=
best_model_dict
[
main_indicator
]:
main_indicator
]:
best_model_dict
.
update
(
cur_met
ir
c
)
best_model_dict
.
update
(
cur_met
ri
c
)
best_model_dict
[
'best_epoch'
]
=
epoch
best_model_dict
[
'best_epoch'
]
=
epoch
save_model
(
save_model
(
model
,
model
,
...
@@ -263,7 +263,7 @@ def train(config,
...
@@ -263,7 +263,7 @@ def train(config,
prefix
=
'best_accuracy'
,
prefix
=
'best_accuracy'
,
best_model_dict
=
best_model_dict
,
best_model_dict
=
best_model_dict
,
epoch
=
epoch
)
epoch
=
epoch
)
best_str
=
'best met
ir
c, {}'
.
format
(
', '
.
join
([
best_str
=
'best met
ri
c, {}'
.
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
)
...
@@ -294,7 +294,7 @@ def train(config,
...
@@ -294,7 +294,7 @@ def train(config,
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
)
best_str
=
'best met
ir
c, {}'
.
format
(
', '
.
join
(
best_str
=
'best met
ri
c, {}'
.
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
)
if
dist
.
get_rank
()
==
0
and
vdl_writer
is
not
None
:
if
dist
.
get_rank
()
==
0
and
vdl_writer
is
not
None
:
...
@@ -323,13 +323,13 @@ def eval(model, valid_dataloader, post_process_class, eval_class):
...
@@ -323,13 +323,13 @@ def eval(model, valid_dataloader, post_process_class, eval_class):
eval_class
(
post_result
,
batch
)
eval_class
(
post_result
,
batch
)
pbar
.
update
(
1
)
pbar
.
update
(
1
)
total_frame
+=
len
(
images
)
total_frame
+=
len
(
images
)
# Get final met
ir
c,eg. acc or hmean
# Get final met
ri
c,eg. acc or hmean
met
ir
c
=
eval_class
.
get_metric
()
met
ri
c
=
eval_class
.
get_metric
()
pbar
.
close
()
pbar
.
close
()
model
.
train
()
model
.
train
()
met
ir
c
[
'fps'
]
=
total_frame
/
total_time
met
ri
c
[
'fps'
]
=
total_frame
/
total_time
return
met
ir
c
return
met
ri
c
def
preprocess
(
is_train
=
False
):
def
preprocess
(
is_train
=
False
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录