Spaces:
Runtime error
Runtime error
Victorlopo21
commited on
Commit
•
ee377d1
1
Parent(s):
8d5df33
Update app.py
Browse files
app.py
CHANGED
@@ -16,39 +16,5 @@ model_dir = model.download()
|
|
16 |
model = joblib.load(model_dir + "/titanic_model.pkl")
|
17 |
|
18 |
|
19 |
-
|
20 |
-
input_list = []
|
21 |
-
input_list.append(pclass)
|
22 |
-
input_list.append(sex)
|
23 |
-
input_list.append(family)
|
24 |
-
input_list.append(groupedage)
|
25 |
-
# 'res' is a list of predictions returned as the label.
|
26 |
-
res = model.predict(np.asarray(input_list).reshape(1, -1))
|
27 |
-
# We add '[0]' to the result of the transformed 'res', because 'res' is a list, and we only want
|
28 |
-
# the first element.
|
29 |
-
if res[0] == 1:
|
30 |
-
passenger_url = "https://cdn.pixabay.com/photo/2018/08/02/18/58/survival-3580200_960_720.png"
|
31 |
-
else:
|
32 |
-
passenger_url = "https://pngimg.com/uploads/death/death_PNG55.png"
|
33 |
-
|
34 |
-
img = Image.open(requests.get(passenger_url, stream=True).raw)
|
35 |
-
return img
|
36 |
-
#return res[0]
|
37 |
-
|
38 |
-
|
39 |
-
demo_titanic = gr.Interface(
|
40 |
-
fn=passenger,
|
41 |
-
title="Titanic Predictive Analytics",
|
42 |
-
description="Experiment to predict if a passenger survived or died in the titanic",
|
43 |
-
allow_flagging="never",
|
44 |
-
inputs=[
|
45 |
-
gr.inputs.Number(default=1.0, label="Pclass (Min:1, Max=3"),
|
46 |
-
gr.inputs.Number(default=1.0, label="Sex (Female:0 and Male:1)"),
|
47 |
-
gr.inputs.Number(default=1.0, label="Family (Number of family members in the boat[0,7])"),
|
48 |
-
gr.inputs.Number(default=1.0, label="Age (Child:0, Adult:1 and Old:2)")
|
49 |
-
],
|
50 |
-
outputs=gr.Image(type="pil"))
|
51 |
-
|
52 |
-
#outputs=gr.Label(num_top_classes=2)
|
53 |
-
demo_titanic.launch()
|
54 |
|
|
|
16 |
model = joblib.load(model_dir + "/titanic_model.pkl")
|
17 |
|
18 |
|
19 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|