SebastianRuff commited on
Commit
fc14255
·
verified ·
1 Parent(s): f3ae851

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -75,6 +75,9 @@ def find_top_images(text_query):
75
 
76
  return all_results
77
 
 
 
 
78
  # Gradio interface setup
79
  with gr.Blocks() as demo:
80
  gr.Markdown("Query Results using OpenAI CLIP (openai/clip-vit-large-patch14-336)")
@@ -82,12 +85,18 @@ with gr.Blocks() as demo:
82
 
83
  # Output row for the model
84
  with gr.Row():
85
- outputs = [gr.Image(label=f"{model_name} - Top Image {i+1}", width=200, height=200) for i in range(5)]
 
 
 
 
 
 
86
 
87
  text_input.submit(
88
  fn=find_top_images,
89
  inputs=text_input,
90
- outputs=outputs
91
  )
92
 
93
  demo.launch()
 
75
 
76
  return all_results
77
 
78
+ def enlarge_image(image_url):
79
+ return gr.Image.update(value=image_url, interactive=False, visible=True)
80
+
81
  # Gradio interface setup
82
  with gr.Blocks() as demo:
83
  gr.Markdown("Query Results using OpenAI CLIP (openai/clip-vit-large-patch14-336)")
 
85
 
86
  # Output row for the model
87
  with gr.Row():
88
+ image_elements = []
89
+ for i in range(5):
90
+ with gr.Column():
91
+ image = gr.Image(label=f"Image {i+1}", width=200, height=200)
92
+ image_elements.append(image)
93
+ # Add a button to enlarge the image
94
+ gr.Button(f"Enlarge Image {i+1}").click(fn=enlarge_image, inputs=image, outputs=image)
95
 
96
  text_input.submit(
97
  fn=find_top_images,
98
  inputs=text_input,
99
+ outputs=image_elements
100
  )
101
 
102
  demo.launch()