Commit
·
a4590c9
1
Parent(s):
303c403
Fix Search Refresh Latency in Gradio Interface
Browse filesSigned-off-by: Snehil Shah <[email protected]>
app.py
CHANGED
@@ -21,7 +21,10 @@ def search_images(modality, count, input_text, input_image):
|
|
21 |
limit = count
|
22 |
)
|
23 |
|
24 |
-
return [gr.update(value="## Results")]+[gr.
|
|
|
|
|
|
|
25 |
|
26 |
def input_interface(choice):
|
27 |
if choice == "Text":
|
@@ -30,7 +33,7 @@ def input_interface(choice):
|
|
30 |
return [gr.update(visible=False), gr.update(visible=True)]
|
31 |
|
32 |
with gr.Blocks() as interface:
|
33 |
-
gr.Markdown("# Multi-Modal Image Search Engine\nSemantically search over 15k images using text or image inputs
|
34 |
|
35 |
# Input Interface
|
36 |
with gr.Column(variant='compact'):
|
@@ -54,6 +57,6 @@ with gr.Blocks() as interface:
|
|
54 |
with gr.Row():
|
55 |
for j in range(4):
|
56 |
images.append(gr.Image(visible=False))
|
57 |
-
images_btn.click(search_images, inputs=[input_type, count, text_input, image_input], outputs=images)
|
58 |
|
59 |
interface.launch()
|
|
|
21 |
limit = count
|
22 |
)
|
23 |
|
24 |
+
return [gr.update(value="## Results\nThe image data is limited, don't expect to find everything!")]+[gr.Image(value=result.payload['url'], visible=True) for result in results]+[gr.Image(visible=False)]*(100-count)
|
25 |
+
|
26 |
+
def clear():
|
27 |
+
return [gr.update(value="")]+[gr.Image(visible=False)]*100
|
28 |
|
29 |
def input_interface(choice):
|
30 |
if choice == "Text":
|
|
|
33 |
return [gr.update(visible=False), gr.update(visible=True)]
|
34 |
|
35 |
with gr.Blocks() as interface:
|
36 |
+
gr.Markdown("# Multi-Modal Image Search Engine\nSemantically search over 15k images using text or image inputs!")
|
37 |
|
38 |
# Input Interface
|
39 |
with gr.Column(variant='compact'):
|
|
|
57 |
with gr.Row():
|
58 |
for j in range(4):
|
59 |
images.append(gr.Image(visible=False))
|
60 |
+
images_btn.click(clear, outputs=images).then(search_images, inputs=[input_type, count, text_input, image_input], outputs=images)
|
61 |
|
62 |
interface.launch()
|