Upload app.py with huggingface_hub
Browse files
app.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import joblib
|
| 4 |
+
|
| 5 |
+
st.set_page_config(page_title="Engine Condition Predictor")
|
| 6 |
+
|
| 7 |
+
st.title("🚗 Engine Predictive Maintenance")
|
| 8 |
+
|
| 9 |
+
# Load model
|
| 10 |
+
@st.cache_resource
|
| 11 |
+
def load_model():
|
| 12 |
+
return joblib.load("best_model.pkl")
|
| 13 |
+
|
| 14 |
+
model = load_model()
|
| 15 |
+
|
| 16 |
+
st.header("Enter Engine Sensor Values")
|
| 17 |
+
|
| 18 |
+
engine_rpm = st.number_input("Engine RPM", value=1500.0)
|
| 19 |
+
lub_oil_pressure = st.number_input("Lub Oil Pressure", value=3.0)
|
| 20 |
+
fuel_pressure = st.number_input("Fuel Pressure", value=2.5)
|
| 21 |
+
coolant_pressure = st.number_input("Coolant Pressure", value=1.5)
|
| 22 |
+
lub_oil_temp = st.number_input("Lub Oil Temperature", value=85.0)
|
| 23 |
+
coolant_temp = st.number_input("Coolant Temperature", value=75.0)
|
| 24 |
+
|
| 25 |
+
if st.button("Predict Engine Condition"):
|
| 26 |
+
|
| 27 |
+
input_df = pd.DataFrame([[
|
| 28 |
+
engine_rpm,
|
| 29 |
+
lub_oil_pressure,
|
| 30 |
+
fuel_pressure,
|
| 31 |
+
coolant_pressure,
|
| 32 |
+
lub_oil_temp,
|
| 33 |
+
coolant_temp
|
| 34 |
+
]], columns=[
|
| 35 |
+
"Engine_RPM",
|
| 36 |
+
"Lub_Oil_Pressure",
|
| 37 |
+
"Fuel_Pressure",
|
| 38 |
+
"Coolant_Pressure",
|
| 39 |
+
"Lub_Oil_Temperature",
|
| 40 |
+
"Coolant_Temperature"
|
| 41 |
+
])
|
| 42 |
+
|
| 43 |
+
prediction = model.predict(input_df)[0]
|
| 44 |
+
|
| 45 |
+
if prediction == 1:
|
| 46 |
+
st.error("⚠ Engine Fault Detected")
|
| 47 |
+
else:
|
| 48 |
+
st.success("✅ Engine Operating Normally")
|