File size: 1,163 Bytes
1690f28
 
 
 
 
 
 
 
 
 
 
 
e9e8948
1690f28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import hopsworks
import joblib
import pandas as pd
import requests
from PIL import Image

project = hopsworks.login()
fs = project.get_feature_store()

print("trying to dl model")
mr = project.get_model_registry()
model = mr.get_model("wine_model", version=1)
model_dir = model.download()
model = joblib.load(model_dir + "/wine_model.pkl")
print("Model downloaded")


def wine(volatile_acidity, chlorides, density, alcohol):
    print("Calling wine function")
    df = pd.DataFrame(
        [[alcohol, chlorides, volatile_acidity, density]],
        columns=["alcohol", "chlorides", "volatile_acidity", "density"],
    )
    print("Predicting")
    print(df)
    res = model.predict(df)
    print(res)
    return res


demo = gr.Interface(
    fn=wine,
    title="Wine Quality Predictive Analytics",
    description="Experiment with different values for these properties",
    allow_flagging="never",
    inputs=[
        gr.Number(label="Alcohol"),
        gr.Number(label="Chlorides"),
        gr.Number(label="Volatile Acidity"),
        gr.Number(label="Density"),
    ],
    outputs=gr.Number(label="Quality"),
)

demo.launch(debug=True)