WCarlW commited on
Commit
6d069bc
·
1 Parent(s): 0733f98

Fix inputs

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -41,20 +41,21 @@ def convertSex(choice):
41
  else:
42
  return gr.Number(2.0)
43
 
 
 
 
 
 
 
 
 
 
44
  demo = gr.Interface(
45
  fn=titanic,
46
  title="Titanic Predictive Analytics",
47
  description="Experiment with Passenger class/Sex/Age/SibSp to predict if the person is survived or not.",
48
  allow_flagging="never",
49
- inputs=[
50
- gr.inputs.Number(default=1.0, label="Pclass (Flight class 1/2/3)"),
51
- gr.inputs.Radio(
52
- ["Male", "Female"],
53
- label="Sex"
54
- ).change(fn=convertSex),
55
- gr.inputs.Number(default=1.0, label="Age (in years)"),
56
- gr.inputs.Number(default=1.0, label="SibSp (number of siblings)"),
57
- ],
58
  outputs=gr.Textbox(label="Result: "))
59
 
60
  demo.launch()
 
41
  else:
42
  return gr.Number(2.0)
43
 
44
+ def inputs():
45
+ pclass = gr.inputs.Number(default=1.0, label="Pclass (Flight class 1/2/3)")
46
+ sex = gr.inputs.Radio(["Male", "Female"], label="Sex")
47
+ sex.change(fn=convertSex, inputs=sex, outputs=sex_num)
48
+ age = gr.inputs.Number(default=1.0, label="Age (in years)")
49
+ sibsp = gr.inputs.Number(default=1.0, label="SibSp (number of siblings)")
50
+ return [pclass, sex_num, age, sibsp]
51
+
52
+
53
  demo = gr.Interface(
54
  fn=titanic,
55
  title="Titanic Predictive Analytics",
56
  description="Experiment with Passenger class/Sex/Age/SibSp to predict if the person is survived or not.",
57
  allow_flagging="never",
58
+ inputs=inputs,
 
 
 
 
 
 
 
 
59
  outputs=gr.Textbox(label="Result: "))
60
 
61
  demo.launch()