Commit
•
4f625bf
0
Parent(s):
Duplicate from XPMaster/KSA_Weather_Prediction
Browse filesCo-authored-by: Mustafa Al Hamad <XPMaster@users.noreply.huggingface.co>
- .gitattributes +32 -0
- README.md +13 -0
- WeatherPredictionKSA.pk +3 -0
- app.py +160 -0
- requirements.txt +2 -0
.gitattributes
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
23 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
32 |
+
WeatherPredictionKSA.pk filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: KSA Weather Prediction
|
3 |
+
emoji: 🦀
|
4 |
+
colorFrom: pink
|
5 |
+
colorTo: purple
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 3.3.1
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
duplicated_from: XPMaster/KSA_Weather_Prediction
|
11 |
+
---
|
12 |
+
|
13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
WeatherPredictionKSA.pk
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5919d5c691ad5472b38426bc14640daad73bb5b86952171cfc85d88ad6386b39
|
3 |
+
size 2676610127
|
app.py
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from backports.zoneinfo import ZoneInfo
|
3 |
+
from datetime import datetime, timedelta, timezone
|
4 |
+
import pickle
|
5 |
+
import sklearn
|
6 |
+
weathers = ['Broken clouds ',
|
7 |
+
'Clear ',
|
8 |
+
'Cloudy ',
|
9 |
+
'Cool ',
|
10 |
+
'Dense fog ',
|
11 |
+
'Drizzle Broken clouds ',
|
12 |
+
'Drizzle Dense fog ',
|
13 |
+
'Drizzle Fog ',
|
14 |
+
'Drizzle More clouds than sun ',
|
15 |
+
'Drizzle Mostly cloudy ',
|
16 |
+
'Drizzle Overcast ',
|
17 |
+
'Drizzle Partly sunny ',
|
18 |
+
'Duststorm ',
|
19 |
+
'Extremely hot ',
|
20 |
+
'Fog ',
|
21 |
+
'Hail Cloudy ',
|
22 |
+
'Hail Partly sunny ',
|
23 |
+
'Hail Passing clouds ',
|
24 |
+
'Haze ',
|
25 |
+
'Heavy rain More clouds than sun ',
|
26 |
+
'Heavy rain Mostly cloudy ',
|
27 |
+
'Heavy rain Overcast ',
|
28 |
+
'Heavy rain Partly sunny ',
|
29 |
+
'Hot ',
|
30 |
+
'Light rain Broken clouds ',
|
31 |
+
'Light rain Fog ',
|
32 |
+
'Light rain More clouds than sun ',
|
33 |
+
'Light rain Mostly cloudy ',
|
34 |
+
'Light rain Overcast ',
|
35 |
+
'Light rain Partly cloudy ',
|
36 |
+
'Light rain Partly sunny ',
|
37 |
+
'Light rain Passing clouds ',
|
38 |
+
'Light rain Scattered clouds ',
|
39 |
+
'Low level haze ',
|
40 |
+
'Mild ',
|
41 |
+
'More clouds than sun ',
|
42 |
+
'Mostly cloudy ',
|
43 |
+
'Overcast ',
|
44 |
+
'Partly cloudy ',
|
45 |
+
'Partly sunny ',
|
46 |
+
'Passing clouds ',
|
47 |
+
'Pleasantly warm ',
|
48 |
+
'Rain Broken clouds ',
|
49 |
+
'Rain Clear ',
|
50 |
+
'Rain Fog ',
|
51 |
+
'Rain More clouds than sun ',
|
52 |
+
'Rain Mostly cloudy ',
|
53 |
+
'Rain Overcast ',
|
54 |
+
'Rain Partly cloudy ',
|
55 |
+
'Rain Partly sunny ',
|
56 |
+
'Rain Passing clouds ',
|
57 |
+
'Rain Sandstorm ',
|
58 |
+
'Rain Scattered clouds ',
|
59 |
+
'Rain showers Partly sunny ',
|
60 |
+
'Refreshingly cool ',
|
61 |
+
'Sandstorm ',
|
62 |
+
'Scattered clouds ',
|
63 |
+
'Smoke ',
|
64 |
+
'Sprinkles Cloudy ',
|
65 |
+
'Sprinkles Duststorm ',
|
66 |
+
'Sprinkles Low level haze ',
|
67 |
+
'Sprinkles Overcast ',
|
68 |
+
'Strong thunderstorms Cloudy ',
|
69 |
+
'Strong thunderstorms More clouds than sun ',
|
70 |
+
'Strong thunderstorms Partly sunny ',
|
71 |
+
'Sunny ',
|
72 |
+
'Thundershowers Partly sunny ',
|
73 |
+
'Thundershowers Passing clouds ',
|
74 |
+
'Thundershowers Scattered clouds ',
|
75 |
+
'Thunderstorms Broken clouds ',
|
76 |
+
'Thunderstorms Cloudy ',
|
77 |
+
'Thunderstorms Fog ',
|
78 |
+
'Thunderstorms More clouds than sun ',
|
79 |
+
'Thunderstorms Mostly cloudy ',
|
80 |
+
'Thunderstorms Overcast ',
|
81 |
+
'Thunderstorms Partly cloudy ',
|
82 |
+
'Thunderstorms Partly sunny ',
|
83 |
+
'Thunderstorms Passing clouds ',
|
84 |
+
'Thunderstorms Sandstorm ',
|
85 |
+
'Thunderstorms Scattered clouds ',
|
86 |
+
'Warm ']
|
87 |
+
|
88 |
+
months = ['January', 'February', 'March', 'April', 'May', 'June', 'July','August', 'September', 'October', 'November', 'December']
|
89 |
+
|
90 |
+
cities = ['Assir',
|
91 |
+
'Baha',
|
92 |
+
'EP',
|
93 |
+
'Hail',
|
94 |
+
'Jawf',
|
95 |
+
'Jazan',
|
96 |
+
'Madina',
|
97 |
+
'Mecca',
|
98 |
+
'Najran',
|
99 |
+
'Northern boarder',
|
100 |
+
'Qassim',
|
101 |
+
'Riyadh',
|
102 |
+
'Tabuk']
|
103 |
+
|
104 |
+
def predict(city,month,year,day,hour,minute,weathertype,wind,hu,baro,vis):
|
105 |
+
|
106 |
+
loaded_model = pickle.load(open("WeatherPredictionKSA.pk", 'rb'))
|
107 |
+
details = [cities.index(city),year,months.index(month),day,hour,minute,weathers.index(weathertype),wind,hu,baro,vis]
|
108 |
+
temp = int(loaded_model.predict([details]))
|
109 |
+
if temp >= 50:
|
110 |
+
emoji = "🥵"
|
111 |
+
elif 40 <= temp <= 49:
|
112 |
+
emoji = "😳"
|
113 |
+
elif 25 <= temp <= 39:
|
114 |
+
emoji = "😌"
|
115 |
+
elif 10 <= temp <= 24:
|
116 |
+
emoji = "😊"
|
117 |
+
elif temp <= 9:
|
118 |
+
emoji = "🥶"
|
119 |
+
return gr.Textbox.update("🌡️ {0} C {1}🌡️".format(temp,emoji))
|
120 |
+
|
121 |
+
with gr.Blocks() as demo:
|
122 |
+
currentSecond= datetime.now().second
|
123 |
+
currentMinute = datetime.now().minute
|
124 |
+
currentHour = datetime.now().hour
|
125 |
+
currentDay = datetime.now().day
|
126 |
+
currentMonth = datetime.now().month
|
127 |
+
currentYear = datetime.now().year
|
128 |
+
dt = datetime(currentYear, currentMonth, currentDay, tzinfo=ZoneInfo("Asia/Riyadh"))
|
129 |
+
fulltime = str(dt)
|
130 |
+
ADD = 0
|
131 |
+
try:
|
132 |
+
if "+" in fulltime:
|
133 |
+
ADD = int(fulltime.split("+")[1].split(":")[0])
|
134 |
+
elif "-" in fulltime:
|
135 |
+
ADD = int(fulltime.split("-")[1].split(":")[0]) * -1
|
136 |
+
except:
|
137 |
+
pass
|
138 |
+
with gr.Row():
|
139 |
+
gr.Markdown("# 🌧️☁️☀️KSA Weather prediction ☀️☁️🌧️\n**Day, Hour, and Minute** are set to **Asia/Riyadh** current time by default but can be changed")
|
140 |
+
with gr.Box():
|
141 |
+
with gr.Row():
|
142 |
+
city = gr.Dropdown(cities,label='City',value='Assir',interactive=True)
|
143 |
+
month = gr.Dropdown(months,label='Month',value=months[currentMonth-1],interactive=True)
|
144 |
+
with gr.Row():
|
145 |
+
year = gr.Number(int(currentYear),label='Year',interactive=True)
|
146 |
+
day = gr.Number(int(currentDay),label='Day',interactive=True)
|
147 |
+
hour = gr.Number(int(currentHour)+ADD,label='Hour',interactive=True)
|
148 |
+
minute = gr.Number(int(currentMinute),label='Minute',interactive=True)
|
149 |
+
with gr.Row():
|
150 |
+
weathertype = gr.Dropdown(weathers,label='Weather type',value='Cloudy ',interactive=True)
|
151 |
+
wind = gr.Number(label='Wind',interactive=True)
|
152 |
+
hu = gr.Number(label='Humidity',interactive=True)
|
153 |
+
baro = gr.Number(label='Barometer',interactive=True)
|
154 |
+
vis = gr.Number(label='Visibility',interactive=True)
|
155 |
+
with gr.Row():
|
156 |
+
temp = gr.Textbox("😊😌Awaiting input😳🥵",label='Predicted temp',interactive=False)
|
157 |
+
btn = gr.Button(value="Predict")
|
158 |
+
btn.click(predict, inputs=[city,month,year,day,hour,minute,weathertype,wind,hu,baro,vis], outputs=temp)
|
159 |
+
|
160 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
backports.zoneinfo
|
2 |
+
scikit-learn>=1.0.1
|