Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,85 +1,34 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
-
|
4 |
-
|
5 |
-
import
|
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 |
-
# Visuals
|
37 |
-
def show_heatmap(df):
|
38 |
-
st.subheader("π‘οΈ Fault Distribution Heatmap")
|
39 |
-
|
40 |
-
map_data = df.groupby(['Site', 'AlertLevel']).size().reset_index(name="Count")
|
41 |
-
fig = px.density_heatmap(
|
42 |
-
map_data, x="Site", y="AlertLevel", z="Count", color_continuous_scale="Reds", title="Alerts per Site"
|
43 |
-
)
|
44 |
-
st.plotly_chart(fig, use_container_width=True)
|
45 |
-
|
46 |
-
def show_red_alerts(df):
|
47 |
-
st.subheader("π¨ Blinking Red Alert Poles")
|
48 |
-
red_df = df[df["AlertLevel"] == "Red"]
|
49 |
-
if red_df.empty:
|
50 |
-
st.success("No red alerts right now!")
|
51 |
-
return
|
52 |
-
|
53 |
-
for _, row in red_df.iterrows():
|
54 |
-
with st.container():
|
55 |
-
st.markdown(
|
56 |
-
f"<div style='padding:8px; background-color:#ffcccc; animation: blink 1s infinite;'>"
|
57 |
-
f"<strong>{row['PoleID']}</strong>: {', '.join(row['Anomalies'])}</div>",
|
58 |
-
unsafe_allow_html=True
|
59 |
-
)
|
60 |
-
|
61 |
-
st.markdown(
|
62 |
-
"""
|
63 |
-
<style>
|
64 |
-
@keyframes blink {
|
65 |
-
50% { background-color: #ff4d4d; }
|
66 |
-
}
|
67 |
-
</style>
|
68 |
-
""",
|
69 |
-
unsafe_allow_html=True
|
70 |
-
)
|
71 |
-
|
72 |
-
# Main
|
73 |
-
st.set_page_config("VIEP Heatmap Dashboard", layout="wide")
|
74 |
-
st.title("π Vedavathi Smart Pole Monitoring Dashboard")
|
75 |
-
|
76 |
-
df = generate_mock_data()
|
77 |
-
|
78 |
-
# Filters
|
79 |
-
alert_filter = st.selectbox("Filter by Alert Level", ["All", "Green", "Yellow", "Red"])
|
80 |
-
if alert_filter != "All":
|
81 |
-
df = df[df["AlertLevel"] == alert_filter]
|
82 |
-
|
83 |
-
# Views
|
84 |
-
show_heatmap(df)
|
85 |
-
show_red_alerts(df)
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
+
from modules.simulator import simulate_data
|
4 |
+
from modules.filters import apply_filters
|
5 |
+
from modules.visuals import display_dashboard, display_charts, display_map_with_alerts
|
6 |
+
from modules.ai_engine import AIEngine
|
7 |
+
|
8 |
+
st.set_page_config(page_title="Vedavathi Smart Pole Monitoring", layout="wide")
|
9 |
+
st.title("π‘ Vedavathi Smart Pole Monitoring - Heatmap AI Simulator")
|
10 |
+
|
11 |
+
# Sidebar Controls
|
12 |
+
st.sidebar.header("π οΈ Simulation Controls")
|
13 |
+
num_poles = st.sidebar.slider("Number of Poles", min_value=10, max_value=500, value=50)
|
14 |
+
simulate_faults = st.sidebar.checkbox("Simulate Random Faults", value=True)
|
15 |
+
|
16 |
+
# Simulate Data
|
17 |
+
df = simulate_data(num_poles, simulate_faults)
|
18 |
+
|
19 |
+
# AI-based Health Prediction
|
20 |
+
ai = AIEngine()
|
21 |
+
df = ai.predict_health(df)
|
22 |
+
|
23 |
+
# Sidebar Filters
|
24 |
+
st.sidebar.header("π Filter Data")
|
25 |
+
alert_filter = st.sidebar.multiselect("Alert Level", ["Green", "Yellow", "Red"], default=["Green", "Yellow", "Red"])
|
26 |
+
cam_filter = st.sidebar.selectbox("Camera Status", ["All", "Online", "Offline"], index=0)
|
27 |
+
df = apply_filters(df, alert_filter, cam_filter)
|
28 |
+
|
29 |
+
# Dashboard UI
|
30 |
+
display_dashboard(df)
|
31 |
+
st.subheader("π Live Pole Map")
|
32 |
+
display_map_with_alerts(df)
|
33 |
+
st.subheader("π Energy + Sensor Charts")
|
34 |
+
display_charts(df)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|