eybro commited on
Commit
2157496
·
verified ·
1 Parent(s): 6e845d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -10
app.py CHANGED
@@ -130,33 +130,43 @@ def load_example(example_name):
130
  if image_path:
131
  return Image.open(image_path)
132
  return None
133
-
134
  with gr.Blocks() as demo:
135
- gr.Markdown(
136
- """
137
  # Image to Video App
138
  Find your favorite Gordon Ramasay scene by uploading an image from the scene, the app will thereafter find a corresponding youtube video for that scene.
139
  Or try one of our examples (unseen data for the model).
140
- """
141
- )
142
  with gr.Row():
143
  with gr.Column():
144
  inp_image = gr.Image(label="Upload Image", type="pil")
145
  example_selection = gr.Radio(
146
- choices=list(example_images.values()),
147
  label="Select Example Image",
148
- type="value"
149
  )
150
- with gr.Column():
151
- output = gr.Markdown()
 
 
152
 
 
 
 
 
 
 
 
 
153
  submit_button = gr.Button("Submit")
154
 
 
155
  submit_button.click(
156
  lambda user_image, selected_example: inference(user_image=user_image, selected_example=selected_example),
157
  inputs=[inp_image, example_selection],
158
  outputs=output
159
  )
160
-
161
  if __name__ == "__main__":
162
  demo.launch()
 
130
  if image_path:
131
  return Image.open(image_path)
132
  return None
133
+
134
  with gr.Blocks() as demo:
135
+ gr.Markdown("""
 
136
  # Image to Video App
137
  Find your favorite Gordon Ramasay scene by uploading an image from the scene, the app will thereafter find a corresponding youtube video for that scene.
138
  Or try one of our examples (unseen data for the model).
139
+ """)
140
+
141
  with gr.Row():
142
  with gr.Column():
143
  inp_image = gr.Image(label="Upload Image", type="pil")
144
  example_selection = gr.Radio(
145
+ choices=list(example_images.keys()),
146
  label="Select Example Image",
147
+ type="value" # Ensure single string return value
148
  )
149
+ example_display = gr.Image(label="Selected Example Image", type="pil")
150
+
151
+ with gr.Column():
152
+ output = gr.Markdown()
153
 
154
+ # Update the example image when an example is selected
155
+ example_selection.change(
156
+ lambda selected_example: load_example(selected_example),
157
+ inputs=[example_selection],
158
+ outputs=[example_display]
159
+ )
160
+
161
+ # Submit button to trigger inference
162
  submit_button = gr.Button("Submit")
163
 
164
+ # Handle submit button click
165
  submit_button.click(
166
  lambda user_image, selected_example: inference(user_image=user_image, selected_example=selected_example),
167
  inputs=[inp_image, example_selection],
168
  outputs=output
169
  )
170
+
171
  if __name__ == "__main__":
172
  demo.launch()