Spaces:
Sleeping
Sleeping
Daniel Varga
commited on
Commit
·
bb469ae
1
Parent(s):
51b0e53
tidying
Browse files
app.py
CHANGED
|
@@ -54,12 +54,19 @@ embeddings /= np.linalg.norm(embeddings, axis=-1)[:, None]
|
|
| 54 |
|
| 55 |
n, d = embeddings.shape
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
annoy_index.
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
|
| 65 |
filenames = data["filenames"]
|
|
|
|
| 54 |
|
| 55 |
n, d = embeddings.shape
|
| 56 |
|
| 57 |
+
|
| 58 |
+
def build_ann_index(embeddings):
|
| 59 |
+
print("annoy indexing")
|
| 60 |
+
n, d = embeddings.shape
|
| 61 |
+
annoy_index = annoy.AnnoyIndex(d, "angular")
|
| 62 |
+
for i, vec in enumerate(embeddings):
|
| 63 |
+
annoy_index.add_item(i, vec)
|
| 64 |
+
annoy_index.build(10)
|
| 65 |
+
print("done")
|
| 66 |
+
return annoy_index
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
annoy_index = build_ann_index(embeddings)
|
| 70 |
|
| 71 |
|
| 72 |
filenames = data["filenames"]
|