File size: 2,012 Bytes
4ef4650
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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()