Spaces:
Runtime error
Runtime error
fixing tensor device
Browse files
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 =
|
| 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
|
| 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):
|