Update app.py
Browse files
app.py
CHANGED
@@ -195,19 +195,20 @@ with gr.Blocks(title="Animal Classifier", css=css) as demo:
|
|
195 |
elem_classes=["centered-examples"]
|
196 |
)
|
197 |
|
198 |
-
# Handle image selection from examples
|
199 |
def select_example(evt: gr.SelectData):
|
200 |
-
|
|
|
201 |
|
202 |
examples_gallery.select(
|
203 |
fn=select_example,
|
204 |
-
outputs=[image_preview, current_image],
|
205 |
show_progress=False
|
206 |
)
|
207 |
-
|
208 |
-
#
|
209 |
upload_btn.upload(
|
210 |
-
fn=lambda file: (file.name, file.name),
|
211 |
inputs=upload_btn,
|
212 |
outputs=[image_preview, current_image]
|
213 |
)
|
|
|
195 |
elem_classes=["centered-examples"]
|
196 |
)
|
197 |
|
198 |
+
# Handle image selection from examples - FIXED OUTPUTS
|
199 |
def select_example(evt: gr.SelectData):
|
200 |
+
selected_path = example_images[evt.index]
|
201 |
+
return selected_path, selected_path # Return both image preview and state
|
202 |
|
203 |
examples_gallery.select(
|
204 |
fn=select_example,
|
205 |
+
outputs=[image_preview, current_image], # Match both components
|
206 |
show_progress=False
|
207 |
)
|
208 |
+
|
209 |
+
# Fix upload handler too
|
210 |
upload_btn.upload(
|
211 |
+
fn=lambda file: (file.name, file.name), # Return both preview and state
|
212 |
inputs=upload_btn,
|
213 |
outputs=[image_preview, current_image]
|
214 |
)
|