Spaces:
Runtime error
Runtime error
Commit
·
c3b6f23
1
Parent(s):
53f43bd
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,7 @@ links = np.load('data.npy', allow_pickle=True)
|
|
13 |
|
14 |
|
15 |
def get_html(url_list):
|
16 |
-
html = "<div style='margin-top: 50px; max-width:
|
17 |
for url in url_list:
|
18 |
html2 = f"<img style='height: 200px; margin: 2px' src='{escape(url)}'>"
|
19 |
html = html + html2
|
@@ -21,7 +21,7 @@ def get_html(url_list):
|
|
21 |
return html
|
22 |
|
23 |
|
24 |
-
def image_search(query, top_k=
|
25 |
with torch.no_grad():
|
26 |
text_embedding = text_encoder(**tokenizer(query, return_tensors='pt')).pooler_output
|
27 |
values, indices = torch.cosine_similarity(text_embedding, image_embeddings).sort(descending=True)
|
@@ -32,8 +32,7 @@ description = '''
|
|
32 |
# Persian (fa) image search
|
33 |
- Enter your query and hit enter
|
34 |
|
35 |
-
|
36 |
-
- Made with ❤️ in my basement
|
37 |
'''
|
38 |
|
39 |
|
|
|
13 |
|
14 |
|
15 |
def get_html(url_list):
|
16 |
+
html = "<div style='margin-top: 50px; max-width: 1100px; display: flex; flex-wrap: wrap; justify-content: space-evenly'>"
|
17 |
for url in url_list:
|
18 |
html2 = f"<img style='height: 200px; margin: 2px' src='{escape(url)}'>"
|
19 |
html = html + html2
|
|
|
21 |
return html
|
22 |
|
23 |
|
24 |
+
def image_search(query, top_k=10):
|
25 |
with torch.no_grad():
|
26 |
text_embedding = text_encoder(**tokenizer(query, return_tensors='pt')).pooler_output
|
27 |
values, indices = torch.cosine_similarity(text_embedding, image_embeddings).sort(descending=True)
|
|
|
32 |
# Persian (fa) image search
|
33 |
- Enter your query and hit enter
|
34 |
|
35 |
+
Built with [CLIP-fa](https://github.com/sajjjadayobi/CLIPfa) model and 25k images from Unsplash
|
|
|
36 |
'''
|
37 |
|
38 |
|