Small fixes to the demos (#1030)

* updated PyPi version to 2.9.0b

* added to init

* moved media_data

* formatting

* updated PyPi version to 2.9.0b2

* default selected

* deprecated keyvalues

* fixed a few small issues
This commit is contained in:
Abubakar Abid 2022-04-20 14:57:45 -07:00 committed by GitHub
parent 76eab3f9ce
commit 161a7a8472
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 48 additions and 6 deletions

View File

@ -1 +0,0 @@
numpy

View File

@ -53,7 +53,8 @@ inputs = [
gr.Dropdown(["Matplotlib", "Plotly", "Bokeh"], label="Plot Type"),
gr.Slider(minimum=1, maximum=4, default_value=3.2, label="R"),
gr.Dropdown(["January", "February", "March", "April", "May"], label="Month"),
gr.CheckboxGroup(["USA", "Canada", "Mexico", "UK"], label="Countries"),
gr.CheckboxGroup(["USA", "Canada", "Mexico", "UK"], label="Countries",
default_selected=["USA", "Canada"]),
gr.Checkbox(label="Social Distancing?"),
]
outputs = gr.Plot(type="auto")

42
demo/random_demos.py Normal file
View File

@ -0,0 +1,42 @@
"""Opens X demos randomly for quick inspection
Usage: python random_demos.py <num_demos>
Example: python random_demos.py 8
Assumes:
- This is being run from the gradio/demo/ directory
"""
from __future__ import annotations
import argparse
import importlib
import os
import random
import gradio as gr
parser = argparse.ArgumentParser()
parser.add_argument("num_demos", help="number of demos to launch", type=int, default=4)
args = parser.parse_args()
# get the list of directory names
demos_list = next(os.walk('.'))[1]
# Some demos are just too large or need to be run in a special way, so we'll just skip them
demos_list.remove('streaming_wav2vec')
demos_list.remove('blocks_neural_instrument_coding')
demos_list.remove('reverse_audio')
demos_list.remove('image_classifier')
demos_list.remove('flagged')
for d, demo_name in enumerate(random.sample(demos_list, args.num_demos)):
print(f"Launching demo {d+1}/{args.num_demos}: {demo_name}")
# import the run.py file from inside the directory specified by args.demo_name
run = importlib.import_module(f"{demo_name}.run")
demo: gr.Blocks = run.demo
if d == args.num_demos - 1:
demo.launch(prevent_thread_lock=False, inbrowser=True) # prevent main thread from exiting
else:
demo.launch(prevent_thread_lock=True, inbrowser=True)

View File

@ -29,7 +29,7 @@ def text_analysis(text):
demo = gr.Interface(
text_analysis,
gr.Textbox(placeholder="Enter sentence here..."),
["highlight", "key_values", "html"],
["highlight", "json", "html"],
examples=[
["What a beautiful morning for a walk!"],
["It was the best of times, it was the worst of times."],

View File

@ -25,7 +25,7 @@ args = parser.parse_args()
# import the run.py file from inside the directory specified by args.demo_name
run = importlib.import_module(f"{args.demo_name}.run")
demo: gr.Blocks = run.iface
demo: gr.Blocks = run.demo
config = demo.get_config_file()
json.dump(config, open(args.file_path, "w"), indent=2)

View File

@ -55,7 +55,7 @@
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.1/iframeResizer.contentWindow.min.js"></script>
<title>Gradio</title>
<script type="module" crossorigin src="./assets/index.2f71b643.js"></script>
<script type="module" crossorigin src="./assets/index.48da79ea.js"></script>
<link rel="stylesheet" href="./assets/index.39bf42f9.css">
</head>

View File

@ -1 +1 @@
2.9.0b2
2.9.0b2