Himanshu2003's picture
Create app.py
80db93d verified
raw
history blame
952 Bytes
import streamlit as st
from PIL import Image
from dotenv import load_dotenv
import google.generativeai as genai
import os
load_dotenv()
genai.configure(api_key= os.getenv("GOOGLE_API_KEY"))
model = genai.GenerativeModel("gemini-1.5-flash")
def get_gemini_response(image, input=""):
if input == "":
response = model.generate_content(image)
else:
response = model.generate_content([input, image])
return response.text
st.set_page_config(page_title="Image Recognition QnA Chatbot")
st.header("🌟 PixelWhiz: See the Unseen 🌟")
input = st.text_input("Input: ", key="input")
file = st.file_uploader("Choose an image...", type=['jpeg', 'jpg', 'png'])
if file is not None:
image = Image.open(file)
st.image(image)
submit = st.button("SUBMIT")
if submit and image is not None:
response = get_gemini_response([image, input])
st.subheader("The Response is")
st.write(response)