Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
0b6290ea
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看板
未验证
提交
0b6290ea
编写于
5月 16, 2022
作者:
littletomatodonkey
提交者:
GitHub
5月 16, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add support for static training (#6297)
* add support for static training * fix assert info
上级
0571a41d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
22 addition
and
1 deletion
+22
-1
ppocr/modeling/architectures/__init__.py
ppocr/modeling/architectures/__init__.py
+19
-1
tools/train.py
tools/train.py
+3
-0
未找到文件。
ppocr/modeling/architectures/__init__.py
浏览文件 @
0b6290ea
...
@@ -15,10 +15,13 @@
...
@@ -15,10 +15,13 @@
import
copy
import
copy
import
importlib
import
importlib
from
paddle.jit
import
to_static
from
paddle.static
import
InputSpec
from
.base_model
import
BaseModel
from
.base_model
import
BaseModel
from
.distillation_model
import
DistillationModel
from
.distillation_model
import
DistillationModel
__all__
=
[
'build_model'
]
__all__
=
[
"build_model"
,
"apply_to_static"
]
def
build_model
(
config
):
def
build_model
(
config
):
...
@@ -30,3 +33,18 @@ def build_model(config):
...
@@ -30,3 +33,18 @@ def build_model(config):
mod
=
importlib
.
import_module
(
__name__
)
mod
=
importlib
.
import_module
(
__name__
)
arch
=
getattr
(
mod
,
name
)(
config
)
arch
=
getattr
(
mod
,
name
)(
config
)
return
arch
return
arch
def
apply_to_static
(
model
,
config
,
logger
):
if
config
[
"Global"
].
get
(
"to_static"
,
False
)
is
not
True
:
return
model
assert
"image_shape"
in
config
[
"Global"
],
"image_shape must be assigned for static training mode..."
supported_list
=
[
"DB"
]
assert
config
[
"Architecture"
][
"algorithm"
]
in
supported_list
,
f
"algorithms that supports static training must in in
{
supported_list
}
but got
{
config
[
'Architecture'
][
'algorithm'
]
}
"
specs
=
[
InputSpec
([
None
]
+
config
[
"Global"
][
"image_shape"
])]
model
=
to_static
(
model
,
input_spec
=
specs
)
logger
.
info
(
"Successfully to apply @to_static with specs: {}"
.
format
(
specs
))
return
model
tools/train.py
浏览文件 @
0b6290ea
...
@@ -35,6 +35,7 @@ from ppocr.postprocess import build_post_process
...
@@ -35,6 +35,7 @@ from ppocr.postprocess import build_post_process
from
ppocr.metrics
import
build_metric
from
ppocr.metrics
import
build_metric
from
ppocr.utils.save_load
import
load_model
from
ppocr.utils.save_load
import
load_model
from
ppocr.utils.utility
import
set_seed
from
ppocr.utils.utility
import
set_seed
from
ppocr.modeling.architectures
import
apply_to_static
import
tools.program
as
program
import
tools.program
as
program
dist
.
get_world_size
()
dist
.
get_world_size
()
...
@@ -121,6 +122,8 @@ def main(config, device, logger, vdl_writer):
...
@@ -121,6 +122,8 @@ def main(config, device, logger, vdl_writer):
if
config
[
'Global'
][
'distributed'
]:
if
config
[
'Global'
][
'distributed'
]:
model
=
paddle
.
DataParallel
(
model
)
model
=
paddle
.
DataParallel
(
model
)
model
=
apply_to_static
(
model
,
config
,
logger
)
# build loss
# build loss
loss_class
=
build_loss
(
config
[
'Loss'
])
loss_class
=
build_loss
(
config
[
'Loss'
])
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录