Spaces:
Runtime error
Runtime error
Commit
·
b3ad2bc
1
Parent(s):
355e1f1
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,48 +1,25 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from PIL import Image
|
| 3 |
import hopsworks
|
| 4 |
-
import joblib
|
| 5 |
|
| 6 |
project = hopsworks.login()
|
| 7 |
fs = project.get_feature_store()
|
| 8 |
-
mr = project.get_model_registry()
|
| 9 |
-
model = mr.get_model("titanic_survival_modal", version=1)
|
| 10 |
-
model_dir = model.download()
|
| 11 |
-
model = joblib.load(model_dir + "/titanic_model.pkl")
|
| 12 |
-
|
| 13 |
-
def tb_titanic(pclass,sex,age,sibsp,parch,embarked,fare_per_customer,cabin):
|
| 14 |
-
input_list = []
|
| 15 |
-
input_list.append(pclass)
|
| 16 |
-
input_list.append(sex)
|
| 17 |
-
input_list.append(age)
|
| 18 |
-
input_list.append(sibsp)
|
| 19 |
-
input_list.append(parch)
|
| 20 |
-
input_list.append(embarked)
|
| 21 |
-
input_list.append(fare_per_customer)
|
| 22 |
-
input_list.append(cabin)
|
| 23 |
-
# 'res' is a list of predictions returned as the label.
|
| 24 |
-
#global res
|
| 25 |
-
res = model.predict(np.asarray(input_list).reshape(1, 8))
|
| 26 |
-
if res[0]=="S":
|
| 27 |
-
return ("survived")
|
| 28 |
-
else:
|
| 29 |
-
return("deceased")
|
| 30 |
-
|
| 31 |
-
|
| 32 |
|
| 33 |
dataset_api = project.get_dataset_api()
|
|
|
|
|
|
|
|
|
|
| 34 |
dataset_api.download("Resources/images/df_recent.png")
|
| 35 |
dataset_api.download("Resources/images/confusion_matrix.png")
|
| 36 |
|
| 37 |
with gr.Blocks() as demo:
|
| 38 |
-
fn=tb_titanic,
|
| 39 |
with gr.Row():
|
| 40 |
with gr.Column():
|
| 41 |
-
gr.Label("Today's Predicted
|
| 42 |
-
|
| 43 |
with gr.Column():
|
| 44 |
-
gr.Label("Today's Actual
|
| 45 |
-
|
| 46 |
with gr.Row():
|
| 47 |
with gr.Column():
|
| 48 |
gr.Label("Recent Prediction History")
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from PIL import Image
|
| 3 |
import hopsworks
|
|
|
|
| 4 |
|
| 5 |
project = hopsworks.login()
|
| 6 |
fs = project.get_feature_store()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
dataset_api = project.get_dataset_api()
|
| 9 |
+
|
| 10 |
+
dataset_api.download("Resources/images/latest_survived.png")
|
| 11 |
+
dataset_api.download("Resources/images/actual_survived.png")
|
| 12 |
dataset_api.download("Resources/images/df_recent.png")
|
| 13 |
dataset_api.download("Resources/images/confusion_matrix.png")
|
| 14 |
|
| 15 |
with gr.Blocks() as demo:
|
|
|
|
| 16 |
with gr.Row():
|
| 17 |
with gr.Column():
|
| 18 |
+
gr.Label("Today's Predicted Image")
|
| 19 |
+
input_img = gr.Image("latest_survived.png", elem_id="predicted-img")
|
| 20 |
with gr.Column():
|
| 21 |
+
gr.Label("Today's Actual Image")
|
| 22 |
+
input_img = gr.Image("actual_survived.png", elem_id="actual-img")
|
| 23 |
with gr.Row():
|
| 24 |
with gr.Column():
|
| 25 |
gr.Label("Recent Prediction History")
|