Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import google.generativeai as genai
|
3 |
+
genai.configure(api_key="AIzaSyDM1ZP6Tvmg_RSOwk0RIvz-noUDlUxR8Fc")
|
4 |
+
from PIL import Image
|
5 |
+
def get_response(inp,img):
|
6 |
+
model=genai.GenerativeModel('gemini-pro-vision')
|
7 |
+
if(inp!=""):
|
8 |
+
response=model.generate_content([inp,img])
|
9 |
+
else:
|
10 |
+
response=model.generate_content(image)
|
11 |
+
return response.text
|
12 |
+
st.header("Project")
|
13 |
+
inpu=st.text_input("Enter your input:",key='input')
|
14 |
+
|
15 |
+
upf=st.file_uploader("Drag your image ",type=['jpeg','jpg','png'])
|
16 |
+
if(upf is not None):
|
17 |
+
image=Image.open(upf)
|
18 |
+
st.image(image,caption='uploaded image',use_column_width=True)
|
19 |
+
submit=st.button("Ask")
|
20 |
+
if(submit):
|
21 |
+
resp=get_response(img=image,inp=inpu)
|
22 |
+
st.write(resp)
|