Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
3e8c78b8
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看板
提交
3e8c78b8
编写于
9月 30, 2022
作者:
文幕地方
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix tablerec-rare train error
上级
48a785f9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
15 addition
and
20 deletion
+15
-20
ppocr/modeling/heads/table_att_head.py
ppocr/modeling/heads/table_att_head.py
+15
-20
未找到文件。
ppocr/modeling/heads/table_att_head.py
浏览文件 @
3e8c78b8
...
...
@@ -82,7 +82,8 @@ class TableAttentionHead(nn.Layer):
batch_size
=
fea
.
shape
[
0
]
hidden
=
paddle
.
zeros
((
batch_size
,
self
.
hidden_size
))
output_hiddens
=
paddle
.
zeros
((
batch_size
,
self
.
max_text_length
+
1
,
self
.
hidden_size
))
output_hiddens
=
paddle
.
zeros
(
(
batch_size
,
self
.
max_text_length
+
1
,
self
.
hidden_size
))
if
self
.
training
and
targets
is
not
None
:
structure
=
targets
[
0
]
for
i
in
range
(
self
.
max_text_length
+
1
):
...
...
@@ -91,19 +92,13 @@ class TableAttentionHead(nn.Layer):
(
outputs
,
hidden
),
alpha
=
self
.
structure_attention_cell
(
hidden
,
fea
,
elem_onehots
)
output_hiddens
[:,
i
,
:]
=
outputs
# output_hiddens.append(paddle.unsqueeze(outputs, axis=1))
output
=
paddle
.
concat
(
output_hiddens
,
axis
=
1
)
structure_probs
=
self
.
structure_generator
(
output
)
if
self
.
loc_type
==
1
:
loc_preds
=
self
.
loc_generator
(
output
)
loc_preds
=
F
.
sigmoid
(
loc_preds
)
else
:
loc_fea
=
fea
.
transpose
([
0
,
2
,
1
])
loc_fea
=
self
.
loc_fea_trans
(
loc_fea
)
loc_fea
=
loc_fea
.
transpose
([
0
,
2
,
1
])
loc_concat
=
paddle
.
concat
([
output
,
loc_fea
],
axis
=
2
)
loc_preds
=
self
.
loc_generator
(
loc_concat
)
loc_preds
=
F
.
sigmoid
(
loc_preds
)
structure_probs
=
self
.
structure_generator
(
output_hiddens
)
loc_fea
=
fea
.
transpose
([
0
,
2
,
1
])
loc_fea
=
self
.
loc_fea_trans
(
loc_fea
)
loc_fea
=
loc_fea
.
transpose
([
0
,
2
,
1
])
loc_concat
=
paddle
.
concat
([
output_hiddens
,
loc_fea
],
axis
=
2
)
loc_preds
=
self
.
loc_generator
(
loc_concat
)
loc_preds
=
F
.
sigmoid
(
loc_preds
)
else
:
temp_elem
=
paddle
.
zeros
(
shape
=
[
batch_size
],
dtype
=
"int32"
)
structure_probs
=
None
...
...
@@ -118,17 +113,15 @@ class TableAttentionHead(nn.Layer):
(
outputs
,
hidden
),
alpha
=
self
.
structure_attention_cell
(
hidden
,
fea
,
elem_onehots
)
output_hiddens
[:,
i
,
:]
=
outputs
# output_hiddens.append(paddle.unsqueeze(outputs, axis=1))
structure_probs_step
=
self
.
structure_generator
(
outputs
)
temp_elem
=
structure_probs_step
.
argmax
(
axis
=
1
,
dtype
=
"int32"
)
output
=
output_hiddens
structure_probs
=
self
.
structure_generator
(
output
)
structure_probs
=
self
.
structure_generator
(
output_hiddens
)
structure_probs
=
F
.
softmax
(
structure_probs
)
loc_fea
=
fea
.
transpose
([
0
,
2
,
1
])
loc_fea
=
self
.
loc_fea_trans
(
loc_fea
)
loc_fea
=
loc_fea
.
transpose
([
0
,
2
,
1
])
loc_concat
=
paddle
.
concat
([
output
,
loc_fea
],
axis
=
2
)
loc_concat
=
paddle
.
concat
([
output
_hiddens
,
loc_fea
],
axis
=
2
)
loc_preds
=
self
.
loc_generator
(
loc_concat
)
loc_preds
=
F
.
sigmoid
(
loc_preds
)
return
{
'structure_probs'
:
structure_probs
,
'loc_preds'
:
loc_preds
}
...
...
@@ -203,8 +196,10 @@ class SLAHead(nn.Layer):
fea
=
fea
.
transpose
([
0
,
2
,
1
])
# (NTC)(batch, width, channels)
hidden
=
paddle
.
zeros
((
batch_size
,
self
.
hidden_size
))
structure_preds
=
paddle
.
zeros
((
batch_size
,
self
.
max_text_length
+
1
,
self
.
num_embeddings
))
loc_preds
=
paddle
.
zeros
((
batch_size
,
self
.
max_text_length
+
1
,
self
.
loc_reg_num
))
structure_preds
=
paddle
.
zeros
(
(
batch_size
,
self
.
max_text_length
+
1
,
self
.
num_embeddings
))
loc_preds
=
paddle
.
zeros
(
(
batch_size
,
self
.
max_text_length
+
1
,
self
.
loc_reg_num
))
structure_preds
.
stop_gradient
=
True
loc_preds
.
stop_gradient
=
True
if
self
.
training
and
targets
is
not
None
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录