Spaces:
Runtime error
Runtime error
import gradio as gr | |
import datetime | |
import time | |
import joblib | |
week = {"Monday":1,"Tuesday":2,"Wednesday":3,'Thursday':4,'Friday':5,"Saturday":6,'Sunday':7} | |
def prediction(t,len,air,airfrom,airto,day): | |
x = time.strptime(t,'%H:%M:%S') | |
t = datetime.timedelta(hours=x.tm_hour,minutes=x.tm_min,seconds=x.tm_sec).total_seconds()/60 | |
dataf = { | |
'Time' : t, | |
'Length' : len, | |
'Airline' : [airline_dict[air]], | |
'AirportFrom': [air_from_dict[airfrom]], | |
'AirportTo' : [air_to_dict[airto]], | |
'DayOfWeek': week[day] | |
} | |
d_f = pd.DataFrame(dataf) | |
model = joblib.load('Flight.pkl') | |
if model.predict(d_f) == 1: | |
return "Your Flight will be probably delayed" | |
return "Your Flight will be on time" | |
face = gr.Interface( | |
prediction, | |
[gr.Textbox( | |
label= 'Time of the Flight', | |
info = 'Should be in HH:MM:SS in 24hrs format', | |
lines = 1, | |
value='17:15:00', | |
), | |
gr.Number(value=100,label="Length of Flight"), | |
gr.Textbox( | |
label="Code of Airline", | |
lines=1, | |
value="OO", | |
), | |
gr.Textbox( | |
label=" Departure Airport", | |
info='Airport Code', | |
lines=1, | |
value='MSP', | |
), | |
gr.Textbox( | |
label='Arrival Airport', | |
info='Airport Code', | |
lines=1, | |
value='MOT', | |
), | |
gr.Dropdown(['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],value="Monday",label="Day") | |
],title="Flight Delay Prediction", theme = gr.themes.Base.from_hub("freddyaboulton/test-blue") ,outputs="text" | |
) | |
face.launch() |