martenb commited on
Commit
4bae2b2
·
1 Parent(s): 4f6df6d

Updated app at lör 11 nov 2023 18:57:23 CET

Browse files
Files changed (2) hide show
  1. app.py +69 -0
  2. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from PIL import Image
3
+ import hopsworks
4
+
5
+ # IDE Help
6
+ from hopsworks.core.dataset_api import DatasetApi
7
+
8
+ # Images
9
+ hopsworks_images_location = "Resources/images"
10
+ hopsworks_images = {
11
+ "latest_iris":
12
+ {
13
+ "name": "latest_iris.png",
14
+ "local_path": ""
15
+ },
16
+ "actual_iris":
17
+ {
18
+ "name": "actual_iris.png",
19
+ "local_path": ""
20
+ },
21
+ "df_recent":
22
+ {
23
+ "name": "df_recent.png",
24
+ "local_path": ""
25
+ },
26
+ "confusion_matrix":
27
+ {
28
+ "name": "confusion_matrix.png",
29
+ "local_path": ""
30
+ }
31
+ }
32
+
33
+ print("Logging in to Hopsworks...")
34
+ project = hopsworks.login()
35
+
36
+ print("Getting feature store...")
37
+ fs = project.get_feature_store()
38
+
39
+ print("Get database handler from Hopsworks...")
40
+ dataset_api: DatasetApi = project.get_dataset_api()
41
+
42
+ for image in hopsworks_images:
43
+ print(f"Downloading {hopsworks_images[image]['name']} from Hopsworks...")
44
+ hopsworks_images[image]['local_path'] = dataset_api.download(f"{hopsworks_images_location}/{image}")
45
+ print(f"Saved in: {hopsworks_images[image]['local_path']}")
46
+
47
+ print("Configuring gradio")
48
+ with gr.Blocks() as demo:
49
+ with gr.Row():
50
+ with gr.Column():
51
+ label1 = gr.Label("Today's Predicted Image")
52
+ image1 = gr.Image(hopsworks_images['latest_iris']['local_path'],
53
+ elem_id="predicted-img", type="pil")
54
+ with gr.Column():
55
+ label2 = gr.Label("Today's Actual Image")
56
+ image2 = gr.Image(hopsworks_images['actual_iris']['local_path'],
57
+ elem_id="actual-img", type="pil")
58
+ with gr.Row():
59
+ with gr.Column():
60
+ label3 = gr.Label("Recent Prediction History")
61
+ image3 = gr.Image(hopsworks_images['df_recent']['local_path'],
62
+ elem_id="recent-predictions", type="pil")
63
+ with gr.Column():
64
+ label4 = gr.Label("Confusion Matrix with Historical Prediction Performance")
65
+ image4 = gr.Image(hopsworks_images['confusion_matrix']['local_path'],
66
+ elem_id="confusion-matrix", type="pil")
67
+
68
+ print("Launching gradio...")
69
+ demo.launch(debug=True)
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ hopsworks