Spaces:
Runtime error
Runtime error
Edward Nagy
commited on
Commit
•
4657f3a
1
Parent(s):
948503e
Predict the wine class for the latest added wine
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
|
|
2 |
from PIL import Image
|
3 |
import hopsworks
|
4 |
import pandas as pd
|
|
|
5 |
|
6 |
project = hopsworks.login()
|
7 |
fs = project.get_feature_store()
|
@@ -11,16 +12,27 @@ dataset_api = project.get_dataset_api()
|
|
11 |
dataset_api.download("Resources/images/wine/df_recent.png")
|
12 |
dataset_api.download("Resources/images/wine/confusion_matrix.png")
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
with gr.Blocks() as demo:
|
20 |
with gr.Row():
|
21 |
with gr.Column():
|
22 |
gr.Label("Most Recent Wine Added")
|
23 |
out = gr.Textbox(latest_wine_string, readonly=True)
|
|
|
|
|
|
|
24 |
with gr.Row():
|
25 |
with gr.Column():
|
26 |
gr.Label("Recent Prediction History")
|
|
|
2 |
from PIL import Image
|
3 |
import hopsworks
|
4 |
import pandas as pd
|
5 |
+
import joblib
|
6 |
|
7 |
project = hopsworks.login()
|
8 |
fs = project.get_feature_store()
|
|
|
12 |
dataset_api.download("Resources/images/wine/df_recent.png")
|
13 |
dataset_api.download("Resources/images/wine/confusion_matrix.png")
|
14 |
|
15 |
+
# Read the latest wine added to the feature store
|
16 |
+
wine_fg = fs.get_feature_group(name="wine", version=1)
|
17 |
+
wine_df = wine_fg.read(read_options={"use_hive": True})
|
18 |
+
latest_wine_df = wine_df.tail(1)
|
19 |
+
latest_wine_string = latest_wine_df.to_string(index=False)
|
20 |
+
|
21 |
+
# Predict the wine class
|
22 |
+
mr = project.get_model_registry()
|
23 |
+
model = mr.get_model("wine_class_model", version=1)
|
24 |
+
model_dir = model.download()
|
25 |
+
model = joblib.load(model_dir + "/wine_class_model.pkl")
|
26 |
+
y_pred = model.predict(latest_wine_df)
|
27 |
|
28 |
with gr.Blocks() as demo:
|
29 |
with gr.Row():
|
30 |
with gr.Column():
|
31 |
gr.Label("Most Recent Wine Added")
|
32 |
out = gr.Textbox(latest_wine_string, readonly=True)
|
33 |
+
with gr.Column():
|
34 |
+
gr.Label("Predicted Wine Class")
|
35 |
+
out = gr.Textbox(y_pred[0], readonly=True)
|
36 |
with gr.Row():
|
37 |
with gr.Column():
|
38 |
gr.Label("Recent Prediction History")
|