Spaces:
Runtime error
Runtime error
File size: 1,880 Bytes
e011941 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
import streamlit as st
import pandas as pd
import joblib
from huggingface_hub import hf_hub_download
# =========================================
# Load Model from Hugging Face Hub
# =========================================
model_path = hf_hub_download(
repo_id="geniusut/engine-predictive-maintenance-model",
filename="best_model.pkl"
)
model = joblib.load(model_path)
# =========================================
# Streamlit UI
# =========================================
st.title("Engine Predictive Maintenance")
st.write(
"Enter engine operational parameters "
"to predict maintenance requirements."
)
# =========================================
# User Inputs
# =========================================
engine_rpm = st.number_input(
"Engine RPM",
value=800.0
)
lub_oil_pressure = st.number_input(
"Lub Oil Pressure",
value=3.5
)
fuel_pressure = st.number_input(
"Fuel Pressure",
value=6.5
)
coolant_pressure = st.number_input(
"Coolant Pressure",
value=2.5
)
lub_oil_temp = st.number_input(
"Lub Oil Temperature",
value=75.0
)
coolant_temp = st.number_input(
"Coolant Temperature",
value=80.0
)
# =========================================
# Prepare Input Data
# =========================================
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
# =========================================
if st.button("Predict"):
prediction = model.predict(input_data)[0]
result = (
"Maintenance Required"
if prediction == 1
else "Engine Operating Normally"
)
st.success(f"Prediction Result: {result}")
|