Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files
run.ipynb
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: blocks_essay_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", "
|
|
|
|
| 1 |
+
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: blocks_essay_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", "def change_textbox(choice):\n", " if choice == \"short\":\n", " return gr.Textbox(lines=2, visible=True)\n", " elif choice == \"long\":\n", " return gr.Textbox(lines=8, visible=True, value=\"Lorem ipsum dolor sit amet\")\n", " else:\n", " return gr.Textbox(visible=False)\n", "\n", "with gr.Blocks() as demo:\n", " radio = gr.Radio(\n", " [\"short\", \"long\", \"none\"], label=\"What kind of essay would you like to write?\"\n", " )\n", " text = gr.Textbox(lines=2, interactive=True, show_copy_button=True)\n", " radio.change(fn=change_textbox, inputs=radio, outputs=text)\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
run.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
def change_textbox(choice):
|
| 5 |
if choice == "short":
|
| 6 |
return gr.Textbox(lines=2, visible=True)
|
|
@@ -9,7 +8,6 @@ def change_textbox(choice):
|
|
| 9 |
else:
|
| 10 |
return gr.Textbox(visible=False)
|
| 11 |
|
| 12 |
-
|
| 13 |
with gr.Blocks() as demo:
|
| 14 |
radio = gr.Radio(
|
| 15 |
["short", "long", "none"], label="What kind of essay would you like to write?"
|
|
@@ -17,6 +15,5 @@ with gr.Blocks() as demo:
|
|
| 17 |
text = gr.Textbox(lines=2, interactive=True, show_copy_button=True)
|
| 18 |
radio.change(fn=change_textbox, inputs=radio, outputs=text)
|
| 19 |
|
| 20 |
-
|
| 21 |
if __name__ == "__main__":
|
| 22 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
|
|
|
| 3 |
def change_textbox(choice):
|
| 4 |
if choice == "short":
|
| 5 |
return gr.Textbox(lines=2, visible=True)
|
|
|
|
| 8 |
else:
|
| 9 |
return gr.Textbox(visible=False)
|
| 10 |
|
|
|
|
| 11 |
with gr.Blocks() as demo:
|
| 12 |
radio = gr.Radio(
|
| 13 |
["short", "long", "none"], label="What kind of essay would you like to write?"
|
|
|
|
| 15 |
text = gr.Textbox(lines=2, interactive=True, show_copy_button=True)
|
| 16 |
radio.change(fn=change_textbox, inputs=radio, outputs=text)
|
| 17 |
|
|
|
|
| 18 |
if __name__ == "__main__":
|
| 19 |
demo.launch()
|