Spaces:
Running
Running
gyanbardhan123
commited on
Commit
•
6a2f0ce
1
Parent(s):
d56d87b
Update Image_QA_Gemini.py
Browse files- Image_QA_Gemini.py +29 -29
Image_QA_Gemini.py
CHANGED
@@ -1,30 +1,30 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
from dotenv import load_dotenv
|
3 |
-
load_dotenv()
|
4 |
-
import os
|
5 |
-
from PIL import Image
|
6 |
-
import google.generativeai as genai
|
7 |
-
|
8 |
-
os.getenv("GOOGLE_API_KEY")
|
9 |
-
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
10 |
-
def show():
|
11 |
-
st.header("Image QA")
|
12 |
-
input=st.text_input("Input Prompt: ",key="input")
|
13 |
-
file=st.file_uploader("Chose an image...",type=["jpg","jpeg","png"])
|
14 |
-
image=""
|
15 |
-
if file is not None:
|
16 |
-
image=Image.open(file)
|
17 |
-
st.image(image)
|
18 |
-
|
19 |
-
submit=st.button("Submit")
|
20 |
-
|
21 |
-
if submit:
|
22 |
-
model=genai.GenerativeModel('gemini-
|
23 |
-
st.subheader("The Response is")
|
24 |
-
if input!="":
|
25 |
-
response=model.generate_content([input,image])
|
26 |
-
st.write(response.text)
|
27 |
-
|
28 |
-
else:
|
29 |
-
response=model.generate_content(image)
|
30 |
st.write(response.text)
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from dotenv import load_dotenv
|
3 |
+
load_dotenv()
|
4 |
+
import os
|
5 |
+
from PIL import Image
|
6 |
+
import google.generativeai as genai
|
7 |
+
|
8 |
+
os.getenv("GOOGLE_API_KEY")
|
9 |
+
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
10 |
+
def show():
|
11 |
+
st.header("Image QA")
|
12 |
+
input=st.text_input("Input Prompt: ",key="input")
|
13 |
+
file=st.file_uploader("Chose an image...",type=["jpg","jpeg","png"])
|
14 |
+
image=""
|
15 |
+
if file is not None:
|
16 |
+
image=Image.open(file)
|
17 |
+
st.image(image)
|
18 |
+
|
19 |
+
submit=st.button("Submit")
|
20 |
+
|
21 |
+
if submit:
|
22 |
+
model=genai.GenerativeModel('gemini-1.5-flash')
|
23 |
+
st.subheader("The Response is")
|
24 |
+
if input!="":
|
25 |
+
response=model.generate_content([input,image])
|
26 |
+
st.write(response.text)
|
27 |
+
|
28 |
+
else:
|
29 |
+
response=model.generate_content(image)
|
30 |
st.write(response.text)
|