Spaces:
Runtime error
Runtime error
initial commit
Browse files- app.py +70 -0
- requirements.txt +8 -0
app.py
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
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 |
+
dataset_api.download("Resources/images/latest_state.png",overwrite=True)
|
13 |
+
dataset_api.download("Resources/images/actual_state.png",overwrite=True)
|
14 |
+
dataset_api.download("Resources/images/df_recent_state.png",overwrite=True)
|
15 |
+
dataset_api.download("Resources/images/titanic_confusion_matrix.png",overwrite=True)
|
16 |
+
x=0
|
17 |
+
def update():
|
18 |
+
dataset_api.download("Resources/images/latest_state.png",overwrite=True)
|
19 |
+
dataset_api.download("Resources/images/actual_state.png",overwrite=True)
|
20 |
+
dataset_api.download("Resources/images/df_recent_state.png",overwrite=True)
|
21 |
+
dataset_api.download("Resources/images/titanic_confusion_matrix.png",overwrite=True)
|
22 |
+
|
23 |
+
def update_latest_state_img():
|
24 |
+
im = iio.imread('latest_state.png')
|
25 |
+
return im
|
26 |
+
|
27 |
+
def update_actual_state_img():
|
28 |
+
im = iio.imread('actual_state.png')
|
29 |
+
return im
|
30 |
+
|
31 |
+
def update_df_recent_img():
|
32 |
+
im = iio.imread('df_recent_state.png')
|
33 |
+
return im
|
34 |
+
|
35 |
+
def update_confusion_matrix_img():
|
36 |
+
im = iio.imread('titanic_confusion_matrix.png')
|
37 |
+
return im
|
38 |
+
|
39 |
+
with gr.Blocks() as demo:
|
40 |
+
with gr.Row():
|
41 |
+
with gr.Column():
|
42 |
+
load=gr.Button("Load")
|
43 |
+
load.click(fn=update)
|
44 |
+
with gr.Column():
|
45 |
+
refresh=gr.Button("Refresh")
|
46 |
+
|
47 |
+
with gr.Row():
|
48 |
+
with gr.Column():
|
49 |
+
gr.Label("Today's Predicted Image")
|
50 |
+
input_img = gr.Image("latest_state.png", elem_id="predicted-img")
|
51 |
+
refresh.click(update_latest_state_img,outputs=input_img)
|
52 |
+
|
53 |
+
with gr.Column():
|
54 |
+
gr.Label("Today's Actual Image")
|
55 |
+
input_img = gr.Image("actual_state.png", elem_id="actual-img")
|
56 |
+
refresh.click(update_actual_state_img,outputs=input_img)
|
57 |
+
with gr.Row():
|
58 |
+
with gr.Column():
|
59 |
+
gr.Label("Recent Prediction History")
|
60 |
+
input_img = gr.Image("df_recent_state.png", elem_id="recent-predictions")
|
61 |
+
refresh.click(update_df_recent_img,outputs=input_img)
|
62 |
+
with gr.Column():
|
63 |
+
gr.Label("Confusion Maxtrix with Historical Prediction Performance")
|
64 |
+
input_img = gr.Image("titanic_confusion_matrix.png", elem_id="confusion-matrix")
|
65 |
+
refresh.click(update_confusion_matrix_img,outputs=input_img)
|
66 |
+
|
67 |
+
|
68 |
+
|
69 |
+
|
70 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
hopsworks
|
2 |
+
joblib
|
3 |
+
scikit-learn
|
4 |
+
seaborn
|
5 |
+
dataframe-image
|
6 |
+
modal-client
|
7 |
+
gradio
|
8 |
+
imageio
|