charantejapolavarapu commited on
Commit
d180f5a
·
verified ·
1 Parent(s): 31cd30c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +70 -0
app.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import joblib
4
+ import numpy as np
5
+ import plotly.graph_objects as go
6
+
7
+ # Set Page Config
8
+ st.set_page_config(page_title="AI Predictive Maintenance", layout="wide")
9
+
10
+ # Load Model
11
+ @st.cache_resource
12
+ def load_model():
13
+ return joblib.load('engine_model.pkl')
14
+
15
+ model = load_model()
16
+
17
+ st.title("✈️ Smart Maintenance: Jet Engine RUL Predictor")
18
+ st.markdown("---")
19
+
20
+ # Layout: 2 Columns
21
+ col1, col2 = st.columns([1, 2])
22
+
23
+ with col1:
24
+ st.header("📥 Sensor Inputs")
25
+ cycle = st.slider("Current Flight Cycles", 1, 350, 100)
26
+ s2 = st.number_input("Sensor 2 (LPC Outlet Temp)", value=642.0)
27
+ s3 = st.number_input("Sensor 3 (HPC Outlet Temp)", value=1585.0)
28
+ s4 = st.number_input("Sensor 4 (LPT Outlet Temp)", value=1405.0)
29
+ s7 = st.number_input("Sensor 7 (HPC Outlet Press)", value=553.0)
30
+ s11 = st.number_input("Sensor 11 (HPC Speed)", value=47.5)
31
+
32
+ # Static values for remaining features to simplify UI
33
+ other_features = [550, 2388, 521, 8.4, 392, 39, 23]
34
+
35
+ if st.button("Analyze Engine Health", type="primary"):
36
+ inputs = np.array([[cycle, s2, s3, s4, s7, s11] + other_features])
37
+ prediction = model.predict(inputs)[0]
38
+ st.session_state['prediction'] = max(0, int(prediction))
39
+
40
+ with col2:
41
+ st.header("📊 Diagnostic Results")
42
+ if 'prediction' in st.session_state:
43
+ rul = st.session_state['prediction']
44
+
45
+ # 1. Visual Gauge Chart
46
+ fig = go.Figure(go.Indicator(
47
+ mode = "gauge+number",
48
+ value = rul,
49
+ title = {'text': "Remaining Useful Life (Cycles)"},
50
+ gauge = {
51
+ 'axis': {'range': [0, 200]},
52
+ 'bar': {'color': "black"},
53
+ 'steps' : [
54
+ {'range': [0, 30], 'color': "red"},
55
+ {'range': [30, 70], 'color': "yellow"},
56
+ {'range': [70, 200], 'color': "green"}],
57
+ }
58
+ ))
59
+ st.plotly_chart(fig)
60
+
61
+ # 2. Status Logic
62
+ if rul < 30:
63
+ st.error(f"CRITICAL: Engine failure likely within {rul} cycles. Ground the aircraft immediately!")
64
+ elif rul < 70:
65
+ st.warning(f"CAUTION: Maintenance due soon. Estimated life: {rul} cycles.")
66
+ else:
67
+ st.success(f"HEALTHY: Engine is operating within safe parameters ({rul} cycles remaining).")
68
+
69
+ st.markdown("---")
70
+ st.info("B.Tech AI&DS Special Project: Industrial Time-Series Forecasting")