Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,14 +9,14 @@ import spaces
|
|
9 |
data = pd.read_csv('RB10kstats.csv')
|
10 |
|
11 |
# Convert embedding column from string to numpy array
|
12 |
-
data['
|
13 |
|
14 |
# Initialize FAISS index
|
15 |
-
dimension = len(data['
|
16 |
res = faiss.StandardGpuResources() # use a single GPU
|
17 |
index = faiss.IndexFlatL2(dimension)
|
18 |
gpu_index = faiss.index_cpu_to_gpu(res, 0, index) # move to GPU
|
19 |
-
gpu_index.add(np.stack(data['
|
20 |
|
21 |
# Check if GPU is available
|
22 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
|
|
9 |
data = pd.read_csv('RB10kstats.csv')
|
10 |
|
11 |
# Convert embedding column from string to numpy array
|
12 |
+
data['embeddings'] = data['embeddings'].apply(lambda x: np.fromstring(x[1:-1], sep=', '))
|
13 |
|
14 |
# Initialize FAISS index
|
15 |
+
dimension = len(data['embeddings'][0])
|
16 |
res = faiss.StandardGpuResources() # use a single GPU
|
17 |
index = faiss.IndexFlatL2(dimension)
|
18 |
gpu_index = faiss.index_cpu_to_gpu(res, 0, index) # move to GPU
|
19 |
+
gpu_index.add(np.stack(data['embeddings'].values))
|
20 |
|
21 |
# Check if GPU is available
|
22 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|