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
97633eb1
Unverified
Commit
97633eb1
authored
Feb 27, 2025
by
Xiaomeng Zhao
Committed by
GitHub
Feb 27, 2025
Browse files
Merge pull request #1792 from opendatalab/dev
fix: match multiple captions
parents
b6d60bb0
2629cadc
Changes
1
Hide 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 @
97633eb1
...
...
@@ -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