| import streamlit as st |
| import pandas as pd |
| from huggingface_hub import hf_hub_download |
| import joblib |
|
|
| |
| |
| model_path = hf_hub_download( |
| repo_id='Garg06/Predictive-Maintenance-Model', |
| filename='best_engine_model.joblib' |
| ) |
| model = joblib.load(model_path) |
|
|
| |
| st.title('Engine Predictive Maintenance App') |
| st.write(""" |
| This application predicts whether an engine is **Faulty** or **Normal** based on |
| real-time sensor readings. Enter the current sensor values below to get a prediction. |
| """) |
|
|
| |
| st.header('Engine Sensor Readings') |
|
|
| |
| engine_rpm = st.number_input( |
| 'Engine RPM', |
| min_value=0.0, max_value=2500.0, value=800.0, step=1.0, |
| help='Engine revolutions per minute. Typical idle: ~750 RPM.' |
| ) |
|
|
| |
| lub_oil_pressure = st.number_input( |
| 'Lub Oil Pressure (bar)', |
| min_value=0.0, max_value=10.0, value=3.3, step=0.01, |
| help='Lubrication oil pressure in bar. Healthy range: 2.5β4.5 bar.' |
| ) |
|
|
| |
| fuel_pressure = st.number_input( |
| 'Fuel Pressure (bar)', |
| min_value=0.0, max_value=25.0, value=6.7, step=0.01, |
| help='Fuel system pressure in bar. Healthy range: 4.9β7.7 bar.' |
| ) |
|
|
| |
| coolant_pressure = st.number_input( |
| 'Coolant Pressure (bar)', |
| min_value=0.0, max_value=10.0, value=2.3, step=0.01, |
| help='Engine coolant system pressure in bar. Healthy range: 1.6β2.8 bar.' |
| ) |
|
|
| |
| lub_oil_temp = st.number_input( |
| 'Lub Oil Temperature (Β°C)', |
| min_value=60.0, max_value=100.0, value=77.6, step=0.1, |
| help='Lubrication oil temperature in Β°C. Normal operating range: 75β80 Β°C.' |
| ) |
|
|
| |
| coolant_temp = st.number_input( |
| 'Coolant Temperature (Β°C)', |
| min_value=60.0, max_value=200.0, value=78.4, step=0.1, |
| help='Engine coolant temperature in Β°C. Normal range: 74β83 Β°C.' |
| ) |
|
|
| |
| |
| input_data = pd.DataFrame([{ |
| 'Engine rpm': engine_rpm, |
| 'Lub oil pressure': lub_oil_pressure, |
| 'Fuel pressure': fuel_pressure, |
| 'Coolant pressure': coolant_pressure, |
| 'lub oil temp': lub_oil_temp, |
| 'Coolant temp': coolant_temp, |
| }]) |
|
|
| |
| |
| |
| eps = 1e-6 |
| input_data['pressure_ratio_fuel_coolant'] = ( |
| input_data['Fuel pressure'] / (input_data['Coolant pressure'] + eps) |
| ) |
| input_data['temp_delta_oil_coolant'] = ( |
| input_data['lub oil temp'] - input_data['Coolant temp'] |
| ) |
| input_data['lub_pressure_per_rpm'] = ( |
| (input_data['Lub oil pressure'] / (input_data['Engine rpm'] + eps)) * 1000 |
| ) |
| input_data['coolant_pressure_per_rpm'] = ( |
| (input_data['Coolant pressure'] / (input_data['Engine rpm'] + eps)) * 1000 |
| ) |
| input_data['thermal_stress_index'] = ( |
| (input_data['lub oil temp'] + input_data['Coolant temp']) / 2 |
| ) |
| input_data['pressure_diff_fuel_lub'] = ( |
| input_data['Fuel pressure'] - input_data['Lub oil pressure'] |
| ) |
|
|
| |
| if st.button('Predict Engine Condition'): |
| prediction = model.predict(input_data)[0] |
| probability = model.predict_proba(input_data)[0] |
|
|
| if prediction == 1: |
| st.error( |
| f'β οΈ **Faulty Engine Detected!** ' |
| f'Confidence: {probability[1]:.1%} ' |
| f'\n\nImmediate inspection is recommended to prevent breakdown.' |
| ) |
| else: |
| st.success( |
| f'β
**Engine is Normal.** ' |
| f'Confidence: {probability[0]:.1%} ' |
| f'\n\nAll sensor readings are within acceptable limits.' |
| ) |
|
|
| st.subheader('Input Summary') |
| st.dataframe(input_data) |
|
|