Upload app.py
Browse files
app.py
CHANGED
@@ -11,35 +11,37 @@ fs = project.get_feature_store()
|
|
11 |
|
12 |
|
13 |
mr = project.get_model_registry()
|
14 |
-
model = mr.get_model("
|
15 |
model_dir = model.download()
|
16 |
-
model = joblib.load(model_dir + "/
|
17 |
|
18 |
|
19 |
-
def
|
20 |
input_list = []
|
21 |
-
input_list.append(
|
22 |
-
input_list.append(
|
23 |
-
input_list.append(
|
24 |
-
input_list.append(
|
|
|
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 |
-
|
30 |
-
img = Image.open(requests.get(
|
31 |
return img
|
32 |
|
33 |
demo = gr.Interface(
|
34 |
-
fn=
|
35 |
-
title="
|
36 |
-
description="Experiment with
|
37 |
allow_flagging="never",
|
38 |
inputs=[
|
39 |
-
gr.inputs.Number(default=1.0, label="
|
40 |
-
gr.inputs.Number(default=1.0, label="
|
41 |
-
gr.inputs.Number(default=1.0, label="
|
42 |
-
gr.inputs.Number(default=1.0, label="
|
|
|
43 |
],
|
44 |
outputs=gr.Image(type="pil"))
|
45 |
|
|
|
11 |
|
12 |
|
13 |
mr = project.get_model_registry()
|
14 |
+
model = mr.get_model("titan_modal", version=50)
|
15 |
model_dir = model.download()
|
16 |
+
model = joblib.load(model_dir + "/titan_model.pkl")
|
17 |
|
18 |
|
19 |
+
def titan(pclass, sex, age, fare, famliy):
|
20 |
input_list = []
|
21 |
+
input_list.append(pclass)
|
22 |
+
input_list.append(sex)
|
23 |
+
input_list.append(age)
|
24 |
+
input_list.append(fare)
|
25 |
+
input_list.append(famliy)
|
26 |
# 'res' is a list of predictions returned as the label.
|
27 |
res = model.predict(np.asarray(input_list).reshape(1, -1))
|
28 |
# We add '[0]' to the result of the transformed 'res', because 'res' is a list, and we only want
|
29 |
# the first element.
|
30 |
+
survivor_url = "https://raw.githubusercontent.com/Chaouo/Titanic_serverless_ML/main/image/"+ str(res[0]) + ".png"
|
31 |
+
img = Image.open(requests.get(survivor_url, stream=True).raw)
|
32 |
return img
|
33 |
|
34 |
demo = gr.Interface(
|
35 |
+
fn=titan,
|
36 |
+
title="Titanic Survival Predictive Analytics",
|
37 |
+
description="Experiment with pclass, sex, age, fare, famliy to predict which flower it is.",
|
38 |
allow_flagging="never",
|
39 |
inputs=[
|
40 |
+
gr.inputs.Number(default=1.0, label="pclass (1-3)"),
|
41 |
+
gr.inputs.Number(default=1.0, label="sex (0 indecates male and 1 indecates female)"),
|
42 |
+
gr.inputs.Number(default=1.0, label="age"),
|
43 |
+
gr.inputs.Number(default=1.0, label="fare (0-512)"),
|
44 |
+
gr.inputs.Number(default=1.0, label="famliy (numbers)"),
|
45 |
],
|
46 |
outputs=gr.Image(type="pil"))
|
47 |
|