Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
paddle_dbnet
Commits
5fd2de2e
Unverified
Commit
5fd2de2e
authored
Mar 24, 2022
by
littletomatodonkey
Committed by
GitHub
Mar 24, 2022
Browse files
improve post process (#5758)
* improve post process * rm unused code
parent
c2e45f2d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
16 deletions
+18
-16
ppocr/postprocess/rec_postprocess.py
ppocr/postprocess/rec_postprocess.py
+18
-16
No files found.
ppocr/postprocess/rec_postprocess.py
View file @
5fd2de2e
...
@@ -54,22 +54,24 @@ class BaseRecLabelDecode(object):
...
@@ -54,22 +54,24 @@ class BaseRecLabelDecode(object):
ignored_tokens
=
self
.
get_ignored_tokens
()
ignored_tokens
=
self
.
get_ignored_tokens
()
batch_size
=
len
(
text_index
)
batch_size
=
len
(
text_index
)
for
batch_idx
in
range
(
batch_size
):
for
batch_idx
in
range
(
batch_size
):
char_list
=
[]
selection
=
np
.
ones
(
len
(
text_index
[
batch_idx
]),
dtype
=
bool
)
conf_list
=
[]
for
idx
in
range
(
len
(
text_index
[
batch_idx
])):
if
text_index
[
batch_idx
][
idx
]
in
ignored_tokens
:
continue
if
is_remove_duplicate
:
if
is_remove_duplicate
:
# only for predict
selection
[
1
:]
=
text_index
[
batch_idx
][
1
:]
!=
text_index
[
if
idx
>
0
and
text_index
[
batch_idx
][
idx
-
1
]
==
text_index
[
batch_idx
][:
-
1
]
batch_idx
][
idx
]:
for
ignored_token
in
ignored_tokens
:
continue
selection
&=
text_index
[
batch_idx
]
!=
ignored_token
char_list
.
append
(
self
.
character
[
int
(
text_index
[
batch_idx
][
idx
])])
char_list
=
[
self
.
character
[
text_id
]
for
text_id
in
text_index
[
batch_idx
][
selection
]
]
if
text_prob
is
not
None
:
if
text_prob
is
not
None
:
conf_list
.
append
(
text_prob
[
batch_idx
][
idx
])
conf_list
=
text_prob
[
batch_idx
][
selection
]
else
:
else
:
conf_list
.
append
(
1
)
conf_list
=
[
1
]
*
len
(
selection
)
if
len
(
conf_list
)
==
0
:
conf_list
=
[
0
]
text
=
''
.
join
(
char_list
)
text
=
''
.
join
(
char_list
)
result_list
.
append
((
text
,
np
.
mean
(
conf_list
)))
result_list
.
append
((
text
,
np
.
mean
(
conf_list
)))
return
result_list
return
result_list
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment