Yasaman commited on
Commit
0034483
1 Parent(s): 66e88b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -9
app.py CHANGED
@@ -13,8 +13,8 @@ from functions import *
13
 
14
  project = hopsworks.login()
15
 
16
-
17
- def air_quality(city):
18
  start_date = datetime.now() - timedelta(days=1)
19
  start_time = int(start_date.timestamp()) * 1000
20
  X = pd.read_csv('x.csv')
@@ -24,7 +24,7 @@ def air_quality(city):
24
  X = X.drop(X.columns[0],axis=1)
25
 
26
  mr = project.get_model_registry()
27
- model = mr.get_model("gradient_boost_paris_model", version=1)
28
  model_dir = model.download()
29
  model = joblib.load(model_dir + "/model.pkl")
30
 
@@ -39,14 +39,20 @@ def air_quality(city):
39
  return predictions
40
 
41
 
42
-
43
-
 
 
 
 
 
 
44
 
45
 
46
- demo = gr.Interface(fn=air_quality, title="Air quality predictor",
47
- description="Input a value to get next weeks AQI prediction for Paris", inputs="text", outputs="text")
48
 
49
 
50
 
51
- if __name__ == "__main__":
52
- demo.launch()
 
13
 
14
  project = hopsworks.login()
15
 
16
+ models=["Gradient_Boost","Random_Forest","Lasso"]## Add others models names as in hopsworks
17
+ def air_quality(city,model_name):
18
  start_date = datetime.now() - timedelta(days=1)
19
  start_time = int(start_date.timestamp()) * 1000
20
  X = pd.read_csv('x.csv')
 
24
  X = X.drop(X.columns[0],axis=1)
25
 
26
  mr = project.get_model_registry()
27
+ model = mr.get_model(model_name, version=1)
28
  model_dir = model.download()
29
  model = joblib.load(model_dir + "/model.pkl")
30
 
 
39
  return predictions
40
 
41
 
42
+ with gr.Blocks() as demo:
43
+ gr.Label("Predict air quality in Paris")
44
+ with gr.Row():
45
+ inp = ['text',
46
+ gr.Radio(models, value="Gradient_Boost")]
47
+ out = gr.DataFrame()
48
+ btn = gr.Button("Run prediction")
49
+ btn.click(fn=air_quality, inputs=inp, outputs='text')
50
 
51
 
52
+ #demo = gr.Interface(fn=air_quality, title="Air quality predictor",
53
+ #description="Input a value to get next weeks AQI prediction for Paris", inputs="text", outputs="text")
54
 
55
 
56
 
57
+ if _name_ == "_main_":
58
+ demo.launch()