File size: 1,225 Bytes
306358d
 
 
 
 
 
118c394
a8324df
 
118c394
306358d
 
 
 
 
 
 
 
 
 
 
 
 
c109ee3
 
306358d
3c882df
118c394
3c882df
 
118c394
306358d
 
118c394
306358d
 
118c394
306358d
 
 
 
 
c109ee3
306358d
b4513b7
306358d
 
 
 
 
 
118c394
a8324df
 
118c394
306358d
6cb7afd
306358d
 
 
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import gradio as gr
import torch, numpy as np, pandas as pd
import skimage 
import pickle

default_columns = [
  'precipitation',
  'temp_max',
  'temp_min',
  'wind',
]

options = [
  'drizzle',
  'fog',
  'rain',
  'snow',
  'sun',
]

with open("model.pkl", "rb") as f:
  model = pickle.load(f)

with open("model2.pkl", "rb") as f:
  model2 = pickle.load(f)

def predict(wind, temp_max, temp_min, precipitation):
  f_precipitation = float(precipitation)
  f_max_temp = float(temp_max)
  f_min_temp = float(temp_min)
  f_wind = float(wind)

  default = [
    f_precipitation,
    f_max_temp,
    f_min_temp,
    f_wind,
  ]

  df = pd.DataFrame([default], columns=default_columns)

  prediction = model.predict(df)
  prediction2 = model2.predict(df)

  return [options[round(max(prediction))], options[round(max(prediction2))]]
  
iface = gr.Interface(
  fn=predict,
  title="Weather Prediction",
  allow_flagging="never",
  inputs=[
    gr.inputs.Slider(0, 60, default=30, label="precipitation"),
    gr.inputs.Slider(-10, 40, default=20, label="temp_max"),
    gr.inputs.Slider(-10, 40, default=10, label="temp_min"),
    gr.inputs.Slider(0, 10, default=5, label="wind"),
  ],
  outputs=["text", "text"],
)

iface.launch()