martenb commited on
Commit
4ef4650
·
1 Parent(s): b49ef8a

Updated app at sön 19 nov 2023 21:55:53 CET

Browse files
Files changed (2) hide show
  1. app.py +45 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
9
+ # Placeholder for loading your trained models
10
+ # Load your models here, e.g., model_red = joblib.load('path_to_red_wine_model')
11
+ # model_white = joblib.load('path_to_white_wine_model')
12
+
13
+ def wine_quality(wine_type, fixed_acidity, volatile_acidity, citric_acid, residual_sugar, chlorides,
14
+ free_sulfur_dioxide, total_sulfur_dioxide, density, ph, sulphates, alcohol):
15
+ print("Calling wine_quality() function")
16
+ df = pd.DataFrame([[fixed_acidity, volatile_acidity, citric_acid, residual_sugar, chlorides,
17
+ free_sulfur_dioxide, total_sulfur_dioxide, density, ph, sulphates, alcohol]],
18
+ columns=['fixed_acidity', 'volatile_acidity', 'citric_acid', 'residual_sugar',
19
+ 'chlorides', 'free_sulfur_dioxide', 'total_sulfur_dioxide', 'density',
20
+ 'ph', 'sulphates', 'alcohol'])
21
+ print("Predicting...")
22
+ print(df)
23
+
24
+ # Use the appropriate model based on the wine type
25
+ if wine_type == 'Red':
26
+ # Placeholder for prediction with the red wine model
27
+ # quality = model_red.predict(df)[0]
28
+ quality = "Red Wine Quality Prediction Placeholder"
29
+ else:
30
+ # Placeholder for prediction with the white wine model
31
+ # quality = model_white.predict(df)[0]
32
+ quality = "White Wine Quality Prediction Placeholder"
33
+
34
+ return quality
35
+
36
+
37
+ # Define the Gradio interface
38
+ iface = gr.Interface(fn=wine_quality,
39
+ inputs=["dropdown", "number", "number", "number", "number", "number",
40
+ "number", "number", "number", "number", "number", "number"],
41
+ outputs="text",
42
+ examples=[['Red', 7.4, 0.70, 0.00, 1.9, 0.076, 11.0, 34.0, 0.9978, 3.51, 0.56, 9.4],
43
+ ['White', 7.0, 0.27, 0.36, 20.7, 0.045, 45.0, 170.0, 1.0010, 3.00, 0.45, 8.8]])
44
+
45
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ hopsworks
2
+ joblib
3
+ scikit-learn==1.1.1