update app
Browse files
app.py
CHANGED
@@ -8,7 +8,6 @@ import pandas as pd
|
|
8 |
project = hopsworks.login()
|
9 |
fs = project.get_feature_store()
|
10 |
|
11 |
-
|
12 |
mr = project.get_model_registry()
|
13 |
model = mr.get_model("iris_model", version=1)
|
14 |
model_dir = model.download()
|
@@ -19,23 +18,18 @@ print("Model downloaded")
|
|
19 |
def iris(sepal_length, sepal_width, petal_length, petal_width):
|
20 |
print("Calling function")
|
21 |
# df = pd.DataFrame([[sepal_length],[sepal_width],[petal_length],[petal_width]],
|
22 |
-
df = pd.DataFrame(
|
23 |
-
|
24 |
-
columns=["sepal_length", "sepal_width", "petal_length", "petal_width"],
|
25 |
-
)
|
26 |
print("Predicting")
|
27 |
print(df)
|
28 |
# 'res' is a list of predictions returned as the label.
|
29 |
res = model.predict(df)
|
30 |
-
# We add '[0]' to the result of the transformed 'res', because 'res' is a list, and we only want
|
31 |
# the first element.
|
32 |
# print("Res: {0}").format(res)
|
33 |
print(res)
|
34 |
-
flower_url =
|
35 |
-
|
36 |
-
+ res[0]
|
37 |
-
+ ".png"
|
38 |
-
)
|
39 |
img = Image.open(requests.get(flower_url, stream=True).raw)
|
40 |
return img
|
41 |
|
@@ -51,7 +45,6 @@ demo = gr.Interface(
|
|
51 |
gr.inputs.Number(default=2.0, label="petal length (cm)"),
|
52 |
gr.inputs.Number(default=1.0, label="petal width (cm)"),
|
53 |
],
|
54 |
-
outputs=gr.Image(type="pil")
|
55 |
-
)
|
56 |
|
57 |
-
demo.launch(debug=True)
|
|
|
8 |
project = hopsworks.login()
|
9 |
fs = project.get_feature_store()
|
10 |
|
|
|
11 |
mr = project.get_model_registry()
|
12 |
model = mr.get_model("iris_model", version=1)
|
13 |
model_dir = model.download()
|
|
|
18 |
def iris(sepal_length, sepal_width, petal_length, petal_width):
|
19 |
print("Calling function")
|
20 |
# df = pd.DataFrame([[sepal_length],[sepal_width],[petal_length],[petal_width]],
|
21 |
+
df = pd.DataFrame([[sepal_length, sepal_width, petal_length, petal_width]],
|
22 |
+
columns=['sepal_length', 'sepal_width', 'petal_length', 'petal_width'])
|
|
|
|
|
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 |
+
flower_url = "https://raw.githubusercontent.com/featurestoreorg/serverless-ml-course/main/src/01-module/assets/" + \
|
32 |
+
res[0] + ".png"
|
|
|
|
|
|
|
33 |
img = Image.open(requests.get(flower_url, stream=True).raw)
|
34 |
return img
|
35 |
|
|
|
45 |
gr.inputs.Number(default=2.0, label="petal length (cm)"),
|
46 |
gr.inputs.Number(default=1.0, label="petal width (cm)"),
|
47 |
],
|
48 |
+
outputs=gr.Image(type="pil"))
|
|
|
49 |
|
50 |
+
demo.launch(debug=True)
|