Skip to content

Commit

Permalink
Fix from @JihwanEom's comment
Browse files Browse the repository at this point in the history
Signed-off-by: Kim, Vinnam <vinnam.kim@intel.com>
  • Loading branch information
vinnamkim committed Mar 30, 2023
1 parent 87c1131 commit b3f72d2
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions datumaro/components/annotations/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,34 +59,34 @@ def match_segments(
matches = []
mispred = []

for a_idx, a_segm in enumerate(a_segms):
if len(b_segms) == 0:
break
matched_b = -1
max_dist = -1
b_indices = np.argsort(
[not label_matcher(a_segm, b_segm) for b_segm in b_segms], kind="stable"
) # prioritize those with same label, keep score order
for b_idx in b_indices:
if 0 <= b_matches[b_idx]: # assign a_segm with max conf
# It needs len(a_segms) > 0 and len(b_segms) > 0
if len(b_segms) > 0:
for a_idx, a_segm in enumerate(a_segms):
matched_b = -1
max_dist = -1
b_indices = np.argsort(
[not label_matcher(a_segm, b_segm) for b_segm in b_segms], kind="stable"
) # prioritize those with same label, keep score order
for b_idx in b_indices:
if 0 <= b_matches[b_idx]: # assign a_segm with max conf
continue
d = distances[a_idx, b_idx]
if d < dist_thresh or d <= max_dist:
continue
max_dist = d
matched_b = b_idx

if matched_b < 0:
continue
d = distances[a_idx, b_idx]
if d < dist_thresh or d <= max_dist:
continue
max_dist = d
matched_b = b_idx

if matched_b < 0:
continue
a_matches[a_idx] = matched_b
b_matches[matched_b] = a_idx
a_matches[a_idx] = matched_b
b_matches[matched_b] = a_idx

b_segm = b_segms[matched_b]
b_segm = b_segms[matched_b]

if label_matcher(a_segm, b_segm):
matches.append((a_segm, b_segm))
else:
mispred.append((a_segm, b_segm))
if label_matcher(a_segm, b_segm):
matches.append((a_segm, b_segm))
else:
mispred.append((a_segm, b_segm))

# *_umatched: boxes of (*) we failed to match
a_unmatched = [a_segms[i] for i, m in enumerate(a_matches) if m < 0]
Expand Down

0 comments on commit b3f72d2

Please sign in to comment.