Spaces:
Runtime error
Runtime error
File size: 1,432 Bytes
d396eb3 3cfc838 d396eb3 e2b7861 d396eb3 |
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
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() |