gradio-pr-bot commited on
Commit
ef9f694
1 Parent(s): f6bf0dc

Upload folder using huggingface_hub

Browse files
README.md CHANGED
@@ -5,7 +5,7 @@ emoji: 💩
5
  colorFrom: indigo
6
  colorTo: indigo
7
  sdk: gradio
8
- sdk_version: 4.21.0
9
  app_file: app.py
10
  pinned: false
11
  ---
 
5
  colorFrom: indigo
6
  colorTo: indigo
7
  sdk: gradio
8
+ sdk_version: 4.22.0
9
  app_file: app.py
10
  pinned: false
11
  ---
demos/audio_debugger/run.ipynb CHANGED
@@ -1 +1 @@
1
- {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: audio_debugger"]}, {"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": ["# Downloading files from the demo repo\n", "import os\n", "!wget -q https://github.com/gradio-app/gradio/raw/main/demo/audio_debugger/cantina.wav"]}, {"cell_type": "code", "execution_count": null, "id": "44380577570523278879349135829904343037", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import subprocess\n", "import os\n", "\n", "audio_file = os.path.join(os.path.abspath(''), \"cantina.wav\")\n", "\n", "\n", "with gr.Blocks() as demo:\n", " with gr.Tab(\"Audio\"):\n", " gr.Audio(audio_file)\n", " with gr.Tab(\"Interface\"):\n", " gr.Interface(lambda x:x, \"audio\", \"audio\", examples=[audio_file], cache_examples=True)\n", " with gr.Tab(\"Streaming\"):\n", " gr.Interface(lambda x:x, gr.Audio(streaming=True), \"audio\", examples=[audio_file], cache_examples=True)\n", " with gr.Tab(\"console\"):\n", " ip = gr.Textbox(label=\"User IP Address\")\n", " gr.Interface(lambda cmd:subprocess.run([cmd], capture_output=True, shell=True).stdout.decode('utf-8').strip(), \"text\", \"text\")\n", " \n", " def get_ip(request: gr.Request):\n", " return request.client.host\n", " \n", " demo.load(get_ip, None, ip)\n", " \n", "if __name__ == \"__main__\":\n", " demo.queue()\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
 
1
+ {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: audio_debugger"]}, {"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": ["# Downloading files from the demo repo\n", "import os\n", "!wget -q https://github.com/gradio-app/gradio/raw/main/demo/audio_debugger/cantina.wav"]}, {"cell_type": "code", "execution_count": null, "id": "44380577570523278879349135829904343037", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import subprocess\n", "import os\n", "\n", "audio_file = os.path.join(os.path.abspath(''), \"cantina.wav\")\n", "\n", "\n", "with gr.Blocks() as demo:\n", " with gr.Tab(\"Audio\"):\n", " gr.Audio(audio_file)\n", " with gr.Tab(\"Interface\"):\n", " gr.Interface(\n", " lambda x: x, \"audio\", \"audio\", examples=[audio_file], cache_examples=True\n", " )\n", " with gr.Tab(\"Streaming\"):\n", " gr.Interface(\n", " lambda x: x,\n", " gr.Audio(streaming=True),\n", " \"audio\",\n", " examples=[audio_file],\n", " cache_examples=True,\n", " )\n", " with gr.Tab(\"console\"):\n", " ip = gr.Textbox(label=\"User IP Address\")\n", " gr.Interface(\n", " lambda cmd: subprocess.run([cmd], capture_output=True, shell=True)\n", " .stdout.decode(\"utf-8\")\n", " .strip(),\n", " \"text\",\n", " \"text\",\n", " )\n", "\n", " def get_ip(request: gr.Request):\n", " return request.client.host\n", "\n", " demo.load(get_ip, None, ip)\n", "\n", "if __name__ == \"__main__\":\n", " demo.queue()\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
demos/audio_debugger/run.py CHANGED
@@ -9,18 +9,32 @@ with gr.Blocks() as demo:
9
  with gr.Tab("Audio"):
10
  gr.Audio(audio_file)
11
  with gr.Tab("Interface"):
12
- gr.Interface(lambda x:x, "audio", "audio", examples=[audio_file], cache_examples=True)
 
 
13
  with gr.Tab("Streaming"):
14
- gr.Interface(lambda x:x, gr.Audio(streaming=True), "audio", examples=[audio_file], cache_examples=True)
 
 
 
 
 
 
15
  with gr.Tab("console"):
16
  ip = gr.Textbox(label="User IP Address")
17
- gr.Interface(lambda cmd:subprocess.run([cmd], capture_output=True, shell=True).stdout.decode('utf-8').strip(), "text", "text")
18
-
 
 
 
 
 
 
19
  def get_ip(request: gr.Request):
20
  return request.client.host
21
-
22
  demo.load(get_ip, None, ip)
23
-
24
  if __name__ == "__main__":
25
  demo.queue()
26
  demo.launch()
 
9
  with gr.Tab("Audio"):
10
  gr.Audio(audio_file)
11
  with gr.Tab("Interface"):
12
+ gr.Interface(
13
+ lambda x: x, "audio", "audio", examples=[audio_file], cache_examples=True
14
+ )
15
  with gr.Tab("Streaming"):
16
+ gr.Interface(
17
+ lambda x: x,
18
+ gr.Audio(streaming=True),
19
+ "audio",
20
+ examples=[audio_file],
21
+ cache_examples=True,
22
+ )
23
  with gr.Tab("console"):
24
  ip = gr.Textbox(label="User IP Address")
25
+ gr.Interface(
26
+ lambda cmd: subprocess.run([cmd], capture_output=True, shell=True)
27
+ .stdout.decode("utf-8")
28
+ .strip(),
29
+ "text",
30
+ "text",
31
+ )
32
+
33
  def get_ip(request: gr.Request):
34
  return request.client.host
35
+
36
  demo.load(get_ip, None, ip)
37
+
38
  if __name__ == "__main__":
39
  demo.queue()
40
  demo.launch()
demos/chatbot_multimodal/files/avatar.png ADDED
demos/chatbot_multimodal/files/lion.jpg ADDED
demos/chatbot_multimodal/run.py CHANGED
@@ -8,16 +8,12 @@ import time
8
  def print_like_dislike(x: gr.LikeData):
9
  print(x.index, x.value, x.liked)
10
 
11
-
12
- def add_text(history, text):
13
- history = history + [(text, None)]
14
- return history, gr.Textbox(value="", interactive=False)
15
-
16
-
17
- def add_file(history, file):
18
- history = history + [((file.name,), None)]
19
- return history
20
-
21
 
22
  def bot(history):
23
  response = "**That's cool!**"
@@ -35,26 +31,13 @@ with gr.Blocks() as demo:
35
  bubble_full_width=False,
36
  )
37
 
38
- with gr.Row():
39
- txt = gr.Textbox(
40
- scale=4,
41
- show_label=False,
42
- placeholder="Enter text and press enter, or upload an image",
43
- container=False,
44
- )
45
- btn = gr.UploadButton("📁", file_types=["image", "video", "audio"])
46
-
47
- txt_msg = txt.submit(add_text, [chatbot, txt], [chatbot, txt], queue=False).then(
48
  bot, chatbot, chatbot, api_name="bot_response"
49
  )
50
- txt_msg.then(lambda: gr.Textbox(interactive=True), None, [txt], queue=False)
51
- file_msg = btn.upload(add_file, [chatbot, btn], [chatbot], queue=False).then(
52
- bot, chatbot, chatbot
53
- )
54
-
55
  chatbot.like(print_like_dislike, None, None)
56
 
57
-
58
  demo.queue()
59
  if __name__ == "__main__":
60
  demo.launch()
 
8
  def print_like_dislike(x: gr.LikeData):
9
  print(x.index, x.value, x.liked)
10
 
11
+ def add_message(history, message):
12
+ for x in message["files"]:
13
+ history.append(((x["path"],), None))
14
+ if message["text"] is not None:
15
+ history.append((message["text"], None))
16
+ return history, gr.MultimodalTextbox(value=None, interactive=False, file_types=["image"])
 
 
 
 
17
 
18
  def bot(history):
19
  response = "**That's cool!**"
 
31
  bubble_full_width=False,
32
  )
33
 
34
+ chat_input = gr.MultimodalTextbox(interactive=True, file_types=["image"], placeholder="Enter message or upload file...", show_label=False)
35
+ chat_msg = chat_input.submit(add_message, [chatbot, chat_input], [chatbot, chat_input], queue=False).then(
 
 
 
 
 
 
 
 
36
  bot, chatbot, chatbot, api_name="bot_response"
37
  )
38
+ chat_msg.then(lambda: gr.Textbox(interactive=True), None, [chat_input], queue=False)
 
 
 
 
39
  chatbot.like(print_like_dislike, None, None)
40
 
 
41
  demo.queue()
42
  if __name__ == "__main__":
43
  demo.launch()
requirements.txt CHANGED
@@ -1,6 +1,6 @@
1
 
2
- gradio-client @ git+https://github.com/gradio-app/gradio@446370806cab1884db59dd86181d1c54b9d5d8b2#subdirectory=client/python
3
- https://gradio-builds.s3.amazonaws.com/446370806cab1884db59dd86181d1c54b9d5d8b2/gradio-4.21.0-py3-none-any.whl
4
  pypistats==1.1.0
5
  plotly==5.10.0
6
  opencv-python==4.6.0.66
 
1
 
2
+ gradio-client @ git+https://github.com/gradio-app/gradio@87ee2d7d543bafbc59b3ef09d7cce9d882917c46#subdirectory=client/python
3
+ https://gradio-builds.s3.amazonaws.com/87ee2d7d543bafbc59b3ef09d7cce9d882917c46/gradio-4.22.0-py3-none-any.whl
4
  pypistats==1.1.0
5
  plotly==5.10.0
6
  opencv-python==4.6.0.66