File size: 2,274 Bytes
4bae2b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d2d4314
4bae2b2
 
23ab4ff
4bae2b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import gradio as gr
from PIL import Image
import hopsworks

# IDE Help
from hopsworks.core.dataset_api import DatasetApi

# Images
hopsworks_images_location = "Resources/images"
hopsworks_images = {
    "latest_iris":
        {
            "name": "latest_iris.png",
            "local_path": ""
        },
    "actual_iris":
        {
            "name": "actual_iris.png",
            "local_path": ""
        },
    "df_recent":
        {
            "name": "df_recent.png",
            "local_path": ""
        },
    "confusion_matrix":
        {
            "name": "confusion_matrix.png",
            "local_path": ""
        }
}

print("Logging in to Hopsworks...")
project = hopsworks.login()

print("Getting feature store...")
fs = project.get_feature_store()

print("Get database handler from Hopsworks...")
dataset_api: DatasetApi = project.get_dataset_api()

for image in hopsworks_images:
    print(f"Downloading {hopsworks_images[image]['name']} from Hopsworks...")
    hopsworks_images[image]['local_path'] = dataset_api.download(f"{hopsworks_images_location}/{hopsworks_images[image]['name']}")
    print(f"Saved in: {hopsworks_images[image]['local_path']}")

print("Configuring gradio...")
with gr.Blocks() as demo:
    with gr.Row():
        with gr.Column():
            label1 = gr.Label("Today's Predicted Image")
            image1 = gr.Image(hopsworks_images['latest_iris']['local_path'],
                              elem_id="predicted-img", type="pil")
        with gr.Column():
            label2 = gr.Label("Today's Actual Image")
            image2 = gr.Image(hopsworks_images['actual_iris']['local_path'],
                              elem_id="actual-img", type="pil")
    with gr.Row():
        with gr.Column():
            label3 = gr.Label("Recent Prediction History")
            image3 = gr.Image(hopsworks_images['df_recent']['local_path'],
                              elem_id="recent-predictions", type="pil")
        with gr.Column():
            label4 = gr.Label("Confusion Matrix with Historical Prediction Performance")
            image4 = gr.Image(hopsworks_images['confusion_matrix']['local_path'],
                              elem_id="confusion-matrix", type="pil")

print("Launching gradio...")
demo.launch(debug=True)