tnt306 commited on
Commit
72baa29
·
1 Parent(s): bc74725

Test checkbox

Browse files
Files changed (1) hide show
  1. app.py +27 -9
app.py CHANGED
@@ -3,8 +3,8 @@ from typing import Dict
3
  import gradio as gr
4
 
5
 
6
- def predict(text: str) -> Dict:
7
- return {"alive": 0.9, "death": 0.1}
8
 
9
 
10
  example_list = [[1.0, 1.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0]]
@@ -14,13 +14,31 @@ title = "This is title."
14
  description = "This is description."
15
  article = "This is article."
16
 
17
- demo = gr.Interface(fn=predict,
18
- inputs="text",
19
- outputs=gr.Label(num_top_classes=2, label="Predictions"),
20
- examples=example_list,
21
- title=title,
22
- description=description,
23
- article=article)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  demo.launch(debug=False,
26
  share=True)
 
3
  import gradio as gr
4
 
5
 
6
+ # def predict(text: str) -> Dict:
7
+ # return {"alive": 0.9, "death": 0.1}
8
 
9
 
10
  example_list = [[1.0, 1.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, 0.0]]
 
14
  description = "This is description."
15
  article = "This is article."
16
 
17
+ def sentence_builder(quantity, animal, countries, place, activity_list, morning):
18
+ 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"}"""
19
+
20
+ demo = gr.Interface(
21
+ sentence_builder,
22
+ [
23
+ gr.Slider(2, 20, value=4, label="Count", info="Choose between 2 and 20"),
24
+ gr.Dropdown(
25
+ ["cat", "dog", "bird"], label="Animal", info="Will add more animals later!"
26
+ ),
27
+ gr.CheckboxGroup(["USA", "Japan", "Pakistan"], label="Countries", info="Where are they from?"),
28
+ gr.Radio(["park", "zoo", "road"], label="Location", info="Where did they go?"),
29
+ gr.Dropdown(
30
+ ["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."
31
+ ),
32
+ gr.Checkbox(label="Morning", info="Did they do it in the morning?"),
33
+ ],
34
+ "text",
35
+ examples=[
36
+ [2, "cat", ["Japan", "Pakistan"], "park", ["ate", "swam"], True],
37
+ [4, "dog", ["Japan"], "zoo", ["ate", "swam"], False],
38
+ [10, "bird", ["USA", "Pakistan"], "road", ["ran"], False],
39
+ [8, "cat", ["Pakistan"], "zoo", ["ate"], True],
40
+ ]
41
+ )
42
 
43
  demo.launch(debug=False,
44
  share=True)