Spaces:
Runtime error
Runtime error
added load and refresh button
Browse files
app.py
CHANGED
@@ -2,31 +2,70 @@ import gradio as gr
|
|
2 |
from PIL import Image
|
3 |
import hopsworks
|
4 |
import os
|
|
|
|
|
5 |
|
6 |
project = hopsworks.login(project="test42",api_key_value=os.environ.get("HOPSWORKS_API_KEYS"))
|
7 |
fs = project.get_feature_store()
|
8 |
|
9 |
dataset_api = project.get_dataset_api()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
with gr.Row():
|
18 |
with gr.Column():
|
19 |
gr.Label("Today's Predicted Image")
|
20 |
input_img = gr.Image("latest_iris.png", elem_id="predicted-img")
|
|
|
|
|
21 |
with gr.Column():
|
22 |
gr.Label("Today's Actual Image")
|
23 |
-
input_img = gr.Image("actual_iris.png", elem_id="actual-img")
|
|
|
24 |
with gr.Row():
|
25 |
with gr.Column():
|
26 |
gr.Label("Recent Prediction History")
|
27 |
input_img = gr.Image("df_recent.png", elem_id="recent-predictions")
|
|
|
28 |
with gr.Column():
|
29 |
gr.Label("Confusion Maxtrix with Historical Prediction Performance")
|
30 |
-
input_img = gr.Image("confusion_matrix.png", elem_id="confusion-matrix")
|
|
|
|
|
|
|
|
|
31 |
|
32 |
demo.launch()
|
|
|
2 |
from PIL import Image
|
3 |
import hopsworks
|
4 |
import os
|
5 |
+
import imageio.v3 as iio
|
6 |
+
import inspect
|
7 |
|
8 |
project = hopsworks.login(project="test42",api_key_value=os.environ.get("HOPSWORKS_API_KEYS"))
|
9 |
fs = project.get_feature_store()
|
10 |
|
11 |
dataset_api = project.get_dataset_api()
|
12 |
+
print(inspect.signature(dataset_api.download))
|
13 |
+
dataset_api.download("Resources/images/latest_iris.png",overwrite=True)
|
14 |
+
dataset_api.download("Resources/images/actual_iris.png",overwrite=True)
|
15 |
+
dataset_api.download("Resources/images/df_recent.png",overwrite=True)
|
16 |
+
dataset_api.download("Resources/images/confusion_matrix.png",overwrite=True)
|
17 |
+
x=0
|
18 |
+
def update():
|
19 |
+
dataset_api.download("Resources/images/latest_iris.png",overwrite=True)
|
20 |
+
dataset_api.download("Resources/images/actual_iris.png",overwrite=True)
|
21 |
+
dataset_api.download("Resources/images/df_recent.png",overwrite=True)
|
22 |
+
dataset_api.download("Resources/images/confusion_matrix.png",overwrite=True)
|
23 |
|
24 |
+
def update_latest_iris_img():
|
25 |
+
im = iio.imread('latest_iris.png')
|
26 |
+
return im
|
27 |
+
|
28 |
+
def update_actual_iris_img():
|
29 |
+
im = iio.imread('actual_iris.png')
|
30 |
+
return im
|
31 |
+
|
32 |
+
def update_df_recent_img():
|
33 |
+
im = iio.imread('df_recent.png')
|
34 |
+
return im
|
35 |
+
|
36 |
+
def update_confusion_matrix_img():
|
37 |
+
im = iio.imread('confusion_matrix.png')
|
38 |
+
return im
|
39 |
|
40 |
with gr.Blocks() as demo:
|
41 |
+
with gr.Row():
|
42 |
+
with gr.Column():
|
43 |
+
load=gr.Button("Load")
|
44 |
+
load.click(fn=update)
|
45 |
+
with gr.Column():
|
46 |
+
refresh=gr.Button("Refresh")
|
47 |
+
|
48 |
with gr.Row():
|
49 |
with gr.Column():
|
50 |
gr.Label("Today's Predicted Image")
|
51 |
input_img = gr.Image("latest_iris.png", elem_id="predicted-img")
|
52 |
+
refresh.click(update_latest_iris_img,outputs=input_img)
|
53 |
+
|
54 |
with gr.Column():
|
55 |
gr.Label("Today's Actual Image")
|
56 |
+
input_img = gr.Image("actual_iris.png", elem_id="actual-img")
|
57 |
+
refresh.click(update_actual_iris_img,outputs=input_img)
|
58 |
with gr.Row():
|
59 |
with gr.Column():
|
60 |
gr.Label("Recent Prediction History")
|
61 |
input_img = gr.Image("df_recent.png", elem_id="recent-predictions")
|
62 |
+
refresh.click(update_df_recent_img,outputs=input_img)
|
63 |
with gr.Column():
|
64 |
gr.Label("Confusion Maxtrix with Historical Prediction Performance")
|
65 |
+
input_img = gr.Image("confusion_matrix.png", elem_id="confusion-matrix")
|
66 |
+
refresh.click(update_confusion_matrix_img,outputs=input_img)
|
67 |
+
|
68 |
+
|
69 |
+
|
70 |
|
71 |
demo.launch()
|