Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
4d44b230
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看板
提交
4d44b230
编写于
11月 12, 2020
作者:
W
WenmuZhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
识别模型导出
上级
367c49df
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
4 deletion
+19
-4
tools/program.py
tools/program.py
+15
-1
tools/train.py
tools/train.py
+4
-3
未找到文件。
tools/program.py
浏览文件 @
4d44b230
...
@@ -323,6 +323,20 @@ def eval(model, valid_dataloader, post_process_class, eval_class):
...
@@ -323,6 +323,20 @@ def eval(model, valid_dataloader, post_process_class, eval_class):
return
metirc
return
metirc
def
save_inference_mode
(
model
,
config
,
logger
):
model
.
eval
()
save_path
=
'{}/infer/{}'
.
format
(
config
[
'Global'
][
'save_model_dir'
],
config
[
'Architecture'
][
'model_type'
])
if
config
[
'Architecture'
][
'model_type'
]
==
'rec'
:
input_shape
=
[
None
,
3
,
32
,
None
]
jit_model
=
paddle
.
jit
.
to_static
(
model
,
input_spec
=
[
paddle
.
static
.
InputSpec
(
input_shape
)])
paddle
.
jit
.
save
(
jit_model
,
save_path
)
logger
.
info
(
'inference model save to {}'
.
format
(
save_path
))
model
.
train
()
def
preprocess
():
def
preprocess
():
FLAGS
=
ArgsParser
().
parse_args
()
FLAGS
=
ArgsParser
().
parse_args
()
config
=
load_config
(
FLAGS
.
config
)
config
=
load_config
(
FLAGS
.
config
)
...
@@ -334,7 +348,7 @@ def preprocess():
...
@@ -334,7 +348,7 @@ def preprocess():
alg
=
config
[
'Architecture'
][
'algorithm'
]
alg
=
config
[
'Architecture'
][
'algorithm'
]
assert
alg
in
[
assert
alg
in
[
'EAST'
,
'DB'
,
'SAST'
,
'Rosetta'
,
'CRNN'
,
'STARNet'
,
'RARE'
,
'SRN'
'EAST'
,
'DB'
,
'SAST'
,
'Rosetta'
,
'CRNN'
,
'STARNet'
,
'RARE'
,
'SRN'
,
'CLS'
]
]
device
=
'gpu:{}'
.
format
(
dist
.
ParallelEnv
().
dev_id
)
if
use_gpu
else
'cpu'
device
=
'gpu:{}'
.
format
(
dist
.
ParallelEnv
().
dev_id
)
if
use_gpu
else
'cpu'
...
...
tools/train.py
浏览文件 @
4d44b230
...
@@ -89,6 +89,7 @@ def main(config, device, logger, vdl_writer):
...
@@ -89,6 +89,7 @@ def main(config, device, logger, vdl_writer):
program
.
train
(
config
,
train_dataloader
,
valid_dataloader
,
device
,
model
,
program
.
train
(
config
,
train_dataloader
,
valid_dataloader
,
device
,
model
,
loss_class
,
optimizer
,
lr_scheduler
,
post_process_class
,
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
)
program
.
save_inference_mode
(
model
,
config
,
logger
)
def
test_reader
(
config
,
device
,
logger
):
def
test_reader
(
config
,
device
,
logger
):
...
@@ -102,8 +103,8 @@ def test_reader(config, device, logger):
...
@@ -102,8 +103,8 @@ def test_reader(config, device, logger):
if
count
%
1
==
0
:
if
count
%
1
==
0
:
batch_time
=
time
.
time
()
-
starttime
batch_time
=
time
.
time
()
-
starttime
starttime
=
time
.
time
()
starttime
=
time
.
time
()
logger
.
info
(
"reader: {}, {}, {}"
.
format
(
count
,
logger
.
info
(
"reader: {}, {}, {}"
.
format
(
len
(
data
),
batch_time
))
count
,
len
(
data
[
0
]
),
batch_time
))
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
info
(
e
)
logger
.
info
(
e
)
logger
.
info
(
"finish reader: {}, Success!"
.
format
(
count
))
logger
.
info
(
"finish reader: {}, Success!"
.
format
(
count
))
...
@@ -112,4 +113,4 @@ def test_reader(config, device, logger):
...
@@ -112,4 +113,4 @@ def test_reader(config, device, logger):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
config
,
device
,
logger
,
vdl_writer
=
program
.
preprocess
()
config
,
device
,
logger
,
vdl_writer
=
program
.
preprocess
()
main
(
config
,
device
,
logger
,
vdl_writer
)
main
(
config
,
device
,
logger
,
vdl_writer
)
#
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录