Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,27 +1,31 @@
|
|
1 |
import streamlit as st
|
2 |
import google.generativeai as genAi
|
3 |
from PIL import Image
|
4 |
-
|
5 |
-
genAi.configure(api_key="AIzaSyBZQmot8_8bDxuGiffJ06woJCzH140Erc4str")
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
11 |
else:
|
12 |
-
|
13 |
-
response=model.generate_content(image)
|
14 |
return response.text
|
15 |
|
|
|
16 |
st.header("PROJECT")
|
17 |
-
|
18 |
-
upload_file=st.file_uploader("Choose
|
19 |
-
image=''
|
|
|
20 |
if upload_file is not None:
|
21 |
-
image=Image.open(upload_file)
|
22 |
-
st.image(image,caption="
|
|
|
|
|
|
|
23 |
|
24 |
-
submit=st.button("ASK")
|
25 |
if submit:
|
26 |
-
response=get_response(
|
27 |
-
st.write(response)
|
|
|
1 |
import streamlit as st
|
2 |
import google.generativeai as genAi
|
3 |
from PIL import Image
|
|
|
|
|
4 |
|
5 |
+
# Configure API key
|
6 |
+
genAi.configure(api_key="AIzaSyBZQmot8_8bDxuGiffJ06woJCzH140Erc4")
|
7 |
+
|
8 |
+
def get_response(inputt, image):
|
9 |
+
model = genAi.GenerativeModel('gemini-pro-vision')
|
10 |
+
if inputt != "":
|
11 |
+
response = model.generate_content([inputt, image])
|
12 |
else:
|
13 |
+
response = model.generate_content(image)
|
|
|
14 |
return response.text
|
15 |
|
16 |
+
# Streamlit app header and user inputs
|
17 |
st.header("PROJECT")
|
18 |
+
inputt = st.text_input("Input Prompt", key='inputt')
|
19 |
+
upload_file = st.file_uploader("Choose your file", type=['jpg', 'jpeg', 'png'])
|
20 |
+
image = ''
|
21 |
+
|
22 |
if upload_file is not None:
|
23 |
+
image = Image.open(upload_file)
|
24 |
+
st.image(image, caption="Uploaded Image", use_column_width=True)
|
25 |
+
|
26 |
+
# Button to trigger content generation
|
27 |
+
submit = st.button("ASK")
|
28 |
|
|
|
29 |
if submit:
|
30 |
+
response = get_response(inputt, image)
|
31 |
+
st.write(response)
|