<jupyter_start><jupyter_text>Deep ViT Features - Point CorrespondencesGiven a pair of images, find $k$ semantic correspondences between them.<jupyter_code>#@title Installations and mounting
!pip install tqdm
!pip install faiss-cpu
!pip install timm
!pip install opencv-python
!pip install git+https://github.com/lucasb-eyer/pydensecrf.git
!git clone https://github.com/ShirAmir/dino-vit-features.git
import sys
sys.path.append('dino-vit-features')
%load_ext autoreload
%autoreload 2<jupyter_output><empty_output><jupyter_text>Change Runtime TypeTo get a GPU in Google Colab, go to the top menu: Runtime ➔ Change runtime type and select GPU as Hardware accelerator.<jupyter_code>#@title Configuration:
#@markdown Choose image paths:

image_path1 = 'dino-vit-features/images/cat.jpg' #@param
image_path2 = 'dino-vit-features/images/ibex.jpg' #@param

#@markdown Choose number of points to output:
num_pairs = 10 #@param
#@markdown Choose loading size:
load_size = 224 #@param
#@markdown Choose layer of descriptor:
layer = 9 #@param
#@markdown Choose facet of descriptor:
facet = 'key' #@param
#@markdown Choose if to use a binned descriptor:
bin=True #@param
#@markdown Choose fg / bg threshold:
thresh=0.05 #@param
#@markdown Choose model type:
model_type='dino_vits8' #@param
#@markdown Choose stride:
stride=4 #@param
import matplotlib.pyplot as plt
import torch
from correspondences import find_correspondences, draw_correspondences

with torch.no_grad():
    points1, points2, image1_pil, image2_pil = find_correspondences(image_path1, image_path2, num_pairs, load_size, layer,
                                                                   facet, bin, thresh, model_type, stride)
fig_1, ax1 = plt.subplots()
ax1.axis('off')
ax1.imshow(image1_pil)
fig_2, ax2 = plt.subplots()
ax2.axis('off')
ax2.imshow(image2_pil)


fig1, fig2 = draw_correspondences(points1, points2, image1_pil, image2_pil)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10407006697578568, 'fraction_numerical': 0.01854714064914992, 'mean_word_length': 5.1455696202531644, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '279424', 'license': 'MIT', 'n_tokens_mistral': 691, 'n_tokens_neox': 650, 'n_words': 183, 'path': 'correspondences.ipynb', 'repo_name': 'ShirAmir/dino-vit-features', 'size': '1941'}