File size: 1,631 Bytes
0d5a7ab |
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 |
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) |