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
MinerU
Commits
f70289f9
Commit
f70289f9
authored
Apr 25, 2024
by
赵小蒙
Browse files
fix remove error
parent
1936703b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
10 deletions
+13
-10
magic_pdf/pre_proc/ocr_detect_all_bboxes.py
magic_pdf/pre_proc/ocr_detect_all_bboxes.py
+4
-2
magic_pdf/pre_proc/ocr_span_list_modify.py
magic_pdf/pre_proc/ocr_span_list_modify.py
+9
-8
No files found.
magic_pdf/pre_proc/ocr_detect_all_bboxes.py
View file @
f70289f9
...
...
@@ -71,7 +71,9 @@ def remove_need_drop_blocks(all_bboxes, discarded_blocks):
for
discarded_block
in
discarded_blocks
:
block_bbox
=
block
[:
4
]
if
calculate_overlap_area_in_bbox1_area_ratio
(
block_bbox
,
discarded_block
[
'bbox'
])
>
0.6
:
need_remove
.
append
(
block
)
if
block
not
in
need_remove
:
need_remove
.
append
(
block
)
break
if
len
(
need_remove
)
>
0
:
for
block
in
need_remove
:
...
...
@@ -90,7 +92,7 @@ def remove_overlaps_min_blocks(all_bboxes):
overlap_box
=
get_minbox_if_overlap_by_ratio
(
block1_bbox
,
block2_bbox
,
0.8
)
if
overlap_box
is
not
None
:
bbox_to_remove
=
next
((
block
for
block
in
all_bboxes
if
block
[:
4
]
==
overlap_box
),
None
)
if
bbox_to_remove
is
not
None
:
if
bbox_to_remove
is
not
None
and
bbox_to_remove
not
in
need_remove
:
need_remove
.
append
(
bbox_to_remove
)
if
len
(
need_remove
)
>
0
:
...
...
magic_pdf/pre_proc/ocr_span_list_modify.py
View file @
f70289f9
...
...
@@ -14,14 +14,14 @@ def remove_overlaps_min_spans(spans):
if
span1
!=
span2
:
overlap_box
=
get_minbox_if_overlap_by_ratio
(
span1
[
'bbox'
],
span2
[
'bbox'
],
0.65
)
if
overlap_box
is
not
None
:
bbox_to
_remove
=
next
((
span
for
span
in
spans
if
span
[
'bbox'
]
==
overlap_box
),
None
)
if
bbox_to
_remove
is
not
None
:
dropped_spans
.
append
(
bbox_to
_remove
)
span_need
_remove
=
next
((
span
for
span
in
spans
if
span
[
'bbox'
]
==
overlap_box
),
None
)
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
dropped_span
in
dropped_spans
:
spans
.
remove
(
dropped_span
)
dropped_span
[
'tag'
]
=
DropTag
.
SPAN_OVERLAP
for
span_need_remove
in
dropped_spans
:
spans
.
remove
(
span_need_remove
)
span_need_remove
[
'tag'
]
=
DropTag
.
SPAN_OVERLAP
return
spans
,
dropped_spans
...
...
@@ -33,8 +33,9 @@ def remove_spans_by_bboxes(spans, need_remove_spans_bboxes):
for
span
in
spans
:
for
removed_bbox
in
need_remove_spans_bboxes
:
if
calculate_overlap_area_in_bbox1_area_ratio
(
span
[
'bbox'
],
removed_bbox
)
>
0.5
:
need_remove_spans
.
append
(
span
)
break
if
span
not
in
need_remove_spans
:
need_remove_spans
.
append
(
span
)
break
if
len
(
need_remove_spans
)
>
0
:
for
span
in
need_remove_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