Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,13 +7,13 @@ import torch
|
|
7 |
import json
|
8 |
import spaces
|
9 |
# Load CSV data
|
10 |
-
data = pd.read_csv('
|
11 |
|
12 |
# Convert embedding column from JSON string to numpy array
|
13 |
-
data['
|
14 |
|
15 |
# Initialize FAISS index
|
16 |
-
dimension = len(data['
|
17 |
res = faiss.StandardGpuResources() # use a single GPU
|
18 |
|
19 |
# Check available GPU devices
|
@@ -24,7 +24,7 @@ if num_gpus > 0:
|
|
24 |
else:
|
25 |
raise RuntimeError("No GPU devices available.")
|
26 |
|
27 |
-
gpu_index.add(np.stack(data['
|
28 |
|
29 |
# Check if GPU is available
|
30 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
|
|
7 |
import json
|
8 |
import spaces
|
9 |
# Load CSV data
|
10 |
+
data = pd.read_csv('RBD10kstats.csv')
|
11 |
|
12 |
# Convert embedding column from JSON string to numpy array
|
13 |
+
data['embedding'] = data['embedding'].apply(lambda x: np.array(json.loads(x)))
|
14 |
|
15 |
# Initialize FAISS index
|
16 |
+
dimension = len(data['embedding'][0])
|
17 |
res = faiss.StandardGpuResources() # use a single GPU
|
18 |
|
19 |
# Check available GPU devices
|
|
|
24 |
else:
|
25 |
raise RuntimeError("No GPU devices available.")
|
26 |
|
27 |
+
gpu_index.add(np.stack(data['embedding'].values))
|
28 |
|
29 |
# Check if GPU is available
|
30 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|