pratikshahp commited on
Commit
f37f3c5
·
verified ·
1 Parent(s): 8cb5883

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -13,11 +13,12 @@ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
13
  # Function to process the image and get response from Gemini model
14
  def get_gemini_response(input_prompt, uploaded_file, query):
15
  try:
16
- # Load the image file as bytes
17
  if uploaded_file is None:
18
  return "Please upload an image."
19
- bytes_data = uploaded_file.read()
20
- image_parts = [{"mime_type": uploaded_file.type, "data": bytes_data}]
 
21
 
22
  # Load the Gemini model and get the response
23
  model = genai.GenerativeModel("gemini-pro-vision")
@@ -43,7 +44,7 @@ with gr.Blocks() as invoice_extractor:
43
  )
44
 
45
  input_prompt = gr.Textbox(label="Input Prompt", value=default_prompt, lines=3)
46
- image_input = gr.Image(label="Upload Invoice Image", type="numpy")
47
  query_input = gr.Textbox(label="Enter your query about the invoice", placeholder="e.g., What is the total amount?")
48
  output_response = gr.Textbox(label="Response", lines=5)
49
 
 
13
  # Function to process the image and get response from Gemini model
14
  def get_gemini_response(input_prompt, uploaded_file, query):
15
  try:
16
+ # Check if the image is provided
17
  if uploaded_file is None:
18
  return "Please upload an image."
19
+
20
+ # Prepare the image as bytes
21
+ image_parts = [{"mime_type": "image/png", "data": uploaded_file}]
22
 
23
  # Load the Gemini model and get the response
24
  model = genai.GenerativeModel("gemini-pro-vision")
 
44
  )
45
 
46
  input_prompt = gr.Textbox(label="Input Prompt", value=default_prompt, lines=3)
47
+ image_input = gr.Image(label="Upload Invoice Image", type="binary")
48
  query_input = gr.Textbox(label="Enter your query about the invoice", placeholder="e.g., What is the total amount?")
49
  output_response = gr.Textbox(label="Response", lines=5)
50