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
15cd97ff
Commit
15cd97ff
authored
Feb 26, 2025
by
icecraft
Browse files
fix: match multiple captions
parent
fddf111f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
magic_pdf/model/magic_model.py
magic_pdf/model/magic_model.py
+36
-0
No files found.
magic_pdf/model/magic_model.py
View file @
15cd97ff
...
...
@@ -553,6 +553,42 @@ class MagicModel:
}
)
for
i
in
range
(
len
(
objects
)):
j
=
i
+
OBJ_IDX_OFFSET
if
j
in
seen_idx
:
continue
seen_idx
.
add
(
j
)
nearest_dis
,
nearest_sub_idx
=
float
(
'inf'
),
-
1
for
k
in
range
(
len
(
subjects
)):
dis
=
bbox_distance
(
objects
[
i
][
'bbox'
],
subjects
[
k
][
'bbox'
])
if
dis
<
nearest_dis
:
nearest_dis
=
dis
nearest_sub_idx
=
k
for
k
in
range
(
len
(
subjects
)):
if
k
!=
nearest_sub_idx
:
continue
if
k
in
seen_sub_idx
:
for
kk
in
range
(
len
(
ret
)):
if
ret
[
kk
][
'sub_idx'
]
==
k
:
ret
[
kk
][
'obj_bboxes'
].
append
({
'score'
:
objects
[
i
][
'score'
],
'bbox'
:
objects
[
i
][
'bbox'
]})
break
else
:
ret
.
append
(
{
'sub_bbox'
:
{
'bbox'
:
subjects
[
k
][
'bbox'
],
'score'
:
subjects
[
k
][
'score'
],
},
'obj_bboxes'
:
[
{
'score'
:
objects
[
i
][
'score'
],
'bbox'
:
objects
[
i
][
'bbox'
]}
],
'sub_idx'
:
k
,
}
)
seen_sub_idx
.
add
(
k
)
seen_idx
.
add
(
k
)
for
i
in
range
(
len
(
subjects
)):
if
i
in
seen_sub_idx
:
continue
...
...
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