SamuelHarner commited on
Commit
48ccf8f
·
1 Parent(s): f4d7fc2

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -10
app.py CHANGED
@@ -15,11 +15,14 @@ model = joblib.load(model_dir + "/wine_model.pkl")
15
  print("Model downloaded")
16
 
17
 
18
- def wine(fixed_acidity, citric_acid, type_white, chlorides, volatile_acidity, density, alcohol):
 
19
  print("Calling function")
20
  # df = pd.DataFrame([[sepal_length],[sepal_width],[petal_length],[petal_width]],
21
- df = pd.DataFrame([[fixed_acidity, citric_acid, type_white, chlorides, volatile_acidity, density, alcohol]],
22
- columns=['fixed_acidity', 'citric_acid', 'type_white', 'chlorides', 'volatile_acidity', 'density', 'alcohol'])
 
 
23
  print("Predicting")
24
  print(df)
25
  # 'res' is a list of predictions returned as the label.
@@ -28,6 +31,7 @@ def wine(fixed_acidity, citric_acid, type_white, chlorides, volatile_acidity, de
28
  # the first element.
29
  # print("Res: {0}").format(res)
30
  print(res)
 
31
  star_url = "https://raw.githubusercontent.com/SamuelHarner/review-images/main/images/" + str(res[0]) + "_stars.png"
32
  img = Image.open(requests.get(star_url, stream=True).raw)
33
  return img
@@ -39,13 +43,17 @@ demo = gr.Interface(
39
  "to predict of which quality the wine is.",
40
  allow_flagging="never",
41
  inputs=[
42
- gr.inputs.Number(default=7.2, label="fixed acidity"),
43
- gr.inputs.Number(default=0.34, label="volatile acidity"),
44
- gr.inputs.Number(default=0.32, label="citric acid"),
45
- gr.inputs.Textbox(default=0, label="type (red, white)"),
46
- gr.inputs.Number(default=10.5, label="alcohol"),
47
- gr.inputs.Number(default=0.99, label="density"),
48
- gr.inputs.Number(default=0.06, label="chlorides"),
 
 
 
 
49
  ],
50
  outputs=gr.Image(type="pil"))
51
 
 
15
  print("Model downloaded")
16
 
17
 
18
+ def wine(fixed_acidity, volatile_acidity, citric_acid, residual_sugar, chlorides,
19
+ free_sulfur_dioxide, density, pH, sulphates, alcohol, type_red):
20
  print("Calling function")
21
  # df = pd.DataFrame([[sepal_length],[sepal_width],[petal_length],[petal_width]],
22
+ df = pd.DataFrame([[fixed_acidity, volatile_acidity, citric_acid, residual_sugar, chlorides,
23
+ free_sulfur_dioxide, density, pH, sulphates, alcohol, type_red]],
24
+ columns=['fixed_acidity', 'volatile_acidity', 'citric_acid', 'residual_sugar', 'chlorides',
25
+ 'free_sulfur_dioxide', 'density', 'pH', 'sulphates', 'alcohol', 'type_red'])
26
  print("Predicting")
27
  print(df)
28
  # 'res' is a list of predictions returned as the label.
 
31
  # the first element.
32
  # print("Res: {0}").format(res)
33
  print(res)
34
+
35
  star_url = "https://raw.githubusercontent.com/SamuelHarner/review-images/main/images/" + str(res[0]) + "_stars.png"
36
  img = Image.open(requests.get(star_url, stream=True).raw)
37
  return img
 
43
  "to predict of which quality the wine is.",
44
  allow_flagging="never",
45
  inputs=[
46
+ gr.inputs.Number(default=7.2, label="fixed acidity (3.8 ... 15.9)"),
47
+ gr.inputs.Number(default=0.34, label="volatile acidity (0.00 ... 1.58)"),
48
+ gr.inputs.Number(default=0.32, label="citric acid (0.00 ... 1.66)"),
49
+ gr.inputs.Number(default=0, label="type (0...red, 1...white)"),
50
+ gr.inputs.Number(default=10.5, label="alcohol (8.0 ... 14.9"),
51
+ gr.inputs.Number(default=0.99, label="density (0.99 ... 1.04)"),
52
+ gr.inputs.Number(default=0.06, label="chlorides (0.00 ...0.61)"),
53
+ gr.inputs.Number(default=5.07, label="residual sugar (0.60 ...65.80)"),
54
+ gr.inputs.Number(default=30.06, label="free sulfur dioxide (1.0 ...289.0)"),
55
+ gr.inputs.Number(default=3.22, label="pH (2.72 ...4.01)"),
56
+ gr.inputs.Number(default=0.53, label="sulphates (0.00 ...2.00)"),
57
  ],
58
  outputs=gr.Image(type="pil"))
59