Spaces:
Runtime error
Runtime error
Commit ·
7af5817
1
Parent(s): ccdda20
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,45 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from PIL import Image
|
| 3 |
-
import requests
|
| 4 |
-
import hopsworks
|
| 5 |
-
import joblib
|
| 6 |
-
import pandas as pd
|
| 7 |
-
|
| 8 |
-
project = hopsworks.login()
|
| 9 |
-
fs = project.get_feature_store()
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
mr = project.get_model_registry()
|
| 13 |
-
model = mr.get_model("wine_model", version=2)
|
| 14 |
-
model_dir = model.download()
|
| 15 |
-
model = joblib.load(model_dir + "/wine_model.pkl")
|
| 16 |
-
print("Model downloaded")
|
| 17 |
-
|
| 18 |
-
def wine(alcohol, chlorides, density, type, volatil_acidity):
|
| 19 |
-
print("Calling function")
|
| 20 |
-
df = pd.DataFrame([[alcohol, chlorides, density, type, volatil_acidity]],
|
| 21 |
-
columns=['alcohol','chlorides','density','type','volatil_acidity'])
|
| 22 |
-
print("Predicting")
|
| 23 |
-
print(df)
|
| 24 |
-
res = model.predict(df)
|
| 25 |
-
print(res)
|
| 26 |
-
wine_url = "https://raw.githubusercontent.com/Anniyuku/wine_quality/main/" + res[0] + ".png"
|
| 27 |
-
img = Image.open(requests.get(wine_url, stream=True).raw)
|
| 28 |
-
return img
|
| 29 |
-
|
| 30 |
-
demo = gr.Interface(
|
| 31 |
-
fn=wine,
|
| 32 |
-
title="Wine Predictive Analytics",
|
| 33 |
-
description="Experiment with alcohol, chlorides, density, type, volatil_acidity to predict which flower it is.",
|
| 34 |
-
allow_flagging="never",
|
| 35 |
-
inputs=[
|
| 36 |
-
gr.inputs.Number(default=9.00, label="alcohol"),
|
| 37 |
-
gr.inputs.Number(default=0.60, label="chlorides"),
|
| 38 |
-
gr.inputs.Number(default=1.00, label="density"),
|
| 39 |
-
gr.inputs.Number(default=1.00, label="type"),
|
| 40 |
-
gr.inputs.Number(default=1.00, label="volatil_acidity"),
|
| 41 |
-
],
|
| 42 |
-
outputs=gr.Image(type="pil"))
|
| 43 |
-
|
| 44 |
-
demo.launch(debug=True)
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|