File size: 1,626 Bytes
3aef2ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

import streamlit as st
import pandas as pd
import joblib
from huggingface_hub import hf_hub_download

MODEL_REPO_ID = "Amittripipathi/DecisionTree-engine-predictive-model"
MODEL_FILENAME = "DecisionTree_engine_model.pkl"

# Download model from HF Model Hub & load
model_path = hf_hub_download(repo_id=MODEL_REPO_ID, filename=MODEL_FILENAME)
model = joblib.load(model_path)

# Streamlit UI
st.title("🚗 Engine Failure Prediction")
st.write("Predict whether an engine is faulty or operating normally based on sensor readings.")

# Input form
engine_rpm = st.number_input("Engine RPM", min_value=0, max_value=3000, value=750)
lub_oil_pressure = st.number_input("Lubricating Oil Pressure (MPa)", min_value=0.0, max_value=10.0, value=3.0)
fuel_pressure = st.number_input("Fuel Pressure (MPa)", min_value=0.0, max_value=30.0, value=6.0)
coolant_pressure = st.number_input("Coolant Pressure (MPa)", min_value=0.0, max_value=10.0, value=2.0)
lub_oil_temp = st.number_input("Lubricating Oil Temperature (°C)", min_value=0.0, max_value=200.0, value=78.0)
coolant_temp = st.number_input("Coolant Temperature (°C)", min_value=0.0, max_value=200.0, value=78.0)

if st.button("Predict Engine Condition"):
    input_df = 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
    }])

    prediction = model.predict(input_df)[0]
    result = "⚠️ Faulty Engine" if prediction == 1 else "✅ Normal Engine"
    st.subheader(result)