Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
2aa92e6a
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看板
提交
2aa92e6a
编写于
11月 06, 2020
作者:
W
WenmuZhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug
上级
9467b754
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
8 addition
and
10 deletion
+8
-10
tools/program.py
tools/program.py
+8
-10
未找到文件。
tools/program.py
浏览文件 @
2aa92e6a
...
@@ -152,7 +152,6 @@ def train(config,
...
@@ -152,7 +152,6 @@ def train(config,
pre_best_model_dict
,
pre_best_model_dict
,
logger
,
logger
,
vdl_writer
=
None
):
vdl_writer
=
None
):
cal_metric_during_train
=
config
[
'Global'
].
get
(
'cal_metric_during_train'
,
cal_metric_during_train
=
config
[
'Global'
].
get
(
'cal_metric_during_train'
,
False
)
False
)
log_smooth_window
=
config
[
'Global'
][
'log_smooth_window'
]
log_smooth_window
=
config
[
'Global'
][
'log_smooth_window'
]
...
@@ -185,14 +184,13 @@ def train(config,
...
@@ -185,14 +184,13 @@ def train(config,
for
epoch
in
range
(
start_epoch
,
epoch_num
):
for
epoch
in
range
(
start_epoch
,
epoch_num
):
if
epoch
>
0
:
if
epoch
>
0
:
train_
loader
=
build_dataloader
(
config
,
'Train'
,
device
)
train_
dataloader
=
build_dataloader
(
config
,
'Train'
,
device
,
logger
)
for
idx
,
batch
in
enumerate
(
train_dataloader
):
for
idx
,
batch
in
enumerate
(
train_dataloader
):
if
idx
>=
len
(
train_dataloader
):
if
idx
>=
len
(
train_dataloader
):
break
break
lr
=
optimizer
.
get_lr
()
lr
=
optimizer
.
get_lr
()
t1
=
time
.
time
()
t1
=
time
.
time
()
batch
=
[
paddle
.
to_tensor
(
x
)
for
x
in
batch
]
images
=
batch
[
0
]
images
=
batch
[
0
]
preds
=
model
(
images
)
preds
=
model
(
images
)
loss
=
loss_class
(
preds
,
batch
)
loss
=
loss_class
(
preds
,
batch
)
...
@@ -301,11 +299,11 @@ def eval(model, valid_dataloader, post_process_class, eval_class, logger,
...
@@ -301,11 +299,11 @@ def eval(model, valid_dataloader, post_process_class, eval_class, logger,
with
paddle
.
no_grad
():
with
paddle
.
no_grad
():
total_frame
=
0.0
total_frame
=
0.0
total_time
=
0.0
total_time
=
0.0
#
pbar = tqdm(total=len(valid_dataloader), desc='eval model:')
pbar
=
tqdm
(
total
=
len
(
valid_dataloader
),
desc
=
'eval model:'
)
for
idx
,
batch
in
enumerate
(
valid_dataloader
):
for
idx
,
batch
in
enumerate
(
valid_dataloader
):
if
idx
>=
len
(
valid_dataloader
):
if
idx
>=
len
(
valid_dataloader
):
break
break
images
=
paddle
.
to_tensor
(
batch
[
0
])
images
=
batch
[
0
]
start
=
time
.
time
()
start
=
time
.
time
()
preds
=
model
(
images
)
preds
=
model
(
images
)
...
@@ -315,15 +313,15 @@ def eval(model, valid_dataloader, post_process_class, eval_class, logger,
...
@@ -315,15 +313,15 @@ def eval(model, valid_dataloader, post_process_class, eval_class, logger,
total_time
+=
time
.
time
()
-
start
total_time
+=
time
.
time
()
-
start
# Evaluate the results of the current batch
# Evaluate the results of the current batch
eval_class
(
post_result
,
batch
)
eval_class
(
post_result
,
batch
)
#
pbar.update(1)
pbar
.
update
(
1
)
total_frame
+=
len
(
images
)
total_frame
+=
len
(
images
)
if
idx
%
print_batch_step
==
0
and
dist
.
get_rank
()
==
0
:
#
if idx % print_batch_step == 0 and dist.get_rank() == 0:
logger
.
info
(
'tackling images for eval: {}/{}'
.
format
(
#
logger.info('tackling images for eval: {}/{}'.format(
idx
,
len
(
valid_dataloader
)))
#
idx, len(valid_dataloader)))
# Get final metirc,eg. acc or hmean
# Get final metirc,eg. acc or hmean
metirc
=
eval_class
.
get_metric
()
metirc
=
eval_class
.
get_metric
()
#
pbar.close()
pbar
.
close
()
model
.
train
()
model
.
train
()
metirc
[
'fps'
]
=
total_frame
/
total_time
metirc
[
'fps'
]
=
total_frame
/
total_time
return
metirc
return
metirc
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录