Spaces:
Runtime error

File size: 2,324 Bytes
0b38b8f
11630b6
 
0b38b8f
667a55e
 
 
 
 
11630b6
0b38b8f
 
667a55e
 
11630b6
 
667a55e
 
 
 
 
 
 
 
0b38b8f
 
667a55e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0b38b8f
 
667a55e
 
 
 
0b38b8f
 
667a55e
 
0b38b8f
 
 
 
667a55e
 
0b38b8f
 
 
 
667a55e
 
0b38b8f
 
 
 
667a55e
 
0b38b8f
 
 
 
667a55e
 
0b38b8f
 
 
 
667a55e
 
0b38b8f
 
667a55e
 
 
0b38b8f
667a55e
0b38b8f
667a55e
0b38b8f
 
 
 
 
 
 
 
667a55e
0b38b8f
667a55e
0b38b8f
667a55e
 
0b38b8f
667a55e
 
 
 
 
0b38b8f
667a55e
 
 
f8c6ac3
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
import streamlit as st
import sys
import os

# Add project root to path
ROOT = os.path.abspath(
    os.path.join(
        os.path.dirname(__file__),
        ".."
    )
)

sys.path.insert(0, ROOT)

from src.predict import predict_engine_condition

# =========================
# Page Configuration
# =========================

st.set_page_config(
    page_title="Predictive Maintenance System",
    page_icon="βš™οΈ",
    layout="centered"
)

# =========================
# Sidebar
# =========================

st.sidebar.title("βš™οΈ About")

st.sidebar.info(
    """
    Predictive Maintenance System

    This application predicts whether an engine is:

    βœ… Healthy

    ❌ Faulty

    using operational engine parameters.
    """
)

# =========================
# Main Title
# =========================

st.title("βš™οΈ Predictive Maintenance System")

st.markdown(
    "Enter the engine parameters below and click **Predict Engine Condition**."
)

# =========================
# Input Fields
# =========================

rpm = st.number_input(
    "Engine RPM",
    min_value=0.0,
    value=1500.0
)

lub_pressure = st.number_input(
    "Lub Oil Pressure",
    min_value=0.0,
    value=3.5
)

fuel_pressure = st.number_input(
    "Fuel Pressure",
    min_value=0.0,
    value=4.0
)

coolant_pressure = st.number_input(
    "Coolant Pressure",
    min_value=0.0,
    value=2.5
)

lub_temp = st.number_input(
    "Lub Oil Temperature",
    min_value=0.0,
    value=80.0
)

coolant_temp = st.number_input(
    "Coolant Temperature",
    min_value=0.0,
    value=90.0
)

# =========================
# Prediction Button
# =========================

if st.button("πŸ” Predict Engine Condition"):

    sample = {
        "Engine_RPM": rpm,
        "Lub_Oil_Pressure": lub_pressure,
        "Fuel_Pressure": fuel_pressure,
        "Coolant_Pressure": coolant_pressure,
        "Lub_Oil_Temperature": lub_temp,
        "Coolant_Temperature": coolant_temp
    }

    result = predict_engine_condition(sample)

    st.divider()

    if result == 0:
        st.success("βœ… Prediction: Healthy Engine")
    else:
        st.error("❌ Prediction: Faulty Engine")

# =========================
# Footer
# =========================

st.markdown("---")
st.caption(
    "Built with Python, Scikit-Learn, Streamlit & Hugging Face"
)