from turtle import up from dotenv import load_dotenv import streamlit as st import os from PIL import Image import google.generativeai as genai load_dotenv() genai.configure(api_key = os.getenv('GOOGLE_API_KEY')) model = genai.GenerativeModel('gemini-pro-vision') def get_response(input, image, prompt): response = model.generate_content([input, image[0], prompt]) return response.parts def input_image_setup(image): if image is not None: data = image.getvalue() image_data = [ { "mime_type": image.type, "data": data } ] return image_data else: raise FileNotFoundError("NO FILE UPLOADED.") st.set_page_config('Invoice Extractor') st.header('Gemini Application') prompt = st.text_input("Enter Prompt : " , key='prompt_input') input = st.text_input("what do you want to know : " , key='user_input') uploaded_file = st.file_uploader("Choose an image " , type=["jpg", "jpeg", "png"]) image = "" if uploaded_file is not None: image = Image.open(uploaded_file) st.image(image, use_column_width=True) submit = st.button("Tell me about the image") if submit: image_data = input_image_setup(uploaded_file) response = get_response(input=input, image=image_data, prompt=prompt) st.subheader("The response is : ") st.write(response) # You are an expert food analyst # List all food items shown in image # You are an invoice extractor # what is total amount