File size: 1,436 Bytes
e7a3d57
 
 
 
 
 
6cb1810
e7a3d57
7f4c3e2
e7a3d57
 
 
a715e4b
e7a3d57
 
 
 
 
 
 
 
 
509a137
 
e7a3d57
 
509a137
e7a3d57
509a137
e7a3d57
 
509a137
e7a3d57
 
 
a715e4b
e7a3d57
 
 
 
 
 
 
869b3d0
a715e4b
 
 
 
 
e7a3d57
9db15a2
e7a3d57
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import gradio as gr
from PIL import Image
import requests
import hopsworks as hw
import joblib
import pandas as pd
import xgboost as xgb

project = hw.login(project="jayeshv")
fs = project.get_feature_store()

mr = project.get_model_registry()
model = mr.get_model("wine_model", version=2)
model_dir = model.download()

model = joblib.load(model_dir+'/wine_model.pkl')
print("Model Loaded...")

def wine(type,
         fixed_acidity,
         volatile_acidity,
         sulphates,
         alcohol,
         density):
    print("Lets taste wine?")
    
    df = pd.DataFrame([[type, fixed_acidity, volatile_acidity, sulphates, alcohol, density]],
                      columns = ['type', 'fixed_acidity', 'volatile_acidity',
                                 'sulphates', 'alcohol', 'density'])
    
    print("Predicting...")
    print(df.head())
    res = model.predict(df)
    print(res)
    
    return res

demo = gr.Interface(
    fn = wine,
    title = 'Wine Quality prediction',
    description = '',
    allow_flagging = 'never',
    inputs = [
        gr.Number(value=0, label="type"),
        gr.Number(value=6.3, label="fixed_acidity"),
        gr.Number(value=0.30, label="volatile_acidity"),
        gr.Number(value=0.49, label="sulphates"),
        gr.Number(value=9.5, label="alcohol"),
        gr.Number(value=0.994, label="density")
    ],
    outputs="number" # output's an integer from 3-9
)

demo.launch(debug=True)