File size: 4,116 Bytes
d47fa16
 
 
f6ca5e3
d47fa16
9d6fe04
 
 
d47fa16
 
 
 
 
 
 
 
 
 
 
 
 
 
f336e23
 
 
 
d47fa16
 
 
 
 
 
 
 
 
 
 
6085bd2
 
d47fa16
 
 
 
 
 
 
 
4ec62c9
d47fa16
 
 
 
4ec62c9
d47fa16
4ec62c9
d47fa16
 
 
99a450c
f336e23
 
 
54277d2
f336e23
f6ca5e3
 
 
 
 
 
 
 
 
 
4ec62c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d47fa16
 
 
f6ca5e3
d5b2e6d
4ec62c9
 
d47fa16
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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
    
def upload_file(files):
    file_paths = [file.name for file in files]
    return file_paths
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()
            with gr.Column():
                Aircomp_output_btn=gr.Button("Forecast")
                Air_plot_forecast=gr.Button("Plot")
            Air_plots=gr.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()
            with gr.Column():
                Energy_output_btn=gr.Button("Forecast")
                Ener_plot_forecast=gr.Button("Plot")
            Ener_plots=gr.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)
                boiler_dataframe_input=gr.Dataframe(example_df_boiler.head(100))
                boiler_dataframe_output=gr.Dataframe()
                
            with gr.Column():
                Boiler_output_btn=gr.Button("Forecast")
                boiler_plot_forecast=gr.Button("Plot")
            boil_plots=gr.Plot()

        with gr.TabItem("Upload data"):
            file_output = gr.File()
            upload_button = gr.UploadButton("Click to Upload a File", file_types=["csv"], file_count="multiple")
            upload_button.upload(upload_file, upload_button, file_output)

    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
        
    def plotg_ener(dataframe):
        fig=px.line(dataframe,x='parameter_timestamp',y=dataframe.columns,
                   hover_data={"parameter_timestamp":"|%B %d, %Y"},
                   title="Predictions")
        fig.update_xaxes(
            dtick="D1",
            tickformat="%b\n%Y"
        )
        return fig
    def plotg_boiler(dataframe):
        fig=px.line(dataframe,x='DateString',y=dataframe.columns,
                   hover_data={"DateString":"|%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(plotg_air,inputs=Air_dataframe_output,outputs=Air_plots)
    Ener_plot_forecast.click(plotg_ener,inputs=Ener_dataframe_output,outputs=Ener_plots)
    boiler_plot_forecast.click(plotg_boiler,inputs=boiler_dataframe_output,outputs=boil_plots)
demo.launch(share=True)