Spaces:
Build error
Build error
Commit
·
c35bf48
1
Parent(s):
9d2355f
app.py
Browse files
app.py
CHANGED
@@ -34,7 +34,7 @@ def display_matches(similarity, topk):
|
|
34 |
return best_matched_images
|
35 |
|
36 |
def image_search(Option, topk, search_text, search_image):
|
37 |
-
|
38 |
# Input Text Query
|
39 |
if Option == "Text-To-Image" :
|
40 |
# Encode the given Input text for Search & take it in tensor form
|
@@ -43,7 +43,7 @@ def image_search(Option, topk, search_text, search_image):
|
|
43 |
similarity = util.cos_sim(img_emb, text_emb)
|
44 |
|
45 |
#using the computed similarities, find the topk best matches
|
46 |
-
return display_matches(similarity, topk
|
47 |
elif Option == "Image-To-Image":
|
48 |
# Encode the given Input Image for Search & take it in tensor form
|
49 |
image_emb = model.encode([Image.fromarray(search_image)], convert_to_tensor=True)
|
@@ -51,7 +51,7 @@ def image_search(Option, topk, search_text, search_image):
|
|
51 |
similarity = util.cos_sim(img_emb, image_emb)
|
52 |
|
53 |
#using the computed similarities, find the topk best matches
|
54 |
-
return display_matches(similarity, topk
|
55 |
|
56 |
gr.Interface(fn=image_search, title="Search Image",
|
57 |
description="Enter the text or image to search for the most relevant images...",
|
|
|
34 |
return best_matched_images
|
35 |
|
36 |
def image_search(Option, topk, search_text, search_image):
|
37 |
+
topk = topk+1
|
38 |
# Input Text Query
|
39 |
if Option == "Text-To-Image" :
|
40 |
# Encode the given Input text for Search & take it in tensor form
|
|
|
43 |
similarity = util.cos_sim(img_emb, text_emb)
|
44 |
|
45 |
#using the computed similarities, find the topk best matches
|
46 |
+
return display_matches(similarity, topk)
|
47 |
elif Option == "Image-To-Image":
|
48 |
# Encode the given Input Image for Search & take it in tensor form
|
49 |
image_emb = model.encode([Image.fromarray(search_image)], convert_to_tensor=True)
|
|
|
51 |
similarity = util.cos_sim(img_emb, image_emb)
|
52 |
|
53 |
#using the computed similarities, find the topk best matches
|
54 |
+
return display_matches(similarity, topk)
|
55 |
|
56 |
gr.Interface(fn=image_search, title="Search Image",
|
57 |
description="Enter the text or image to search for the most relevant images...",
|