Spaces:
Runtime error
Runtime error
daniel-rdt
commited on
Commit
•
df617cd
1
Parent(s):
f6fe6c2
added app and requirements
Browse files- app.py +75 -0
- requirements.txt +1 -0
app.py
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import imageio.v3 as iio
|
3 |
+
from PIL import Image
|
4 |
+
import hopsworks
|
5 |
+
|
6 |
+
project = hopsworks.login()
|
7 |
+
fs = project.get_feature_store()
|
8 |
+
|
9 |
+
dataset_api = project.get_dataset_api()
|
10 |
+
|
11 |
+
dataset_api.download("Resources/images/latest_bitcoin_fluctuation_prediction_2.png", overwrite=True)
|
12 |
+
dataset_api.download("Resources/images/latest_bitcoin_fluctuation_actual_2.png", overwrite=True)
|
13 |
+
dataset_api.download("Resources/images/df_recent_2.png", overwrite=True)
|
14 |
+
dataset_api.download("Resources/images/confusion_matrix_2.png", overwrite=True)
|
15 |
+
|
16 |
+
def update():
|
17 |
+
dataset_api.download("Resources/images/latest_bitcoin_fluctuation_prediction_2.png", overwrite=True)
|
18 |
+
dataset_api.download("Resources/images/latest_bitcoin_fluctuation_actual_2.png", overwrite=True)
|
19 |
+
dataset_api.download("Resources/images/df_recent_2.png", overwrite=True)
|
20 |
+
dataset_api.download("Resources/images/confusion_matrix_2.png", overwrite=True)
|
21 |
+
|
22 |
+
def update_fluctuation_prediction_img():
|
23 |
+
im_pred = iio.imread('latest_bitcoin_fluctuation_prediction_2.png')
|
24 |
+
return im_pred
|
25 |
+
|
26 |
+
def update_actual_fluctuation_img():
|
27 |
+
im_act = iio.imread('latest_bitcoin_fluctuation_actual_2.png')
|
28 |
+
return im_act
|
29 |
+
|
30 |
+
def update_df_recent_img():
|
31 |
+
im_hist = iio.imread('df_recent_2.png')
|
32 |
+
return im_hist
|
33 |
+
|
34 |
+
def update_confusion_matrix_img():
|
35 |
+
im_matr = iio.imread('confusion_matrix_2.png')
|
36 |
+
return im_matr
|
37 |
+
|
38 |
+
with gr.Blocks() as demo:
|
39 |
+
with gr.Row():
|
40 |
+
gr.Markdown(
|
41 |
+
"""
|
42 |
+
# Bitcoin Twitter Sentiment Predictor Monitor v2
|
43 |
+
Model version build upon hyperparameter tuning for max. f-1 score.
|
44 |
+
"""
|
45 |
+
)
|
46 |
+
with gr.Row():
|
47 |
+
load=gr.Button("Load Images")
|
48 |
+
load.click(fn=update)
|
49 |
+
with gr.Row():
|
50 |
+
refresh=gr.Button("Refresh (wait 10 seconds after loading images before refreshing")
|
51 |
+
|
52 |
+
with gr.Row():
|
53 |
+
with gr.Column():
|
54 |
+
gr.Label("Today's Predicted Image")
|
55 |
+
input_img_pred = gr.Image("latest_bitcoin_fluctuation_prediction_2.png", elem_id="predicted-img")
|
56 |
+
refresh.click(update_fluctuation_prediction_img,outputs=input_img_pred)
|
57 |
+
|
58 |
+
with gr.Column():
|
59 |
+
gr.Label("Today's Actual Image")
|
60 |
+
input_img_act = gr.Image("latest_bitcoin_fluctuation_actual_2.png", elem_id="actual-img")
|
61 |
+
refresh.click(update_actual_fluctuation_img,outputs=input_img_act)
|
62 |
+
|
63 |
+
with gr.Row():
|
64 |
+
with gr.Column():
|
65 |
+
gr.Label("Recent Prediction History")
|
66 |
+
input_img_hist = gr.Image("df_recent_2.png", elem_id="recent-predictions")
|
67 |
+
refresh.click(update_df_recent_img,outputs=input_img_hist)
|
68 |
+
|
69 |
+
with gr.Column():
|
70 |
+
gr.Label("Confusion Maxtrix with Historical Prediction Performance")
|
71 |
+
input_img_matr = gr.Image("confusion_matrix_2.png", elem_id="confusion-matrix")
|
72 |
+
refresh.click(update_confusion_matrix_img,outputs=input_img_matr)
|
73 |
+
|
74 |
+
|
75 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
hopsworks
|