-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 4836-endpoints-with-non-serializable-outputs
- Loading branch information
Showing
17 changed files
with
260 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: change_vs_input"]}, {"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", " set_button = gr.Button(\"Set Values\")\n", " with gr.Row():\n", " with gr.Column():\n", " gr.Markdown(\"# Enter Here\")\n", " text = gr.Textbox()\n", " num = gr.Number()\n", " slider = gr.Slider()\n", " checkbox = gr.Checkbox()\n", " checkbox_group = gr.CheckboxGroup([\"a\", \"b\", \"c\"])\n", " radio = gr.Radio([\"a\", \"b\", \"c\"])\n", " dropdown = gr.Dropdown([\"a\", \"b\", \"c\"])\n", " colorpicker = gr.ColorPicker()\n", " code = gr.Code()\n", " dataframe = gr.Dataframe()\n", "\n", " with gr.Column():\n", " gr.Markdown(\"# ON:INPUT\")\n", " text_in = gr.Textbox()\n", " num_in = gr.Number()\n", " slider_in = gr.Slider()\n", " checkbox_in = gr.Checkbox()\n", " checkbox_group_in = gr.CheckboxGroup([\"a\", \"b\", \"c\"])\n", " radio_in = gr.Radio([\"a\", \"b\", \"c\"])\n", " dropdown_in = gr.Dropdown([\"a\", \"b\", \"c\"])\n", " colorpicker_in = gr.ColorPicker()\n", " code_in = gr.Code()\n", " dataframe_in = gr.Dataframe()\n", "\n", " with gr.Column():\n", " gr.Markdown(\"# ON:CHANGE\")\n", " text_ch = gr.Textbox()\n", " num_ch = gr.Number()\n", " slider_ch = gr.Slider()\n", " checkbox_ch = gr.Checkbox()\n", " checkbox_group_ch = gr.CheckboxGroup([\"a\", \"b\", \"c\"])\n", " radio_ch = gr.Radio([\"a\", \"b\", \"c\"])\n", " dropdown_ch = gr.Dropdown([\"a\", \"b\", \"c\"])\n", " colorpicker_ch = gr.ColorPicker()\n", " code_ch = gr.Code()\n", " dataframe_ch = gr.Dataframe()\n", "\n", " set_button.click(\n", " lambda: [\"asdf\", 555, 12, True, [\"a\", \"c\"], \"b\", \"b\", \"#FF0000\", \"import gradio as gr\", [[\"a\", \"b\", \"c\", \"d\"], [\"1\", \"2\", \"3\", \"4\"]]], \n", " None, \n", " [text, num, slider, checkbox, checkbox_group, radio, dropdown, colorpicker, code, dataframe])\n", "\n", " text.input(lambda x:x, text, text_in)\n", " num.input(lambda x:x, num, num_in)\n", " slider.input(lambda x:x, slider, slider_in)\n", " checkbox.input(lambda x:x, checkbox, checkbox_in)\n", " checkbox_group.input(lambda x:x, checkbox_group, checkbox_group_in)\n", " radio.input(lambda x:x, radio, radio_in)\n", " dropdown.input(lambda x:x, dropdown, dropdown_in)\n", " colorpicker.input(lambda x:x, colorpicker, colorpicker_in)\n", " code.input(lambda x:x, code, code_in)\n", " dataframe.input(lambda x:x, dataframe, dataframe_in)\n", "\n", " text.change(lambda x:x, text, text_ch)\n", " num.change(lambda x:x, num, num_ch)\n", " slider.change(lambda x:x, slider, slider_ch)\n", " checkbox.change(lambda x:x, checkbox, checkbox_ch)\n", " checkbox_group.change(lambda x:x, checkbox_group, checkbox_group_ch)\n", " radio.change(lambda x:x, radio, radio_ch)\n", " dropdown.change(lambda x:x, dropdown, dropdown_ch)\n", " colorpicker.change(lambda x:x, colorpicker, colorpicker_ch)\n", " code.change(lambda x:x, code, code_ch)\n", " dataframe.change(lambda x:x, dataframe, dataframe_ch)\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} | ||
{"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: change_vs_input"]}, {"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": ["# Downloading files from the demo repo\n", "import os\n", "os.mkdir('files')\n", "!wget -q -O files/cantina.wav https://github.com/gradio-app/gradio/raw/main/demo/change_vs_input/files/cantina.wav\n", "!wget -q -O files/lion.jpg https://github.com/gradio-app/gradio/raw/main/demo/change_vs_input/files/lion.jpg\n", "!wget -q -O files/world.mp4 https://github.com/gradio-app/gradio/raw/main/demo/change_vs_input/files/world.mp4"]}, {"cell_type": "code", "execution_count": null, "id": 44380577570523278879349135829904343037, "metadata": {}, "outputs": [], "source": ["import os\n", "import gradio as gr\n", "\n", "with gr.Blocks() as demo:\n", " set_button = gr.Button(\"Set Values\")\n", " with gr.Row():\n", " with gr.Column(min_width=200):\n", " gr.Markdown(\"# Enter Here\")\n", " text = gr.Textbox()\n", " num = gr.Number()\n", " slider = gr.Slider()\n", " checkbox = gr.Checkbox()\n", " checkbox_group = gr.CheckboxGroup([\"a\", \"b\", \"c\"])\n", " radio = gr.Radio([\"a\", \"b\", \"c\"])\n", " dropdown = gr.Dropdown([\"a\", \"b\", \"c\"])\n", " colorpicker = gr.ColorPicker()\n", " code = gr.Code()\n", " dataframe = gr.Dataframe()\n", " image = gr.Image(elem_id=\"image-original\")\n", " audio = gr.Audio(elem_id=\"audio-original\")\n", " video = gr.Video(elem_id=\"video-original\")\n", "\n", " with gr.Column(min_width=200):\n", " gr.Markdown(\"# ON:INPUT/UPLOAD\")\n", " text_in = gr.Textbox()\n", " num_in = gr.Number()\n", " slider_in = gr.Slider()\n", " checkbox_in = gr.Checkbox()\n", " checkbox_group_in = gr.CheckboxGroup([\"a\", \"b\", \"c\"])\n", " radio_in = gr.Radio([\"a\", \"b\", \"c\"])\n", " dropdown_in = gr.Dropdown([\"a\", \"b\", \"c\"])\n", " colorpicker_in = gr.ColorPicker()\n", " code_in = gr.Code()\n", " dataframe_in = gr.Dataframe()\n", " image_up = gr.Image(elem_id=\"image-upload\")\n", " audio_up = gr.Audio(elem_id=\"audio-upload\")\n", " video_up = gr.Video(elem_id=\"video-upload\")\n", "\n", " with gr.Column(min_width=200):\n", " gr.Markdown(\"# ON:CHANGE\")\n", " text_ch = gr.Textbox()\n", " num_ch = gr.Number()\n", " slider_ch = gr.Slider()\n", " checkbox_ch = gr.Checkbox()\n", " checkbox_group_ch = gr.CheckboxGroup([\"a\", \"b\", \"c\"])\n", " radio_ch = gr.Radio([\"a\", \"b\", \"c\"])\n", " dropdown_ch = gr.Dropdown([\"a\", \"b\", \"c\"])\n", " colorpicker_ch = gr.ColorPicker()\n", " code_ch = gr.Code()\n", " dataframe_ch = gr.Dataframe()\n", " image_ch = gr.Image(elem_id=\"image-change\")\n", " audio_ch = gr.Audio(elem_id=\"audio-change\")\n", " video_ch = gr.Video(elem_id=\"video-change\")\n", "\n", " with gr.Column(min_width=200):\n", " gr.Markdown(\"# ON:CHANGE x2\")\n", " text_ch2 = gr.Textbox()\n", " num_ch2 = gr.Number()\n", " slider_ch2 = gr.Slider()\n", " checkbox_ch2 = gr.Checkbox()\n", " checkbox_group_ch2 = gr.CheckboxGroup([\"a\", \"b\", \"c\"])\n", " radio_ch2 = gr.Radio([\"a\", \"b\", \"c\"])\n", " dropdown_ch2 = gr.Dropdown([\"a\", \"b\", \"c\"])\n", " colorpicker_ch2 = gr.ColorPicker()\n", " code_ch2 = gr.Code()\n", " dataframe_ch2 = gr.Dataframe()\n", " image_ch2 = gr.Image(elem_id=\"image-change-2\")\n", " audio_ch2 = gr.Audio(elem_id=\"audio-change-2\")\n", " video_ch2 = gr.Video(elem_id=\"video-change-2\")\n", "\n", " counter = gr.Number(label=\"Change counter\")\n", "\n", " lion = os.path.join(os.path.abspath(''), \"files/lion.jpg\")\n", " cantina = os.path.join(os.path.abspath(''), \"files/cantina.wav\")\n", " world = os.path.join(os.path.abspath(''), \"files/world.mp4\")\n", "\n", " set_button.click(\n", " lambda: [\"asdf\", 555, 12, True, [\"a\", \"c\"], \"b\", \"b\", \"#FF0000\", \"import gradio as gr\", [[\"a\", \"b\", \"c\", \"d\"], [\"1\", \"2\", \"3\", \"4\"]], lion, cantina, world], \n", " None, \n", " [text, num, slider, checkbox, checkbox_group, radio, dropdown, colorpicker, code, dataframe, image, audio, video])\n", "\n", " text.input(lambda x:x, text, text_in)\n", " num.input(lambda x:x, num, num_in)\n", " slider.input(lambda x:x, slider, slider_in)\n", " checkbox.input(lambda x:x, checkbox, checkbox_in)\n", " checkbox_group.input(lambda x:x, checkbox_group, checkbox_group_in)\n", " radio.input(lambda x:x, radio, radio_in)\n", " dropdown.input(lambda x:x, dropdown, dropdown_in)\n", " colorpicker.input(lambda x:x, colorpicker, colorpicker_in)\n", " code.input(lambda x:x, code, code_in)\n", " dataframe.input(lambda x:x, dataframe, dataframe_in)\n", " image.upload(lambda x:x, image, image_up)\n", " audio.upload(lambda x:x, audio, audio_up)\n", " video.upload(lambda x:x, video, video_up)\n", "\n", " text.change(lambda x,y:(x,y+1), [text, counter], [text_ch, counter])\n", " num.change(lambda x,y:(x, y+1), [num, counter], [num_ch, counter])\n", " slider.change(lambda x,y:(x, y+1), [slider, counter], [slider_ch, counter])\n", " checkbox.change(lambda x,y:(x, y+1), [checkbox, counter], [checkbox_ch, counter])\n", " checkbox_group.change(lambda x,y:(x, y+1), [checkbox_group, counter], [checkbox_group_ch, counter])\n", " radio.change(lambda x,y:(x, y+1), [radio, counter], [radio_ch, counter])\n", " dropdown.change(lambda x,y:(x, y+1), [dropdown, counter], [dropdown_ch, counter])\n", " colorpicker.change(lambda x,y:(x, y+1), [colorpicker, counter], [colorpicker_ch, counter])\n", " code.change(lambda x,y:(x, y+1), [code, counter], [code_ch, counter])\n", " dataframe.change(lambda x,y:(x, y+1), [dataframe, counter], [dataframe_ch, counter])\n", " image.change(lambda x,y:(x, y+1), [image, counter], [image_ch, counter])\n", " audio.change(lambda x,y:(x, y+1), [audio, counter], [audio_ch, counter])\n", " video.change(lambda x,y:(x, y+1), [video, counter], [video_ch, counter])\n", "\n", " text_ch.change(lambda x:x, text_ch, text_ch2)\n", " num_ch.change(lambda x:x, num_ch, num_ch2)\n", " slider_ch.change(lambda x:x, slider_ch, slider_ch2)\n", " checkbox_ch.change(lambda x:x, checkbox_ch, checkbox_ch2)\n", " checkbox_group_ch.change(lambda x:x, checkbox_group_ch, checkbox_group_ch2)\n", " radio_ch.change(lambda x:x, radio_ch, radio_ch2)\n", " dropdown_ch.change(lambda x:x, dropdown_ch, dropdown_ch2)\n", " colorpicker_ch.change(lambda x:x, colorpicker_ch, colorpicker_ch2)\n", " code_ch.change(lambda x:x, code_ch, code_ch2)\n", " dataframe_ch.change(lambda x:x, dataframe_ch, dataframe_ch2)\n", " image_ch.change(lambda x:x, image_ch, image_ch2)\n", " audio_ch.change(lambda x:x, audio_ch, audio_ch2)\n", " video_ch.change(lambda x:x, video_ch, video_ch2)\n", " \n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.