Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
b863528d
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看板
未验证
提交
b863528d
编写于
11月 09, 2020
作者:
M
MissPenguin
提交者:
GitHub
11月 09, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1133 from WenmuZhou/dygraph_rc
fix bug and update save_load to rc version
上级
c93b4a17
b28ea0a9
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
12 addition
and
22 deletion
+12
-22
ppocr/utils/save_load.py
ppocr/utils/save_load.py
+4
-3
requirements.txt
requirements.txt
+1
-0
tools/eval.py
tools/eval.py
+5
-13
tools/program.py
tools/program.py
+2
-6
未找到文件。
ppocr/utils/save_load.py
浏览文件 @
b863528d
...
...
@@ -89,7 +89,8 @@ def init_model(config, model, logger, optimizer=None, lr_scheduler=None):
"Given dir {}.pdparams not exist."
.
format
(
checkpoints
)
assert
os
.
path
.
exists
(
checkpoints
+
".pdopt"
),
\
"Given dir {}.pdopt not exist."
.
format
(
checkpoints
)
para_dict
,
opti_dict
=
paddle
.
load
(
checkpoints
)
para_dict
=
paddle
.
load
(
checkpoints
+
'.pdparams'
)
opti_dict
=
paddle
.
load
(
checkpoints
+
'.pdopt'
)
model
.
set_dict
(
para_dict
)
if
optimizer
is
not
None
:
optimizer
.
set_state_dict
(
opti_dict
)
...
...
@@ -133,8 +134,8 @@ def save_model(net,
"""
_mkdir_if_not_exist
(
model_path
,
logger
)
model_prefix
=
os
.
path
.
join
(
model_path
,
prefix
)
paddle
.
save
(
net
.
state_dict
(),
model_prefix
)
paddle
.
save
(
optimizer
.
state_dict
(),
model_prefix
)
paddle
.
save
(
net
.
state_dict
(),
model_prefix
+
'.pdparams'
)
paddle
.
save
(
optimizer
.
state_dict
(),
model_prefix
+
'.pdopt'
)
# save metric and config
with
open
(
model_prefix
+
'.states'
,
'wb'
)
as
f
:
...
...
requirements.txt
浏览文件 @
b863528d
...
...
@@ -2,6 +2,7 @@ shapely
imgaug
pyclipper
lmdb
opencv-python
==4.2.0.32
tqdm
numpy
visualdl
...
...
tools/eval.py
浏览文件 @
b863528d
...
...
@@ -23,12 +23,8 @@ __dir__ = os.path.dirname(os.path.abspath(__file__))
sys
.
path
.
append
(
__dir__
)
sys
.
path
.
append
(
os
.
path
.
abspath
(
os
.
path
.
join
(
__dir__
,
'..'
)))
import
paddle
# paddle.manual_seed(2)
from
ppocr.utils.logging
import
get_logger
from
ppocr.data
import
build_dataloader
from
ppocr.modeling
import
build_model
from
ppocr.modeling
.architectures
import
build_model
from
ppocr.postprocess
import
build_post_process
from
ppocr.metrics
import
build_metric
from
ppocr.utils.save_load
import
init_model
...
...
@@ -39,8 +35,7 @@ import tools.program as program
def
main
():
global_config
=
config
[
'Global'
]
# build dataloader
eval_loader
,
_
=
build_dataloader
(
config
[
'EVAL'
],
device
,
False
,
global_config
)
valid_dataloader
=
build_dataloader
(
config
,
'Eval'
,
device
,
logger
)
# build post process
post_process_class
=
build_post_process
(
config
[
'PostProcess'
],
...
...
@@ -63,16 +58,13 @@ def main():
eval_class
=
build_metric
(
config
[
'Metric'
])
# start eval
metirc
=
program
.
eval
(
model
,
eval_loader
,
post_process_class
,
eval_class
)
metirc
=
program
.
eval
(
model
,
valid_dataloader
,
post_process_class
,
eval_class
)
logger
.
info
(
'metric eval ***************'
)
for
k
,
v
in
metirc
.
items
():
logger
.
info
(
'{}:{}'
.
format
(
k
,
v
))
if
__name__
==
'__main__'
:
device
,
config
=
program
.
preprocess
()
paddle
.
disable_static
(
device
)
logger
=
get_logger
()
print_dict
(
config
,
logger
)
config
,
device
,
logger
,
vdl_writer
=
program
.
preprocess
()
main
()
tools/program.py
浏览文件 @
b863528d
...
...
@@ -231,7 +231,7 @@ def train(config,
if
global_step
>
start_eval_step
and
\
(
global_step
-
start_eval_step
)
%
eval_batch_step
==
0
and
dist
.
get_rank
()
==
0
:
cur_metirc
=
eval
(
model
,
valid_dataloader
,
post_process_class
,
eval_class
,
logger
,
print_batch_step
)
eval_class
)
cur_metirc_str
=
'cur metirc, {}'
.
format
(
', '
.
join
(
[
'{}: {}'
.
format
(
k
,
v
)
for
k
,
v
in
cur_metirc
.
items
()]))
logger
.
info
(
cur_metirc_str
)
...
...
@@ -293,8 +293,7 @@ def train(config,
return
def
eval
(
model
,
valid_dataloader
,
post_process_class
,
eval_class
,
logger
,
print_batch_step
):
def
eval
(
model
,
valid_dataloader
,
post_process_class
,
eval_class
):
model
.
eval
()
with
paddle
.
no_grad
():
total_frame
=
0.0
...
...
@@ -315,9 +314,6 @@ def eval(model, valid_dataloader, post_process_class, eval_class, logger,
eval_class
(
post_result
,
batch
)
pbar
.
update
(
1
)
total_frame
+=
len
(
images
)
# if idx % print_batch_step == 0 and dist.get_rank() == 0:
# logger.info('tackling images for eval: {}/{}'.format(
# idx, len(valid_dataloader)))
# Get final metirc,eg. acc or hmean
metirc
=
eval_class
.
get_metric
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录