File size: 1,342 Bytes
8a4966f 070bf9f 8a4966f 7ca91fb 8a4966f d13438a d0b522a 4efe46c d0b522a b0c7e9d 8a4966f f31f0f6 d13438a 8a4966f f39f1d3 8a4966f |
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 |
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() |