Spaces:
Runtime error
Runtime error
import gradio as gr | |
import numpy as np | |
import hopsworks | |
import joblib | |
project = hopsworks.login() | |
fs = project.get_feature_store() | |
mr = project.get_model_registry() | |
model = mr.get_model("gradient_boost_model", version=1) | |
model_dir = model.download() | |
model = joblib.load(model_dir + "/model.pkl") | |
def air_quality(temp, humidity, precip, pressure, cloudcover, visibility, uvindex): | |
input_list=[] | |
input_list.append("Helsinki") #city | |
input_list.append(temp) | |
input_list.append(humidity) | |
input_list.append(precip) | |
input_list.append(cloudcover) | |
input_list.append(visibility) | |
input_list.append(uvindex) | |
res = model.predict(np.asarray(input_list).reshape(1,-1)) | |
return res[0] | |
aqi = gr.Interface( | |
fn=air_quality, | |
title="Predicting air quality - Helsinki", | |
description="Predictive air quality model for Helsinki", | |
allow_flagging="never", | |
inputs=[ | |
gr.components.Slider(-30,35, value=0, label="What is today's temperature?"), #temp | |
gr.components.Slider(-4,4,value=0, label="Today's humidity?"), | |
gr.components.Slider(-1,10,value=0, label="How much precipitation today?"), | |
gr.components.Slider(-2,2,value=0, label="How cloudy is it today?"), | |
gr.components.Slider(-3,2,value=0, label="How good is visibility today?"), | |
gr.components.Slider(-2,3,value=0, label="What is the uvindex today?") | |
], | |
outputs=["label"], | |
) | |
aqi.launch() |