hsienchen commited on
Commit
6b2e788
1 Parent(s): 1dd1da1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -10,6 +10,9 @@ import pathlib
10
  txt_model = genai.GenerativeModel('gemini-pro')
11
  vis_model = genai.GenerativeModel('gemini-pro-vision')
12
 
 
 
 
13
  import os
14
 
15
  GOOGLE_API_KEY=os.getenv('GOOGLE_API_KEY')
@@ -46,19 +49,19 @@ def llm_response(history,text,img):
46
  return history
47
 
48
  # Function that takes User Inputs and displays it on ChatUI
49
- text_box_01 = "what is in the image"
50
  def output_query_message(img):
51
  if not img:
52
- return text_box_01
53
  base64 = image_to_base64(img)
54
  data_url = f"data:image/jpeg;base64,{base64}"
55
- outputText = [(f"{text_box_01} ![]({data_url})", None)]
56
  return outputText
57
 
58
  # Function that takes User Inputs, generates Response and displays on Chat UI
59
  def output_llm_response(img):
60
  if not img:
61
- response = txt_model.generate_content(text_box_01)
62
  return response.text
63
 
64
  else:
 
10
  txt_model = genai.GenerativeModel('gemini-pro')
11
  vis_model = genai.GenerativeModel('gemini-pro-vision')
12
 
13
+ txt_prompt_1 = 'The image contains two sample images, A and B. The first image (A) contains a lens, an anti-static strap, an Adrucam board, and a Raspberry Pi board. Which is missing on Image B?'
14
+ txt_display_1 = 'What are missing on B?'
15
+
16
  import os
17
 
18
  GOOGLE_API_KEY=os.getenv('GOOGLE_API_KEY')
 
49
  return history
50
 
51
  # Function that takes User Inputs and displays it on ChatUI
52
+
53
  def output_query_message(img):
54
  if not img:
55
+ return txt_prompt_1
56
  base64 = image_to_base64(img)
57
  data_url = f"data:image/jpeg;base64,{base64}"
58
+ outputText = [(f"{txt_display_1} ![]({data_url})", None)]
59
  return outputText
60
 
61
  # Function that takes User Inputs, generates Response and displays on Chat UI
62
  def output_llm_response(img):
63
  if not img:
64
+ response = txt_model.generate_content(txt_prompt_1)
65
  return response.text
66
 
67
  else: