Spaces:
Runtime error
Runtime error
import gradio as gr | |
import torch, numpy as np, pandas as pd | |
import skimage | |
import pickle | |
default_columns = [ | |
'precipitation', | |
'temp_max', | |
'temp_min', | |
'wind', | |
] | |
options = [ | |
'drizzle', | |
'fog', | |
'rain', | |
'snow', | |
'sun', | |
] | |
with open("model.pkl", "rb") as f: | |
model = pickle.load(f) | |
with open("model2.pkl", "rb") as f: | |
model2 = pickle.load(f) | |
def predict(wind, temp_max, temp_min, precipitation): | |
f_precipitation = float(precipitation) | |
f_max_temp = float(temp_max) | |
f_min_temp = float(temp_min) | |
f_wind = float(wind) | |
default = [ | |
f_precipitation, | |
f_max_temp, | |
f_min_temp, | |
f_wind, | |
] | |
df = pd.DataFrame([default], columns=default_columns) | |
prediction = model.predict(df) | |
prediction2 = model2.predict(df) | |
return [options[round(max(prediction))], options[round(max(prediction2))]] | |
iface = gr.Interface( | |
fn=predict, | |
title="Weather Prediction", | |
allow_flagging="never", | |
inputs=[ | |
gr.inputs.Slider(0, 60, default=30, label="precipitation"), | |
gr.inputs.Slider(-10, 40, default=20, label="temp_max"), | |
gr.inputs.Slider(-10, 40, default=10, label="temp_min"), | |
gr.inputs.Slider(0, 10, default=5, label="wind"), | |
], | |
outputs=["text", "text"], | |
) | |
iface.launch() |