File size: 1,877 Bytes
25c6c7f
 
 
 
 
 
62238cb
 
 
 
 
 
 
25c6c7f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd
import joblib
import os
from huggingface_hub import hf_hub_download

# -------------------------------
# UI
# -------------------------------
st.set_page_config(page_title="Engine Condition Monitoring", layout="centered")
st.title("🚗 Engine Condition Monitoring System")
st.write("Enter engine parameters below to predict condition.")

# -------------------------------
# Load Model
# -------------------------------
@st.cache_resource
def load_model():
    try:
        # Download model from Hugging Face
        model_path = hf_hub_download(
            repo_id="Satyanjay/engine-condition-monitoring-model",
            filename="best_model.joblib"
        )
    except:
        # fallback if running locally
        model_path = "best_model.joblib"

    model = joblib.load(model_path)
    return model


model = load_model()



# Input fields
engine_rpm = st.number_input("Engine RPM", min_value=0.0)
lub_oil_pressure = st.number_input("Lub Oil Pressure", min_value=0.0)
fuel_pressure = st.number_input("Fuel Pressure", min_value=0.0)
coolant_pressure = st.number_input("Coolant Pressure", min_value=0.0)
lub_oil_temp = st.number_input("Lub Oil Temperature", min_value=0.0)
coolant_temp = st.number_input("Coolant Temperature", min_value=0.0)

# -------------------------------
# Prediction
# -------------------------------
if st.button("Predict"):

    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
    }])

    prediction = model.predict(input_data)[0]

    if prediction == 1:
        st.error("⚠️ Engine Condition: FAULT DETECTED")
    else:
        st.success("✅ Engine Condition: NORMAL")