import gradio as gr import numpy as np from PIL import Image import requests from functions import decode_features, get_model import hopsworks import joblib project = hopsworks.login(api_key_value="0rdWXlLgEd3mkGOg.iRZ7TtAkWGPlJHNQcAEph6Qbokoaq7QTBRI9ckwWUki8tIYGyBvrKhJvtLoUOGQ4") fs = project.get_feature_store() # mr = project.get_model_registry() # model = mr.get_model("xgboost_model", version=1) # model_dir = model.download() # model = joblib.load("/model.pkl") model = get_model(project=project, model_name="xgboost_model", evaluation_metric="f1_score", sort_metrics_by="max") def forecast(): x = [ 0. , 24 , -0.68645433, -0.06804887, -0.31264014, -0.13749569, -0.32063957, -0.2942814 , -0.18460245, -0.41253886, 0.06395449, 0.71276574, -0.36466156, -1.03879548, -0.65985627, 0 , 0 , 0.12254366, 0.39172671, 0.34205118, 0.21383452, -1.0216134 , 0.40277851, -0.34577169, -0.36832646, -0.7210296 , 0 ] res = model.predict(np.asarray(x).reshape(-1, 1)) return model_dir demo = gr.Interface( fn=forecast, title="Air Quality Prediction", description="Get aqi value", allow_flagging="never", inputs=[], outputs=gr.Textbox(label="Result: ")) demo.launch()