saad177 commited on
Commit
1690f28
1 Parent(s): 5bbd83a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -0
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import hopsworks
3
+ import joblib
4
+ import pandas as pd
5
+ import requests
6
+ from PIL import Image
7
+
8
+ project = hopsworks.login()
9
+ fs = project.get_feature_store()
10
+
11
+ print("trying to dl model")
12
+ mr = project.get_model_registry()
13
+ model = mr.get_model("wine_model", version=1)
14
+ model_dir = model.download()
15
+ model = joblib.load(model_dir + "/wine_model.pkl")
16
+ print("Model downloaded")
17
+
18
+
19
+ def wine(volatile_acidity, chlorides, density, alcohol):
20
+ print("Calling wine function")
21
+ df = pd.DataFrame(
22
+ [[alcohol, chlorides, volatile_acidity, density]],
23
+ columns=["alcohol", "chlorides", "volatile_acidity", "density"],
24
+ )
25
+ print("Predicting")
26
+ print(df)
27
+ res = model.predict(df)
28
+ print(res)
29
+ return res
30
+
31
+
32
+ demo = gr.Interface(
33
+ fn=wine,
34
+ title="Wine Quality Predictive Analytics",
35
+ description="Experiment with different values for these properties",
36
+ allow_flagging="never",
37
+ inputs=[
38
+ gr.Number(label="Alcohol"),
39
+ gr.Number(label="Chlorides"),
40
+ gr.Number(label="Volatile Acidity"),
41
+ gr.Number(label="Density"),
42
+ ],
43
+ outputs=gr.Number(label="Quality"),
44
+ )
45
+
46
+ demo.launch(debug=True)