Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
d26da4b6
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看板
未验证
提交
d26da4b6
编写于
8月 19, 2022
作者:
Z
zhoujun
提交者:
GitHub
8月 19, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7251 from WenmuZhou/tipc
update table tipc config
上级
65d9d93e
7c5fbd46
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
16 addition
and
12 deletion
+16
-12
test_tipc/configs/en_table_structure/train_infer_python.txt
test_tipc/configs/en_table_structure/train_infer_python.txt
+1
-1
tools/program.py
tools/program.py
+10
-8
tools/train.py
tools/train.py
+5
-3
未找到文件。
test_tipc/configs/en_table_structure/train_infer_python.txt
浏览文件 @
d26da4b6
...
...
@@ -54,6 +54,6 @@ random_infer_input:[{float32,[3,488,488]}]
===========================train_benchmark_params==========================
batch_size:32
fp_items:fp32|fp16
epoch:
1
epoch:
2
--profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile
flags:FLAGS_eager_delete_tensor_gb=0.0;FLAGS_fraction_of_gpu_memory_to_use=0.98;FLAGS_conv_workspace_size_limit=4096
tools/program.py
浏览文件 @
d26da4b6
...
...
@@ -162,18 +162,18 @@ def to_float32(preds):
for
k
in
preds
:
if
isinstance
(
preds
[
k
],
dict
)
or
isinstance
(
preds
[
k
],
list
):
preds
[
k
]
=
to_float32
(
preds
[
k
])
el
se
:
preds
[
k
]
=
p
addle
.
to_tensor
(
preds
[
k
],
dtype
=
'float32'
)
el
if
isinstance
(
preds
[
k
],
paddle
.
Tensor
)
:
preds
[
k
]
=
p
reds
[
k
].
astype
(
paddle
.
float32
)
elif
isinstance
(
preds
,
list
):
for
k
in
range
(
len
(
preds
)):
if
isinstance
(
preds
[
k
],
dict
):
preds
[
k
]
=
to_float32
(
preds
[
k
])
elif
isinstance
(
preds
[
k
],
list
):
preds
[
k
]
=
to_float32
(
preds
[
k
])
el
se
:
preds
[
k
]
=
p
addle
.
to_tensor
(
preds
[
k
],
dtype
=
'float32'
)
el
se
:
preds
=
paddle
.
to_tensor
(
preds
,
dtype
=
'float32'
)
el
if
isinstance
(
preds
[
k
],
paddle
.
Tensor
)
:
preds
[
k
]
=
p
reds
[
k
].
astype
(
paddle
.
float32
)
el
if
isinstance
(
preds
,
paddle
.
Tensor
)
:
preds
=
preds
.
astype
(
paddle
.
float32
)
return
preds
...
...
@@ -190,7 +190,8 @@ def train(config,
pre_best_model_dict
,
logger
,
log_writer
=
None
,
scaler
=
None
):
scaler
=
None
,
amp_level
=
'O2'
):
cal_metric_during_train
=
config
[
'Global'
].
get
(
'cal_metric_during_train'
,
False
)
calc_epoch_interval
=
config
[
'Global'
].
get
(
'calc_epoch_interval'
,
1
)
...
...
@@ -276,7 +277,7 @@ def train(config,
model_average
=
True
# use amp
if
scaler
:
with
paddle
.
amp
.
auto_cast
(
level
=
'O2'
):
with
paddle
.
amp
.
auto_cast
(
level
=
amp_level
):
if
model_type
==
'table'
or
extra_input
:
preds
=
model
(
images
,
data
=
batch
[
1
:])
elif
model_type
in
[
"kie"
,
'vqa'
]:
...
...
@@ -514,6 +515,7 @@ def eval(model,
sum_images
,
i
),
fm_lr
)
else
:
preds
=
model
(
images
)
preds
=
to_float32
(
preds
)
else
:
if
model_type
==
'table'
or
extra_input
:
preds
=
model
(
images
,
data
=
batch
[
1
:])
...
...
tools/train.py
浏览文件 @
d26da4b6
...
...
@@ -147,6 +147,7 @@ def main(config, device, logger, vdl_writer):
len
(
valid_dataloader
)))
use_amp
=
config
[
"Global"
].
get
(
"use_amp"
,
False
)
amp_level
=
config
[
"Global"
].
get
(
"amp_level"
,
'O2'
)
if
use_amp
:
AMP_RELATED_FLAGS_SETTING
=
{
'FLAGS_cudnn_batchnorm_spatial_persistent'
:
1
,
...
...
@@ -159,8 +160,9 @@ def main(config, device, logger, vdl_writer):
scaler
=
paddle
.
amp
.
GradScaler
(
init_loss_scaling
=
scale_loss
,
use_dynamic_loss_scaling
=
use_dynamic_loss_scaling
)
model
,
optimizer
=
paddle
.
amp
.
decorate
(
models
=
model
,
optimizers
=
optimizer
,
level
=
'O2'
,
master_weight
=
True
)
if
amp_level
==
"O2"
:
model
,
optimizer
=
paddle
.
amp
.
decorate
(
models
=
model
,
optimizers
=
optimizer
,
level
=
amp_level
,
master_weight
=
True
)
else
:
scaler
=
None
...
...
@@ -169,7 +171,7 @@ def main(config, device, logger, vdl_writer):
# start train
program
.
train
(
config
,
train_dataloader
,
valid_dataloader
,
device
,
model
,
loss_class
,
optimizer
,
lr_scheduler
,
post_process_class
,
eval_class
,
pre_best_model_dict
,
logger
,
vdl_writer
,
scaler
)
eval_class
,
pre_best_model_dict
,
logger
,
vdl_writer
,
scaler
,
amp_level
)
def
test_reader
(
config
,
device
,
logger
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录