Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,19 +11,19 @@ fs = project.get_feature_store()
|
|
| 11 |
|
| 12 |
|
| 13 |
mr = project.get_model_registry()
|
| 14 |
-
model = mr.get_model("
|
| 15 |
model_dir = model.download()
|
| 16 |
model = joblib.load(model_dir + "/wine_model.pkl")
|
| 17 |
|
| 18 |
|
| 19 |
-
def wine(
|
| 20 |
print("Calling function")
|
| 21 |
-
if type=='White':
|
| 22 |
-
|
| 23 |
-
else:
|
| 24 |
-
|
| 25 |
-
df = pd.DataFrame([[
|
| 26 |
-
columns=['
|
| 27 |
print("Predicting")
|
| 28 |
print(df)
|
| 29 |
# 'res' is a list of predictions returned as the label.
|
|
@@ -31,6 +31,7 @@ def wine(type, volatile_acidity, chlorides, density, alcohol):
|
|
| 31 |
# We add '[0]' to the result of the transformed 'res', because 'res' is a list, and we only want
|
| 32 |
# the first element.
|
| 33 |
print(res)
|
|
|
|
| 34 |
flower_url = "https://raw.githubusercontent.com/rezaqorbani/scalable-ml-and-dl-labs/main/lab1/wine/wine_images/" + str(res[0]) + ".png"
|
| 35 |
img = Image.open(requests.get(flower_url, stream=True).raw)
|
| 36 |
return img
|
|
@@ -42,9 +43,11 @@ demo = gr.Interface(
|
|
| 42 |
description="Experiment with different input features to predict the wine quality.",
|
| 43 |
allow_flagging="never",
|
| 44 |
inputs=[
|
| 45 |
-
gr.inputs.Radio(default='White', label="Wine type", choices=['White','Red']),
|
| 46 |
gr.inputs.Slider(0,1.6,label='Volatile Acidity'),
|
|
|
|
| 47 |
gr.inputs.Slider(0,0.7, label="Chlorides"),
|
|
|
|
| 48 |
gr.inputs.Slider(0.98,1.04, label="Density"),
|
| 49 |
gr.inputs.Number(default='10', label="Alcohol"),
|
| 50 |
],
|
|
|
|
| 11 |
|
| 12 |
|
| 13 |
mr = project.get_model_registry()
|
| 14 |
+
model = mr.get_model("wine_model_final", version=1)
|
| 15 |
model_dir = model.download()
|
| 16 |
model = joblib.load(model_dir + "/wine_model.pkl")
|
| 17 |
|
| 18 |
|
| 19 |
+
def wine(volatile_acidity,citric_acid, chlorides, total_sulfur_dioxide, density, alcohol):
|
| 20 |
print("Calling function")
|
| 21 |
+
# if type=='White':
|
| 22 |
+
# type=1
|
| 23 |
+
# else:
|
| 24 |
+
# type=0
|
| 25 |
+
df = pd.DataFrame([[volatile_acidity, citric_acid, chlorides, total_sulfur_dioxide ,density, alcohol]],
|
| 26 |
+
columns=['volatile_acidity','citric_acid', 'chlorides', 'total_sulfur_dioxide','density', 'alcohol'])
|
| 27 |
print("Predicting")
|
| 28 |
print(df)
|
| 29 |
# 'res' is a list of predictions returned as the label.
|
|
|
|
| 31 |
# We add '[0]' to the result of the transformed 'res', because 'res' is a list, and we only want
|
| 32 |
# the first element.
|
| 33 |
print(res)
|
| 34 |
+
#TO_DO: Add images, change to url to the directory with our images
|
| 35 |
flower_url = "https://raw.githubusercontent.com/rezaqorbani/scalable-ml-and-dl-labs/main/lab1/wine/wine_images/" + str(res[0]) + ".png"
|
| 36 |
img = Image.open(requests.get(flower_url, stream=True).raw)
|
| 37 |
return img
|
|
|
|
| 43 |
description="Experiment with different input features to predict the wine quality.",
|
| 44 |
allow_flagging="never",
|
| 45 |
inputs=[
|
| 46 |
+
#gr.inputs.Radio(default='White', label="Wine type", choices=['White','Red']),
|
| 47 |
gr.inputs.Slider(0,1.6,label='Volatile Acidity'),
|
| 48 |
+
gr.inputs.Slider(0,1.7,label='Citric Acid'),
|
| 49 |
gr.inputs.Slider(0,0.7, label="Chlorides"),
|
| 50 |
+
gr.inputs.Slider(6,440,label='Total Sulfur Dioxide'),
|
| 51 |
gr.inputs.Slider(0.98,1.04, label="Density"),
|
| 52 |
gr.inputs.Number(default='10', label="Alcohol"),
|
| 53 |
],
|