File size: 1,660 Bytes
7972db5
 
3d5887f
7972db5
f1b164e
7972db5
 
 
 
 
 
6fa710d
b761ec3
7972db5
 
 
 
 
 
 
 
 
 
 
 
ad1994b
 
 
 
 
 
7972db5
 
 
 
 
 
 
ad1994b
7972db5
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd
from huggingface_hub import hf_hub_download, HfApi
import joblib
import os

# Initialize HF API with token from environment
api = HfApi(token=os.getenv("HF_TOKEN"))

# Download and load the model from Hugging Face
model_path = hf_hub_download(
    repo_id="adi333/engine-failure-prediction-model",
    repo_type="model",
    filename="best_engine_failure_prediction_model_v1.joblib"
)
model = joblib.load(model_path)

# Streamlit UI
st.title("Engine Failure Prediction")
st.write("""
This application predicts whether the automobile's engine condition is good or it needs maintenance. 
Please enter the engine sensor readings  below to get a prediction.
""")

# --- User inputs ---
engineRPM = st.number_input("Engine rpm", value=30.0)
lubOilPressure = st.number_input("Lub oil pressure", value=30.0)
fuelPressure = st.number_input("Fuel pressure", value=30.0)
coolantPressure = st.number_input("Coolant pressure",value=30.0)
lubOilTemp = st.number_input("lub oil temp(in °C)",value=30.0)
coolantTemp = st.number_input("Coolant temp (in °C)",value=30.0)

# --- Assemble input ---
input_data = pd.DataFrame([{
    'Engine rpm' : engineRPM,
    'Lub oil pressure': lubOilPressure,
    'Fuel pressure': fuelPressure,
    'Coolant pressure': coolantPressure,
    'lub oil temp': lubOilTemp,
    'Coolant temp': coolantTemp
}])

# --- Prediction ---
if st.button("Predict Engine Condition"):
    prediction = model.predict(input_data)[0]
    result = "Engine condition is good" if prediction==0 else "Engine condition is faulty"
    st.subheader("Prediction Result:")
    st.success(f"The model predicts: **{result}**")