taesiri commited on
Commit
d5bf018
·
1 Parent(s): f75ba36

fixing tensor device

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -12,7 +12,7 @@ from collections import Counter
12
  from SimSearch import FaissCosineNeighbors
13
 
14
  # HELPERS
15
- to_np = lambda x: x.data.to('cpu').numpy()
16
 
17
  # DOWNLOAD THE DATASET and Files
18
 
@@ -54,7 +54,7 @@ class GamePhysicsSearcher:
54
  y_train = []
55
 
56
  for i, vfile in enumerate(tqdm(self.all_embeddings)):
57
- vfeatures = to_np(self.read_features(vfile))
58
  features[vfile.split('/')[-1]] = vfeatures
59
  X_train.extend(vfeatures)
60
  y_train.extend([i]*vfeatures.shape[0])
@@ -74,7 +74,7 @@ class GamePhysicsSearcher:
74
  with torch.no_grad():
75
  text_features = self.CLIP_MODEL.encode_text(text_tokens).float()
76
  text_features /= text_features.norm(dim=-1, keepdim=True)
77
- return to_np(text_features)
78
 
79
  # Source: https://stackoverflow.com/a/480227
80
  def f7(self, seq):
 
12
  from SimSearch import FaissCosineNeighbors
13
 
14
  # HELPERS
15
+ # to_np = lambda x: x.data.to('cpu').numpy()
16
 
17
  # DOWNLOAD THE DATASET and Files
18
 
 
54
  y_train = []
55
 
56
  for i, vfile in enumerate(tqdm(self.all_embeddings)):
57
+ vfeatures = self.read_features(vfile)
58
  features[vfile.split('/')[-1]] = vfeatures
59
  X_train.extend(vfeatures)
60
  y_train.extend([i]*vfeatures.shape[0])
 
74
  with torch.no_grad():
75
  text_features = self.CLIP_MODEL.encode_text(text_tokens).float()
76
  text_features /= text_features.norm(dim=-1, keepdim=True)
77
+ return text_features
78
 
79
  # Source: https://stackoverflow.com/a/480227
80
  def f7(self, seq):