mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-17 11:29:58 +08:00
fixed more demos
This commit is contained in:
parent
3010d55132
commit
5fa69783e9
@ -4,13 +4,14 @@ import gradio as gr
|
||||
def image_mod(text):
|
||||
return text[::-1]
|
||||
|
||||
block = gr.Blocks()
|
||||
demo = gr.Blocks()
|
||||
|
||||
with block:
|
||||
with demo:
|
||||
text = gr.Textbox()
|
||||
btn = gr.Button("Run")
|
||||
btn.click(image_mod, text, text)
|
||||
|
||||
print(block.get_config_file())
|
||||
print(demo.get_config_file())
|
||||
|
||||
if __name__ == "__main__":
|
||||
block.launch()
|
||||
demo.launch()
|
||||
|
@ -82,48 +82,48 @@ def fn(
|
||||
)
|
||||
|
||||
|
||||
iface = gr.Interface(
|
||||
demo = gr.Interface(
|
||||
fn,
|
||||
inputs=[
|
||||
gr.inputs.Textbox(default="Lorem ipsum", label="Textbox"),
|
||||
gr.inputs.Textbox(lines=3, placeholder="Type here..", label="Textbox 2"),
|
||||
gr.inputs.Number(label="Number", default=42),
|
||||
gr.inputs.Slider(minimum=10, maximum=20, default=15, label="Slider: 10 - 20"),
|
||||
gr.inputs.Slider(maximum=20, step=0.04, label="Slider: step @ 0.04"),
|
||||
gr.inputs.Checkbox(label="Checkbox"),
|
||||
gr.inputs.CheckboxGroup(
|
||||
label="CheckboxGroup", choices=CHOICES, default=CHOICES[0:2]
|
||||
gr.Textbox(default_value="Lorem ipsum", label="Textbox"),
|
||||
gr.Textbox(lines=3, placeholder="Type here..", label="Textbox 2"),
|
||||
gr.Number(label="Number", default=42),
|
||||
gr.Slider(minimum=10, maximum=20, default_value=15, label="Slider: 10 - 20"),
|
||||
gr.Slider(maximum=20, step=0.04, label="Slider: step @ 0.04"),
|
||||
gr.Checkbox(label="Checkbox"),
|
||||
gr.CheckboxGroup(
|
||||
label="CheckboxGroup", choices=CHOICES, default_selected=CHOICES[0:2]
|
||||
),
|
||||
gr.inputs.Radio(label="Radio", choices=CHOICES, default=CHOICES[2]),
|
||||
gr.inputs.Dropdown(label="Dropdown", choices=CHOICES),
|
||||
gr.inputs.Image(label="Image", optional=True),
|
||||
gr.inputs.Image(label="Image w/ Cropper", tool="select", optional=True),
|
||||
gr.inputs.Image(label="Sketchpad", source="canvas", optional=True),
|
||||
gr.inputs.Image(label="Webcam", source="webcam", optional=True),
|
||||
gr.inputs.Video(label="Video", optional=True),
|
||||
gr.inputs.Audio(label="Audio", optional=True),
|
||||
gr.inputs.Audio(label="Microphone", source="microphone", optional=True),
|
||||
gr.inputs.File(label="File", optional=True),
|
||||
gr.inputs.Dataframe(label="Dataframe", headers=["Name", "Age", "Gender"]),
|
||||
gr.inputs.Timeseries(x="time", y=["price", "value"], optional=True),
|
||||
gr.Radio(label="Radio", choices=CHOICES, default_selected=CHOICES[2]),
|
||||
gr.Dropdown(label="Dropdown", choices=CHOICES),
|
||||
gr.Image(label="Image"),
|
||||
gr.Image(label="Image w/ Cropper", tool="select"),
|
||||
gr.Image(label="Sketchpad", source="canvas"),
|
||||
gr.Image(label="Webcam", source="webcam"),
|
||||
gr.Video(label="Video"),
|
||||
gr.Audio(label="Audio"),
|
||||
gr.Audio(label="Microphone", source="microphone"),
|
||||
gr.File(label="File"),
|
||||
gr.Dataframe(label="Dataframe", headers=["Name", "Age", "Gender"]),
|
||||
gr.Timeseries(x="time", y=["price", "value"]),
|
||||
],
|
||||
outputs=[
|
||||
gr.outputs.Textbox(label="Textbox"),
|
||||
gr.outputs.Label(label="Label"),
|
||||
gr.outputs.Audio(label="Audio"),
|
||||
gr.outputs.Image(label="Image"),
|
||||
gr.outputs.Video(label="Video"),
|
||||
gr.outputs.HighlightedText(
|
||||
gr.Textbox(label="Textbox"),
|
||||
gr.Label(label="Label"),
|
||||
gr.Audio(label="Audio"),
|
||||
gr.Image(label="Image"),
|
||||
gr.Video(label="Video"),
|
||||
gr.HighlightedText(
|
||||
label="HighlightedText", color_map={"punc": "pink", "test 0": "blue"}
|
||||
),
|
||||
gr.outputs.HighlightedText(label="HighlightedText", show_legend=True),
|
||||
gr.outputs.JSON(label="JSON"),
|
||||
gr.outputs.HTML(label="HTML"),
|
||||
gr.outputs.File(label="File"),
|
||||
gr.outputs.Dataframe(label="Dataframe"),
|
||||
gr.outputs.Dataframe(label="Numpy", type="numpy"),
|
||||
gr.outputs.Carousel("image", label="Carousel"),
|
||||
gr.outputs.Timeseries(x="time", y=["price", "value"], label="Timeseries"),
|
||||
gr.HighlightedText(label="HighlightedText", show_legend=True),
|
||||
gr.JSON(label="JSON"),
|
||||
gr.HTML(label="HTML"),
|
||||
gr.File(label="File"),
|
||||
gr.Dataframe(label="Dataframe"),
|
||||
gr.Dataframe(label="Numpy"),
|
||||
gr.Carousel(components="image", label="Carousel"),
|
||||
gr.Timeseries(x="time", y=["price", "value"], label="Timeseries"),
|
||||
],
|
||||
examples=[
|
||||
[
|
||||
@ -156,4 +156,4 @@ iface = gr.Interface(
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
iface.launch()
|
||||
demo.launch()
|
||||
|
@ -9,11 +9,10 @@ def longest_word(text):
|
||||
|
||||
ex = "The quick brown fox jumped over the lazy dog."
|
||||
|
||||
iface = gr.Interface(
|
||||
demo = gr.Interface(
|
||||
longest_word, "textbox", "label", interpretation="default", examples=[[ex]]
|
||||
)
|
||||
|
||||
iface.test_launch()
|
||||
|
||||
if __name__ == "__main__":
|
||||
iface.launch()
|
||||
demo.launch()
|
||||
|
@ -37,13 +37,14 @@ def main_note(audio):
|
||||
if pitch not in volume_per_pitch:
|
||||
volume_per_pitch[pitch] = 0
|
||||
volume_per_pitch[pitch] += 1.0 * volume / total_volume
|
||||
volume_per_pitch = {k:float(v) for k,v in volume_per_pitch.items()}
|
||||
return volume_per_pitch
|
||||
|
||||
|
||||
iface = gr.Interface(
|
||||
demo = gr.Interface(
|
||||
main_note,
|
||||
"audio",
|
||||
gr.outputs.Label(num_top_classes=4),
|
||||
gr.Audio(source="microphone"),
|
||||
gr.Label(num_top_classes=4),
|
||||
examples=[
|
||||
["audio/recording1.wav"],
|
||||
["audio/cantina.wav"],
|
||||
@ -52,4 +53,4 @@ iface = gr.Interface(
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
iface.launch()
|
||||
demo.launch()
|
||||
|
Loading…
Reference in New Issue
Block a user