Delete app.py
Browse files
app.py
DELETED
|
@@ -1,118 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import pandas as pd
|
| 3 |
-
import joblib
|
| 4 |
-
from huggingface_hub import hf_hub_download
|
| 5 |
-
|
| 6 |
-
# ----------------------------------------
|
| 7 |
-
# Page Configuration
|
| 8 |
-
# ----------------------------------------
|
| 9 |
-
|
| 10 |
-
st.set_page_config(
|
| 11 |
-
page_title="Predictive Maintenance",
|
| 12 |
-
page_icon="🚗",
|
| 13 |
-
layout="centered"
|
| 14 |
-
)
|
| 15 |
-
|
| 16 |
-
st.title("🚗 Predictive Maintenance System")
|
| 17 |
-
st.write(
|
| 18 |
-
"""
|
| 19 |
-
This application predicts whether an engine requires maintenance
|
| 20 |
-
based on its sensor readings using the trained AdaBoost model.
|
| 21 |
-
"""
|
| 22 |
-
)
|
| 23 |
-
|
| 24 |
-
# ----------------------------------------
|
| 25 |
-
# Load Model from Hugging Face
|
| 26 |
-
# ----------------------------------------
|
| 27 |
-
|
| 28 |
-
MODEL_REPO = "killswitch009/predictive-maintenance-model"
|
| 29 |
-
MODEL_FILE = "best_model.pkl"
|
| 30 |
-
|
| 31 |
-
@st.cache_resource
|
| 32 |
-
def load_model():
|
| 33 |
-
model_path = hf_hub_download(
|
| 34 |
-
repo_id=MODEL_REPO,
|
| 35 |
-
filename=MODEL_FILE
|
| 36 |
-
)
|
| 37 |
-
return joblib.load(model_path)
|
| 38 |
-
|
| 39 |
-
#model = load_model()
|
| 40 |
-
|
| 41 |
-
try:
|
| 42 |
-
model = load_model()
|
| 43 |
-
st.success("✅ Model loaded successfully!")
|
| 44 |
-
except Exception as e:
|
| 45 |
-
st.error(f"Error loading model: {e}")
|
| 46 |
-
st.stop()
|
| 47 |
-
|
| 48 |
-
# ----------------------------------------
|
| 49 |
-
# User Inputs
|
| 50 |
-
# ----------------------------------------
|
| 51 |
-
|
| 52 |
-
st.header("Enter Engine Sensor Values")
|
| 53 |
-
|
| 54 |
-
engine_rpm = st.number_input(
|
| 55 |
-
"Engine RPM",
|
| 56 |
-
min_value=0,
|
| 57 |
-
value=800
|
| 58 |
-
)
|
| 59 |
-
|
| 60 |
-
lub_pressure = st.number_input(
|
| 61 |
-
"Lub Oil Pressure",
|
| 62 |
-
min_value=0.0,
|
| 63 |
-
value=3.2
|
| 64 |
-
)
|
| 65 |
-
|
| 66 |
-
fuel_pressure = st.number_input(
|
| 67 |
-
"Fuel Pressure",
|
| 68 |
-
min_value=0.0,
|
| 69 |
-
value=6.5
|
| 70 |
-
)
|
| 71 |
-
|
| 72 |
-
coolant_pressure = st.number_input(
|
| 73 |
-
"Coolant Pressure",
|
| 74 |
-
min_value=0.0,
|
| 75 |
-
value=2.3
|
| 76 |
-
)
|
| 77 |
-
|
| 78 |
-
lub_temp = st.number_input(
|
| 79 |
-
"Lub Oil Temperature",
|
| 80 |
-
min_value=0.0,
|
| 81 |
-
value=77.0
|
| 82 |
-
)
|
| 83 |
-
|
| 84 |
-
coolant_temp = st.number_input(
|
| 85 |
-
"Coolant Temperature",
|
| 86 |
-
min_value=0.0,
|
| 87 |
-
value=78.0
|
| 88 |
-
)
|
| 89 |
-
|
| 90 |
-
# ----------------------------------------
|
| 91 |
-
# Prediction
|
| 92 |
-
# ----------------------------------------
|
| 93 |
-
|
| 94 |
-
if st.button("Predict Engine Condition"):
|
| 95 |
-
|
| 96 |
-
input_data = pd.DataFrame({
|
| 97 |
-
"Engine rpm":[engine_rpm],
|
| 98 |
-
"Lub oil pressure":[lub_pressure],
|
| 99 |
-
"Fuel pressure":[fuel_pressure],
|
| 100 |
-
"Coolant pressure":[coolant_pressure],
|
| 101 |
-
"lub oil temp":[lub_temp],
|
| 102 |
-
"Coolant temp":[coolant_temp]
|
| 103 |
-
})
|
| 104 |
-
|
| 105 |
-
prediction = model.predict(input_data)[0]
|
| 106 |
-
probability = model.predict_proba(input_data)[0]
|
| 107 |
-
|
| 108 |
-
st.subheader("Prediction Result")
|
| 109 |
-
|
| 110 |
-
if prediction == 1:
|
| 111 |
-
st.error("⚠️ Engine Requires Maintenance")
|
| 112 |
-
else:
|
| 113 |
-
st.success("✅ Engine Operating Normally")
|
| 114 |
-
|
| 115 |
-
st.write("### Prediction Confidence")
|
| 116 |
-
|
| 117 |
-
st.write(f"Normal : {probability[0]*100:.2f}%")
|
| 118 |
-
st.write(f"Maintenance Required : {probability[1]*100:.2f}%")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|