Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
483e5038
P
PaddleOCR
项目概览
PaddlePaddle
/
PaddleOCR
大约 1 年 前同步成功
通知
1523
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
483e5038
编写于
10月 10, 2022
作者:
z37757
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
通过变量类型判断是否是visual
上级
c25eec88
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
22 addition
and
17 deletion
+22
-17
ppocr/losses/rec_rfl_loss.py
ppocr/losses/rec_rfl_loss.py
+11
-7
ppocr/postprocess/rec_postprocess.py
ppocr/postprocess/rec_postprocess.py
+11
-10
未找到文件。
ppocr/losses/rec_rfl_loss.py
浏览文件 @
483e5038
...
...
@@ -36,22 +36,26 @@ class RFLLoss(nn.Layer):
self
.
total_loss
=
{}
total_loss
=
0.0
if
isinstance
(
predicts
,
tuple
)
or
isinstance
(
predicts
,
list
):
cnt_outputs
,
seq_outputs
=
predicts
else
:
cnt_outputs
,
seq_outputs
=
predicts
,
None
# batch [image, label, length, cnt_label]
if
predicts
[
0
]
is
not
None
:
cnt_loss
=
self
.
cnt_loss
(
predicts
[
0
]
,
if
cnt_outputs
is
not
None
:
cnt_loss
=
self
.
cnt_loss
(
cnt_outputs
,
paddle
.
cast
(
batch
[
3
],
paddle
.
float32
))
self
.
total_loss
[
'cnt_loss'
]
=
cnt_loss
total_loss
+=
cnt_loss
if
predicts
[
1
]
is
not
None
:
if
seq_outputs
is
not
None
:
targets
=
batch
[
1
].
astype
(
"int64"
)
label_lengths
=
batch
[
2
].
astype
(
'int64'
)
batch_size
,
num_steps
,
num_classes
=
predicts
[
1
].
shape
[
0
],
predicts
[
1
].
shape
[
1
],
predicts
[
1
]
.
shape
[
2
]
assert
len
(
targets
.
shape
)
==
len
(
list
(
predicts
[
1
]
.
shape
))
-
1
,
\
batch_size
,
num_steps
,
num_classes
=
seq_outputs
.
shape
[
0
],
seq_outputs
.
shape
[
1
],
seq_outputs
.
shape
[
2
]
assert
len
(
targets
.
shape
)
==
len
(
list
(
seq_outputs
.
shape
))
-
1
,
\
"The target's shape and inputs's shape is [N, d] and [N, num_steps]"
inputs
=
predicts
[
1
]
[:,
:
-
1
,
:]
inputs
=
seq_outputs
[:,
:
-
1
,
:]
targets
=
targets
[:,
1
:]
inputs
=
paddle
.
reshape
(
inputs
,
[
-
1
,
inputs
.
shape
[
-
1
]])
...
...
ppocr/postprocess/rec_postprocess.py
浏览文件 @
483e5038
...
...
@@ -287,12 +287,13 @@ class RFLLabelDecode(BaseRecLabelDecode):
return
result_list
def
__call__
(
self
,
preds
,
label
=
None
,
*
args
,
**
kwargs
):
if
len
(
preds
)
==
2
:
cnt_pred
,
preds
=
preds
if
isinstance
(
preds
,
paddle
.
Tensor
):
preds
=
preds
.
numpy
()
preds_idx
=
preds
.
argmax
(
axis
=
2
)
preds_prob
=
preds
.
max
(
axis
=
2
)
# if seq_outputs is not None:
if
isinstance
(
preds
,
tuple
)
or
isinstance
(
preds
,
list
):
cnt_outputs
,
seq_outputs
=
preds
if
isinstance
(
seq_outputs
,
paddle
.
Tensor
):
seq_outputs
=
seq_outputs
.
numpy
()
preds_idx
=
seq_outputs
.
argmax
(
axis
=
2
)
preds_prob
=
seq_outputs
.
max
(
axis
=
2
)
text
=
self
.
decode
(
preds_idx
,
preds_prob
,
is_remove_duplicate
=
False
)
if
label
is
None
:
...
...
@@ -301,11 +302,11 @@ class RFLLabelDecode(BaseRecLabelDecode):
return
text
,
label
else
:
cnt_
pred
=
preds
if
isinstance
(
cnt_
pred
,
paddle
.
Tensor
):
cnt_
pred
=
cnt_pred
.
numpy
()
cnt_
outputs
=
preds
if
isinstance
(
cnt_
outputs
,
paddle
.
Tensor
):
cnt_
outputs
=
cnt_outputs
.
numpy
()
cnt_length
=
[]
for
lens
in
cnt_
pred
:
for
lens
in
cnt_
outputs
:
length
=
round
(
np
.
sum
(
lens
))
cnt_length
.
append
(
length
)
if
label
is
None
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录