tab / app.py
GhoulMac's picture
Update app.py
f6ca5e3
raw
history blame
No virus
2.92 kB
import gradio as gr
import pandas as pd
import Generate
import plotly.express as px
example_df_aircomp=pd.read_csv('data/aircompressordata.csv')
example_df_ener=pd.read_csv('data/energymeter.csv')
example_df_boiler=pd.read_csv('data/Boiler1.csv')
demo=gr.Blocks(title="EcoForecast")
def pred_air(date):
preds=Generate.inference_Aircomp(date,example_df_aircomp)
return preds
def pred_ener(date):
preds=Generate.inference_Energy(date,example_df_ener)
return preds
def pred_boiler(date):
preds=Generate.inference_boiler(date,example_df_boiler)
return preds
with demo:
gr.Markdown("Tool for predicting the next seven days of data in the future using the last 200 points of data incoming")
with gr.Tabs():
with gr.TabItem("Air compressor data"):
with gr.Row():
Air_input=gr.Text(placeholder="Enter date and like the example only",show_label=False)
air_dataframe_input=gr.Dataframe(example_df_aircomp.head(100))
Air_dataframe_output=gr.Dataframe()
Air_plots=gr.Plot()
with gr.Column():
Aircomp_output_btn=gr.Button("Forecast")
Air_plot_forecast=gr.Button("Plot")
with gr.TabItem("Energymeter data"):
with gr.Row():
ener_input=gr.Text(placeholder="Enter the date and time in example format only",show_label=False)
ener_dataframe_input=gr.Dataframe(example_df_ener.head(100))
Ener_dataframe_output=gr.Dataframe()
Ener_plots=gr.Plot()
with gr.Column():
Energy_output_btn=gr.Button("Forecast")
Ener_plot_forecast=gr.Button("Plot")
with gr.TabItem("Boiler data"):
with gr.Row():
boiler_input=gr.Text(placeholder="Enter the date and time in example format only",show_label=False)
ener_dataframe_input=gr.Dataframe(example_df_boiler.head(100))
boiler_dataframe_output=gr.Dataframe()
boil_plots=gr.Plot()
with gr.Column():
Boiler_output_btn=gr.Button("Forecast")
boiler_plot_forecast=gr.Button("Plot")
def plotg_air(dataframe):
fig=px.line(dataframe,x='timestamp',y=dataframe.columns,
hover_data={"timestamp":"|%B %d, %Y"},
title="Predictions")
fig.update_xaxes(
dtick="D1",
tickformat="%b\n%Y"
)
return fig
Aircomp_output_btn.click(pred_air,inputs=Air_input,outputs=Air_dataframe_output)
Energy_output_btn.click(pred_ener,inputs=ener_input,outputs=Ener_dataframe_output)
Boiler_output_btn.click(pred_boiler,inputs=boiler_input,outputs=boiler_dataframe_output)
Air_plot_forecast.click(inputs=Air_dataframe_output,outputs=Air_plots)
demo.launch(share=True)