Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -83,27 +83,11 @@ def response(message, history):
|
|
83 |
image = Image.open(file).convert('RGB')
|
84 |
image_preview = preprocess_image(image)
|
85 |
if image_preview:
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
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 |
-
# Asegurarse de que el texto y las imágenes estén en el formato correcto
|
99 |
-
prompts = []
|
100 |
-
if text_prompt:
|
101 |
-
prompts.append({"parts": [{"text": text_prompt}], "role": "user"})
|
102 |
-
|
103 |
-
if image_prompts:
|
104 |
-
prompts.extend(image_prompts)
|
105 |
-
|
106 |
-
# Enviar el mensaje al modelo
|
107 |
response = chat.send_message(prompts)
|
108 |
response.resolve()
|
109 |
|
|
|
83 |
image = Image.open(file).convert('RGB')
|
84 |
image_preview = preprocess_image(image)
|
85 |
if image_preview:
|
86 |
+
cache_pil_image(image)
|
87 |
+
image_prompts.append(image_preview) # Incluir en la lista de prompts
|
88 |
+
|
89 |
+
# Combinar texto e imágenes para el modelo
|
90 |
+
prompts = [text_prompt] + image_prompts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
response = chat.send_message(prompts)
|
92 |
response.resolve()
|
93 |
|