Skip to content

Commit

Permalink
Merge pull request #28 from hturki/bugfix/kmeans-fix
Browse files Browse the repository at this point in the history
Update DINO correspondence script to remove redundant assignment loop
  • Loading branch information
hturki authored May 26, 2023
2 parents a32b60a + 8013261 commit 9b472ad
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions scripts/extract_dino_correspondences.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,10 @@ def find_correspondences(extractor: ViTExtractor, image_path1: str, image_path2:
bb_cls_attn = (bb_cls_attn1 + bb_cls_attn2) / 2
ranks = bb_cls_attn

for k in range(n_clusters):
for i, (label, rank) in enumerate(zip(kmeans.labels_, ranks)):
if rank > bb_topk_sims[label]:
bb_topk_sims[label] = rank
bb_indices_to_show[label] = i
for i, (label, rank) in enumerate(zip(kmeans.labels_, ranks)):
if rank > bb_topk_sims[label]:
bb_topk_sims[label] = rank
bb_indices_to_show[label] = i

# get coordinates to show
indices_to_show = torch.nonzero(bbs_mask, as_tuple=False).squeeze(dim=1)[
Expand Down

0 comments on commit 9b472ad

Please sign in to comment.