SamuelHarner commited on
Commit
2b63692
·
1 Parent(s): 3353585

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +5 -4
  2. app.py +51 -0
  3. requirements.txt +4 -0
README.md CHANGED
@@ -1,12 +1,13 @@
1
  ---
2
  title: Wine
3
- emoji: 🏃
4
- colorFrom: green
5
  colorTo: green
6
  sdk: gradio
7
- sdk_version: 4.1.2
8
  app_file: app.py
9
  pinned: false
 
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
  title: Wine
3
+ emoji: 🐢
4
+ colorFrom: pink
5
  colorTo: green
6
  sdk: gradio
7
+ sdk_version: 3.5
8
  app_file: app.py
9
  pinned: false
10
+ license: apache-2.0
11
  ---
12
 
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from PIL import Image, ImageDraw, ImageFont
3
+ import requests
4
+ import hopsworks
5
+ import joblib
6
+ import pandas as pd
7
+
8
+ project = hopsworks.login()
9
+ fs = project.get_feature_store()
10
+
11
+ mr = project.get_model_registry()
12
+ model = mr.get_model("wine_model", version=1)
13
+ model_dir = model.download()
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.
26
+ res = model.predict(df)
27
+ # We add '[0]' to the result of the transformed 'res', because 'res' is a list, and we only want
28
+ # the first element.
29
+ # print("Res: {0}").format(res)
30
+ print(res)
31
+ return str(res[0])
32
+
33
+ demo = gr.Interface(
34
+ fn=wine,
35
+ title="Wine Quality Predictive Analytics",
36
+ description="Experiment with fixed_acidity, citric_acid, type, chlorides, volatile_acidity, density, alcohol"
37
+ "to predict of which quality the wine is.",
38
+ allow_flagging="never",
39
+ inputs=[
40
+ gr.inputs.Number(default=7.2, label="fixed acidity"),
41
+ gr.inputs.Number(default=0.34, label="volatile acidity"),
42
+ gr.inputs.Number(default=0.32, label="citric acid"),
43
+ gr.inputs.Textbox(default="red", label="type (red, white)"),
44
+ gr.inputs.Number(default=10.5, label="alcohol"),
45
+ gr.inputs.Number(default=0.99, label="density"),
46
+ gr.inputs.Number(default=0.06, label="chlorides"),
47
+ ],
48
+ outputs="text")
49
+
50
+ demo.launch(debug=True)
51
+
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ hopsworks
2
+ joblib
3
+ scikit-learn==1.1.1
4
+ httpx==0.24.1