Spaces:
Running
Running
Upload with huggingface_hub
Browse files- requirements.txt +1 -1
- run.ipynb +1 -1
- run.py +27 -16
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
|
2 |
-
https://gradio-main-build.s3.amazonaws.com/
|
|
|
1 |
|
2 |
+
https://gradio-main-build.s3.amazonaws.com/092b7448e657811ec8c6a041b87314ac8842fb52/gradio-3.20.1-py3-none-any.whl
|
run.ipynb
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: chatbot_multimodal"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "from urllib.parse import quote\n", "\n", "
|
|
|
1 |
+
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: chatbot_multimodal"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "from urllib.parse import quote\n", "\n", "with gr.Blocks() as demo:\n", " chatbot = gr.Chatbot(elem_id=\"chatbot\").style(height=500)\n", "\n", " with gr.Row():\n", " with gr.Column(scale=0.85):\n", " txt = gr.Textbox(\n", " show_label=False,\n", " placeholder=\"Enter text and press enter, or upload an image\",\n", " ).style(container=False)\n", " with gr.Column(scale=0.15, min_width=0):\n", " btn = gr.UploadButton(\"\ud83d\uddbc\ufe0f\", file_types=[\"image\"])\n", "\n", " def add_text(history, text):\n", " history = history + [(text, None)]\n", " return history, \"\"\n", "\n", " def add_image(history, image):\n", " history = history + [(f\"})\", None)]\n", " return history\n", "\n", " def bot_response(history):\n", " response = \"Cool!\"\n", " history[-1][1] = response\n", " return history\n", "\n", " txt.submit(add_text, [chatbot, txt], [chatbot, txt]).then(\n", " bot_response, chatbot, chatbot\n", " )\n", " btn.upload(add_image, [chatbot, btn], [chatbot]).then(\n", " bot_response, chatbot, chatbot\n", " )\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
run.py
CHANGED
@@ -1,26 +1,37 @@
|
|
1 |
import gradio as gr
|
2 |
from urllib.parse import quote
|
3 |
|
4 |
-
def add_text(history, text):
|
5 |
-
history = history + [(text, text + "?")]
|
6 |
-
return history
|
7 |
-
|
8 |
-
def add_image(history, image):
|
9 |
-
history = history + [(f"})", "Cool pic!")]
|
10 |
-
return history
|
11 |
-
|
12 |
with gr.Blocks() as demo:
|
13 |
chatbot = gr.Chatbot(elem_id="chatbot").style(height=500)
|
14 |
-
|
15 |
with gr.Row():
|
16 |
with gr.Column(scale=0.85):
|
17 |
-
txt = gr.Textbox(
|
|
|
|
|
|
|
18 |
with gr.Column(scale=0.15, min_width=0):
|
19 |
btn = gr.UploadButton("🖼️", file_types=["image"])
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
if __name__ == "__main__":
|
26 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from urllib.parse import quote
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
with gr.Blocks() as demo:
|
5 |
chatbot = gr.Chatbot(elem_id="chatbot").style(height=500)
|
6 |
+
|
7 |
with gr.Row():
|
8 |
with gr.Column(scale=0.85):
|
9 |
+
txt = gr.Textbox(
|
10 |
+
show_label=False,
|
11 |
+
placeholder="Enter text and press enter, or upload an image",
|
12 |
+
).style(container=False)
|
13 |
with gr.Column(scale=0.15, min_width=0):
|
14 |
btn = gr.UploadButton("🖼️", file_types=["image"])
|
15 |
+
|
16 |
+
def add_text(history, text):
|
17 |
+
history = history + [(text, None)]
|
18 |
+
return history, ""
|
19 |
+
|
20 |
+
def add_image(history, image):
|
21 |
+
history = history + [(f"})", None)]
|
22 |
+
return history
|
23 |
+
|
24 |
+
def bot_response(history):
|
25 |
+
response = "Cool!"
|
26 |
+
history[-1][1] = response
|
27 |
+
return history
|
28 |
+
|
29 |
+
txt.submit(add_text, [chatbot, txt], [chatbot, txt]).then(
|
30 |
+
bot_response, chatbot, chatbot
|
31 |
+
)
|
32 |
+
btn.upload(add_image, [chatbot, btn], [chatbot]).then(
|
33 |
+
bot_response, chatbot, chatbot
|
34 |
+
)
|
35 |
+
|
36 |
if __name__ == "__main__":
|
37 |
+
demo.launch()
|