Spaces:
Sleeping
Sleeping
filip_praca
commited on
Commit
•
55e527c
1
Parent(s):
ad33cee
initial
Browse files
app.py
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import numpy as np
|
3 |
+
from PIL import Image
|
4 |
+
import requests
|
5 |
+
|
6 |
+
import hopsworks
|
7 |
+
import joblib
|
8 |
+
|
9 |
+
project = hopsworks.login()
|
10 |
+
fs = project.get_feature_store()
|
11 |
+
|
12 |
+
|
13 |
+
mr = project.get_model_registry()
|
14 |
+
model = mr.get_model("wine_model", version=1)
|
15 |
+
model_dir = model.download()
|
16 |
+
model = joblib.load(model_dir + "/wine_model.pkl")
|
17 |
+
|
18 |
+
|
19 |
+
def wine(fixed_acidity,
|
20 |
+
volatile_acidity,
|
21 |
+
citric_acid,
|
22 |
+
residual_sugar,
|
23 |
+
chlorides,
|
24 |
+
free_sulfur_dioxide,
|
25 |
+
total_sulfur_dioxide,
|
26 |
+
density,
|
27 |
+
pH,
|
28 |
+
sulphates,
|
29 |
+
alcohol,
|
30 |
+
white):
|
31 |
+
input_list = []
|
32 |
+
|
33 |
+
input_list.append(fixed_acidity)
|
34 |
+
input_list.append(volatile_acidity)
|
35 |
+
input_list.append(citric_acid)
|
36 |
+
input_list.append(residual_sugar)
|
37 |
+
input_list.append(chlorides)
|
38 |
+
input_list.append(free_sulfur_dioxide)
|
39 |
+
input_list.append(total_sulfur_dioxide)
|
40 |
+
input_list.append(density)
|
41 |
+
input_list.append(pH)
|
42 |
+
input_list.append(sulphates)
|
43 |
+
input_list.append(alcohol)
|
44 |
+
input_list.append(white)
|
45 |
+
|
46 |
+
res = model.predict(np.asarray(input_list).reshape(1, -1))
|
47 |
+
return res
|
48 |
+
|
49 |
+
demo = gr.Interface(
|
50 |
+
fn=wine,
|
51 |
+
title="Wine prediction",
|
52 |
+
description="Wine quality prediction",
|
53 |
+
allow_flagging="never",
|
54 |
+
inputs=[
|
55 |
+
gr.inputs.Number(default=1.0, label="fixed_acidity"),
|
56 |
+
gr.inputs.Number(default=1.0, label="volatile_acidity"),
|
57 |
+
gr.inputs.Number(default=1.0, label="citric_acid"),
|
58 |
+
gr.inputs.Number(default=1.0, label="residual_sugar"),
|
59 |
+
gr.inputs.Number(default=1.0, label="chlorides"),
|
60 |
+
gr.inputs.Number(default=1.0, label="free_sulfur_dioxide"),
|
61 |
+
gr.inputs.Number(default=1.0, label="total_sulfur_dioxide"),
|
62 |
+
gr.inputs.Number(default=1.0, label="density"),
|
63 |
+
gr.inputs.Number(default=1.0, label="pH"),
|
64 |
+
gr.inputs.Number(default=1.0, label="sulphates"),
|
65 |
+
gr.inputs.Number(default=1.0, label="alcohol"),
|
66 |
+
gr.inputs.Number(default=1.0, label="white")
|
67 |
+
],
|
68 |
+
outputs=gr.Text(value="none")
|
69 |
+
)
|
70 |
+
|
71 |
+
|
72 |
+
demo.launch()
|