Spaces:
Runtime error
Runtime error
Commit
·
4fed8fd
1
Parent(s):
be54493
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import joblib
|
2 |
+
import os
|
3 |
+
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
from huggingface_hub import hf_hub_download
|
7 |
+
|
8 |
+
|
9 |
+
file_path = hf_hub_download("osanseviero/wine-quality", "sklearn_model.joblib", use_auth_token=os.environ['TOKEN'])
|
10 |
+
model = joblib(filepath)
|
11 |
+
|
12 |
+
def predict(data):
|
13 |
+
return model.predict(data.to_numpy())
|
14 |
+
|
15 |
+
|
16 |
+
headers = [
|
17 |
+
"fixed acidity",
|
18 |
+
"volatile acidity",
|
19 |
+
"citric acid",
|
20 |
+
"residual sugar",
|
21 |
+
"chlorides",
|
22 |
+
"free sulfur dioxide",
|
23 |
+
"total sulfur dioxide",
|
24 |
+
"density",
|
25 |
+
"pH",
|
26 |
+
"sulphates",
|
27 |
+
"alcohol",
|
28 |
+
]
|
29 |
+
default = [
|
30 |
+
[7.4, 0.7, 0, 1.9, 0.076, 11, 34, 0.9978, 3.51, 0.56, 9.4],
|
31 |
+
[7.8, 0.88, 0, 2.6, 0.098, 25, 67, 0.9968, 3.2, 0.68, 9.8],
|
32 |
+
[7.8, 0.76, 0.04, 2.3, 0.092, 15, 54, 0.997, 3.26, 0.65, 9.8],
|
33 |
+
]
|
34 |
+
|
35 |
+
iface = gr.Interface(
|
36 |
+
wine_quality_predictor,
|
37 |
+
title="Wine Quality predictor with SKLearn",
|
38 |
+
inputs=gr.inputs.Dataframe(
|
39 |
+
headers=headers,
|
40 |
+
default=default,
|
41 |
+
),
|
42 |
+
outputs="numpy",
|
43 |
+
description="Learn how to create demos of private models at https://huggingface.co/spaces/osanseviero/tips-and-tricks"
|
44 |
+
)
|
45 |
+
iface.launch()
|