gradio/demo/basic_text.py

28 lines
1.0 KiB
Python
Raw Normal View History

2020-06-10 08:00:30 +08:00
import gradio as gr
2020-07-09 05:53:24 +08:00
2020-06-10 08:00:30 +08:00
2020-07-06 23:21:08 +08:00
def answer_question(quantity, animal, place, activity_list, morning, etc):
return f"""The {quantity} {animal}s went to the {place} where they {" and ".join(activity_list)} until the {"morning" if morning else "night"}""", "OK"
2020-06-11 14:04:14 +08:00
2020-06-19 04:15:27 +08:00
gr.Interface(answer_question,
2020-06-12 02:25:38 +08:00
[
2020-07-01 01:11:52 +08:00
gr.inputs.Slider(2, 20),
gr.inputs.Dropdown(["cat", "dog", "bird"]),
gr.inputs.Radio(["park", "zoo", "road"]),
gr.inputs.CheckboxGroup(["ran", "swam", "ate", "slept"]),
gr.inputs.Checkbox(label="Is it the morning?"),
2020-07-06 23:21:08 +08:00
gr.inputs.Textbox(default="What else?"),
2020-07-01 01:11:52 +08:00
],
2020-07-06 23:21:08 +08:00
[
2020-07-09 05:53:24 +08:00
gr.outputs.Textbox(),
gr.outputs.Textbox(),
2020-07-06 23:21:08 +08:00
],
2020-07-01 01:11:52 +08:00
examples=[
[2, "cat", "park", ["ran", "swam"], True],
[4, "dog", "zoo", ["ate", "swam"], False],
[10, "bird", "road", ["ran"], False],
[8, "cat", "zoo", ["ate"], True],
2020-06-19 04:15:27 +08:00
]
2020-06-30 03:22:32 +08:00
).launch()