Spaces:
Runtime error
Runtime error
Download app.py from Scalable-ML/SmartCast: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/spaces/Scalable-ML/SmartCast/resolve/main/app.py
- Command line
-
hf download hf://spaces/Scalable-ML/SmartCast/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Scalable-ML/SmartCast/resolve/main/app.py
1.32 kB
| import gradio as gr | |
| from PIL import Image | |
| import hopsworks | |
| project = hopsworks.login(project="ID2223_L2") | |
| fs = project.get_feature_store() | |
| predictions_fg = fs.get_feature_group(name="weather_predictions", version=1) | |
| query = predictions_fg.select_all() | |
| predictions_df = query.read(read_options={"use_hive": True}) | |
| predictions_df = predictions_df.sort_values(by=["timestamp_local"]) | |
| print(predictions_df) | |
| print(predictions_df.tail(4)) | |
| dataset_api = project.get_dataset_api() | |
| dataset_api.download("Resources/weather/last_prediction.txt") | |
| dataset_api.download("Resources/weather/prediction_graph.png") | |
| def latest_prediction(path): | |
| f = open(path,"r") | |
| date = f.readline() | |
| temp = f.readline() | |
| f.close() | |
| return "## Prediction at time : "+date+"\n\n ## Predicted temperature:"+temp | |
| with gr.Blocks() as demo: | |
| with gr.Row(): | |
| with gr.Column(): | |
| gr.Label("Latest Predicted Forecast") | |
| gr.Markdown(latest_prediction("last_prediction.txt")) | |
| with gr.Column(): | |
| gr.Label("Graph of Recent Predictions") | |
| input_img = gr.Image("prediction_graph.png", elem_id="temperature-graph") | |
| with gr.Row(): | |
| with gr.Column(): | |
| gr.Label("Recent Prediction History") | |
| gr.DataFrame(predictions_df, interactive=False) | |
| demo.launch() |