JuanJoseMV's picture
First commit
0d5a7ab
raw
history blame
1.63 kB
import gradio as gr
from src.visualization import plot_time_series
PROJECT_HTML_PATH = "sections/project_description.html"
WELCOME_HTML_PATH = "sections/welcome_section.html"
DEMO_HTML_PATH = "sections/demo_section.html"
TRY_IT_YOURSELF_HTML_PATH = "sections/try_it_yourself.html"
CSS_FILE_PATH = "sections/styles/blocks.css"
ANOMALY_METHODS = ["LSTM", "ARIMA", "IQR"]
with open(PROJECT_HTML_PATH, "r") as file:
project_description_html = file.read()
with open(WELCOME_HTML_PATH, "r") as file:
welcome_html = file.read()
with open(DEMO_HTML_PATH, "r") as file:
demo_section_html = file.read()
with open(TRY_IT_YOURSELF_HTML_PATH, "r") as file:
try_it_yourself_html = file.read()
with open(CSS_FILE_PATH, "r") as css_file:
blocks_css = css_file.read()
with gr.Blocks(css=blocks_css) as demo:
gr.HTML(project_description_html)
gr.Markdown(welcome_html)
gr.Markdown(demo_section_html)
gr.HTML(try_it_yourself_html)
file_input = gr.File(label="Upload Time Series CSV")
plot_btn = gr.Button("Plot Time Series")
plot_output = gr.Plot(label="Time Series Plot")
method_input = gr.Dropdown(choices=ANOMALY_METHODS, label="Select Anomaly Detection Method", value="LSTM")
analyze_btn = gr.Button("Detect Anomalies")
anomaly_output = gr.Plot(label="Anomaly Detection Results")
plot_btn.click(
fn=plot_time_series,
inputs=[file_input],
outputs=[plot_output]
)
# analyze_btn.click(
# fn=detect_anomalies,
# inputs=[file_input, method_input],
# outputs=[anomaly_output]
# )
demo.launch(show_api=False)