wine / app.py
martenb's picture
Updated app at sön 19 nov 2023 21:55:53 CET
4ef4650
raw
history blame
2.01 kB
import gradio as gr
from PIL import Image
import requests
import hopsworks
import joblib
import pandas as pd
# Placeholder for loading your trained models
# Load your models here, e.g., model_red = joblib.load('path_to_red_wine_model')
# model_white = joblib.load('path_to_white_wine_model')
def wine_quality(wine_type, fixed_acidity, volatile_acidity, citric_acid, residual_sugar, chlorides,
free_sulfur_dioxide, total_sulfur_dioxide, density, ph, sulphates, alcohol):
print("Calling wine_quality() function")
df = pd.DataFrame([[fixed_acidity, volatile_acidity, citric_acid, residual_sugar, chlorides,
free_sulfur_dioxide, total_sulfur_dioxide, density, ph, sulphates, alcohol]],
columns=['fixed_acidity', 'volatile_acidity', 'citric_acid', 'residual_sugar',
'chlorides', 'free_sulfur_dioxide', 'total_sulfur_dioxide', 'density',
'ph', 'sulphates', 'alcohol'])
print("Predicting...")
print(df)
# Use the appropriate model based on the wine type
if wine_type == 'Red':
# Placeholder for prediction with the red wine model
# quality = model_red.predict(df)[0]
quality = "Red Wine Quality Prediction Placeholder"
else:
# Placeholder for prediction with the white wine model
# quality = model_white.predict(df)[0]
quality = "White Wine Quality Prediction Placeholder"
return quality
# Define the Gradio interface
iface = gr.Interface(fn=wine_quality,
inputs=["dropdown", "number", "number", "number", "number", "number",
"number", "number", "number", "number", "number", "number"],
outputs="text",
examples=[['Red', 7.4, 0.70, 0.00, 1.9, 0.076, 11.0, 34.0, 0.9978, 3.51, 0.56, 9.4],
['White', 7.0, 0.27, 0.36, 20.7, 0.045, 45.0, 170.0, 1.0010, 3.00, 0.45, 8.8]])
iface.launch()