mirror of
https://github.com/opendatalab/MinerU.git
synced 2026-03-27 11:08:32 +07:00
Merge pull request #1792 from opendatalab/dev
fix: match multiple captions
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user