gzomer commited on
Commit
953b27b
·
1 Parent(s): d06d290

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -1,9 +1,19 @@
1
  from clip_multilingual.search import MultiLingualSearch
2
 
3
- #images_embeddings = np.load('/path/to/images_embeddings')
4
- #images_data = [...] # List of image info for each row of the embeddings. For instance, it could be a list of urls, filepaths, ids. They will be returned when calling the search function
 
 
 
 
 
 
 
 
 
 
5
 
6
- model = None
7
- semantic_search = MultiLingualSearch(model, images_embeddings, images_data)
8
 
9
  results = semantic_search.search('people smiling')
 
 
1
  from clip_multilingual.search import MultiLingualSearch
2
 
3
+ @st.cache(
4
+ suppress_st_warning=True,
5
+ hash_funcs={
6
+ Tokenizer: lambda _: None
7
+ }
8
+ )
9
+ def load_model():
10
+ unsplash_base_folder = './'
11
+ all_embeddings = np.load(f'{unsplash_base_folder}/embeddings.npy')
12
+ with open(f'{unsplash_base_folder}/urls.json') as f:
13
+ all_urls = json.load(f)
14
+ return MultiLingualSearch(all_embeddings, all_urls)
15
 
16
+ semantic_search = load_model()
 
17
 
18
  results = semantic_search.search('people smiling')
19
+ print(result)