Spaces:
Runtime error
Runtime error
| 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 | |
| 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) | |