2020-06-10 08:00:30 +08:00
|
|
|
import gradio as gr
|
2020-08-28 23:56:03 +08:00
|
|
|
|
2022-01-21 21:44:12 +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
|
|
|
|
|
|
|
|
2022-03-29 06:28:01 +08:00
|
|
|
demo = gr.Interface(
|
2020-08-28 23:56:03 +08:00
|
|
|
sentence_builder,
|
|
|
|
[
|
2022-07-19 23:16:56 +08:00
|
|
|
gr.Slider(2, 20, value=4),
|
2022-03-29 06:28:01 +08:00
|
|
|
gr.Dropdown(["cat", "dog", "bird"]),
|
|
|
|
gr.Radio(["park", "zoo", "road"]),
|
|
|
|
gr.CheckboxGroup(["ran", "swam", "ate", "slept"]),
|
|
|
|
gr.Checkbox(label="Is it the morning?"),
|
2020-08-28 23:56:03 +08:00
|
|
|
],
|
|
|
|
"text",
|
|
|
|
examples=[
|
|
|
|
[2, "cat", "park", ["ran", "swam"], True],
|
|
|
|
[4, "dog", "zoo", ["ate", "swam"], False],
|
|
|
|
[10, "bird", "road", ["ran"], False],
|
|
|
|
[8, "cat", "zoo", ["ate"], True],
|
2021-05-13 00:29:18 +08:00
|
|
|
],
|
2021-05-29 01:04:03 +08:00
|
|
|
)
|
2020-10-23 22:28:30 +08:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2022-03-29 06:28:01 +08:00
|
|
|
demo.launch()
|