Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
cd7b2ea9
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看板
提交
cd7b2ea9
编写于
1月 06, 2022
作者:
文幕地方
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add pretrained params to backbone
上级
9ecfc348
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
25 addition
and
26 deletion
+25
-26
configs/vqa/re/layoutxlm.yml
configs/vqa/re/layoutxlm.yml
+1
-2
configs/vqa/ser/layoutlm.yml
configs/vqa/ser/layoutlm.yml
+1
-2
configs/vqa/ser/layoutxlm.yml
configs/vqa/ser/layoutxlm.yml
+1
-2
ppocr/modeling/backbones/vqa_layoutlm.py
ppocr/modeling/backbones/vqa_layoutlm.py
+22
-20
未找到文件。
configs/vqa/re/layoutxlm.yml
浏览文件 @
cd7b2ea9
...
...
@@ -8,7 +8,6 @@ Global:
# evaluation is run every 10 iterations after the 0th iteration
eval_batch_step
:
[
0
,
19
]
cal_metric_during_train
:
False
pretrained_model
:
&pretrained_model
layoutxlm-base-uncased
# This field can only be changed by modifying the configuration file
save_inference_dir
:
use_visualdl
:
False
infer_img
:
doc/vqa/input/zh_val_21.jpg
...
...
@@ -20,7 +19,7 @@ Architecture:
Transform
:
Backbone
:
name
:
LayoutXLMForRe
pretrained
_model
:
*pretrained_model
pretrained
:
True
checkpoints
:
Loss
:
...
...
configs/vqa/ser/layoutlm.yml
浏览文件 @
cd7b2ea9
...
...
@@ -8,7 +8,6 @@ Global:
# evaluation is run every 10 iterations after the 0th iteration
eval_batch_step
:
[
0
,
19
]
cal_metric_during_train
:
False
pretrained_model
:
&pretrained_model
layoutlm-base-uncased
# This field can only be changed by modifying the configuration file
save_inference_dir
:
use_visualdl
:
False
infer_img
:
doc/vqa/input/zh_val_0.jpg
...
...
@@ -20,7 +19,7 @@ Architecture:
Transform
:
Backbone
:
name
:
LayoutLMForSer
pretrained
_model
:
*pretrained_model
pretrained
:
True
checkpoints
:
num_classes
:
&num_classes
7
...
...
configs/vqa/ser/layoutxlm.yml
浏览文件 @
cd7b2ea9
...
...
@@ -8,7 +8,6 @@ Global:
# evaluation is run every 10 iterations after the 0th iteration
eval_batch_step
:
[
0
,
19
]
cal_metric_during_train
:
False
pretrained_model
:
&pretrained_model
layoutxlm-base-uncased
# This field can only be changed by modifying the configuration file
save_inference_dir
:
use_visualdl
:
False
infer_img
:
doc/vqa/input/zh_val_42.jpg
...
...
@@ -20,7 +19,7 @@ Architecture:
Transform
:
Backbone
:
name
:
LayoutXLMForSer
pretrained
_model
:
*pretrained_model
pretrained
:
True
checkpoints
:
num_classes
:
&num_classes
7
...
...
ppocr/modeling/backbones/vqa_layoutlm.py
浏览文件 @
cd7b2ea9
...
...
@@ -24,21 +24,32 @@ from paddlenlp.transformers import LayoutLMModel, LayoutLMForTokenClassification
__all__
=
[
"LayoutXLMForSer"
,
'LayoutLMForSer'
]
pretrained_model_dict
=
{
LayoutXLMModel
:
'layoutxlm-base-uncased'
,
LayoutLMModel
:
'layoutlm-base-uncased'
}
class
NLPBaseModel
(
nn
.
Layer
):
def
__init__
(
self
,
base_model_class
,
model_class
,
type
=
'ser'
,
pretrained
_model
=
Non
e
,
pretrained
=
Tru
e
,
checkpoints
=
None
,
**
kwargs
):
super
(
NLPBaseModel
,
self
).
__init__
()
assert
pretrained_model
is
not
None
or
checkpoints
is
not
None
,
"one of pretrained_model and checkpoints must be not None"
if
checkpoints
is
not
None
:
self
.
model
=
model_class
.
from_pretrained
(
checkpoints
)
else
:
base_model
=
base_model_class
.
from_pretrained
(
pretrained_model
)
pretrained_model_name
=
pretrained_model_dict
[
base_model_class
]
if
pretrained
:
base_model
=
base_model_class
.
from_pretrained
(
pretrained_model_name
)
else
:
base_model
=
base_model_class
(
**
base_model_class
.
pretrained_init_configuration
[
pretrained_model_name
])
if
type
==
'ser'
:
self
.
model
=
model_class
(
base_model
,
num_classes
=
kwargs
[
'num_classes'
],
dropout
=
None
)
...
...
@@ -48,16 +59,13 @@ class NLPBaseModel(nn.Layer):
class
LayoutXLMForSer
(
NLPBaseModel
):
def
__init__
(
self
,
num_classes
,
pretrained_model
=
'layoutxlm-base-uncased'
,
checkpoints
=
None
,
def
__init__
(
self
,
num_classes
,
pretrained
=
True
,
checkpoints
=
None
,
**
kwargs
):
super
(
LayoutXLMForSer
,
self
).
__init__
(
LayoutXLMModel
,
LayoutXLMForTokenClassification
,
'ser'
,
pretrained
_model
,
pretrained
,
checkpoints
,
num_classes
=
num_classes
)
...
...
@@ -75,16 +83,13 @@ class LayoutXLMForSer(NLPBaseModel):
class
LayoutLMForSer
(
NLPBaseModel
):
def
__init__
(
self
,
num_classes
,
pretrained_model
=
'layoutxlm-base-uncased'
,
checkpoints
=
None
,
def
__init__
(
self
,
num_classes
,
pretrained
=
True
,
checkpoints
=
None
,
**
kwargs
):
super
(
LayoutLMForSer
,
self
).
__init__
(
LayoutLMModel
,
LayoutLMForTokenClassification
,
'ser'
,
pretrained
_model
,
pretrained
,
checkpoints
,
num_classes
=
num_classes
)
...
...
@@ -100,13 +105,10 @@ class LayoutLMForSer(NLPBaseModel):
class
LayoutXLMForRe
(
NLPBaseModel
):
def
__init__
(
self
,
pretrained_model
=
'layoutxlm-base-uncased'
,
checkpoints
=
None
,
**
kwargs
):
super
(
LayoutXLMForRe
,
self
).
__init__
(
LayoutXLMModel
,
LayoutXLMForRelationExtraction
,
're'
,
pretrained_model
,
checkpoints
)
def
__init__
(
self
,
pretrained
=
True
,
checkpoints
=
None
,
**
kwargs
):
super
(
LayoutXLMForRe
,
self
).
__init__
(
LayoutXLMModel
,
LayoutXLMForRelationExtraction
,
're'
,
pretrained
,
checkpoints
)
def
forward
(
self
,
x
):
x
=
self
.
model
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录