Spaces:
Build error
Build error
| import gradio as gr | |
| from PIL import Image | |
| import hopsworks | |
| import os | |
| import imageio.v3 as io | |
| import inspect | |
| project = hopsworks.login() | |
| fs = project.get_feature_store() | |
| dataset_api = project.get_dataset_api() | |
| dataset_api.download("Resources/images/latest_titanic.png") | |
| dataset_api.download("Resources/images/actual_titanic.png") | |
| dataset_api.download("Resources/images/df_recent.png") | |
| dataset_api.download("Resources/images/confusion_matrix.png") | |
| def update_latest_img(): | |
| img = io.imread('latest_titanic.png') | |
| return img | |
| def update_actual_img(): | |
| img = io.imread('actual_titanic.png') | |
| return img | |
| def update_df_recent_img(): | |
| img = io.imread('df_recent.png') | |
| return img | |
| def update_confusion_matrix_img(): | |
| img = io.imread('confusion_matrix.png') | |
| return img | |
| def update(): | |
| dataset_api.download("Resources/images/latest_titanic.png",overwrite=True) | |
| dataset_api.download("Resources/images/actual_titanic.png",overwrite=True) | |
| dataset_api.download("Resources/images/df_recent.png",overwrite=True) | |
| dataset_api.download("Resources/images/confusion_matrix.png",overwrite=True) | |
| return None | |
| with gr.Blocks() as demo: | |
| with gr.Row(): | |
| load=gr.Button("Load") | |
| load=load.click(fn=update) | |
| with gr.Row(): | |
| refresh=gr.Button("Refresh") | |
| with gr.Row(): | |
| with gr.Column(): | |
| gr.Label("Today's Predicted Result") | |
| input_img = gr.Image("latest_titanic.png", elem_id="predicted-img") | |
| refresh.click(update_latest_img, outputs=input_img) | |
| with gr.Column(): | |
| gr.Label("Today's Actual Result") | |
| input_img = gr.Image("actual_titanic.png", elem_id="actual-img") | |
| refresh.click(update_actual_img, outputs=input_img) | |
| with gr.Row(): | |
| with gr.Column(): | |
| gr.Label("Recent Prediction History") | |
| input_img = gr.Image("df_recent.png", elem_id="recent-predictions") | |
| refresh.click(update_df_recent_img, outputs=input_img) | |
| with gr.Column(): | |
| gr.Label("Confusion Maxtrix with Historical Prediction Performance") | |
| input_img = gr.Image("confusion_matrix.png", elem_id="confusion-matrix") | |
| refresh.click(update_confusion_matrix_img, outputs=input_img) | |
| demo.launch() | |