Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| import pandas as pd | |
| from huggingface_hub import hf_hub_download | |
| import joblib | |
| # Download and load the trained model | |
| model_path = hf_hub_download(repo_id="KaushikBs/Predictive-Maintenance", filename="best_model_v1.joblib") | |
| model = joblib.load(model_path) | |
| # Streamlit UI | |
| st.title("App for predicting Engine Failures") | |
| st.write(""" | |
| This application predicts potential engine failures for vehicles | |
| based on its characteristics such as engine RPM, fuel pressure, lub oil temperature and pressure, coolant temperature and pressure. | |
| Please enter the sensor data below to get a failure prediction. | |
| """) | |
| # User input | |
| engine_rpm = st.number_input("Engine RPM", min_value=1.0, max_value=2500.0, value=800.0, step=1.0) | |
| lub_oil_pressure = st.number_input("Lub Oil Pressure (kPa)", min_value=0.0, max_value=8.0, value=3.3, step=0.01) | |
| fuel_pressure = st.number_input("Fuel Pressure (kPa)", min_value=0.0, max_value=22.0, value=6.6, step=0.01) | |
| coolant_pressure = st.number_input("Coolant Pressure (kPa)", min_value=0.0, max_value=8.0, value=2.3, step = 0.01) | |
| lub_oil_temp = st.number_input("Lub Oil Temperature (C)", min_value=70.0, max_value=90.0, value=77.6, step=0.01) | |
| coolant_temp = st.number_input("Coolant Temperature (C)", min_value=60.0, max_value=200.0, value=78.0, step=0.01) | |
| # Assemble input into DataFrame | |
| 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 | |
| }]) | |
| # Predict button | |
| if st.button("Predict Failure"): | |
| prediction = model.predict(input_data)[0] | |
| if prediction >= 0.45: | |
| decision = "Failure predicted" | |
| else: | |
| decision = "No failure predicted" | |
| st.subheader("Prediction Result:") | |
| st.success(decision) | |