Commit 2: Add 50 file(s)
Browse files- demos/image_editor_events/run.ipynb +1 -1
- demos/image_editor_events/run.py +0 -1
- demos/matrix_transpose/run.ipynb +1 -1
- demos/matrix_transpose/run.py +1 -1
- demos/native_plots/bar_plot_demo.py +5 -5
- demos/native_plots/line_plot_demo.py +5 -5
- demos/native_plots/scatter_plot_demo.py +5 -6
- demos/reverse_audio/run.ipynb +1 -1
- demos/reverse_audio/run.py +1 -1
demos/image_editor_events/run.ipynb
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: image_editor_events"]}, {"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", "import numpy as np\n", "\n", "\n", "def predict(im):\n", " return im[\"composite\"]\n", "\n", "\n", "def verify_clear(im):\n", " print(im)\n", " return int(not np.any(im[\"composite\"])), im[\"composite\"]\n", "\n", "\n", "with gr.Blocks() as demo:\n", " with gr.Group():\n", " with gr.Row():\n", " im = gr.ImageEditor(\n", " type=\"numpy\",\n", "
|
|
|
|
| 1 |
+
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: image_editor_events"]}, {"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", "import numpy as np\n", "\n", "\n", "def predict(im):\n", " return im[\"composite\"]\n", "\n", "\n", "def verify_clear(im):\n", " print(im)\n", " return int(not np.any(im[\"composite\"])), im[\"composite\"]\n", "\n", "\n", "with gr.Blocks() as demo:\n", " with gr.Group():\n", " with gr.Row():\n", " im = gr.ImageEditor(\n", " type=\"numpy\",\n", " elem_id=\"image_editor\",\n", " )\n", " im_preview = gr.Image()\n", " with gr.Group():\n", " with gr.Row():\n", "\n", " n_upload = gr.Label(\n", " 0,\n", " label=\"upload\",\n", " elem_id=\"upload\",\n", " )\n", " n_change = gr.Label(\n", " 0,\n", " label=\"change\",\n", " elem_id=\"change\",\n", " )\n", " n_input = gr.Label(\n", " 0,\n", " label=\"input\",\n", " elem_id=\"input\",\n", " )\n", " n_apply = gr.Label(\n", " 0,\n", " label=\"apply\",\n", " elem_id=\"apply\",\n", " )\n", " cleared_properly = gr.Number(label=\"cleared properly\")\n", " clear_btn = gr.Button(\"Clear Button\", elem_id=\"clear\")\n", "\n", " im.upload(\n", " lambda x: int(x) + 1, outputs=n_upload, inputs=n_upload, show_progress=\"hidden\"\n", " )\n", " im.change(\n", " lambda x: int(x) + 1, outputs=n_change, inputs=n_change, show_progress=\"hidden\"\n", " )\n", " im.input(\n", " lambda x: int(x) + 1, outputs=n_input, inputs=n_input, show_progress=\"hidden\"\n", " )\n", " im.apply(\n", " lambda x: int(x) + 1, outputs=n_apply, inputs=n_apply, show_progress=\"hidden\"\n", " )\n", " im.change(predict, outputs=im_preview, inputs=im, show_progress=\"hidden\")\n", " clear_btn.click(\n", " lambda: None,\n", " None,\n", " im,\n", " ).then(verify_clear, inputs=im, outputs=[cleared_properly, im])\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
demos/image_editor_events/run.py
CHANGED
|
@@ -16,7 +16,6 @@ with gr.Blocks() as demo:
|
|
| 16 |
with gr.Row():
|
| 17 |
im = gr.ImageEditor(
|
| 18 |
type="numpy",
|
| 19 |
-
crop_size="1:1",
|
| 20 |
elem_id="image_editor",
|
| 21 |
)
|
| 22 |
im_preview = gr.Image()
|
|
|
|
| 16 |
with gr.Row():
|
| 17 |
im = gr.ImageEditor(
|
| 18 |
type="numpy",
|
|
|
|
| 19 |
elem_id="image_editor",
|
| 20 |
)
|
| 21 |
im_preview = gr.Image()
|
demos/matrix_transpose/run.ipynb
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: matrix_transpose"]}, {"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 numpy as np\n", "\n", "import gradio as gr\n", "\n", "def transpose(matrix):\n", " return matrix.T\n", "\n", "demo = gr.Interface(\n", " transpose,\n", " gr.Dataframe(type=\"numpy\", datatype=\"number\", row_count=5, col_count=3,
|
|
|
|
| 1 |
+
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: matrix_transpose"]}, {"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 numpy as np\n", "\n", "import gradio as gr\n", "\n", "def transpose(matrix):\n", " return matrix.T\n", "\n", "demo = gr.Interface(\n", " transpose,\n", " gr.Dataframe(type=\"numpy\", datatype=\"number\", row_count=5, col_count=3, buttons=[\"fullscreen\"]),\n", " \"numpy\",\n", " examples=[\n", " [np.zeros((30, 30)).tolist()],\n", " [np.ones((2, 2)).tolist()],\n", " [np.random.randint(0, 10, (3, 10)).tolist()],\n", " [np.random.randint(0, 10, (10, 3)).tolist()],\n", " [np.random.randint(0, 10, (10, 10)).tolist()],\n", " ],\n", " cache_examples=False\n", ")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
demos/matrix_transpose/run.py
CHANGED
|
@@ -7,7 +7,7 @@ def transpose(matrix):
|
|
| 7 |
|
| 8 |
demo = gr.Interface(
|
| 9 |
transpose,
|
| 10 |
-
gr.Dataframe(type="numpy", datatype="number", row_count=5, col_count=3,
|
| 11 |
"numpy",
|
| 12 |
examples=[
|
| 13 |
[np.zeros((30, 30)).tolist()],
|
|
|
|
| 7 |
|
| 8 |
demo = gr.Interface(
|
| 9 |
transpose,
|
| 10 |
+
gr.Dataframe(type="numpy", datatype="number", row_count=5, col_count=3, buttons=["fullscreen"]),
|
| 11 |
"numpy",
|
| 12 |
examples=[
|
| 13 |
[np.zeros((30, 30)).tolist()],
|
demos/native_plots/bar_plot_demo.py
CHANGED
|
@@ -15,14 +15,14 @@ with gr.Blocks() as bar_plots:
|
|
| 15 |
temp_sensor_data,
|
| 16 |
x="time",
|
| 17 |
y="temperature",
|
| 18 |
-
|
| 19 |
)
|
| 20 |
temp_by_time_location = gr.BarPlot(
|
| 21 |
temp_sensor_data,
|
| 22 |
x="time",
|
| 23 |
y="temperature",
|
| 24 |
color="location",
|
| 25 |
-
|
| 26 |
)
|
| 27 |
|
| 28 |
time_graphs = [temp_by_time, temp_by_time_location]
|
|
@@ -51,7 +51,7 @@ with gr.Blocks() as bar_plots:
|
|
| 51 |
food_rating_data,
|
| 52 |
x="cuisine",
|
| 53 |
y="price",
|
| 54 |
-
|
| 55 |
)
|
| 56 |
with gr.Column(scale=0):
|
| 57 |
gr.Button("Sort $ > $$$").click(lambda: gr.BarPlot(sort="y"), None, price_by_cuisine)
|
|
@@ -64,7 +64,7 @@ with gr.Blocks() as bar_plots:
|
|
| 64 |
x="rating",
|
| 65 |
y="price",
|
| 66 |
x_bin=1,
|
| 67 |
-
|
| 68 |
)
|
| 69 |
price_by_rating_color = gr.BarPlot(
|
| 70 |
food_rating_data,
|
|
@@ -73,7 +73,7 @@ with gr.Blocks() as bar_plots:
|
|
| 73 |
color="cuisine",
|
| 74 |
x_bin=1,
|
| 75 |
color_map={"Italian": "red", "Mexican": "green", "Chinese": "blue"},
|
| 76 |
-
|
| 77 |
)
|
| 78 |
|
| 79 |
if __name__ == "__main__":
|
|
|
|
| 15 |
temp_sensor_data,
|
| 16 |
x="time",
|
| 17 |
y="temperature",
|
| 18 |
+
buttons=["export"],
|
| 19 |
)
|
| 20 |
temp_by_time_location = gr.BarPlot(
|
| 21 |
temp_sensor_data,
|
| 22 |
x="time",
|
| 23 |
y="temperature",
|
| 24 |
color="location",
|
| 25 |
+
buttons=["export"],
|
| 26 |
)
|
| 27 |
|
| 28 |
time_graphs = [temp_by_time, temp_by_time_location]
|
|
|
|
| 51 |
food_rating_data,
|
| 52 |
x="cuisine",
|
| 53 |
y="price",
|
| 54 |
+
buttons=["export"],
|
| 55 |
)
|
| 56 |
with gr.Column(scale=0):
|
| 57 |
gr.Button("Sort $ > $$$").click(lambda: gr.BarPlot(sort="y"), None, price_by_cuisine)
|
|
|
|
| 64 |
x="rating",
|
| 65 |
y="price",
|
| 66 |
x_bin=1,
|
| 67 |
+
buttons=["export"],
|
| 68 |
)
|
| 69 |
price_by_rating_color = gr.BarPlot(
|
| 70 |
food_rating_data,
|
|
|
|
| 73 |
color="cuisine",
|
| 74 |
x_bin=1,
|
| 75 |
color_map={"Italian": "red", "Mexican": "green", "Chinese": "blue"},
|
| 76 |
+
buttons=["export"],
|
| 77 |
)
|
| 78 |
|
| 79 |
if __name__ == "__main__":
|
demos/native_plots/line_plot_demo.py
CHANGED
|
@@ -14,14 +14,14 @@ with gr.Blocks() as line_plots:
|
|
| 14 |
temp_sensor_data,
|
| 15 |
x="time",
|
| 16 |
y="temperature",
|
| 17 |
-
|
| 18 |
)
|
| 19 |
temp_by_time_location = gr.LinePlot(
|
| 20 |
temp_sensor_data,
|
| 21 |
x="time",
|
| 22 |
y="temperature",
|
| 23 |
color="location",
|
| 24 |
-
|
| 25 |
)
|
| 26 |
|
| 27 |
time_graphs = [temp_by_time, temp_by_time_location]
|
|
@@ -49,14 +49,14 @@ with gr.Blocks() as line_plots:
|
|
| 49 |
food_rating_data,
|
| 50 |
x="cuisine",
|
| 51 |
y="price",
|
| 52 |
-
|
| 53 |
)
|
| 54 |
with gr.Row():
|
| 55 |
price_by_rating = gr.LinePlot(
|
| 56 |
food_rating_data,
|
| 57 |
x="rating",
|
| 58 |
y="price",
|
| 59 |
-
|
| 60 |
)
|
| 61 |
price_by_rating_color = gr.LinePlot(
|
| 62 |
food_rating_data,
|
|
@@ -64,7 +64,7 @@ with gr.Blocks() as line_plots:
|
|
| 64 |
y="price",
|
| 65 |
color="cuisine",
|
| 66 |
color_map={"Italian": "red", "Mexican": "green", "Chinese": "blue"},
|
| 67 |
-
|
| 68 |
)
|
| 69 |
|
| 70 |
if __name__ == "__main__":
|
|
|
|
| 14 |
temp_sensor_data,
|
| 15 |
x="time",
|
| 16 |
y="temperature",
|
| 17 |
+
buttons=["export"],
|
| 18 |
)
|
| 19 |
temp_by_time_location = gr.LinePlot(
|
| 20 |
temp_sensor_data,
|
| 21 |
x="time",
|
| 22 |
y="temperature",
|
| 23 |
color="location",
|
| 24 |
+
buttons=["export"],
|
| 25 |
)
|
| 26 |
|
| 27 |
time_graphs = [temp_by_time, temp_by_time_location]
|
|
|
|
| 49 |
food_rating_data,
|
| 50 |
x="cuisine",
|
| 51 |
y="price",
|
| 52 |
+
buttons=["export"],
|
| 53 |
)
|
| 54 |
with gr.Row():
|
| 55 |
price_by_rating = gr.LinePlot(
|
| 56 |
food_rating_data,
|
| 57 |
x="rating",
|
| 58 |
y="price",
|
| 59 |
+
buttons=["export"],
|
| 60 |
)
|
| 61 |
price_by_rating_color = gr.LinePlot(
|
| 62 |
food_rating_data,
|
|
|
|
| 64 |
y="price",
|
| 65 |
color="cuisine",
|
| 66 |
color_map={"Italian": "red", "Mexican": "green", "Chinese": "blue"},
|
| 67 |
+
buttons=["export"],
|
| 68 |
)
|
| 69 |
|
| 70 |
if __name__ == "__main__":
|
demos/native_plots/scatter_plot_demo.py
CHANGED
|
@@ -14,14 +14,14 @@ with gr.Blocks() as scatter_plots:
|
|
| 14 |
temp_sensor_data,
|
| 15 |
x="time",
|
| 16 |
y="temperature",
|
| 17 |
-
|
| 18 |
)
|
| 19 |
temp_by_time_location = gr.ScatterPlot(
|
| 20 |
temp_sensor_data,
|
| 21 |
x="time",
|
| 22 |
y="temperature",
|
| 23 |
color="location",
|
| 24 |
-
|
| 25 |
)
|
| 26 |
|
| 27 |
time_graphs = [temp_by_time, temp_by_time_location]
|
|
@@ -49,7 +49,7 @@ with gr.Blocks() as scatter_plots:
|
|
| 49 |
food_rating_data,
|
| 50 |
x="cuisine",
|
| 51 |
y="price",
|
| 52 |
-
|
| 53 |
)
|
| 54 |
with gr.Row():
|
| 55 |
price_by_rating = gr.ScatterPlot(
|
|
@@ -57,15 +57,14 @@ with gr.Blocks() as scatter_plots:
|
|
| 57 |
x="rating",
|
| 58 |
y="price",
|
| 59 |
color="wait",
|
| 60 |
-
|
| 61 |
-
show_export_button=True,
|
| 62 |
)
|
| 63 |
price_by_rating_color = gr.ScatterPlot(
|
| 64 |
food_rating_data,
|
| 65 |
x="rating",
|
| 66 |
y="price",
|
| 67 |
color="cuisine",
|
| 68 |
-
|
| 69 |
)
|
| 70 |
|
| 71 |
if __name__ == "__main__":
|
|
|
|
| 14 |
temp_sensor_data,
|
| 15 |
x="time",
|
| 16 |
y="temperature",
|
| 17 |
+
buttons=["export"],
|
| 18 |
)
|
| 19 |
temp_by_time_location = gr.ScatterPlot(
|
| 20 |
temp_sensor_data,
|
| 21 |
x="time",
|
| 22 |
y="temperature",
|
| 23 |
color="location",
|
| 24 |
+
buttons=["export"],
|
| 25 |
)
|
| 26 |
|
| 27 |
time_graphs = [temp_by_time, temp_by_time_location]
|
|
|
|
| 49 |
food_rating_data,
|
| 50 |
x="cuisine",
|
| 51 |
y="price",
|
| 52 |
+
buttons=["export"],
|
| 53 |
)
|
| 54 |
with gr.Row():
|
| 55 |
price_by_rating = gr.ScatterPlot(
|
|
|
|
| 57 |
x="rating",
|
| 58 |
y="price",
|
| 59 |
color="wait",
|
| 60 |
+
buttons=["actions", "export"],
|
|
|
|
| 61 |
)
|
| 62 |
price_by_rating_color = gr.ScatterPlot(
|
| 63 |
food_rating_data,
|
| 64 |
x="rating",
|
| 65 |
y="price",
|
| 66 |
color="cuisine",
|
| 67 |
+
buttons=["export"],
|
| 68 |
)
|
| 69 |
|
| 70 |
if __name__ == "__main__":
|
demos/reverse_audio/run.ipynb
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: reverse_audio"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio numpy "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["\n", "import numpy as np\n", "\n", "import gradio as gr\n", "\n", "def reverse_audio(audio):\n", " sr, data = audio\n", " return (sr, np.flipud(data))\n", "\n", "input_audio = gr.Audio(\n", " sources=[\"microphone\"],\n", " waveform_options=gr.WaveformOptions(\n", " waveform_color=\"#01C6FF\",\n", " waveform_progress_color=\"#0066B4\",\n", " skip_length=2,\n", "
|
|
|
|
| 1 |
+
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: reverse_audio"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio numpy "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["\n", "import numpy as np\n", "\n", "import gradio as gr\n", "\n", "def reverse_audio(audio):\n", " sr, data = audio\n", " return (sr, np.flipud(data))\n", "\n", "input_audio = gr.Audio(\n", " sources=[\"microphone\"],\n", " waveform_options=gr.WaveformOptions(\n", " waveform_color=\"#01C6FF\",\n", " waveform_progress_color=\"#0066B4\",\n", " skip_length=2,\n", " show_recording_waveform=False,\n", " ),\n", ")\n", "demo = gr.Interface(\n", " fn=reverse_audio,\n", " inputs=input_audio,\n", " outputs=\"audio\"\n", ")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
demos/reverse_audio/run.py
CHANGED
|
@@ -13,7 +13,7 @@ input_audio = gr.Audio(
|
|
| 13 |
waveform_color="#01C6FF",
|
| 14 |
waveform_progress_color="#0066B4",
|
| 15 |
skip_length=2,
|
| 16 |
-
|
| 17 |
),
|
| 18 |
)
|
| 19 |
demo = gr.Interface(
|
|
|
|
| 13 |
waveform_color="#01C6FF",
|
| 14 |
waveform_progress_color="#0066B4",
|
| 15 |
skip_length=2,
|
| 16 |
+
show_recording_waveform=False,
|
| 17 |
),
|
| 18 |
)
|
| 19 |
demo = gr.Interface(
|