aliabd HF staff commited on
Commit
c494ce1
1 Parent(s): 9f8ac69

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. run.ipynb +1 -1
  2. run.py +2 -3
run.ipynb CHANGED
@@ -1 +1 @@
1
- {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: render_merge_simple"]}, {"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", "\n", "with gr.Blocks() as demo:\n", " text_count = gr.State(1)\n", " add_btn = gr.Button(\"Add Box\")\n", " add_btn.click(lambda x: x + 1, text_count, text_count)\n", "\n", " @gr.render(inputs=text_count)\n", " def render_count(count):\n", " boxes = []\n", " for i in range(count):\n", " box = gr.Textbox(key=i, label=f\"Box {i}\")\n", " boxes.append(box)\n", "\n", " def merge(*args):\n", " return \" \".join(args)\n", " \n", " merge_btn.click(merge, boxes, output)\n", "\n", "\n", " merge_btn = gr.Button(\"Merge\")\n", " output = gr.Textbox(label=\"Merged Output\")\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: render_merge_simple"]}, {"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", "\n", "with gr.Blocks() as demo:\n", " text_count = gr.State(1)\n", " add_btn = gr.Button(\"Add Box\")\n", " add_btn.click(lambda x: x + 1, text_count, text_count)\n", "\n", " @gr.render(inputs=text_count)\n", " def render_count(count):\n", " boxes = []\n", " for i in range(count):\n", " box = gr.Textbox(key=i, label=f\"Box {i}\")\n", " boxes.append(box)\n", "\n", " def merge(*args):\n", " return \" \".join(args)\n", "\n", " merge_btn.click(merge, boxes, output)\n", "\n", " merge_btn = gr.Button(\"Merge\")\n", " output = gr.Textbox(label=\"Merged Output\")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
run.py CHANGED
@@ -14,12 +14,11 @@ with gr.Blocks() as demo:
14
 
15
  def merge(*args):
16
  return " ".join(args)
17
-
18
- merge_btn.click(merge, boxes, output)
19
 
 
20
 
21
  merge_btn = gr.Button("Merge")
22
  output = gr.Textbox(label="Merged Output")
23
 
24
  if __name__ == "__main__":
25
- demo.launch()
 
14
 
15
  def merge(*args):
16
  return " ".join(args)
 
 
17
 
18
+ merge_btn.click(merge, boxes, output)
19
 
20
  merge_btn = gr.Button("Merge")
21
  output = gr.Textbox(label="Merged Output")
22
 
23
  if __name__ == "__main__":
24
+ demo.launch()