John Smith commited on
Commit
cb9b710
·
1 Parent(s): bcaf4b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -11
app.py CHANGED
@@ -1,16 +1,33 @@
1
  import gradio as gr
2
 
3
- # Define your model prediction function
4
- def predict(selected_option):
5
- # Implement your model prediction logic here based on the selected_option
6
- result = f"You selected: {selected_option}"
7
- return result
8
 
9
- # Create a Dropdown input component
10
- input_dropdown = gr.inputs.Dropdown(choices=["Option 1", "Option 2", "Option 3"])
11
 
12
- # Create the Gradio interface
13
- iface = gr.Interface(fn=predict, inputs=input_dropdown, outputs="text")
14
 
15
- # Launch the interface
16
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
 
 
 
 
 
3
 
4
+ def sentence_builder(quantity, animal, countries, place, activity_list, morning):
5
+ return f"""The {quantity} {animal}s from {" and ".join(countries)} went to the {place} where they {" and ".join(activity_list)} until the {"morning" if morning else "night"}"""
6
 
 
 
7
 
8
+ demo = gr.Interface(
9
+ sentence_builder,
10
+ [
11
+ gr.Slider(2, 20, value=4, label="Count", info="Choose between 2 and 20"),
12
+ gr.Dropdown(
13
+ ["cat", "dog", "bird"], label="Animal", info="Will add more animals later!"
14
+ ),
15
+ gr.CheckboxGroup(["USA", "Japan", "Pakistan"], label="Countries", info="Where are they from?"),
16
+ gr.Radio(["park", "zoo", "road"], label="Location", info="Where did they go?"),
17
+ gr.Dropdown(
18
+ ["ran", "swam", "ate", "slept"], value=["swam", "slept"], multiselect=True, label="Activity", info="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed auctor, nisl eget ultricies aliquam, nunc nisl aliquet nunc, eget aliquam nisl nunc vel nisl."
19
+ ),
20
+ gr.Checkbox(label="Morning", info="Did they do it in the morning?"),
21
+ ],
22
+ "text",
23
+ examples=[
24
+ [2, "cat", ["Japan", "Pakistan"], "park", ["ate", "swam"], True],
25
+ [4, "dog", ["Japan"], "zoo", ["ate", "swam"], False],
26
+ [10, "bird", ["USA", "Pakistan"], "road", ["ran"], False],
27
+ [8, "cat", ["Pakistan"], "zoo", ["ate"], True],
28
+ ]
29
+ )
30
+
31
+ if __name__ == "__main__":
32
+ demo.launch()
33
+