Santiago Roman commited on
Commit
34c1b45
·
1 Parent(s): 39ec31e
Files changed (2) hide show
  1. app.py +41 -0
  2. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from PIL import Image
3
+ import hopsworks
4
+ import datetime
5
+
6
+ project = hopsworks.login()
7
+ fs = project.get_feature_store()
8
+ air_fg = fs.get_or_create_feature_group(name="air_quality_predictions",
9
+ version=2,
10
+ primary_key=["date"],
11
+ description="Air quality predictions"
12
+ )
13
+
14
+ air_fg = air_fg.show(20).sort_values('date', ignore_index=True)
15
+ prediction = air_fg.iloc[-1]['pred_aqi']
16
+ date = air_fg.iloc[-1]['date']
17
+ date_str = datetime.date.fromtimestamp(date//1000).strftime("%Y-%m-%d")
18
+
19
+
20
+ with gr.Blocks() as demo:
21
+
22
+ if prediction == 0 or prediction <= 50 :
23
+ img_string = "aqi_green.png"
24
+ elif prediction > 50 or prediction <= 100:
25
+ img_string= "aqi_yellow.png"
26
+ elif prediction > 100 or prediction <= 150:
27
+ img_string= "aqi_red.png"
28
+ elif prediction > 150 or prediction <= 200:
29
+ img_string= "aqi_purple.png"
30
+ else:
31
+ img_string= "aqi_black.png"
32
+
33
+ with gr.Row():
34
+ with gr.Column():
35
+ gr.Label(f"Predicted AQI for {date_str} in Madrid is {prediction}")
36
+ input_img = gr.Image("images/" + img_string, elem_id="predicted-img")
37
+
38
+ demo.launch()
39
+
40
+
41
+
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ hopsworks