File size: 858 Bytes
6fedaa7
 
 
 
 
383842f
6fedaa7
 
 
 
651d250
6fedaa7
 
 
c307f2e
6fedaa7
 
 
 
b315b3e
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import sklearn
import gradio as gr
import joblib
import pandas as pd
import datasets
import dateutil.parser as dp

title = "Stoclholm Highway E4 Real Time Traffic Prediction"
description = "Stockholm E4 (59°23'44.7"" N 17°59'00.4""E) highway real time traffic prediction, updated in every hour"

inputs = [gr.Dataframe(row_count = (1, "fixed"), col_count=(7,"fixed"), label="Input Data", interactive=1)]

outputs = [gr.Dataframe(row_count = (1, "fixed"), col_count=(1, "fixed"), label="Predictions", headers=["Congestion Level"])]

model = joblib.load("./traffic_model.pkl")


def infer(input_dataframe):
  return pd.DataFrame(model.predict(input_dataframe))
referenceTime = dp.parse(json_response_smhi["referenceTime"]).timestamp()
gr.Interface(fn = infer, inputs = inputs, outputs = referenceTime, title=title, description=description,live=True).launch()