Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -97,23 +97,24 @@ def process_input(message, history, selected_option, similarity_threshold, syste
|
|
| 97 |
history.append((message, response))
|
| 98 |
return history, history, image
|
| 99 |
|
| 100 |
-
def update_image(
|
| 101 |
-
|
| 102 |
-
|
| 103 |
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
# Depuraci贸n: Imprimir los resultados
|
| 108 |
-
print("Full Response:", full_response)
|
| 109 |
-
print("Image URL:", image_url)
|
| 110 |
|
|
|
|
|
|
|
|
|
|
| 111 |
if image_url and os.path.exists(image_url):
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
|
|
|
|
|
|
| 117 |
else:
|
| 118 |
print("No se encontr贸 una imagen v谩lida.")
|
| 119 |
return None
|
|
|
|
| 97 |
history.append((message, response))
|
| 98 |
return history, history, image
|
| 99 |
|
| 100 |
+
def update_image(image_url):
|
| 101 |
+
"""
|
| 102 |
+
Retorna los datos de la imagen para ser mostrados en Gradio.
|
| 103 |
|
| 104 |
+
Args:
|
| 105 |
+
image_url (str): Ruta de la imagen.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
+
Returns:
|
| 108 |
+
bytes o None: Datos de la imagen si existe, de lo contrario None.
|
| 109 |
+
"""
|
| 110 |
if image_url and os.path.exists(image_url):
|
| 111 |
+
try:
|
| 112 |
+
with open(image_url, "rb") as img_file:
|
| 113 |
+
image_data = img_file.read()
|
| 114 |
+
return image_data
|
| 115 |
+
except Exception as e:
|
| 116 |
+
print(f"Error al leer la imagen: {e}")
|
| 117 |
+
return None
|
| 118 |
else:
|
| 119 |
print("No se encontr贸 una imagen v谩lida.")
|
| 120 |
return None
|