import streamlit as st | |
import google.generativeai as genai | |
genai.configure(api_key="AIzaSyDM1ZP6Tvmg_RSOwk0RIvz-noUDlUxR8Fc") | |
from PIL import Image | |
def get_response(inp,img): | |
model=genai.GenerativeModel('gemini-pro-vision') | |
if(inp!=""): | |
response=model.generate_content([inp,img]) | |
else: | |
response=model.generate_content(image) | |
return response.text | |
st.header("Project") | |
inpu=st.text_input("Enter your input:",key='input') | |
upf=st.file_uploader("Drag your image ",type=['jpeg','jpg','png']) | |
if(upf is not None): | |
image=Image.open(upf) | |
st.image(image,caption='uploaded image',use_column_width=True) | |
submit=st.button("Ask") | |
if(submit): | |
resp=get_response(img=image,inp=inpu) | |
st.write(resp) |