katerinavr commited on
Commit
a113671
1 Parent(s): 8201fe8

Add requirements

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -19,7 +19,7 @@ model = SentenceTransformer('clip-ViT-B-32')
19
  #Open the precomputed embeddings
20
  #emb_filename = 'unsplash-25k-photos-embeddings.pkl'
21
  ds_with_embeddings = load_dataset("kvriza8/image-embeddings", use_auth_token=True)
22
- ds_with_embeddings['train'].add_faiss_index(column='embeddings')
23
  # img_names, img_emb = ds_with_embeddings['train']['image'], ds_with_embeddings['train']['embeddings']
24
  # with open(emb_filename, 'rb') as fIn:
25
  # img_names, img_emb = pickle.load(fIn)
@@ -56,6 +56,7 @@ def search_text(query, top_k=1):
56
 
57
  def get_image_from_text(text_prompt, number_to_retrieve=6):
58
  prompt = model.encode(text_prompt)
 
59
  scores, retrieved_examples = ds_with_embeddings['train'].get_nearest_examples('embeddings', prompt,k=number_to_retrieve)
60
  return retrieved_examples
61
  # plt.figure(figsize=(15, 15))
 
19
  #Open the precomputed embeddings
20
  #emb_filename = 'unsplash-25k-photos-embeddings.pkl'
21
  ds_with_embeddings = load_dataset("kvriza8/image-embeddings", use_auth_token=True)
22
+
23
  # img_names, img_emb = ds_with_embeddings['train']['image'], ds_with_embeddings['train']['embeddings']
24
  # with open(emb_filename, 'rb') as fIn:
25
  # img_names, img_emb = pickle.load(fIn)
 
56
 
57
  def get_image_from_text(text_prompt, number_to_retrieve=6):
58
  prompt = model.encode(text_prompt)
59
+ ds_with_embeddings['train'].add_faiss_index(column='embeddings')
60
  scores, retrieved_examples = ds_with_embeddings['train'].get_nearest_examples('embeddings', prompt,k=number_to_retrieve)
61
  return retrieved_examples
62
  # plt.figure(figsize=(15, 15))