File size: 1,154 Bytes
1932c5d
 
 
 
 
 
 
 
 
 
8eb9e4f
1932c5d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from dotenv import load_dotenv

load_dotenv()
import streamlit as st
import os
# from PIL import Image
import PIL.Image

import google.generativeai as genai

# genai.configure(api_key=secrets("gkey"))

model = genai.GenerativeModel('gemini-pro-vision')

def get_gemini_response(prompt,img,input):
    # input,img,prompt
    response=model.generate_content([prompt,img,input])
    return response.text

st.set_page_config(page_title='Gemini Multlanguage Invoice Extractor')
st.header('Gemini LLm Application')
input=st.text_input("Input :",key='input')
imgupload=st.file_uploader('Choose Invoice File',type=['jpg','jpeg','png'])

img=""
if imgupload is not None:
    img=PIL.Image.open(imgupload)
    st.image(img,caption='Uploaded Image',use_column_width=True)
else:
   
    st.write("Please upload an image file.")

submit=st.button('Query Invoice')

input_prompt="""
You are an expert in understanding invoices.We will upload a 
image as invoice and you will answer any questions based on the uploaded invoice.
"""
if submit:
        response=get_gemini_response(input_prompt,img,input)
        st.subheader('Response is :')
        st.write(response)