Spaces:
Runtime error
Runtime error
import gradio as gr | |
from PIL import Image | |
import requests | |
import hopsworks | |
import joblib | |
import pandas as pd | |
project = hopsworks.login() | |
fs = project.get_feature_store() | |
mr = project.get_model_registry() | |
model = mr.get_model("wine_model", version=2) | |
model_dir = model.download() | |
model = joblib.load(model_dir + "/wine_model.pkl") | |
print("Model downloaded") | |
def wine(alcohol, chlorides, density, type, volatil_acidity): | |
print("Calling function") | |
df = pd.DataFrame([[alcohol, chlorides, density, type, volatil_acidity]], | |
columns=['alcohol','chlorides','density','type','volatil_acidity']) | |
print("Predicting") | |
print(df) | |
res = model.predict(df) | |
print(res) | |
wine_url = "https://raw.githubusercontent.com/Anniyuku/wine_quality/main/" + res[0] + ".png" | |
img = Image.open(requests.get(wine_url, stream=True).raw) | |
return img | |
demo = gr.Interface( | |
fn=wine, | |
title="Wine Predictive Analytics", | |
description="Experiment with alcohol, chlorides, density, type, volatil_acidity to predict which flower it is.", | |
allow_flagging="never", | |
inputs=[ | |
gr.inputs.Number(default=10.00, label="alcohol"), | |
gr.inputs.Number(default=0.60, label="chlorides"), | |
gr.inputs.Number(default=1.00, label="density"), | |
gr.inputs.Number(default=1.00, label="type"), | |
gr.inputs.Number(default=1.00, label="volatil_acidity"), | |
], | |
outputs=gr.Image(type="pil")) | |
demo.launch(debug=True) | |