Spaces:
Running
Running
File size: 852 Bytes
13d2dd0 469966c 13d2dd0 469966c 13d2dd0 469966c 13d2dd0 469966c 13d2dd0 |
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 |
import gradio as gr
from train import WeatherPredictor
# Initialize the predictor
predictor = WeatherPredictor('basel-weather.csv')
predictor.load_model('weather_predictor.pth')
def predict_weather(input_date):
# Use a dictionary to return JSON-like data
result = predictor.predict(input_date)
return {
"temperature": result['temp'],
"precipitation": result['precip'],
"snow": result['snow'],
"windspeed": result['windspeed']
}
# Create Gradio interface
app = gr.Interface(
fn=predict_weather,
inputs=gr.Textbox(label="Enter Date (dd/mm/yy)"),
outputs=gr.JSON(label="Weather Prediction"), # Change outputs to JSON
title="Weather Predictor",
description="Enter a date to get weather predictions in JSON format."
)
# Launch the interface
if __name__ == "__main__":
app.launch() |