Spaces:
Runtime error
Runtime error
Upload with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: indigo
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 3.16.2
|
| 8 |
-
app_file:
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
+
|
| 2 |
---
|
| 3 |
+
title: examples_component_main
|
| 4 |
+
emoji: 🔥
|
| 5 |
colorFrom: indigo
|
| 6 |
+
colorTo: indigo
|
| 7 |
sdk: gradio
|
| 8 |
sdk_version: 3.16.2
|
| 9 |
+
app_file: run.py
|
| 10 |
pinned: false
|
| 11 |
---
|
|
|
|
|
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
https://gradio-main-build.s3.amazonaws.com/9a259cb8d0d002b445c4a36e0b60821d8b1ca052/gradio-3.16.2-py3-none-any.whl
|
run.ipynb
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: examples_component"]}, {"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", "\n", "def combine(a, b):\n", " return a + \" \" + b\n", "\n", "css = \"footer {display: none !important;} .gradio-container {min-height: 0px !important;} #col_1 {min-width: 0 !important; max-width: 25%; height: 100%;} #col_2 {min-width: 0 !important; max-width: 25%; height: 100%;} #col_3 {min-width: 0 !important; max-width: 25%; height: 100%;} #col_4 {min-width: 0 !important; max-width: 25%; height: 100%;}\"\n", "\n", "with gr.Blocks(css=css) as demo:\n", " with gr.Row():\n", " with gr.Column(elem_id=\"col_1\"):\n", " txt = gr.Textbox(label=\"Input 1\", elem_id=\"input_1_text\")\n", " with gr.Column(elem_id=\"col_2\"):\n", " txt_2 = gr.Textbox(label=\"Input 2\", elem_id=\"input_2_text\")\n", " with gr.Column(elem_id=\"col_3\"):\n", " btn = gr.Button(value=\"Combine Inputs\", elem_id=\"combine_button\")\n", " with gr.Column(elem_id=\"col_4\"):\n", " txt_3 = gr.Textbox(value=\"\", label=\"Output\", elem_id=\"output_text\")\n", " btn.click(combine, inputs=[txt, txt_2], outputs=[txt_3])\n", "\n", " gr.Examples(\n", " [[\"Hello\", \"World\"], [\"Machine\", \"Learning\"], [\"Gradio\", \"Docs\"]],\n", " [txt, txt_2],\n", " txt_3,\n", " combine,\n", " cache_examples=True,\n", " )\n", " \n", "demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
run.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def combine(a, b):
|
| 5 |
+
return a + " " + b
|
| 6 |
+
|
| 7 |
+
css = "footer {display: none !important;} .gradio-container {min-height: 0px !important;} #col_1 {min-width: 0 !important; max-width: 25%; height: 100%;} #col_2 {min-width: 0 !important; max-width: 25%; height: 100%;} #col_3 {min-width: 0 !important; max-width: 25%; height: 100%;} #col_4 {min-width: 0 !important; max-width: 25%; height: 100%;}"
|
| 8 |
+
|
| 9 |
+
with gr.Blocks(css=css) as demo:
|
| 10 |
+
with gr.Row():
|
| 11 |
+
with gr.Column(elem_id="col_1"):
|
| 12 |
+
txt = gr.Textbox(label="Input 1", elem_id="input_1_text")
|
| 13 |
+
with gr.Column(elem_id="col_2"):
|
| 14 |
+
txt_2 = gr.Textbox(label="Input 2", elem_id="input_2_text")
|
| 15 |
+
with gr.Column(elem_id="col_3"):
|
| 16 |
+
btn = gr.Button(value="Combine Inputs", elem_id="combine_button")
|
| 17 |
+
with gr.Column(elem_id="col_4"):
|
| 18 |
+
txt_3 = gr.Textbox(value="", label="Output", elem_id="output_text")
|
| 19 |
+
btn.click(combine, inputs=[txt, txt_2], outputs=[txt_3])
|
| 20 |
+
|
| 21 |
+
gr.Examples(
|
| 22 |
+
[["Hello", "World"], ["Machine", "Learning"], ["Gradio", "Docs"]],
|
| 23 |
+
[txt, txt_2],
|
| 24 |
+
txt_3,
|
| 25 |
+
combine,
|
| 26 |
+
cache_examples=True,
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
demo.launch()
|