Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import pandas as pd
|
| 4 |
+
import numpy as np
|
| 5 |
+
import joblib
|
| 6 |
+
from huggingface_hub import hf_hub_download
|
| 7 |
+
|
| 8 |
+
st.set_page_config(page_title="Predictive Maintenance", layout="wide")
|
| 9 |
+
|
| 10 |
+
@st.cache_resource
|
| 11 |
+
def load_model():
|
| 12 |
+
repo = "SharleyK/predictive-maintenance-model"
|
| 13 |
+
model = joblib.load(hf_hub_download(repo, "best_model.pkl"))
|
| 14 |
+
scaler = joblib.load(hf_hub_download(repo, "scaler.pkl"))
|
| 15 |
+
return model, scaler
|
| 16 |
+
|
| 17 |
+
model, scaler = load_model()
|
| 18 |
+
|
| 19 |
+
st.title("Predictive Maintenance - Engine Failure Prediction")
|
| 20 |
+
|
| 21 |
+
engine_rpm = st.slider("Engine RPM", 100, 2500, 800)
|
| 22 |
+
lub_oil_pressure = st.slider("Lub Oil Pressure", 0.0, 8.0, 3.0)
|
| 23 |
+
fuel_pressure = st.slider("Fuel Pressure", 0.0, 22.0, 6.0)
|
| 24 |
+
coolant_pressure = st.slider("Coolant Pressure", 0.0, 8.0, 2.5)
|
| 25 |
+
lub_oil_temp = st.slider("Lub Oil Temp", 70.0, 95.0, 80.0)
|
| 26 |
+
coolant_temp = st.slider("Coolant Temp", 60.0, 200.0, 85.0)
|
| 27 |
+
|
| 28 |
+
if st.button("Predict"):
|
| 29 |
+
X = pd.DataFrame([{
|
| 30 |
+
"engine_rpm": engine_rpm,
|
| 31 |
+
"lub_oil_pressure": lub_oil_pressure,
|
| 32 |
+
"fuel_pressure": fuel_pressure,
|
| 33 |
+
"coolant_pressure": coolant_pressure,
|
| 34 |
+
"lub_oil_temp": lub_oil_temp,
|
| 35 |
+
"coolant_temp": coolant_temp
|
| 36 |
+
}])
|
| 37 |
+
|
| 38 |
+
X_scaled = scaler.transform(X)
|
| 39 |
+
prediction = model.predict(X_scaled)[0]
|
| 40 |
+
|
| 41 |
+
if prediction == 1:
|
| 42 |
+
st.error("Engine Failure Detected")
|
| 43 |
+
else:
|
| 44 |
+
st.success("Engine Operating Normally")
|