Spaces:
Sleeping
Sleeping
riabayonaor
commited on
Commit
•
b673df1
1
Parent(s):
add943c
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import google.generativeai as genai
|
3 |
import os
|
4 |
-
from PIL import Image
|
5 |
import io
|
|
|
|
|
|
|
6 |
|
7 |
# Configuración de la API
|
8 |
gemini_api_key = os.getenv("GEMINI_API_KEY")
|
@@ -14,10 +14,15 @@ else:
|
|
14 |
|
15 |
def identify_object(image_bytes):
|
16 |
try:
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
21 |
return response
|
22 |
except Exception as e:
|
23 |
st.error(f"Error al identificar la imagen: {e}")
|
|
|
|
|
|
|
1 |
import os
|
|
|
2 |
import io
|
3 |
+
import google.generativeai as genai
|
4 |
+
from PIL import Image
|
5 |
+
import streamlit as st
|
6 |
|
7 |
# Configuración de la API
|
8 |
gemini_api_key = os.getenv("GEMINI_API_KEY")
|
|
|
14 |
|
15 |
def identify_object(image_bytes):
|
16 |
try:
|
17 |
+
image_data = {
|
18 |
+
"mime_type": "image/jpeg",
|
19 |
+
"data": image_bytes
|
20 |
+
}
|
21 |
+
content = [
|
22 |
+
{"image_blob": image_data},
|
23 |
+
{"text": "What is in this image?"}
|
24 |
+
]
|
25 |
+
response = model.generate_content({"content": content})
|
26 |
return response
|
27 |
except Exception as e:
|
28 |
st.error(f"Error al identificar la imagen: {e}")
|