aliabd HF Staff commited on
Commit
c3f54eb
·
verified ·
1 Parent(s): 0c148d2

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. run.ipynb +1 -1
  2. run.py +1 -2
run.ipynb CHANGED
@@ -1 +1 @@
1
- {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: upload_and_download"]}, {"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": ["from pathlib import Path\n", "import gradio as gr\n", "\n", "def upload_file(filepath):\n", " name = Path(filepath).name\n", " return [gr.UploadButton(visible=False), gr.DownloadButton(label=f\"Download {name}\", value=filepath, visible=True)]\n", "\n", "def download_file():\n", " return [gr.UploadButton(visible=True), gr.DownloadButton(visible=False)]\n", "\n", "with gr.Blocks() as demo:\n", " gr.Markdown(\"First upload a file and and then you'll be able download it (but only once!)\")\n", " with gr.Row():\n", " u = gr.UploadButton(\"Upload a file\", file_count=\"single\")\n", " d = gr.DownloadButton(\"Download the file\", visible=False)\n", "\n", " u.upload(upload_file, u, [u, d])\n", " d.click(download_file, None, [u, d])\n", "\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
 
1
+ {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: upload_and_download"]}, {"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": ["from pathlib import Path\n", "import gradio as gr\n", "\n", "def upload_file(filepath):\n", " name = Path(filepath).name\n", " return [gr.UploadButton(visible=False), gr.DownloadButton(label=f\"Download {name}\", value=filepath, visible=True)]\n", "\n", "def download_file():\n", " return [gr.UploadButton(visible=True), gr.DownloadButton(visible=False)]\n", "\n", "with gr.Blocks() as demo:\n", " gr.Markdown(\"First upload a file and and then you'll be able download it (but only once!)\")\n", " with gr.Row():\n", " u = gr.UploadButton(\"Upload a file\", file_count=\"single\")\n", " d = gr.DownloadButton(\"Download the file\", visible=False)\n", "\n", " u.upload(upload_file, u, [u, d])\n", " d.click(download_file, None, [u, d])\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
run.py CHANGED
@@ -17,6 +17,5 @@ with gr.Blocks() as demo:
17
  u.upload(upload_file, u, [u, d])
18
  d.click(download_file, None, [u, d])
19
 
20
-
21
  if __name__ == "__main__":
22
- demo.launch()
 
17
  u.upload(upload_file, u, [u, d])
18
  d.click(download_file, None, [u, d])
19
 
 
20
  if __name__ == "__main__":
21
+ demo.launch()