Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -76,15 +76,24 @@ def response(message, history):
|
|
76 |
text_prompt = message["text"]
|
77 |
files = message["files"]
|
78 |
|
79 |
-
#
|
80 |
-
image_prompts = [
|
81 |
if files:
|
82 |
for file in files:
|
83 |
image = Image.open(file).convert('RGB')
|
84 |
image_preview = preprocess_image(image)
|
85 |
if image_preview:
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
# Combinar texto e imágenes para el modelo
|
90 |
prompts = [text_prompt] + image_prompts
|
|
|
76 |
text_prompt = message["text"]
|
77 |
files = message["files"]
|
78 |
|
79 |
+
# Procesar imágenes cargadas
|
80 |
+
image_prompts = []
|
81 |
if files:
|
82 |
for file in files:
|
83 |
image = Image.open(file).convert('RGB')
|
84 |
image_preview = preprocess_image(image)
|
85 |
if image_preview:
|
86 |
+
# Guardar la imagen y obtener la ruta
|
87 |
+
image_path = cache_pil_image(image)
|
88 |
+
# Leer la imagen en formato binario para enviarla como Blob
|
89 |
+
with open(image_path, "rb") as img_file:
|
90 |
+
img_data = img_file.read()
|
91 |
+
# Crear un diccionario con los datos binarios y su tipo MIME
|
92 |
+
image_prompt = {
|
93 |
+
"mime_type": "image/jpeg",
|
94 |
+
"data": img_data
|
95 |
+
}
|
96 |
+
image_prompts.append(image_prompt)
|
97 |
|
98 |
# Combinar texto e imágenes para el modelo
|
99 |
prompts = [text_prompt] + image_prompts
|