Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
c459b725
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看板
提交
c459b725
编写于
10月 08, 2022
作者:
z37757
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加RFL CNT分支infer支持
上级
3f8602c1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
11 deletion
+18
-11
ppocr/modeling/heads/rec_rfl_head.py
ppocr/modeling/heads/rec_rfl_head.py
+2
-3
ppocr/postprocess/rec_postprocess.py
ppocr/postprocess/rec_postprocess.py
+6
-4
tools/infer_rec.py
tools/infer_rec.py
+10
-4
未找到文件。
ppocr/modeling/heads/rec_rfl_head.py
浏览文件 @
c459b725
...
...
@@ -103,7 +103,6 @@ class RFLHead(nn.Layer):
else
:
seq_outputs
=
self
.
seq_head
(
seq_inputs
,
None
,
self
.
batch_max_legnth
)
return
cnt_outputs
,
seq_outputs
else
:
seq_outputs
=
None
return
cnt_outputs
,
seq_outputs
return
cnt_outputs
ppocr/postprocess/rec_postprocess.py
浏览文件 @
c459b725
...
...
@@ -287,9 +287,8 @@ class RFLLabelDecode(BaseRecLabelDecode):
return
result_list
def
__call__
(
self
,
preds
,
label
=
None
,
*
args
,
**
kwargs
):
cnt_pred
,
preds
=
preds
if
preds
is
not
None
:
if
len
(
preds
)
==
2
:
cnt_pred
,
preds
=
preds
if
isinstance
(
preds
,
paddle
.
Tensor
):
preds
=
preds
.
numpy
()
preds_idx
=
preds
.
argmax
(
axis
=
2
)
...
...
@@ -302,9 +301,12 @@ class RFLLabelDecode(BaseRecLabelDecode):
return
text
,
label
else
:
cnt_pred
=
preds
if
isinstance
(
cnt_pred
,
paddle
.
Tensor
):
cnt_pred
=
cnt_pred
.
numpy
()
cnt_length
=
[]
for
lens
in
cnt_pred
:
length
=
round
(
paddle
.
sum
(
lens
).
item
(
))
length
=
round
(
np
.
sum
(
lens
))
cnt_length
.
append
(
length
)
if
label
is
None
:
return
cnt_length
...
...
tools/infer_rec.py
浏览文件 @
c459b725
...
...
@@ -97,7 +97,8 @@ def main():
elif
config
[
'Architecture'
][
'algorithm'
]
==
"SAR"
:
op
[
op_name
][
'keep_keys'
]
=
[
'image'
,
'valid_ratio'
]
elif
config
[
'Architecture'
][
'algorithm'
]
==
"RobustScanner"
:
op
[
op_name
][
'keep_keys'
]
=
[
'image'
,
'valid_ratio'
,
'word_positons'
]
op
[
op_name
][
'keep_keys'
]
=
[
'image'
,
'valid_ratio'
,
'word_positons'
]
else
:
op
[
op_name
][
'keep_keys'
]
=
[
'image'
]
transforms
.
append
(
op
)
...
...
@@ -136,9 +137,10 @@ def main():
if
config
[
'Architecture'
][
'algorithm'
]
==
"RobustScanner"
:
valid_ratio
=
np
.
expand_dims
(
batch
[
1
],
axis
=
0
)
word_positons
=
np
.
expand_dims
(
batch
[
2
],
axis
=
0
)
img_metas
=
[
paddle
.
to_tensor
(
valid_ratio
),
paddle
.
to_tensor
(
word_positons
),
]
img_metas
=
[
paddle
.
to_tensor
(
valid_ratio
),
paddle
.
to_tensor
(
word_positons
),
]
images
=
np
.
expand_dims
(
batch
[
0
],
axis
=
0
)
images
=
paddle
.
to_tensor
(
images
)
if
config
[
'Architecture'
][
'algorithm'
]
==
"SRN"
:
...
...
@@ -160,6 +162,10 @@ def main():
"score"
:
float
(
post_result
[
key
][
0
][
1
]),
}
info
=
json
.
dumps
(
rec_info
,
ensure_ascii
=
False
)
elif
isinstance
(
post_result
,
list
)
and
isinstance
(
post_result
[
0
],
int
):
# for RFLearning CNT branch
info
=
str
(
post_result
[
0
])
else
:
if
len
(
post_result
[
0
])
>=
2
:
info
=
post_result
[
0
][
0
]
+
"
\t
"
+
str
(
post_result
[
0
][
1
])
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录