Spaces:
Sleeping
Sleeping
Commit
·
ac6cec3
1
Parent(s):
e194882
Fix: Python 3.11
Browse files- README.md +2 -1
- app.py +31 -88
- requirements.txt +1 -3
README.md
CHANGED
|
@@ -4,7 +4,8 @@ emoji: 🔧
|
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 4.
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: true
|
| 10 |
license: mit
|
|
|
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.36.0
|
| 8 |
+
python_version: "3.11"
|
| 9 |
app_file: app.py
|
| 10 |
pinned: true
|
| 11 |
license: mit
|
app.py
CHANGED
|
@@ -1,125 +1,68 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Predictive Agent - LSTM-Based RUL Prediction
|
| 3 |
-
Predicts Remaining Useful Life for CCGT equipment.
|
| 4 |
-
Author: David Fernandez - Industrial AI Engineer
|
| 5 |
-
"""
|
| 6 |
-
|
| 7 |
import gradio as gr
|
| 8 |
|
| 9 |
-
# Thresholds
|
| 10 |
-
THRESHOLDS = {
|
| 11 |
-
'health_index': (70, 40), # good, warning (higher is better)
|
| 12 |
-
'vibration': (0.3, 0.5), # good, warning (lower is better)
|
| 13 |
-
'heat_rate_delta': (4, 8), # good, warning (lower is better)
|
| 14 |
-
}
|
| 15 |
-
|
| 16 |
def predict(health_index, vibration, heat_rate_delta, operating_hours, start_count):
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
# Weighted RUL calculation
|
| 27 |
-
composite = (hi_factor * 0.35 + vib_factor * 0.25 + hr_factor * 0.20 +
|
| 28 |
-
hours_factor * 0.12 + starts_factor * 0.08)
|
| 29 |
-
|
| 30 |
rul = int(composite * 200)
|
| 31 |
|
| 32 |
-
# Urgency
|
| 33 |
if rul < 30:
|
| 34 |
-
urgency = "CRITICAL"
|
| 35 |
-
action = "Schedule emergency maintenance within 48 hours"
|
| 36 |
elif rul < 100:
|
| 37 |
-
urgency = "SCHEDULED"
|
| 38 |
-
action = "Plan maintenance in next available window"
|
| 39 |
else:
|
| 40 |
-
urgency = "ROUTINE"
|
| 41 |
-
action = "Continue normal monitoring"
|
| 42 |
-
|
| 43 |
-
# Status checks
|
| 44 |
-
def status(val, good, warn, lower_is_better=True):
|
| 45 |
-
if lower_is_better:
|
| 46 |
-
return "OK" if val <= good else "WARNING" if val <= warn else "CRITICAL"
|
| 47 |
-
return "OK" if val >= good else "WARNING" if val >= warn else "CRITICAL"
|
| 48 |
|
| 49 |
-
hi_status = status(health_index, 70, 40, lower_is_better=False)
|
| 50 |
-
vib_status = status(vibration, 0.3, 0.5)
|
| 51 |
-
hr_status = status(heat_rate_delta, 4, 8)
|
| 52 |
-
|
| 53 |
-
# Recommendations
|
| 54 |
recs = []
|
| 55 |
if health_index < 60:
|
| 56 |
-
recs.append("
|
| 57 |
if vibration > 0.4:
|
| 58 |
-
recs.append("
|
| 59 |
if heat_rate_delta > 6:
|
| 60 |
-
recs.append("
|
| 61 |
-
if operating_hours > 60000:
|
| 62 |
-
recs.append("4. **Major Overhaul Planning** - High operating hours")
|
| 63 |
if not recs:
|
| 64 |
-
recs.append("Continue normal
|
| 65 |
|
| 66 |
return f"""# RUL Prediction
|
| 67 |
|
| 68 |
## Remaining Useful Life: **{rul} cycles**
|
| 69 |
|
| 70 |
-
|
| 71 |
-
{action}
|
| 72 |
-
|
| 73 |
-
---
|
| 74 |
|
| 75 |
## Equipment Status
|
| 76 |
-
| Parameter | Value |
|
| 77 |
-
|
| 78 |
-
| Health Index | {health_index}% |
|
| 79 |
-
| Vibration | {vibration} in/s |
|
| 80 |
-
| Heat Rate Delta | {heat_rate_delta}% |
|
| 81 |
-
| Operating Hours | {int(operating_hours):,} |
|
| 82 |
-
| Start Count | {int(start_count):,} |
|
| 83 |
|
| 84 |
## Recommendations
|
| 85 |
{chr(10).join(recs)}
|
| 86 |
-
|
| 87 |
-
---
|
| 88 |
-
*Model: [rul-predictor-ccgt](https://huggingface.co/davidfertube/rul-predictor-ccgt)*
|
| 89 |
"""
|
| 90 |
|
| 91 |
demo = gr.Interface(
|
| 92 |
fn=predict,
|
| 93 |
inputs=[
|
| 94 |
-
gr.Number(label="Health Index (%)", value=85
|
| 95 |
-
gr.Number(label="Vibration (in/s)", value=0.18
|
| 96 |
-
gr.Number(label="Heat Rate Delta (%)", value=2.5
|
| 97 |
gr.Number(label="Operating Hours", value=52000),
|
| 98 |
gr.Number(label="Start Count", value=950),
|
| 99 |
],
|
| 100 |
-
outputs=
|
| 101 |
title="Predictive Agent",
|
| 102 |
-
description="
|
| 103 |
-
|
| 104 |
-
Predict Remaining Useful Life to optimize maintenance scheduling.
|
| 105 |
-
|
| 106 |
-
Click an example below to test.""",
|
| 107 |
examples=[
|
| 108 |
-
[96.5, 0.14, 1.2, 48500, 920],
|
| 109 |
-
[42.3, 0.48, 8.5, 68000, 1180],
|
| 110 |
],
|
| 111 |
-
cache_examples=False,
|
| 112 |
-
article="""
|
| 113 |
-
## How It Works
|
| 114 |
-
```
|
| 115 |
-
Health Metrics → LSTM Inference → RUL Estimate → Maintenance Plan
|
| 116 |
-
```
|
| 117 |
-
|
| 118 |
-
**Resources**: [Model](https://huggingface.co/davidfertube/rul-predictor-ccgt) | [Dataset](https://huggingface.co/datasets/davidfertube/ccgt-health-history) | [Portfolio](https://davidfernandez.dev)
|
| 119 |
-
|
| 120 |
-
*Built by David Fernandez - Industrial AI Engineer*
|
| 121 |
-
"""
|
| 122 |
)
|
| 123 |
|
| 124 |
-
|
| 125 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
def predict(health_index, vibration, heat_rate_delta, operating_hours, start_count):
|
| 4 |
+
# Calculate RUL
|
| 5 |
+
hi = health_index / 100
|
| 6 |
+
vib = 1 - min(vibration, 1)
|
| 7 |
+
hr = 1 - min(heat_rate_delta / 15, 1)
|
| 8 |
+
hours = 1 - min(operating_hours / 80000, 1)
|
| 9 |
+
starts = 1 - min(start_count / 1500, 1)
|
| 10 |
+
|
| 11 |
+
composite = hi * 0.35 + vib * 0.25 + hr * 0.20 + hours * 0.12 + starts * 0.08
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
rul = int(composite * 200)
|
| 13 |
|
|
|
|
| 14 |
if rul < 30:
|
| 15 |
+
urgency = "CRITICAL - Immediate maintenance"
|
|
|
|
| 16 |
elif rul < 100:
|
| 17 |
+
urgency = "SCHEDULED - Plan maintenance"
|
|
|
|
| 18 |
else:
|
| 19 |
+
urgency = "ROUTINE - Continue monitoring"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
recs = []
|
| 22 |
if health_index < 60:
|
| 23 |
+
recs.append("- Hot Gas Path Inspection needed")
|
| 24 |
if vibration > 0.4:
|
| 25 |
+
recs.append("- Bearing analysis required")
|
| 26 |
if heat_rate_delta > 6:
|
| 27 |
+
recs.append("- Compressor wash recommended")
|
|
|
|
|
|
|
| 28 |
if not recs:
|
| 29 |
+
recs.append("- Continue normal monitoring")
|
| 30 |
|
| 31 |
return f"""# RUL Prediction
|
| 32 |
|
| 33 |
## Remaining Useful Life: **{rul} cycles**
|
| 34 |
|
| 35 |
+
**{urgency}**
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
## Equipment Status
|
| 38 |
+
| Parameter | Value |
|
| 39 |
+
|-----------|-------|
|
| 40 |
+
| Health Index | {health_index}% |
|
| 41 |
+
| Vibration | {vibration} in/s |
|
| 42 |
+
| Heat Rate Delta | {heat_rate_delta}% |
|
| 43 |
+
| Operating Hours | {int(operating_hours):,} |
|
| 44 |
+
| Start Count | {int(start_count):,} |
|
| 45 |
|
| 46 |
## Recommendations
|
| 47 |
{chr(10).join(recs)}
|
|
|
|
|
|
|
|
|
|
| 48 |
"""
|
| 49 |
|
| 50 |
demo = gr.Interface(
|
| 51 |
fn=predict,
|
| 52 |
inputs=[
|
| 53 |
+
gr.Number(label="Health Index (%)", value=85),
|
| 54 |
+
gr.Number(label="Vibration (in/s)", value=0.18),
|
| 55 |
+
gr.Number(label="Heat Rate Delta (%)", value=2.5),
|
| 56 |
gr.Number(label="Operating Hours", value=52000),
|
| 57 |
gr.Number(label="Start Count", value=950),
|
| 58 |
],
|
| 59 |
+
outputs="markdown",
|
| 60 |
title="Predictive Agent",
|
| 61 |
+
description="LSTM-Based RUL Prediction for CCGT Equipment",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
examples=[
|
| 63 |
+
[96.5, 0.14, 1.2, 48500, 920],
|
| 64 |
+
[42.3, 0.48, 8.5, 68000, 1180],
|
| 65 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
)
|
| 67 |
|
| 68 |
+
demo.launch()
|
|
|
requirements.txt
CHANGED
|
@@ -1,3 +1 @@
|
|
| 1 |
-
gradio==4.
|
| 2 |
-
numpy
|
| 3 |
-
pandas
|
|
|
|
| 1 |
+
gradio==4.36.0
|
|
|
|
|
|