Spaces:
Sleeping
Sleeping
File size: 4,676 Bytes
3f92c41 e551557 cdc7940 e551557 cdc7940 e551557 cdc7940 e551557 e194882 3f92c41 cdc7940 e194882 e551557 cdc7940 e194882 e551557 cdc7940 3f92c41 e551557 cdc7940 3f92c41 e551557 cdc7940 e551557 e194882 3f92c41 cdc7940 3f92c41 cdc7940 3f92c41 cdc7940 e551557 cdc7940 e194882 cdc7940 3f92c41 e551557 3f92c41 e194882 3f92c41 e551557 cdc7940 e551557 cdc7940 e551557 cdc7940 e194882 e551557 cdc7940 e551557 3f92c41 cdc7940 3f92c41 ac6cec3 |
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
import gradio as gr
# =============================================================================
# PREDICTIVE AGENT - LSTM-Based RUL Prediction
# Author: David Fernandez | Industrial AI Engineer | LangGraph Contributor
# =============================================================================
def predict(health_index, vibration, heat_rate_delta, operating_hours, start_count):
"""Predict Remaining Useful Life based on equipment health."""
# Normalize factors (0-1 scale)
hi_factor = health_index / 100
vib_factor = 1 - min(vibration / 1.0, 1)
hr_factor = 1 - min(heat_rate_delta / 15, 1)
hours_factor = 1 - min(operating_hours / 80000, 1)
starts_factor = 1 - min(start_count / 1500, 1)
# Weighted composite
composite = (
hi_factor * 0.35 +
vib_factor * 0.25 +
hr_factor * 0.20 +
hours_factor * 0.12 +
starts_factor * 0.08
)
rul = int(composite * 200)
# Urgency
if rul < 30:
urgency = "๐ด CRITICAL"
action = "Schedule emergency maintenance within 48 hours."
elif rul < 100:
urgency = "๐ก SCHEDULED"
action = "Plan maintenance in next outage window (2-4 weeks)."
else:
urgency = "๐ข ROUTINE"
action = "Continue normal monitoring. No immediate action."
# Status checks
def status(val, good, warn, lower_better=True):
if lower_better:
if val <= good: return "โ
OK"
elif val <= warn: return "โ ๏ธ WARNING"
else: return "๐ด CRITICAL"
else:
if val >= good: return "โ
OK"
elif val >= warn: return "โ ๏ธ WARNING"
else: return "๐ด CRITICAL"
# Recommendations
recs = []
if health_index < 60:
recs.append("๐ง **Hot Gas Path Inspection** - Health index degraded")
if vibration > 0.4:
recs.append("๐ง **Bearing Analysis** - Elevated vibration")
if heat_rate_delta > 6:
recs.append("๐ง **Compressor Wash** - Heat rate deviation")
if operating_hours > 60000:
recs.append("๐ง **Major Overhaul Planning** - High hours")
if not recs:
recs.append("โ
Continue normal monitoring")
return f"""# ๐ฎ RUL Prediction Report
## Remaining Useful Life: **{rul} cycles**
## {urgency}
{action}
---
## Equipment Status
| Parameter | Value | Status |
|-----------|-------|--------|
| Health Index | {health_index}% | {status(health_index, 70, 40, False)} |
| Vibration | {vibration} in/s | {status(vibration, 0.3, 0.5)} |
| Heat Rate Delta | {heat_rate_delta}% | {status(heat_rate_delta, 4, 8)} |
| Operating Hours | {int(operating_hours):,} | {status(operating_hours, 50000, 65000)} |
| Start Count | {int(start_count):,} | {status(start_count, 1000, 1200)} |
---
## Recommendations
{chr(10).join(recs)}
---
## Model Details
- **Algorithm**: LSTM Neural Network
- **Confidence**: {int(composite * 100)}% composite health
---
*Model: [rul-predictor-ccgt](https://huggingface.co/davidfertube/rul-predictor-ccgt) | Dataset: [ccgt-health-history](https://huggingface.co/datasets/davidfertube/ccgt-health-history)*
"""
# Create the interface
demo = gr.Interface(
fn=predict,
inputs=[
gr.Number(label="Health Index (%)", value=85, minimum=0, maximum=100),
gr.Number(label="Vibration (in/s)", value=0.18, minimum=0, maximum=1),
gr.Number(label="Heat Rate Delta (%)", value=2.5, minimum=0, maximum=15),
gr.Number(label="Operating Hours", value=52000),
gr.Number(label="Start Count", value=950),
],
outputs=gr.Markdown(label="RUL Prediction"),
title="๐ง Predictive Agent",
description="""
## LSTM-Based Remaining Useful Life (RUL) Prediction
**How to use:**
1. Click an example below to load demo values
2. Click "Submit" to see the RUL prediction
3. Or enter your own equipment health data
**What it does:** Predicts equipment failure timeline for CCGT turbines using LSTM neural networks.
""",
article="""
---
### How It Works
```
Health Metrics โ LSTM Model โ RUL Prediction โ Maintenance Priority
```
**Key Metrics:** Health Index, Vibration, Heat Rate Delta, Operating Hours, Start Count
**Resources:** [Model](https://huggingface.co/davidfertube/rul-predictor-ccgt) | [Dataset](https://huggingface.co/datasets/davidfertube/ccgt-health-history) | [Portfolio](https://davidfernandez.dev)
*Built by David Fernandez - Industrial AI Engineer | LangGraph Contributor*
""",
examples=[
[96.5, 0.14, 1.2, 48500, 920], # Healthy equipment
[42.3, 0.48, 8.5, 68000, 1180], # Degraded equipment
],
cache_examples=False,
)
demo.launch()
|