| import streamlit as st |
| import pandas as pd |
| import joblib |
| from huggingface_hub import hf_hub_download |
| import os |
|
|
| |
| st.set_page_config( |
| page_title="Predictive Maintenance App-Final", |
| page_icon="⚙️", |
| layout="centered" |
| ) |
|
|
| st.title("⚙️ Engine Predictive Maintenance-Final") |
| st.write("Enter the engine sensor readings to predict if maintenance is required.") |
|
|
| |
| @st.cache_resource |
| def load_model(): |
| repo_id = "Sirisha335/Predictive_Maintaince_final" |
| model_filename = "models/best_random_forest_model.joblib" |
|
|
| |
| |
| |
| |
|
|
| try: |
| model_path = hf_hub_download(repo_id=repo_id, filename=model_filename, repo_type="dataset") |
| model = joblib.load(model_path) |
| return model |
| except Exception as e: |
| st.error(f"Error loading model: {e}") |
| st.stop() |
|
|
| model = load_model() |
|
|
| |
| st.header("Engine Sensor Readings") |
|
|
| engine_rpm = st.slider("Engine RPM", min_value=0, max_value=2500, value=750, step=10) |
| lub_oil_pressure = st.slider("Lub Oil Pressure (bar)", min_value=0.0, max_value=8.0, value=3.0, step=0.1) |
| fuel_pressure = st.slider("Fuel Pressure (bar)", min_value=0.0, max_value=25.0, value=6.0, step=0.1) |
| coolant_pressure = st.slider("Coolant Pressure (bar)", min_value=0.0, max_value=8.0, value=2.0, step=0.1) |
| coolant_temp = st.slider("Coolant Temperature (°C)", min_value=60.0, max_value=130.0, value=80.0, step=0.1) |
|
|
| |
| input_data = pd.DataFrame([[ |
| engine_rpm, lub_oil_pressure, fuel_pressure, coolant_pressure, coolant_temp |
| ]], columns=[ |
| 'Engine rpm', 'Lub oil pressure', 'Fuel pressure', 'Coolant pressure', 'Coolant temp' |
| ]) |
|
|
| |
| if st.button("Predict Engine Condition"): |
| prediction = model.predict(input_data)[0] |
| prediction_proba = model.predict_proba(input_data)[0] |
|
|
| st.subheader("Prediction Result") |
| if prediction == 1: |
| st.error(f"⚠️ **Maintenance Required!** (Faulty Engine Predicted)") |
| st.write(f"Confidence (Faulty): **{prediction_proba[1]*100:.2f}%**") |
| st.write(f"Confidence (Normal): {prediction_proba[0]*100:.2f}%") |
| st.warning("Immediate inspection and maintenance are recommended.") |
| else: |
| st.success(f"✅ **Engine Condition: Normal**") |
| st.write(f"Confidence (Normal): **{prediction_proba[0]*100:.2f}%**") |
| st.write(f"Confidence (Faulty): {prediction_proba[1]*100:.2f}%") |
| st.info("Continue regular monitoring.") |
|
|
| st.markdown("---") |
| st.caption("This application predicts engine condition based on sensor readings using a pre-trained Random Forest Classifier.") |
|
|