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
4f612cbc
Commit
4f612cbc
authored
Jul 23, 2025
by
myhloli
Browse files
fix: improve candidate sorting logic in vlm_magic_model.py
parent
beacccb6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
mineru/backend/vlm/vlm_magic_model.py
mineru/backend/vlm/vlm_magic_model.py
+7
-3
No files found.
mineru/backend/vlm/vlm_magic_model.py
View file @
4f612cbc
...
...
@@ -320,7 +320,10 @@ def __tie_up_category_by_distance_v3(
candidates
.
sort
(
key
=
lambda
x
:
(
x
[
2
]
-
left_x
)
**
2
+
(
x
[
3
]
-
top_y
)
**
2
)
fst_idx
,
fst_kind
,
left_x
,
top_y
=
candidates
[
0
]
candidates
.
sort
(
key
=
lambda
x
:
(
x
[
2
]
-
left_x
)
**
2
+
(
x
[
3
]
-
top_y
)
**
2
)
fst_bbox
=
subjects
[
fst_idx
][
'bbox'
]
if
fst_kind
==
SUB_BIT_KIND
else
objects
[
fst_idx
-
OBJ_IDX_OFFSET
][
'bbox'
]
candidates
.
sort
(
key
=
lambda
x
:
bbox_distance
(
fst_bbox
,
subjects
[
x
[
0
]][
'bbox'
])
if
x
[
1
]
==
SUB_BIT_KIND
else
bbox_distance
(
fst_bbox
,
objects
[
x
[
0
]
-
OBJ_IDX_OFFSET
][
'bbox'
]))
nxt
=
None
for
i
in
range
(
1
,
len
(
candidates
)):
...
...
@@ -339,8 +342,9 @@ def __tie_up_category_by_distance_v3(
pair_dis
=
bbox_distance
(
subjects
[
sub_idx
][
"bbox"
],
objects
[
obj_idx
][
"bbox"
])
nearest_dis
=
float
(
"inf"
)
for
i
in
range
(
N
):
if
i
in
seen_idx
or
i
==
sub_idx
:
continue
# 取消原先算法中 1对1 匹配的偏置
# if i in seen_idx or i == sub_idx:
# continue
nearest_dis
=
min
(
nearest_dis
,
bbox_distance
(
subjects
[
i
][
"bbox"
],
objects
[
obj_idx
][
"bbox"
]))
if
pair_dis
>=
3
*
nearest_dis
:
...
...
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