DA1212 commited on
Commit
262eea6
·
verified ·
1 Parent(s): 8d15a00

Delete MULITLUINGAL TEXT EXTRACTOR.py

Browse files
Files changed (1) hide show
  1. MULITLUINGAL TEXT EXTRACTOR.py +0 -68
MULITLUINGAL TEXT EXTRACTOR.py DELETED
@@ -1,68 +0,0 @@
1
- from dotenv import load_dotenv
2
-
3
- load_dotenv()
4
- import pathlib
5
- import textwrap
6
- import streamlit as st
7
- import os
8
- from PIL import Image
9
- import google.generativeai as genai
10
-
11
- os.getenv("GOOGLE_API_KEY")
12
- genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
13
-
14
-
15
- #input means what to do by this app which is the input prompt and is general
16
- #prompt means what it wants at that point of time
17
- #image means what image we want to apply
18
- #this function gives the response from the model
19
- def get_gemini_response(input,image,prompt):
20
- model=genai.GenerativeModel('gemini-pro-vision')
21
- response=model.generate_content([input,image[0],prompt])
22
- return response.text
23
-
24
-
25
- #load the image and convert the image in bytes
26
- def input_image_setup(uploaded_file):
27
- if uploaded_file is not None:
28
- # Read the file into bytes
29
- bytes_data = uploaded_file.getvalue()
30
-
31
- image_parts = [
32
- {
33
- "mime_type": uploaded_file.type,
34
- "data": bytes_data
35
- }
36
- ]
37
- return image_parts
38
- else:
39
- raise FileNotFoundError("No file uploaded")
40
-
41
-
42
- st.set_page_config(page_title="Mulitlanguage Invoice Extractor")
43
-
44
- st.header("Mulitlanguage Invoice Extractor")
45
- input=st.text_input("Input Prompt: ",key="input")
46
- uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
47
- image=""
48
- if uploaded_file is not None:
49
- image = Image.open(uploaded_file)
50
- st.image(image, caption="Uploaded Image.", use_column_width=True)
51
-
52
-
53
- submit=st.button("Tell me about the image")
54
-
55
-
56
- input_prompt = """
57
- You are an expert in understanding invoices.
58
- You will receive input images as invoices &
59
- you will have to answer questions based on the input image
60
- """
61
-
62
-
63
-
64
- if submit:
65
- image_data=input_image_setup(uploaded_file) #get the image data
66
- response=get_gemini_response(input_prompt,image_data,input)
67
- st.subheader("The response is")
68
- st.write(response)