Spaces:
Runtime error
Runtime error
Commit
·
2dff389
1
Parent(s):
b31c0c9
Update app.py
Browse files
app.py
CHANGED
@@ -41,7 +41,7 @@ def compute_text_embeddings(list_of_strings):
|
|
41 |
|
42 |
def download_img(path):
|
43 |
img_data = requests.get(path).content
|
44 |
-
local_path = path.split("/")[-1]
|
45 |
with open(local_path, 'wb') as handler:
|
46 |
handler.write(img_data)
|
47 |
return local_path
|
@@ -58,9 +58,10 @@ def predict(im):
|
|
58 |
n_results=3
|
59 |
text_embeddings = compute_text_embeddings([query]).detach().numpy()
|
60 |
results = np.argsort((embeddings@text_embeddings.T)[:, 0])[-1:-n_results-1:-1]
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
64 |
|
65 |
title = "Draw to Search"
|
66 |
iface = gr.Interface(
|
|
|
41 |
|
42 |
def download_img(path):
|
43 |
img_data = requests.get(path).content
|
44 |
+
local_path = path.split("/")[-1]
|
45 |
with open(local_path, 'wb') as handler:
|
46 |
handler.write(img_data)
|
47 |
return local_path
|
|
|
58 |
n_results=3
|
59 |
text_embeddings = compute_text_embeddings([query]).detach().numpy()
|
60 |
results = np.argsort((embeddings@text_embeddings.T)[:, 0])[-1:-n_results-1:-1]
|
61 |
+
outputs = [download_img(df.iloc[i]['path']) for i in results]
|
62 |
+
outputs.insert(0, {LABELS[i]: v.item() for i, v in zip(indices, values)})
|
63 |
+
print(outputs)
|
64 |
+
return outputs
|
65 |
|
66 |
title = "Draw to Search"
|
67 |
iface = gr.Interface(
|