samnji commited on
Commit
78fd827
Β·
1 Parent(s): 41f1f7d
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -32,13 +32,14 @@ def generate_output_html(top_3_products):
32
  return output_html
33
 
34
  def encode_text(text):
35
- inputs = processor(text, return_tensors="pt", padding=True, truncation=True)
36
  return inputs
37
 
38
  def encode_image(image):
39
- inputs = processor(images=image, return_tensors="pt", padding=True, truncation=True)
40
  return inputs
41
 
 
42
  def initial_query(image, text):
43
  text_inputs = encode_text(text)
44
  image_inputs = encode_image(image)
@@ -76,15 +77,17 @@ with gr.Blocks() as demo:
76
  chatbot = gr.Chatbot([], elem_id="chatbot").style(height=750)
77
 
78
  with gr.Row():
79
- with gr.Column(scale=0.85):
80
  txt = gr.Textbox(
81
  show_label=False,
82
  placeholder="Enter text and press enter, or upload an image",
83
  ).style(container=False)
84
  with gr.Column(scale=0.15, min_width=0):
85
  btn = gr.UploadButton("πŸ“", file_types=["image", "video", "audio"])
 
 
86
 
87
- txt.submit(bot, [chatbot, txt], chatbot)
 
88
  btn.upload(bot, [chatbot, btn], chatbot)
89
-
90
  demo.launch()
 
32
  return output_html
33
 
34
  def encode_text(text):
35
+ inputs = processor(text=[text], return_tensors="pt", padding=True, truncation=True)
36
  return inputs
37
 
38
  def encode_image(image):
39
+ inputs = processor(images=[image], return_tensors="pt", padding=True, truncation=True)
40
  return inputs
41
 
42
+
43
  def initial_query(image, text):
44
  text_inputs = encode_text(text)
45
  image_inputs = encode_image(image)
 
77
  chatbot = gr.Chatbot([], elem_id="chatbot").style(height=750)
78
 
79
  with gr.Row():
80
+ with gr.Column(scale=0.70):
81
  txt = gr.Textbox(
82
  show_label=False,
83
  placeholder="Enter text and press enter, or upload an image",
84
  ).style(container=False)
85
  with gr.Column(scale=0.15, min_width=0):
86
  btn = gr.UploadButton("πŸ“", file_types=["image", "video", "audio"])
87
+ with gr.Column(scale=0.15, min_width=0):
88
+ send_btn = gr.Button("Send")
89
 
90
+ # Set the on_click action for the send_btn
91
+ send_btn.on_click(bot, [chatbot, txt], chatbot)
92
  btn.upload(bot, [chatbot, btn], chatbot)
 
93
  demo.launch()