YannisK commited on
Commit
092e211
1 Parent(s): 6d52033
Files changed (1) hide show
  1. app.py +23 -23
app.py CHANGED
@@ -30,11 +30,11 @@ net.load_state_dict(state['state_dict'])
30
 
31
 
32
  # ---------------------------------------
33
- # transform = transforms.Compose([
34
- # transforms.Resize(1024),
35
- # transforms.ToTensor(),
36
- # transforms.Normalize(**dict(zip(["mean", "std"], net.runtime['mean_std'])))
37
- # ])
38
  # ---------------------------------------
39
 
40
  class ImgDataset(data.Dataset):
@@ -88,24 +88,24 @@ def generate_matching_superfeatures(im1, im2, scale_id=6, threshold=50, sf_ids='
88
 
89
  # extract features
90
  with torch.no_grad():
91
- # output1 = net.get_superfeatures(im1_tensor.to(device), scales=[scales[scale_id]])
92
- # feats1 = output1[0][0]
93
- # attns1 = output1[1][0]
94
- # strenghts1 = output1[2][0]
95
-
96
- # output2 = net.get_superfeatures(im2_tensor.to(device), scales=[scales[scale_id]])
97
- # feats2 = output2[0][0]
98
- # attns2 = output2[1][0]
99
- # strenghts2 = output2[2][0]
100
- outputs = []
101
- for im_tensor in loader:
102
- outputs.append(net.get_superfeatures(im_tensor.to(device), scales=[scales[scale_id]]))
103
- feats1 = outputs[0][0][0]
104
- attns1 = outputs[0][1][0]
105
- strenghts1 = outputs[0][2][0]
106
- feats2 = outputs[1][0][0]
107
- attns2 = outputs[1][1][0]
108
- strenghts2 = outputs[1][2][0]
109
  print(feats1.shape, feats2.shape)
110
  print(attns1.shape, attns2.shape)
111
  print(strenghts1.shape, strenghts2.shape)
 
30
 
31
 
32
  # ---------------------------------------
33
+ transform = transforms.Compose([
34
+ transforms.Resize(1024),
35
+ transforms.ToTensor(),
36
+ transforms.Normalize(**dict(zip(["mean", "std"], net.runtime['mean_std'])))
37
+ ])
38
  # ---------------------------------------
39
 
40
  class ImgDataset(data.Dataset):
 
88
 
89
  # extract features
90
  with torch.no_grad():
91
+ output1 = net.get_superfeatures(im1_tensor.to(device), scales=[scales[scale_id]])
92
+ feats1 = output1[0][0]
93
+ attns1 = output1[1][0]
94
+ strenghts1 = output1[2][0]
95
+
96
+ output2 = net.get_superfeatures(im2_tensor.to(device), scales=[scales[scale_id]])
97
+ feats2 = output2[0][0]
98
+ attns2 = output2[1][0]
99
+ strenghts2 = output2[2][0]
100
+ # outputs = []
101
+ # for im_tensor in loader:
102
+ # outputs.append(net.get_superfeatures(im_tensor.to(device), scales=[scales[scale_id]]))
103
+ # feats1 = outputs[0][0][0]
104
+ # attns1 = outputs[0][1][0]
105
+ # strenghts1 = outputs[0][2][0]
106
+ # feats2 = outputs[1][0][0]
107
+ # attns2 = outputs[1][1][0]
108
+ # strenghts2 = outputs[1][2][0]
109
  print(feats1.shape, feats2.shape)
110
  print(attns1.shape, attns2.shape)
111
  print(strenghts1.shape, strenghts2.shape)