Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,21 +6,22 @@ predictor = WeatherPredictor('basel-weather.csv')
|
|
6 |
predictor.load_model('weather_predictor.pth')
|
7 |
|
8 |
def predict_weather(input_date):
|
|
|
9 |
result = predictor.predict(input_date)
|
10 |
-
return
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
# Create Gradio interface
|
13 |
app = gr.Interface(
|
14 |
fn=predict_weather,
|
15 |
inputs=gr.Textbox(label="Enter Date (dd/mm/yy)"),
|
16 |
-
outputs=
|
17 |
-
gr.Textbox(label="Temperature"),
|
18 |
-
gr.Textbox(label="Precipitation"),
|
19 |
-
gr.Textbox(label="Snow"),
|
20 |
-
gr.Textbox(label="Windspeed")
|
21 |
-
],
|
22 |
title="Weather Predictor",
|
23 |
-
description="Enter a date to get weather predictions."
|
24 |
)
|
25 |
|
26 |
# Launch the interface
|
|
|
6 |
predictor.load_model('weather_predictor.pth')
|
7 |
|
8 |
def predict_weather(input_date):
|
9 |
+
# Use a dictionary to return JSON-like data
|
10 |
result = predictor.predict(input_date)
|
11 |
+
return {
|
12 |
+
"temperature": result['temp'],
|
13 |
+
"precipitation": result['precip'],
|
14 |
+
"snow": result['snow'],
|
15 |
+
"windspeed": result['windspeed']
|
16 |
+
}
|
17 |
|
18 |
# Create Gradio interface
|
19 |
app = gr.Interface(
|
20 |
fn=predict_weather,
|
21 |
inputs=gr.Textbox(label="Enter Date (dd/mm/yy)"),
|
22 |
+
outputs=gr.JSON(label="Weather Prediction"), # Change outputs to JSON
|
|
|
|
|
|
|
|
|
|
|
23 |
title="Weather Predictor",
|
24 |
+
description="Enter a date to get weather predictions in JSON format."
|
25 |
)
|
26 |
|
27 |
# Launch the interface
|