Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
bmw-ocr
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
1b22a0ab
authored
2021-02-03 17:14:49 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix card bug
1 parent
123530e2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
src/apps/doc/management/commands/ocr_process.py
src/apps/doc/management/commands/ocr_process.py
View file @
1b22a0a
...
...
@@ -244,6 +244,7 @@ class Command(BaseCommand, LoggerMixin):
return
date_res
def
merge_card
(
self
,
bs_summary
):
classify_info
=
{}
merged_bs_summary
=
{}
sorted_card
=
sorted
(
bs_summary
.
keys
(),
key
=
lambda
x
:
bs_summary
[
x
][
'count'
],
reverse
=
True
)
for
main_card
in
sorted_card
:
...
...
@@ -266,10 +267,13 @@ class Command(BaseCommand, LoggerMixin):
merge_cards
.
append
(
card
)
for
card
in
merge_cards
:
del
bs_summary
[
card
]
merged_bs_summary
[
main_card
][
'classify'
]
=
self
.
get_most
(
merged_bs_summary
[
main_card
][
'classify'
])
most_classify
=
self
.
get_most
(
merged_bs_summary
[
main_card
][
'classify'
])
classify_count
=
classify_info
.
get
(
most_classify
,
0
)
classify_info
[
most_classify
]
=
classify_count
+
1
merged_bs_summary
[
main_card
][
'classify'
]
=
most_classify
merged_bs_summary
[
main_card
][
'role'
]
=
self
.
get_most
(
merged_bs_summary
[
main_card
][
'role'
])
del
bs_summary
return
merged_bs_summary
return
merged_bs_summary
,
classify_info
def
prune_bs_summary
(
self
,
bs_summary
):
for
summary
in
bs_summary
.
values
():
...
...
@@ -341,15 +345,16 @@ class Command(BaseCommand, LoggerMixin):
if
len
(
bs_summary
)
==
1
:
merged_bs_summary
=
self
.
prune_bs_summary
(
bs_summary
)
one_card
=
True
classify_info
=
{}
# 多卡号
else
:
merged_bs_summary
=
self
.
merge_card
(
bs_summary
)
merged_bs_summary
,
classify_info
=
self
.
merge_card
(
bs_summary
)
for
card_summary
in
merged_bs_summary
.
values
():
merge_role
=
[]
classify_summary
=
unknown_summary
.
get
(
card_summary
[
'classify'
],
{})
for
role
,
summary
in
classify_summary
.
items
():
if
one_card
or
role
in
card_summary
[
'role_set'
]:
if
one_card
or
classify_info
.
get
(
card_summary
[
'classify'
],
0
)
==
1
or
role
in
card_summary
[
'role_set'
]:
merge_role
.
append
(
role
)
# card_summary['confidence'].extend(summary['confidence'])
card_summary
[
'sheet'
]
.
extend
(
summary
[
'sheet'
])
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment