mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-27 01:40:20 +08:00
checked 7 more demos
This commit is contained in:
parent
1a500bff43
commit
d074d23d76
@ -17,7 +17,7 @@ def chat(message, history):
|
||||
return history, history
|
||||
|
||||
|
||||
iface = gr.Interface(
|
||||
demo = gr.Interface(
|
||||
chat,
|
||||
["text", "state"],
|
||||
["chatbot", "state"],
|
||||
@ -25,4 +25,4 @@ iface = gr.Interface(
|
||||
allow_flagging="never",
|
||||
)
|
||||
if __name__ == "__main__":
|
||||
iface.launch()
|
||||
demo.launch()
|
||||
|
@ -11,15 +11,15 @@ def diff_texts(text1, text2):
|
||||
]
|
||||
|
||||
|
||||
iface = gr.Interface(
|
||||
demo = gr.Interface(
|
||||
diff_texts,
|
||||
[
|
||||
gr.inputs.Textbox(
|
||||
gr.Textbox(
|
||||
lines=3, default="The quick brown fox jumped over the lazy dogs."
|
||||
),
|
||||
gr.inputs.Textbox(lines=3, default="The fast brown fox jumps over lazy dogs."),
|
||||
gr.Textbox(lines=3, default="The fast brown fox jumps over lazy dogs."),
|
||||
],
|
||||
gr.outputs.HighlightedText(color_map={"+": "green", "-": "pink"}),
|
||||
gr.HighlightedText(),
|
||||
)
|
||||
if __name__ == "__main__":
|
||||
iface.launch()
|
||||
demo.launch()
|
||||
|
@ -18,20 +18,20 @@ def recognize_digit(image):
|
||||
return {str(i): prediction[i] for i in range(10)}
|
||||
|
||||
|
||||
im = gradio.inputs.Image(
|
||||
im = gradio.Image(
|
||||
shape=(28, 28), image_mode="L", invert_colors=False, source="canvas"
|
||||
)
|
||||
|
||||
iface = gr.Interface(
|
||||
demo = gr.Interface(
|
||||
recognize_digit,
|
||||
im,
|
||||
gradio.outputs.Label(num_top_classes=3),
|
||||
gradio.Label(num_top_classes=3),
|
||||
live=True,
|
||||
interpretation="default",
|
||||
capture_session=True,
|
||||
)
|
||||
|
||||
iface.test_launch()
|
||||
demo.test_launch()
|
||||
|
||||
if __name__ == "__main__":
|
||||
iface.launch()
|
||||
demo.launch()
|
||||
|
@ -25,18 +25,18 @@ def disease_report(img, scan_for, generate_report):
|
||||
return results, report if generate_report else None
|
||||
|
||||
|
||||
iface = gr.Interface(
|
||||
demo = gr.Interface(
|
||||
disease_report,
|
||||
[
|
||||
"image",
|
||||
gr.inputs.CheckboxGroup(
|
||||
gr.CheckboxGroup(
|
||||
["Cancer", "Rash", "Heart Failure", "Stroke", "Diabetes", "Pneumonia"]
|
||||
),
|
||||
"checkbox",
|
||||
],
|
||||
[
|
||||
gr.outputs.Carousel(["text", "image"], label="Disease"),
|
||||
gr.outputs.File(label="Report"),
|
||||
gr.Carousel(["text", "image"], label="Disease"),
|
||||
gr.File(label="Report"),
|
||||
],
|
||||
title="Disease Report",
|
||||
description="Upload an Xray and select the diseases to scan for.",
|
||||
@ -46,4 +46,4 @@ iface = gr.Interface(
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
iface.launch()
|
||||
demo.launch()
|
||||
|
@ -5,21 +5,19 @@ def filter_records(records, gender):
|
||||
return records[records["gender"] == gender]
|
||||
|
||||
|
||||
iface = gr.Interface(
|
||||
demo = gr.Interface(
|
||||
filter_records,
|
||||
[
|
||||
gr.inputs.Dataframe(
|
||||
gr.Dataframe(
|
||||
headers=["name", "age", "gender"],
|
||||
datatype=["str", "number", "str"],
|
||||
row_count=5,
|
||||
),
|
||||
gr.inputs.Dropdown(["M", "F", "O"]),
|
||||
gr.Dropdown(["M", "F", "O"]),
|
||||
],
|
||||
"dataframe",
|
||||
description="Enter gender as 'M', 'F', or 'O' for other.",
|
||||
)
|
||||
|
||||
iface.test_launch()
|
||||
|
||||
if __name__ == "__main__":
|
||||
iface.launch()
|
||||
demo.launch()
|
||||
|
@ -1,5 +1,3 @@
|
||||
import random
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
@ -24,19 +22,19 @@ def plot_forecast(final_year, companies, noise, show_legend, point_style):
|
||||
return fig
|
||||
|
||||
|
||||
iface = gr.Interface(
|
||||
demo = gr.Interface(
|
||||
plot_forecast,
|
||||
[
|
||||
gr.inputs.Radio([2025, 2030, 2035, 2040], label="Project to:"),
|
||||
gr.inputs.CheckboxGroup(
|
||||
gr.Radio([2025, 2030, 2035, 2040], label="Project to:"),
|
||||
gr.CheckboxGroup(
|
||||
["Google", "Microsoft", "Gradio"], label="Company Selection"
|
||||
),
|
||||
gr.inputs.Slider(1, 100, label="Noise Level"),
|
||||
gr.inputs.Checkbox(label="Show Legend"),
|
||||
gr.inputs.Dropdown(["cross", "line", "circle"], label="Style"),
|
||||
gr.Slider(1, 100, label="Noise Level"),
|
||||
gr.Checkbox(label="Show Legend"),
|
||||
gr.Dropdown(["cross", "line", "circle"], label="Style"),
|
||||
],
|
||||
gr.outputs.Image(plot=True, label="forecast"),
|
||||
gr.Image(plot=True, label="forecast"),
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
iface.launch()
|
||||
demo.launch()
|
||||
|
@ -6,7 +6,7 @@ Example: python write_config.py calculator output.json
|
||||
Assumes:
|
||||
- The demo_name is a folder in this directory
|
||||
- The demo_name folder contains a run.py file
|
||||
- The run.py which defines a Gradio Interface/Blocks instance called demo
|
||||
- The run.py file defines a Gradio Interface/Blocks instance called `demo`
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
Loading…
Reference in New Issue
Block a user