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}/{image}") 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)