Spaces:
Runtime error
Runtime error
filip_praca
commited on
Commit
•
b7aa8c5
1
Parent(s):
c75b835
hello test
Browse files
app.py
CHANGED
@@ -1,51 +1,7 @@
|
|
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 |
-
import os
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
mr = project.get_model_registry()
|
14 |
-
model = mr.get_model("iris_model", version=1)
|
15 |
-
model_dir = model.download()
|
16 |
-
model = joblib.load(model_dir + "/iris_model.pkl")
|
17 |
-
print("Model downloaded")
|
18 |
-
|
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([[sepal_length,sepal_width,petal_length,petal_width]],
|
23 |
-
columns=['sepal_length','sepal_width','petal_length','petal_width'])
|
24 |
-
print("Predicting")
|
25 |
-
print(df)
|
26 |
-
# 'res' is a list of predictions returned as the label.
|
27 |
-
res = model.predict(df)
|
28 |
-
# We add '[0]' to the result of the transformed 'res', because 'res' is a list, and we only want
|
29 |
-
# the first element.
|
30 |
-
# print("Res: {0}").format(res)
|
31 |
-
print(res)
|
32 |
-
flower_url = "https://raw.githubusercontent.com/featurestoreorg/serverless-ml-course/main/src/01-module/assets/" + res[0] + ".png"
|
33 |
-
img = Image.open(requests.get(flower_url, stream=True).raw)
|
34 |
-
return img
|
35 |
-
|
36 |
-
demo = gr.Interface(
|
37 |
-
fn=iris,
|
38 |
-
title="Iris Flower Predictive Analytics",
|
39 |
-
description="Experiment with sepal/petal lengths/widths to predict which flower it is.",
|
40 |
-
allow_flagging="never",
|
41 |
-
inputs=[
|
42 |
-
gr.inputs.Number(default=2.0, label="sepal length (cm)"),
|
43 |
-
gr.inputs.Number(default=1.0, label="sepal width (cm)"),
|
44 |
-
gr.inputs.Number(default=2.0, label="petal length (cm)"),
|
45 |
-
gr.inputs.Number(default=1.0, label="petal width (cm)"),
|
46 |
-
],
|
47 |
-
outputs=gr.Image(type="pil")
|
48 |
-
)
|
49 |
-
|
50 |
-
demo.launch(debug=True)
|
51 |
|
|
|
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
def greet(name):
|
4 |
+
return "Hello " + name + "!!"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
iface = gr.Interface(fn=greet,inputs="text",outputs="text")
|
7 |
+
iface.launch()
|