Add image output to wine quality prediction
Browse files
app.py
CHANGED
@@ -2,6 +2,8 @@ import gradio as gr
|
|
2 |
import hopsworks
|
3 |
import joblib
|
4 |
import pandas as pd
|
|
|
|
|
5 |
|
6 |
project = hopsworks.login()
|
7 |
fs = project.get_feature_store()
|
@@ -30,7 +32,11 @@ def wine(fixed_acidity, volatile_acidity, citric_acid, residual_sugar, chlorides
|
|
30 |
# the first element.
|
31 |
|
32 |
print(res)
|
33 |
-
|
|
|
|
|
|
|
|
|
34 |
|
35 |
iface = gr.Interface(
|
36 |
fn=wine,
|
@@ -49,6 +55,7 @@ iface = gr.Interface(
|
|
49 |
gr.Number(label="alcohol", value=13.1),
|
50 |
gr.Radio(["red", "white"], label="type", value="white")
|
51 |
],
|
52 |
-
outputs=gr.Number(label="quality")
|
|
|
53 |
|
54 |
iface.launch()
|
|
|
2 |
import hopsworks
|
3 |
import joblib
|
4 |
import pandas as pd
|
5 |
+
from PIL import Image
|
6 |
+
import requests
|
7 |
|
8 |
project = hopsworks.login()
|
9 |
fs = project.get_feature_store()
|
|
|
32 |
# the first element.
|
33 |
|
34 |
print(res)
|
35 |
+
|
36 |
+
url = "https://raw.githubusercontent.com/pierrelefevre/scalable-ml/main/lab1/task2/img/" + int(res[0]) + ".png"
|
37 |
+
img = Image.open(requests.get(url, stream=True).raw)
|
38 |
+
|
39 |
+
return [res[0], img]
|
40 |
|
41 |
iface = gr.Interface(
|
42 |
fn=wine,
|
|
|
55 |
gr.Number(label="alcohol", value=13.1),
|
56 |
gr.Radio(["red", "white"], label="type", value="white")
|
57 |
],
|
58 |
+
outputs=[gr.Number(label="quality"),
|
59 |
+
gr.Image(type="pil")])
|
60 |
|
61 |
iface.launch()
|