Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
cf31719c
P
PaddleOCR
项目概览
PaddlePaddle
/
PaddleOCR
大约 1 年 前同步成功
通知
1528
Star
32962
Fork
6643
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
108
列表
看板
标记
里程碑
合并请求
7
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
108
Issue
108
列表
看板
标记
里程碑
合并请求
7
合并请求
7
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
cf31719c
编写于
9月 05, 2022
作者:
Z
zhoujun
提交者:
GitHub
9月 05, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7485 from WenmuZhou/table_label
support onnx infer of SLANet
上级
e0194680
93d9d682
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
23 addition
and
17 deletion
+23
-17
configs/table/SLANet.yml
configs/table/SLANet.yml
+1
-1
configs/table/SLANet_ch.yml
configs/table/SLANet_ch.yml
+1
-1
ppocr/modeling/heads/table_att_head.py
ppocr/modeling/heads/table_att_head.py
+9
-8
ppstructure/table/predict_structure.py
ppstructure/table/predict_structure.py
+12
-7
未找到文件。
configs/table/SLANet.yml
浏览文件 @
cf31719c
...
...
@@ -12,7 +12,7 @@ Global:
checkpoints
:
save_inference_dir
:
./output/SLANet/infer
use_visualdl
:
False
infer_img
:
doc
/table/table.jpg
infer_img
:
ppstructure/docs
/table/table.jpg
# for data or label process
character_dict_path
:
ppocr/utils/dict/table_structure_dict.txt
character_type
:
en
...
...
configs/table/SLANet_ch.yml
浏览文件 @
cf31719c
...
...
@@ -12,7 +12,7 @@ Global:
checkpoints
:
save_inference_dir
:
./output/SLANet_ch/infer
use_visualdl
:
False
infer_img
:
doc
/table/table.jpg
infer_img
:
ppstructure/docs
/table/table.jpg
# for data or label process
character_dict_path
:
ppocr/utils/dict/table_structure_dict_ch.txt
character_type
:
en
...
...
ppocr/modeling/heads/table_att_head.py
浏览文件 @
cf31719c
...
...
@@ -166,6 +166,7 @@ class SLAHead(nn.Layer):
self
.
max_text_length
=
max_text_length
self
.
emb
=
self
.
_char_to_onehot
self
.
num_embeddings
=
out_channels
self
.
loc_reg_num
=
loc_reg_num
# structure
self
.
structure_attention_cell
=
AttentionGRUCell
(
...
...
@@ -213,15 +214,17 @@ class SLAHead(nn.Layer):
fea
=
fea
.
transpose
([
0
,
2
,
1
])
# (NTC)(batch, width, channels)
hidden
=
paddle
.
zeros
((
batch_size
,
self
.
hidden_size
))
structure_preds
=
[]
loc_preds
=
[]
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
:
structure
=
targets
[
0
]
for
i
in
range
(
self
.
max_text_length
+
1
):
hidden
,
structure_step
,
loc_step
=
self
.
_decode
(
structure
[:,
i
],
fea
,
hidden
)
structure_preds
.
append
(
structure_step
)
loc_preds
.
append
(
loc_step
)
structure_preds
[:,
i
,
:]
=
structure_step
loc_preds
[:,
i
,
:]
=
loc_step
else
:
pre_chars
=
paddle
.
zeros
(
shape
=
[
batch_size
],
dtype
=
"int32"
)
max_text_length
=
paddle
.
to_tensor
(
self
.
max_text_length
)
...
...
@@ -231,10 +234,8 @@ class SLAHead(nn.Layer):
hidden
,
structure_step
,
loc_step
=
self
.
_decode
(
pre_chars
,
fea
,
hidden
)
pre_chars
=
structure_step
.
argmax
(
axis
=
1
,
dtype
=
"int32"
)
structure_preds
.
append
(
structure_step
)
loc_preds
.
append
(
loc_step
)
structure_preds
=
paddle
.
stack
(
structure_preds
,
axis
=
1
)
loc_preds
=
paddle
.
stack
(
loc_preds
,
axis
=
1
)
structure_preds
[:,
i
,
:]
=
structure_step
loc_preds
[:,
i
,
:]
=
loc_step
if
not
self
.
training
:
structure_preds
=
F
.
softmax
(
structure_preds
)
return
{
'structure_probs'
:
structure_preds
,
'loc_preds'
:
loc_preds
}
...
...
ppstructure/table/predict_structure.py
浏览文件 @
cf31719c
...
...
@@ -68,6 +68,7 @@ def build_pre_process_list(args):
class
TableStructurer
(
object
):
def
__init__
(
self
,
args
):
self
.
use_onnx
=
args
.
use_onnx
pre_process_list
=
build_pre_process_list
(
args
)
if
args
.
table_algorithm
not
in
[
'TableMaster'
]:
postprocess_params
=
{
...
...
@@ -98,13 +99,17 @@ class TableStructurer(object):
return
None
,
0
img
=
np
.
expand_dims
(
img
,
axis
=
0
)
img
=
img
.
copy
()
self
.
input_tensor
.
copy_from_cpu
(
img
)
self
.
predictor
.
run
()
outputs
=
[]
for
output_tensor
in
self
.
output_tensors
:
output
=
output_tensor
.
copy_to_cpu
()
outputs
.
append
(
output
)
if
self
.
use_onnx
:
input_dict
=
{}
input_dict
[
self
.
input_tensor
.
name
]
=
img
outputs
=
self
.
predictor
.
run
(
self
.
output_tensors
,
input_dict
)
else
:
self
.
input_tensor
.
copy_from_cpu
(
img
)
self
.
predictor
.
run
()
outputs
=
[]
for
output_tensor
in
self
.
output_tensors
:
output
=
output_tensor
.
copy_to_cpu
()
outputs
.
append
(
output
)
preds
=
{}
preds
[
'structure_probs'
]
=
outputs
[
1
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录