Spaces:
Runtime error
Runtime error
shivangibithel
commited on
Commit
•
0d8779b
1
Parent(s):
5c6849b
Update app.py
Browse files
app.py
CHANGED
@@ -16,11 +16,11 @@ model = SentenceTransformer(model_name)
|
|
16 |
|
17 |
# # Load the FAISS index
|
18 |
# index_name = 'index.faiss'
|
19 |
-
# index_url = '
|
20 |
# wget.download(index_url, index_name)
|
21 |
-
# index = faiss.read_index(
|
22 |
|
23 |
-
vectors = np.load("
|
24 |
vector_dimension = vectors.shape[1]
|
25 |
index = faiss.IndexFlatL2(vector_dimension)
|
26 |
faiss.normalize_L2(vectors)
|
@@ -28,7 +28,7 @@ index.add(vectors)
|
|
28 |
|
29 |
# Map the image ids to the corresponding image URLs
|
30 |
image_map_name = 'captions.json'
|
31 |
-
image_map_url = '
|
32 |
wget.download(image_map_url, image_map_name)
|
33 |
|
34 |
with open(image_map_name, 'r') as f:
|
@@ -52,7 +52,7 @@ def search(query, k=5):
|
|
52 |
for i in I[0]:
|
53 |
text_id = i
|
54 |
image_id = str(image_list[i])
|
55 |
-
image_url = "
|
56 |
image_urls.append(image_url)
|
57 |
|
58 |
return image_urls
|
|
|
16 |
|
17 |
# # Load the FAISS index
|
18 |
# index_name = 'index.faiss'
|
19 |
+
# index_url = './'
|
20 |
# wget.download(index_url, index_name)
|
21 |
+
# index = faiss.read_index(faiss_flickr8k.index)
|
22 |
|
23 |
+
vectors = np.load("./sbert_text_features.npy")
|
24 |
vector_dimension = vectors.shape[1]
|
25 |
index = faiss.IndexFlatL2(vector_dimension)
|
26 |
faiss.normalize_L2(vectors)
|
|
|
28 |
|
29 |
# Map the image ids to the corresponding image URLs
|
30 |
image_map_name = 'captions.json'
|
31 |
+
image_map_url = './captions.json'
|
32 |
wget.download(image_map_url, image_map_name)
|
33 |
|
34 |
with open(image_map_name, 'r') as f:
|
|
|
52 |
for i in I[0]:
|
53 |
text_id = i
|
54 |
image_id = str(image_list[i])
|
55 |
+
image_url = "./Images/" + image_id
|
56 |
image_urls.append(image_url)
|
57 |
|
58 |
return image_urls
|