import streamlit as st import pandas as pd import joblib from huggingface_hub import hf_hub_download # Hugging Face Model Repo MODEL_REPO = "Vignesh-vigu/PM-XGBoost-Model" MODEL_FILE = "best_xgb_model.joblib" # Download and Load Model @st.cache_resource def load_model(): model_path = hf_hub_download( repo_id=MODEL_REPO, filename=MODEL_FILE, repo_type="model" ) return joblib.load(model_path) model = load_model() # Page Config st.set_page_config(page_title="Engine Predictive Maintenance", page_icon="โš™๏ธ", layout="wide") st.title("๐Ÿš— Engine Predictive Maintenance System") st.write("Predict whether an engine requires maintenance using sensor data.") # Sidebar Inputs st.sidebar.header("๐Ÿ“ Engine Sensor Inputs") rpm = st.sidebar.number_input("Engine RPM", min_value=0, max_value=4000, value=750) oil_pressure = st.sidebar.number_input("Lub Oil Pressure (bar)", min_value=0.0, max_value=15.0, value=3.0) fuel_pressure = st.sidebar.number_input("Fuel Pressure (bar)", min_value=0.0, max_value=30.0, value=5.0) coolant_pressure = st.sidebar.number_input("Coolant Pressure (bar)", min_value=0.0, max_value=20.0, value=2.0) oil_temp = st.sidebar.number_input("Lub Oil Temperature (ยฐC)", min_value=0.0, max_value=200.0, value=75.0) cool_temp = st.sidebar.number_input("Coolant Temperature (ยฐC)", min_value=0.0, max_value=250.0, value=80.0) if st.sidebar.button("๐Ÿ” Predict Engine Condition"): input_df = pd.DataFrame([[ rpm, oil_pressure, fuel_pressure, coolant_pressure, oil_temp, cool_temp ]], columns=[ "Engine rpm", "Lub oil pressure", "Fuel pressure", "Coolant pressure", "lub oil temp", "Coolant temp" ]) prediction = model.predict(input_df)[0] status = ("โš ๏ธ Faulty Engine โ€” Maintenance Required!" if prediction == 1 else "โœ… Normal Engine โ€” No Action Required") st.subheader("๐Ÿงพ Prediction Result:") st.markdown(f"### {status}") st.write("### ๐Ÿ” Input Data") st.dataframe(input_df, use_container_width=True)