gradio/demo/sentence_builder.py

24 lines
925 B
Python
Raw Normal View History

2020-06-10 08:00:30 +08:00
import gradio as gr
2020-07-15 06:43:47 +08:00
import numpy as np
2020-06-10 08:00:30 +08:00
2020-08-20 05:27:22 +08:00
def sentence_builder(quantity, animal, place, activity_list, morning):
2020-08-15 03:34:26 +08:00
return f"""The {quantity} {animal}s went to the {place} where they {" and ".join(activity_list)} until the {"morning" if morning else "night"}"""
2020-06-11 14:04:14 +08:00
2020-08-20 05:27:22 +08:00
gr.Interface(sentence_builder,
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-08-15 03:34:26 +08:00
"text",
2020-07-01 01:11:52 +08:00
examples=[
2020-08-15 03:34:26 +08:00
[2, "cat", "park", ["ran", "swam"], True],
[4, "dog", "zoo", ["ate", "swam"], False],
[10, "bird", "road", ["ran"], False],
[8, "cat", "zoo", ["ate"], True],
2020-07-15 06:43:47 +08:00
],
2020-06-30 03:22:32 +08:00
).launch()