sasha HF staff commited on
Commit
a97b4c6
1 Parent(s): b8bec10

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -3,10 +3,15 @@ import gradio as gr
3
  from datasets import load_dataset
4
  from transformers import AutoModel, AutoFeatureExtractor
5
  import wikipedia
 
6
 
7
  # Only runs once when the script is first run.
8
- with open("slugs_1024_new.pickle", "rb") as handle:
9
- index = pickle.load(handle)
 
 
 
 
10
 
11
  # Load model for computing embeddings.
12
  feature_extractor = AutoFeatureExtractor.from_pretrained("sasha/autotrain-sea-slug-similarity-2498977005")
 
3
  from datasets import load_dataset
4
  from transformers import AutoModel, AutoFeatureExtractor
5
  import wikipedia
6
+ import numpy as np
7
 
8
  # Only runs once when the script is first run.
9
+ #with open("slugs_1024_new.pickle", "rb") as handle:
10
+ # index = pickle.load(handle)
11
+
12
+ embs= np.load('slugs_embeddings_1024k.npy', 'rb')
13
+ index = pynndescent.NNDescent(embs, metric="cosine")
14
+ index.prepare()
15
 
16
  # Load model for computing embeddings.
17
  feature_extractor = AutoFeatureExtractor.from_pretrained("sasha/autotrain-sea-slug-similarity-2498977005")