Spaces:
Runtime error
Runtime error
step 6
Browse files
app.py
CHANGED
@@ -38,24 +38,24 @@ def encode_image(image):
|
|
38 |
inputs = processor(images=[image], return_tensors="pt", padding=True, truncation=True)
|
39 |
return inputs
|
40 |
|
41 |
-
def
|
42 |
-
if
|
43 |
-
image = preprocess_image(
|
44 |
-
|
|
|
|
|
45 |
output_html = generate_output_html(top_3_products)
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
def send_message(chatbot, txt):
|
50 |
-
bot(chatbot, txt)
|
51 |
|
52 |
chatbot = gr.Chatbot([]).style(height=750)
|
53 |
txt = gr.Textbox(placeholder="Enter text and press enter, or upload an image", show_label=False)
|
54 |
-
btn = gr.UploadButton("
|
55 |
-
send_btn = gr.Button("Send",
|
56 |
|
57 |
with gr.Blocks() as demo:
|
58 |
chatbot
|
59 |
gr.Row(txt, btn, send_btn)
|
60 |
|
61 |
demo.launch()
|
|
|
|
38 |
inputs = processor(images=[image], return_tensors="pt", padding=True, truncation=True)
|
39 |
return inputs
|
40 |
|
41 |
+
def send_message(chatbot, txt, btn):
|
42 |
+
if btn is not None:
|
43 |
+
image = preprocess_image(btn)
|
44 |
+
else:
|
45 |
+
image = None
|
46 |
+
top_3_products = initial_query(image, txt)
|
47 |
output_html = generate_output_html(top_3_products)
|
48 |
+
chatbot.append_message("You", txt)
|
49 |
+
chatbot.append_message("AI", output_html)
|
|
|
|
|
|
|
50 |
|
51 |
chatbot = gr.Chatbot([]).style(height=750)
|
52 |
txt = gr.Textbox(placeholder="Enter text and press enter, or upload an image", show_label=False)
|
53 |
+
btn = gr.UploadButton("๐ธ", file_types=["image", "video", "audio"])
|
54 |
+
send_btn = gr.Button("Send", action=send_message)
|
55 |
|
56 |
with gr.Blocks() as demo:
|
57 |
chatbot
|
58 |
gr.Row(txt, btn, send_btn)
|
59 |
|
60 |
demo.launch()
|
61 |
+
|