Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -75,23 +75,26 @@ def find_top_images(text_query):
|
|
| 75 |
|
| 76 |
return all_results
|
| 77 |
|
| 78 |
-
def
|
| 79 |
# Return the larger image when clicked
|
| 80 |
-
return gr.Image.update(value=image_url,
|
| 81 |
|
| 82 |
# Gradio interface setup
|
| 83 |
with gr.Blocks() as demo:
|
| 84 |
gr.Markdown("Query Results using OpenAI CLIP (openai/clip-vit-large-patch14-336)")
|
| 85 |
text_input = gr.Textbox(label="Enter your text query")
|
| 86 |
|
|
|
|
|
|
|
|
|
|
| 87 |
# Output row for the model
|
| 88 |
image_elements = []
|
| 89 |
with gr.Row():
|
| 90 |
for i in range(5):
|
| 91 |
image = gr.Image(label=f"Image {i+1}", width=200, height=200)
|
| 92 |
image_elements.append(image)
|
| 93 |
-
# Add the on-click event to zoom the image
|
| 94 |
-
image.
|
| 95 |
|
| 96 |
text_input.submit(
|
| 97 |
fn=find_top_images,
|
|
@@ -99,4 +102,4 @@ with gr.Blocks() as demo:
|
|
| 99 |
outputs=image_elements
|
| 100 |
)
|
| 101 |
|
| 102 |
-
demo.launch()
|
|
|
|
| 75 |
|
| 76 |
return all_results
|
| 77 |
|
| 78 |
+
def enlarge_image(image_url):
|
| 79 |
# Return the larger image when clicked
|
| 80 |
+
return gr.Image.update(value=image_url, interactive=False, visible=True, width=600, height=600)
|
| 81 |
|
| 82 |
# Gradio interface setup
|
| 83 |
with gr.Blocks() as demo:
|
| 84 |
gr.Markdown("Query Results using OpenAI CLIP (openai/clip-vit-large-patch14-336)")
|
| 85 |
text_input = gr.Textbox(label="Enter your text query")
|
| 86 |
|
| 87 |
+
with gr.Row():
|
| 88 |
+
image_output = gr.Image(label="Enlarged Image", visible=False, width=600, height=600)
|
| 89 |
+
|
| 90 |
# Output row for the model
|
| 91 |
image_elements = []
|
| 92 |
with gr.Row():
|
| 93 |
for i in range(5):
|
| 94 |
image = gr.Image(label=f"Image {i+1}", width=200, height=200)
|
| 95 |
image_elements.append(image)
|
| 96 |
+
# Add the on-click event to zoom the image by passing the image URL to the enlarge_image function
|
| 97 |
+
image.select(fn=enlarge_image, inputs=image, outputs=image_output)
|
| 98 |
|
| 99 |
text_input.submit(
|
| 100 |
fn=find_top_images,
|
|
|
|
| 102 |
outputs=image_elements
|
| 103 |
)
|
| 104 |
|
| 105 |
+
demo.launch()
|