Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| import pandas as pd | |
| import joblib | |
| from huggingface_hub import hf_hub_download | |
| # download model from HuggingFace (force download if needed) | |
| model_path = hf_hub_download( | |
| repo_id="krishna233/engine-maintenance-model", | |
| filename="engine_failure_model.pkl" | |
| ) | |
| # load model | |
| model = joblib.load(model_path) | |
| # page title | |
| st.title("Engine Predictive Maintenance") | |
| # input fields | |
| rpm = st.number_input("Engine RPM") | |
| oil_pressure = st.number_input("Lub Oil Pressure") | |
| fuel_pressure = st.number_input("Fuel Pressure") | |
| coolant_pressure = st.number_input("Coolant Pressure") | |
| oil_temp = st.number_input("Lub Oil Temp") | |
| coolant_temp = st.number_input("Coolant Temp") | |
| # predict button | |
| if st.button("Predict"): | |
| input_df = pd.DataFrame({ | |
| "Engine_rpm":[rpm], | |
| "Lub_oil_pressure":[oil_pressure], | |
| "Fuel_pressure":[fuel_pressure], | |
| "Coolant_pressure":[coolant_pressure], | |
| "lub_oil_temp":[oil_temp], | |
| "Coolant_temp":[coolant_temp] | |
| }) | |
| prediction = model.predict(input_df)[0] | |
| if prediction == 1: | |
| st.error("Engine needs maintenance") | |
| else: | |
| st.success("Engine working normally") |