SevenhuijsenM
commited on
Commit
·
bc31129
1
Parent(s):
1e8d0b0
Iris prediction
Browse files- Images/setosa.jpg +0 -0
- Images/versicolor.jpg +0 -0
- Images/virginica.jpg +0 -0
- app.py +25 -13
- flagged/log.csv +4 -0
Images/setosa.jpg
ADDED
![]() |
Images/versicolor.jpg
ADDED
![]() |
Images/virginica.jpg
ADDED
![]() |
app.py
CHANGED
@@ -1,18 +1,30 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
8 |
inputs=[
|
9 |
-
gr.Textbox(label="Sepal Length"),
|
10 |
-
gr.Textbox(label="Sepal Width"),
|
11 |
-
gr.Textbox(label="Petal Length"),
|
12 |
-
gr.Textbox(label="Petal Width"),
|
13 |
-
],
|
14 |
-
outputs="text",
|
15 |
-
live=True
|
16 |
)
|
17 |
-
|
18 |
-
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import hopsworks
|
3 |
+
import joblib
|
4 |
+
import pandas as pd
|
5 |
+
import numpy as np
|
6 |
+
project = hopsworks.login()
|
7 |
+
fs = project.get_feature_store()
|
8 |
|
9 |
+
mr = project.get_model_registry()
|
10 |
+
model = mr.get_model("iris_model", version=1)
|
11 |
+
model_dir = model.download()
|
12 |
+
model = joblib.load(model_dir + "/iris_model.pkl")
|
13 |
+
feature_view = fs.get_feature_view(name="iris", version=1)
|
14 |
+
batch_data = feature_view.get_batch_data()
|
15 |
|
16 |
+
def greet(sep_length, sep_width, pet_length, pet_width):
|
17 |
+
df = pd.DataFrame({ "sepal_length": sep_length, "sepal_width": sep_width, "petal_length": pet_length, "petal_width": pet_width}, index=[0])
|
18 |
+
prediction = model.predict(df)[0]
|
19 |
+
return prediction, f"Images\{prediction}.jpg"
|
20 |
+
|
21 |
+
predict = gr.Interface(
|
22 |
+
fn=greet,
|
23 |
inputs=[
|
24 |
+
gr.Textbox(placeholder="Sepal length here", label = "Sepal Length"),
|
25 |
+
gr.Textbox(placeholder="Sepal width here", label = "Sepal Width"),
|
26 |
+
gr.Textbox(placeholder="Petal length here", label = "Petal Length"),
|
27 |
+
gr.Textbox(placeholder="Petal width here", label = "Petal Width")],
|
28 |
+
outputs=[gr.Textbox(label = "Prediction"), gr.Image(type="pil", label="Iris")],
|
|
|
|
|
29 |
)
|
30 |
+
predict.launch()
|
|
flagged/log.csv
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Sepal Length,Sepal Width,Petal Length,Petal Width,output,flag,username,timestamp
|
2 |
+
1,2,nu3,number,"Sepal Length: 1, Sepal Width: 2, Petal Length: nu3, Petal Width: number",,,2023-11-12 13:07:01.911729
|
3 |
+
1,2,nu3,number,"Sepal Length: 1, Sepal Width: 2, Petal Length: nu3, Petal Width: number",,,2023-11-12 13:07:02.351389
|
4 |
+
1,2,nu3,number,"Sepal Length: 1, Sepal Width: 2, Petal Length: nu3, Petal Width: number",,,2023-11-12 13:07:02.524937
|