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
f1252e71
Commit
f1252e71
authored
May 08, 2024
by
赵小蒙
Browse files
fix lost image bug
parent
875b5db1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
magic_pdf/pre_proc/ocr_dict_merge.py
magic_pdf/pre_proc/ocr_dict_merge.py
+6
-5
No files found.
magic_pdf/pre_proc/ocr_dict_merge.py
View file @
f1252e71
from
loguru
import
logger
from
magic_pdf.libs.boxbase
import
__is_overlaps_y_exceeds_threshold
,
get_minbox_if_overlap_by_ratio
,
\
calculate_overlap_area_in_bbox1_area_ratio
calculate_overlap_area_in_bbox1_area_ratio
,
_is_in_or_part_overlap_with_area_ratio
from
magic_pdf.libs.drop_tag
import
DropTag
from
magic_pdf.libs.ocr_content_type
import
ContentType
,
BlockType
from
magic_pdf.pre_proc.ocr_span_list_modify
import
modify_y_axis
,
modify_inline_equation
...
...
@@ -247,10 +247,11 @@ def fix_image_block(block, img_blocks):
block
[
'blocks'
]
=
[]
# 遍历img_blocks,找到与当前block匹配的img_block
for
img_block
in
img_blocks
:
if
img_block
[
'bbox'
]
==
block
[
'bbox'
]:
if
_is_in_or_part_overlap_with_area_ratio
(
block
[
'bbox'
],
img_block
[
'bbox'
],
0.95
):
# 创建img_body_block
for
span
in
block
[
'spans'
]:
if
span
[
'type'
]
==
ContentType
.
Image
and
span
[
'bbox'
]
==
img_block
[
'img_body_bbox'
]:
if
span
[
'type'
]
==
ContentType
.
Image
and
img_block
[
'img_body_bbox'
]
==
span
[
'bbox'
]
:
# 创建img_body_block
img_body_block
=
make_body_block
(
span
,
img_block
[
'img_body_bbox'
],
BlockType
.
ImageBody
)
block
[
'blocks'
].
append
(
img_body_block
)
...
...
@@ -275,11 +276,11 @@ def fix_table_block(block, table_blocks):
block
[
'blocks'
]
=
[]
# 遍历table_blocks,找到与当前block匹配的table_block
for
table_block
in
table_blocks
:
if
table_
block
[
'bbox'
]
==
block
[
'bbox'
]:
if
_is_in_or_part_overlap_with_area_ratio
(
block
[
'bbox'
]
,
table_
block
[
'bbox'
]
,
0.95
)
:
# 创建table_body_block
for
span
in
block
[
'spans'
]:
if
span
[
'type'
]
==
ContentType
.
Table
and
span
[
'bbox'
]
==
table_block
[
'table_body_bbox'
]:
if
span
[
'type'
]
==
ContentType
.
Table
and
table_block
[
'table_body_bbox'
]
==
span
[
'bbox'
]
:
# 创建table_body_block
table_body_block
=
make_body_block
(
span
,
table_block
[
'table_body_bbox'
],
BlockType
.
TableBody
)
block
[
'blocks'
].
append
(
table_body_block
)
...
...
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