Spaces:
Runtime error
Runtime error
Commit
·
d78e5c8
1
Parent(s):
683698a
Update app.py
Browse files
app.py
CHANGED
@@ -39,9 +39,6 @@ for message in chat_history:
|
|
39 |
|
40 |
user_input = st.text_input("")
|
41 |
|
42 |
-
# File uploader for images
|
43 |
-
uploaded_file = st.file_uploader("Upload an image (optional)")
|
44 |
-
|
45 |
if user_input:
|
46 |
chat_history.append({"role": role, "parts": [{"text": user_input}]})
|
47 |
|
@@ -85,7 +82,10 @@ st.title("Image Description Generator")
|
|
85 |
|
86 |
uploaded_file = st.file_uploader("Upload an image here", type=["png", "jpg", "jpeg"])
|
87 |
|
88 |
-
|
|
|
|
|
|
|
89 |
image_parts = [
|
90 |
{
|
91 |
"mime_type": uploaded_file.type,
|
@@ -94,7 +94,7 @@ if uploaded_file:
|
|
94 |
]
|
95 |
|
96 |
prompt_parts = [
|
97 |
-
|
98 |
image_parts[0],
|
99 |
]
|
100 |
|
@@ -105,4 +105,4 @@ if uploaded_file:
|
|
105 |
)
|
106 |
|
107 |
response = model.generate_content(prompt_parts)
|
108 |
-
st.markdown(f"**Model's
|
|
|
39 |
|
40 |
user_input = st.text_input("")
|
41 |
|
|
|
|
|
|
|
42 |
if user_input:
|
43 |
chat_history.append({"role": role, "parts": [{"text": user_input}]})
|
44 |
|
|
|
82 |
|
83 |
uploaded_file = st.file_uploader("Upload an image here", type=["png", "jpg", "jpeg"])
|
84 |
|
85 |
+
# Text input for asking questions about the image
|
86 |
+
image_question = st.text_input("Ask something about the image:")
|
87 |
+
|
88 |
+
if uploaded_file and image_question:
|
89 |
image_parts = [
|
90 |
{
|
91 |
"mime_type": uploaded_file.type,
|
|
|
94 |
]
|
95 |
|
96 |
prompt_parts = [
|
97 |
+
image_question,
|
98 |
image_parts[0],
|
99 |
]
|
100 |
|
|
|
105 |
)
|
106 |
|
107 |
response = model.generate_content(prompt_parts)
|
108 |
+
st.markdown(f"**Model's answer:** {response.text}")
|