Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
d89c6b43
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看板
提交
d89c6b43
编写于
9月 28, 2021
作者:
L
LDOUBLEV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add profile
上级
3b2e50a1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
6 deletion
+19
-6
tools/program.py
tools/program.py
+12
-2
tools/train.py
tools/train.py
+7
-4
未找到文件。
tools/program.py
浏览文件 @
d89c6b43
...
...
@@ -42,6 +42,13 @@ class ArgsParser(ArgumentParser):
self
.
add_argument
(
"-c"
,
"--config"
,
help
=
"configuration file to use"
)
self
.
add_argument
(
"-o"
,
"--opt"
,
nargs
=
'+'
,
help
=
"set configuration options"
)
self
.
add_argument
(
'-p'
,
'--profiler_options'
,
type
=
str
,
default
=
None
,
help
=
'The option of profiler, which should be in format
\"
key1=value1;key2=value2;key3=value3
\"
.'
)
def
parse_args
(
self
,
argv
=
None
):
args
=
super
(
ArgsParser
,
self
).
parse_args
(
argv
)
...
...
@@ -151,7 +158,8 @@ def train(config,
eval_class
,
pre_best_model_dict
,
logger
,
vdl_writer
=
None
):
vdl_writer
=
None
,
profiler_options
=
None
):
cal_metric_during_train
=
config
[
'Global'
].
get
(
'cal_metric_during_train'
,
False
)
log_smooth_window
=
config
[
'Global'
][
'log_smooth_window'
]
...
...
@@ -208,6 +216,7 @@ def train(config,
max_iter
=
len
(
train_dataloader
)
-
1
if
platform
.
system
(
)
==
"Windows"
else
len
(
train_dataloader
)
for
idx
,
batch
in
enumerate
(
train_dataloader
):
profiler
.
add_profiler_step
(
profiler_options
)
train_reader_cost
+=
time
.
time
()
-
batch_start
if
idx
>=
max_iter
:
break
...
...
@@ -392,6 +401,7 @@ def eval(model,
def
preprocess
(
is_train
=
False
):
FLAGS
=
ArgsParser
().
parse_args
()
profiler_options
=
FLAGS
.
profiler_options
config
=
load_config
(
FLAGS
.
config
)
merge_config
(
FLAGS
.
opt
)
...
...
@@ -431,4 +441,4 @@ def preprocess(is_train=False):
print_dict
(
config
,
logger
)
logger
.
info
(
'train with paddle {} and device {}'
.
format
(
paddle
.
__version__
,
device
))
return
config
,
device
,
logger
,
vdl_writer
return
config
,
device
,
logger
,
vdl_writer
,
profiler_options
tools/train.py
浏览文件 @
d89c6b43
...
...
@@ -41,7 +41,7 @@ import tools.program as program
dist
.
get_world_size
()
def
main
(
config
,
device
,
logger
,
vdl_writer
):
def
main
(
config
,
device
,
logger
,
vdl_writer
,
profiler_options
):
# init dist environment
if
config
[
'Global'
][
'distributed'
]:
dist
.
init_parallel_env
()
...
...
@@ -105,7 +105,8 @@ 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
)
eval_class
,
pre_best_model_dict
,
logger
,
vdl_writer
,
profiler_options
)
def
test_reader
(
config
,
device
,
logger
):
...
...
@@ -127,6 +128,8 @@ def test_reader(config, device, logger):
if
__name__
==
'__main__'
:
config
,
device
,
logger
,
vdl_writer
=
program
.
preprocess
(
is_train
=
True
)
main
(
config
,
device
,
logger
,
vdl_writer
)
config
,
device
,
logger
,
vdl_writer
,
profiler_options
=
program
.
preprocess
(
is_train
=
True
)
main
(
config
,
device
,
logger
,
vdl_writer
,
profiler_options
)
# test_reader(config, device, logger)
# test_reader(config, device, logger)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录