Spaces:
Sleeping
Sleeping
DIVYANSHI SINGH commited on
Commit ·
652c989
1
Parent(s): 27a3018
Full Restoration of Premium UI and Analytical Insights (Stabilized)
Browse files
app.py
CHANGED
|
@@ -24,8 +24,6 @@ st.markdown("""
|
|
| 24 |
|
| 25 |
html, body, [class*="css"] {
|
| 26 |
font-family: 'Inter', sans-serif;
|
| 27 |
-
background-color: #0B0E14;
|
| 28 |
-
color: #E6E6E6;
|
| 29 |
}
|
| 30 |
|
| 31 |
h1, h2, h3 {
|
|
@@ -34,6 +32,11 @@ st.markdown("""
|
|
| 34 |
letter-spacing: -0.5px;
|
| 35 |
}
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
/* Glassmorphism Sidebar */
|
| 38 |
[data-testid="stSidebar"] {
|
| 39 |
background-color: rgba(22, 27, 34, 0.95);
|
|
@@ -136,15 +139,22 @@ with st.sidebar:
|
|
| 136 |
|
| 137 |
# MAIN: ReliabilityPulse
|
| 138 |
st.title("⚡ ReliabilityPulse")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
-
#
|
| 141 |
@st.fragment
|
| 142 |
def run_stable_diagnostics():
|
| 143 |
if not models_ready:
|
| 144 |
st.warning("Core engine is offline. Please ensure models/ directory is populated.")
|
| 145 |
return
|
| 146 |
|
| 147 |
-
# Internal Logic
|
| 148 |
type_map = {"L": 0, "M": 1, "H": 2}
|
| 149 |
type_val = type_map[input_type]
|
| 150 |
temp_diff = input_proc_temp - input_air_temp
|
|
@@ -162,101 +172,99 @@ def run_stable_diagnostics():
|
|
| 162 |
model = all_models[selected_model_name]
|
| 163 |
prob = model.predict_proba(input_scaled)[0, 1]
|
| 164 |
|
| 165 |
-
if prob < 0.2: status,
|
| 166 |
-
elif prob < 0.5: status,
|
| 167 |
-
elif prob < 0.8: status,
|
| 168 |
-
else: status,
|
| 169 |
|
| 170 |
-
#
|
| 171 |
c1, c2, c3 = st.columns(3)
|
| 172 |
with c1: st.metric("Failure Probability", f"{prob*100:.1f}%")
|
| 173 |
with c2: st.metric("System Health", status)
|
| 174 |
-
with c3: st.metric("Tool Stress", f"{tool_wear_torque:.
|
| 175 |
|
| 176 |
st.write("---")
|
| 177 |
st.markdown(f"#### Asset Health: {s_icon} **{status}**")
|
| 178 |
st.progress(min(int(prob * 100), 100))
|
| 179 |
-
|
| 180 |
st.info(f"**Diagnostic Metric**: `Power: {power:.1f}W` | `Delta: {temp_diff:.1f}K` | `Stress: {tool_wear_torque:.1f}`")
|
| 181 |
|
| 182 |
-
#
|
| 183 |
@st.fragment
|
| 184 |
def render_visual_engine():
|
| 185 |
st.header("📈 Visual Data Engine")
|
| 186 |
-
st.info("Directly analyzing 10 key diagnostic signatures from the AI4I 2020 dataset.")
|
| 187 |
|
| 188 |
-
#
|
| 189 |
-
st.write("### 📊 Population Diagnostics")
|
| 190 |
v_c1, v_c2 = st.columns(2)
|
| 191 |
with v_c1:
|
| 192 |
st.image(path_utils.get_output_path('failure_distribution.png'), use_container_width=True)
|
| 193 |
-
st.
|
| 194 |
with v_c2:
|
| 195 |
st.image(path_utils.get_output_path('failure_rate_by_type.png'), use_container_width=True)
|
| 196 |
-
st.
|
| 197 |
|
| 198 |
st.write("---")
|
| 199 |
-
|
| 200 |
-
# 2. Row: Sensor Envelopes
|
| 201 |
-
st.write("### 🌡️ Sensor Envelopes")
|
| 202 |
v_c3, v_c4 = st.columns(2)
|
| 203 |
with v_c3:
|
| 204 |
st.image(path_utils.get_output_path('numeric_distributions.png'), use_container_width=True)
|
| 205 |
-
st.
|
| 206 |
with v_c4:
|
| 207 |
st.image(path_utils.get_output_path('sensor_boxplots.png'), use_container_width=True)
|
| 208 |
-
st.
|
| 209 |
|
| 210 |
st.write("---")
|
| 211 |
-
|
| 212 |
-
# 3. Row: Decision Intelligence
|
| 213 |
-
st.write("### 🔍 Decision Intelligence")
|
| 214 |
v_c5, v_c6 = st.columns(2)
|
| 215 |
with v_c5:
|
| 216 |
st.image(path_utils.get_output_path('feature_importance.png'), use_container_width=True)
|
| 217 |
-
st.
|
| 218 |
with v_c6:
|
| 219 |
st.image(path_utils.get_output_path('correlation_heatmap.png'), use_container_width=True)
|
| 220 |
-
st.
|
| 221 |
|
| 222 |
st.write("---")
|
| 223 |
-
|
| 224 |
-
# 4. Row: Failure Modes
|
| 225 |
-
st.write("### ⚙️ Failure Mechanism Analysis")
|
| 226 |
v_c7, v_c8 = st.columns(2)
|
| 227 |
with v_c7:
|
| 228 |
st.image(path_utils.get_output_path('sub_label_counts.png'), use_container_width=True)
|
| 229 |
-
st.
|
| 230 |
with v_c8:
|
| 231 |
st.image(path_utils.get_output_path('anomaly_scores.png'), use_container_width=True)
|
| 232 |
-
st.
|
| 233 |
|
| 234 |
st.write("---")
|
| 235 |
-
|
| 236 |
-
# 5. Row: Performance Benchmarks
|
| 237 |
-
st.write("### 🎯 Model Performance Benchmarks")
|
| 238 |
v_c9, v_c10 = st.columns(2)
|
| 239 |
with v_c9:
|
| 240 |
st.image(path_utils.get_output_path('roc_curve_comparison.png'), use_container_width=True)
|
| 241 |
-
st.
|
| 242 |
with v_c10:
|
| 243 |
st.image(path_utils.get_output_path('confusion_matrix_xgboost.png'), use_container_width=True)
|
| 244 |
-
st.
|
| 245 |
-
|
| 246 |
-
# Tabs
|
| 247 |
-
tab_predict, tab_viz, tab_docs = st.tabs(["🚀 Real-time Diagnostics", "📈 Visual Data Engine", "📁 Asset Specs"])
|
| 248 |
|
|
|
|
| 249 |
with tab_predict:
|
| 250 |
-
|
| 251 |
|
| 252 |
with tab_viz:
|
| 253 |
render_visual_engine()
|
| 254 |
|
| 255 |
-
with
|
|
|
|
| 256 |
st.markdown("""
|
| 257 |
-
|
| 258 |
-
**
|
| 259 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
""")
|
| 261 |
|
| 262 |
# Footer
|
|
|
|
| 24 |
|
| 25 |
html, body, [class*="css"] {
|
| 26 |
font-family: 'Inter', sans-serif;
|
|
|
|
|
|
|
| 27 |
}
|
| 28 |
|
| 29 |
h1, h2, h3 {
|
|
|
|
| 32 |
letter-spacing: -0.5px;
|
| 33 |
}
|
| 34 |
|
| 35 |
+
.main {
|
| 36 |
+
background-color: #0B0E14;
|
| 37 |
+
color: #E6E6E6;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
/* Glassmorphism Sidebar */
|
| 41 |
[data-testid="stSidebar"] {
|
| 42 |
background-color: rgba(22, 27, 34, 0.95);
|
|
|
|
| 139 |
|
| 140 |
# MAIN: ReliabilityPulse
|
| 141 |
st.title("⚡ ReliabilityPulse")
|
| 142 |
+
st.markdown("### Industrial Reliability Forecasting & Maintenance Hub")
|
| 143 |
+
|
| 144 |
+
# Tabs
|
| 145 |
+
tab_predict, tab_viz, tab_about = st.tabs([
|
| 146 |
+
"🚀 Real-time Diagnostics",
|
| 147 |
+
"📈 Visual Data Engine",
|
| 148 |
+
"📁 Asset Documentation"
|
| 149 |
+
])
|
| 150 |
|
| 151 |
+
# FRAGMENT: Prediction Stability
|
| 152 |
@st.fragment
|
| 153 |
def run_stable_diagnostics():
|
| 154 |
if not models_ready:
|
| 155 |
st.warning("Core engine is offline. Please ensure models/ directory is populated.")
|
| 156 |
return
|
| 157 |
|
|
|
|
| 158 |
type_map = {"L": 0, "M": 1, "H": 2}
|
| 159 |
type_val = type_map[input_type]
|
| 160 |
temp_diff = input_proc_temp - input_air_temp
|
|
|
|
| 172 |
model = all_models[selected_model_name]
|
| 173 |
prob = model.predict_proba(input_scaled)[0, 1]
|
| 174 |
|
| 175 |
+
if prob < 0.2: status, s_icon = "OPTIMAL", "✅"
|
| 176 |
+
elif prob < 0.5: status, s_icon = "MONITOR", "⚠️"
|
| 177 |
+
elif prob < 0.8: status, s_icon = "WARNING", "🚨"
|
| 178 |
+
else: status, s_icon = "CRITICAL", "🛑"
|
| 179 |
|
| 180 |
+
# RESTORED 3-COLUMN METRICS
|
| 181 |
c1, c2, c3 = st.columns(3)
|
| 182 |
with c1: st.metric("Failure Probability", f"{prob*100:.1f}%")
|
| 183 |
with c2: st.metric("System Health", status)
|
| 184 |
+
with c3: st.metric("Tool Stress", f"{tool_wear_torque:.1f}")
|
| 185 |
|
| 186 |
st.write("---")
|
| 187 |
st.markdown(f"#### Asset Health: {s_icon} **{status}**")
|
| 188 |
st.progress(min(int(prob * 100), 100))
|
|
|
|
| 189 |
st.info(f"**Diagnostic Metric**: `Power: {power:.1f}W` | `Delta: {temp_diff:.1f}K` | `Stress: {tool_wear_torque:.1f}`")
|
| 190 |
|
| 191 |
+
# FRAGMENT: Visual Stability
|
| 192 |
@st.fragment
|
| 193 |
def render_visual_engine():
|
| 194 |
st.header("📈 Visual Data Engine")
|
|
|
|
| 195 |
|
| 196 |
+
# ROW 1
|
|
|
|
| 197 |
v_c1, v_c2 = st.columns(2)
|
| 198 |
with v_c1:
|
| 199 |
st.image(path_utils.get_output_path('failure_distribution.png'), use_container_width=True)
|
| 200 |
+
st.info("**Insight**: Class imbalance handled via SMOTE.")
|
| 201 |
with v_c2:
|
| 202 |
st.image(path_utils.get_output_path('failure_rate_by_type.png'), use_container_width=True)
|
| 203 |
+
st.info("**Insight**: Baseline risk varies significantly by asset grade.")
|
| 204 |
|
| 205 |
st.write("---")
|
| 206 |
+
# ROW 2
|
|
|
|
|
|
|
| 207 |
v_c3, v_c4 = st.columns(2)
|
| 208 |
with v_c3:
|
| 209 |
st.image(path_utils.get_output_path('numeric_distributions.png'), use_container_width=True)
|
| 210 |
+
st.info("**Insight**: Envelopes show high variance in Torque and RPM.")
|
| 211 |
with v_c4:
|
| 212 |
st.image(path_utils.get_output_path('sensor_boxplots.png'), use_container_width=True)
|
| 213 |
+
st.info("**Insight**: Outliers typically precede tool failure events.")
|
| 214 |
|
| 215 |
st.write("---")
|
| 216 |
+
# ROW 3
|
|
|
|
|
|
|
| 217 |
v_c5, v_c6 = st.columns(2)
|
| 218 |
with v_c5:
|
| 219 |
st.image(path_utils.get_output_path('feature_importance.png'), use_container_width=True)
|
| 220 |
+
st.info("**Insight**: Tool Wear & Torque interaction is the top predictor.")
|
| 221 |
with v_c6:
|
| 222 |
st.image(path_utils.get_output_path('correlation_heatmap.png'), use_container_width=True)
|
| 223 |
+
st.info("**Insight**: Thermal delta captures heat transfer efficiency.")
|
| 224 |
|
| 225 |
st.write("---")
|
| 226 |
+
# ROW 4
|
|
|
|
|
|
|
| 227 |
v_c7, v_c8 = st.columns(2)
|
| 228 |
with v_c7:
|
| 229 |
st.image(path_utils.get_output_path('sub_label_counts.png'), use_container_width=True)
|
| 230 |
+
st.info("**Insight**: HDF and PWF are dominant failure modes.")
|
| 231 |
with v_c8:
|
| 232 |
st.image(path_utils.get_output_path('anomaly_scores.png'), use_container_width=True)
|
| 233 |
+
st.info("**Insight**: Isolation Forest effectively flags novel signatures.")
|
| 234 |
|
| 235 |
st.write("---")
|
| 236 |
+
# ROW 5
|
|
|
|
|
|
|
| 237 |
v_c9, v_c10 = st.columns(2)
|
| 238 |
with v_c9:
|
| 239 |
st.image(path_utils.get_output_path('roc_curve_comparison.png'), use_container_width=True)
|
| 240 |
+
st.info("**Insight**: XGBoost maintains ~0.95 AUC accuracy.")
|
| 241 |
with v_c10:
|
| 242 |
st.image(path_utils.get_output_path('confusion_matrix_xgboost.png'), use_container_width=True)
|
| 243 |
+
st.info("**Insight**: High Recall prioritizes asset uptime.")
|
|
|
|
|
|
|
|
|
|
| 244 |
|
| 245 |
+
# --- Render Tabs ---
|
| 246 |
with tab_predict:
|
| 247 |
+
run_stable_diagnostics()
|
| 248 |
|
| 249 |
with tab_viz:
|
| 250 |
render_visual_engine()
|
| 251 |
|
| 252 |
+
with tab_about:
|
| 253 |
+
st.header("🏭 Project Overview & Roadmap")
|
| 254 |
st.markdown("""
|
| 255 |
+
**ReliabilityPulse** is an industrial-grade intelligence suite designed to protect manufacturing revenue.
|
| 256 |
+
By forecasting failures **24-72 hours** in advance, it transforms reactive maintenance into a proactive strategy.
|
| 257 |
+
|
| 258 |
+
### 🎯 Tech Stack:
|
| 259 |
+
- **Modeling**: Python 3.12, XGBoost, Scikit-Learn
|
| 260 |
+
- **Frontend**: Streamlit with Custom Glassmorphism CSS
|
| 261 |
+
- **Storage**: Git LFS for large scale binary assets
|
| 262 |
+
- **Data**: UCI AI4I 2020 Predictive Maintenance
|
| 263 |
+
|
| 264 |
+
### 🛠️ Operational Flow:
|
| 265 |
+
1. **Sensing**: Telemetry ingestion via the Control Center.
|
| 266 |
+
2. **Analysis**: Real-time cross-referencing with historical failure signatures.
|
| 267 |
+
3. **Strategy**: Automated maintenance triggers based on calculated Risk Levels.
|
| 268 |
""")
|
| 269 |
|
| 270 |
# Footer
|