matheuscvp
commited on
Commit
•
e702b56
1
Parent(s):
5df7966
update
Browse files
README.md
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: predict_weather
|
3 |
+
colorFrom: cyan
|
4 |
+
colorTo: blue
|
5 |
+
sdk: gradio
|
6 |
+
sdk_version: 3.16.2
|
7 |
+
app_file: app.py
|
8 |
+
pinned: false
|
9 |
+
---
|
app.py
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import torch, numpy as np, pandas as pd
|
3 |
+
import skimage
|
4 |
+
import pickle
|
5 |
+
|
6 |
+
default_columns = [
|
7 |
+
'Wind',
|
8 |
+
'Max Temperature',
|
9 |
+
'Min Temperature',
|
10 |
+
'Precipitation',
|
11 |
+
]
|
12 |
+
|
13 |
+
options = [
|
14 |
+
'drizzle',
|
15 |
+
'fog',
|
16 |
+
'rain',
|
17 |
+
'snow',
|
18 |
+
'sun',
|
19 |
+
]
|
20 |
+
|
21 |
+
with open("model.pkl", "rb") as f:
|
22 |
+
model = pickle.load(f)
|
23 |
+
|
24 |
+
|
25 |
+
def predict(wind, max_temp, min_temp, precipitation):
|
26 |
+
f_wind = float(wind)
|
27 |
+
f_max_temp = float(max_temp)
|
28 |
+
f_min_temp = float(min_temp)
|
29 |
+
f_precipitation = float(precipitation)
|
30 |
+
|
31 |
+
default = [
|
32 |
+
f_wind,
|
33 |
+
f_max_temp,
|
34 |
+
f_min_temp,
|
35 |
+
f_precipitation,
|
36 |
+
]
|
37 |
+
|
38 |
+
df = pd.DataFrame([default], columns=default_columns)
|
39 |
+
|
40 |
+
prediction = model.predict(df)
|
41 |
+
|
42 |
+
return options[prediction[0]]
|
43 |
+
|
44 |
+
iface = gr.Interface(
|
45 |
+
fn=predict,
|
46 |
+
title="Weather Prediction",
|
47 |
+
allow_flagging="never",
|
48 |
+
inputs=[
|
49 |
+
gr.inputs.Slider(0, 100, default=50, label="Wind"),
|
50 |
+
gr.inputs.Slider(0, 100, default=50, label="Max Temperature"),
|
51 |
+
gr.inputs.Slider(0, 100, default=50, label="Min Temperature"),
|
52 |
+
gr.inputs.Slider(0, 100, default=50, label="Precipitation"),
|
53 |
+
],
|
54 |
+
outputs=[
|
55 |
+
gr.outputs.Label(label="Weather"),
|
56 |
+
],
|
57 |
+
)
|
58 |
+
|
59 |
+
iface.launch()
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:90a63350fb9087ea7e09e026a5c28740cc100beeec25831eaefc4ebab08a2bbc
|
3 |
+
size 3670
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|
3 |
+
pandas
|