Spaces:
Sleeping
Sleeping
sandrocalzada
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -60,29 +60,28 @@ def get_selected_image(image_name):
|
|
60 |
return load_image(preloaded_images[image_name])
|
61 |
|
62 |
# Define Gradio interface
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
).launch()
|
|
|
60 |
return load_image(preloaded_images[image_name])
|
61 |
|
62 |
# Define Gradio interface
|
63 |
+
with gr.Blocks() as app:
|
64 |
+
image_selector = gr.Radio(
|
65 |
+
choices=list(preloaded_images.keys()),
|
66 |
+
label="Selecciona una imagen"
|
67 |
+
)
|
68 |
+
|
69 |
+
image_display = gr.Image(label="Imagen", type="pil")
|
70 |
+
|
71 |
+
def update_image(selected_image_name):
|
72 |
+
image_data = get_selected_image(selected_image_name)
|
73 |
+
return gr.Image.update(value=PIL.Image.open(io.BytesIO(image_data)))
|
74 |
+
|
75 |
+
image_selector.change(fn=update_image, inputs=image_selector, outputs=image_display)
|
76 |
+
|
77 |
+
interface = gr.Interface(
|
78 |
+
fn=ImageChat,
|
79 |
+
inputs=image_display,
|
80 |
+
outputs=gr.Dataframe(headers=["Pregunta", "Respuesta"], label="Resultados"),
|
81 |
+
title="Análisis de Imagen",
|
82 |
+
theme="Taithrah/Minimal"
|
83 |
+
)
|
84 |
+
|
85 |
+
interface.launch()
|
86 |
+
|
87 |
+
app.launch()
|
|