Download app.py from ID2223/wine: direct link, hf CLI and curl.
- Browser
- Download file 1.44 kB
-
https://huggingface.co/spaces/ID2223/wine/resolve/main/app.py
- Command line
-
hf download hf://spaces/ID2223/wine/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ID2223/wine/resolve/main/app.py
1.44 kB
| import gradio as gr | |
| from PIL import Image | |
| import requests | |
| import hopsworks as hw | |
| import joblib | |
| import pandas as pd | |
| import xgboost as xgb | |
| project = hw.login(project="jayeshv") | |
| 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 Loaded...") | |
| def wine(type, | |
| fixed_acidity, | |
| volatile_acidity, | |
| sulphates, | |
| alcohol, | |
| density): | |
| print("Lets taste wine?") | |
| df = pd.DataFrame([[type, fixed_acidity, volatile_acidity, sulphates, alcohol, density]], | |
| columns = ['type', 'fixed_acidity', 'volatile_acidity', | |
| 'sulphates', 'alcohol', 'density']) | |
| print("Predicting...") | |
| print(df.head()) | |
| res = model.predict(df) | |
| print(res) | |
| return res | |
| demo = gr.Interface( | |
| fn = wine, | |
| title = 'Wine Quality prediction', | |
| description = '', | |
| allow_flagging = 'never', | |
| inputs = [ | |
| gr.Number(value=0, label="type"), | |
| gr.Number(value=6.3, label="fixed_acidity"), | |
| gr.Number(value=0.30, label="volatile_acidity"), | |
| gr.Number(value=0.49, label="sulphates"), | |
| gr.Number(value=9.5, label="alcohol"), | |
| gr.Number(value=0.994, label="density") | |
| ], | |
| outputs="number" # output's an integer from 3-9 | |
| ) | |
| demo.launch(debug=True) | |