Spaces:
Runtime error
Runtime error
File size: 2,336 Bytes
b1d7b07 39e136e b1d7b07 4e0c1fc b1d7b07 |
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 71 72 73 74 |
import gradio as gr
from PIL import Image
import requests
import hopsworks
import joblib
# Connect to Hopsworks
project = hopsworks.login(project="finetune")
fs = project.get_feature_store()
dataset_api = project.get_dataset_api()
def show_reloaded_images():
'''
Show new images.
'''
# download emoticons
for day in range(1,7):
img = f'Resources/img_prediction/{day}.png'
dataset_api.download(img, overwrite=True)
# download snow prediction forecast
dataset_api.download("Resources/img_prediction/plot.png", overwrite=True)
# optput images
plot_pred = Image.open("plot.png")
img1 = Image.open("1.png")
img2 = Image.open("2.png")
img3 = Image.open("3.png")
img4 = Image.open("4.png")
img5 = Image.open("5.png")
img6 = Image.open("6.png")
output = [plot_pred, img1, img2, img3, img4, img5, img6]
return output
def show_history():
'''
Get history of predictions.
'''
dataset_api.download("Resources/img_prediction/plot_history.png", overwrite=True)
plot_hist = Image.open("plot_history.png")
return plot_hist
with gr.Blocks() as demo:
with gr.Tabs():
with gr.TabItem("Snow prediction"):
with gr.Row():
btn = gr.Button("New prediction").style(full_width=True)
with gr.Row():
plot_pred = gr.Image(label="Predicted snow height").style(height=400) # plotted graph
with gr.Row():
#input_img1 = gr.Image("1.png", elem_id="Day 1")
img1 = gr.Image().style(width=25)
img2 = gr.Image().style(width=25)
img3 = gr.Image().style(width=25)
img4 = gr.Image().style(width=25)
img5 = gr.Image().style(width=25)
img6 = gr.Image().style(width=25)
with gr.TabItem("Accuracy of past 10 days"):
with gr.Row():
btn2 = gr.Button("Get history").style(full_width=True)
with gr.Row():
pred_hist = gr.Image(label="Past 10 days of predictions").style(height=500)
btn.click(show_reloaded_images,
inputs=None,
outputs=[plot_pred, img1, img2, img3, img4, img5, img6])
btn2.click(show_history,
inputs=None,
outputs=pred_hist)
demo.launch()
|