forked from ShirAmir/dino-vit-features
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.py
42 lines (34 loc) · 1.17 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#@title Configuration:
#@markdown Choose image paths:
image_path1 = 'images/cat.jpg' #@param
image_path2 = '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()