Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pdf-miner
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Qin Kaijie
pdf-miner
Commits
5f992de4
Commit
5f992de4
authored
Jul 22, 2024
by
myhloli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(magic_pdf): prevent removal of low-confidence spans already dropped
parent
ba07ebce
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
ocr_span_list_modify.py
magic_pdf/pre_proc/ocr_span_list_modify.py
+12
-7
No files found.
magic_pdf/pre_proc/ocr_span_list_modify.py
View file @
5f992de4
...
...
@@ -5,19 +5,24 @@ from magic_pdf.libs.boxbase import calculate_overlap_area_in_bbox1_area_ratio, g
from
magic_pdf.libs.drop_tag
import
DropTag
from
magic_pdf.libs.ocr_content_type
import
ContentType
,
BlockType
def
remove_overlaps_low_confidence_spans
(
spans
):
dropped_spans
=
[]
# 删除重叠spans中置信度低的的那些
for
span1
in
spans
:
for
span2
in
spans
:
if
span1
!=
span2
:
if
calculate_iou
(
span1
[
'bbox'
],
span2
[
'bbox'
])
>
0.9
:
if
span1
[
'score'
]
<
span2
[
'score'
]:
span_need_remove
=
span1
else
:
span_need_remove
=
span2
if
span_need_remove
is
not
None
and
span_need_remove
not
in
dropped_spans
:
dropped_spans
.
append
(
span_need_remove
)
# span1 或 span2 任何一个都不应该在 dropped_spans 中
if
span1
in
dropped_spans
or
span2
in
dropped_spans
:
continue
else
:
if
calculate_iou
(
span1
[
'bbox'
],
span2
[
'bbox'
])
>
0.9
:
if
span1
[
'score'
]
<
span2
[
'score'
]:
span_need_remove
=
span1
else
:
span_need_remove
=
span2
if
span_need_remove
is
not
None
and
span_need_remove
not
in
dropped_spans
:
dropped_spans
.
append
(
span_need_remove
)
if
len
(
dropped_spans
)
>
0
:
for
span_need_remove
in
dropped_spans
:
...
...
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