Louis VAUBOURDOLLE
commited on
Commit
·
7e24559
1
Parent(s):
86a4396
[ADD] gradio example
Browse files
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
def sentence_builder(quantity, animal, place, activity_list, morning):
|
| 4 |
+
return f"""The {quantity} {animal}s went to the {place} where they {" and ".join(activity_list)} until the {"morning" if morning else "night"}"""
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
iface = gr.Interface(
|
| 8 |
+
sentence_builder,
|
| 9 |
+
[
|
| 10 |
+
gr.inputs.Slider(2, 20),
|
| 11 |
+
gr.inputs.Dropdown(["cat", "dog", "bird"]),
|
| 12 |
+
gr.inputs.Radio(["park", "zoo", "road"]),
|
| 13 |
+
gr.inputs.CheckboxGroup(["ran", "swam", "ate", "slept"]),
|
| 14 |
+
gr.inputs.Checkbox(label="Is it the morning?"),
|
| 15 |
+
],
|
| 16 |
+
"text",
|
| 17 |
+
examples=[
|
| 18 |
+
[2, "cat", "park", ["ran", "swam"], True],
|
| 19 |
+
[4, "dog", "zoo", ["ate", "swam"], False],
|
| 20 |
+
[10, "bird", "road", ["ran"], False],
|
| 21 |
+
[8, "cat", "zoo", ["ate"], True],
|
| 22 |
+
],
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
iface.launch()
|