Spaces:
Runtime error
Runtime error
Upload app.py with huggingface_hub
Browse files
app.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import pandas as pd
|
| 4 |
+
import joblib
|
| 5 |
+
from huggingface_hub import hf_hub_download
|
| 6 |
+
|
| 7 |
+
MODEL_REPO_ID = "Amittripipathi/DecisionTree-engine-predictive-model"
|
| 8 |
+
MODEL_FILENAME = "DecisionTree_engine_model.pkl"
|
| 9 |
+
|
| 10 |
+
# Download model from HF Model Hub & load
|
| 11 |
+
model_path = hf_hub_download(repo_id=MODEL_REPO_ID, filename=MODEL_FILENAME)
|
| 12 |
+
model = joblib.load(model_path)
|
| 13 |
+
|
| 14 |
+
# Streamlit UI
|
| 15 |
+
st.title("🚗 Engine Failure Prediction")
|
| 16 |
+
st.write("Predict whether an engine is faulty or operating normally based on sensor readings.")
|
| 17 |
+
|
| 18 |
+
# Input form
|
| 19 |
+
engine_rpm = st.number_input("Engine RPM", min_value=0, max_value=3000, value=750)
|
| 20 |
+
lub_oil_pressure = st.number_input("Lubricating Oil Pressure (MPa)", min_value=0.0, max_value=10.0, value=3.0)
|
| 21 |
+
fuel_pressure = st.number_input("Fuel Pressure (MPa)", min_value=0.0, max_value=30.0, value=6.0)
|
| 22 |
+
coolant_pressure = st.number_input("Coolant Pressure (MPa)", min_value=0.0, max_value=10.0, value=2.0)
|
| 23 |
+
lub_oil_temp = st.number_input("Lubricating Oil Temperature (°C)", min_value=0.0, max_value=200.0, value=78.0)
|
| 24 |
+
coolant_temp = st.number_input("Coolant Temperature (°C)", min_value=0.0, max_value=200.0, value=78.0)
|
| 25 |
+
|
| 26 |
+
if st.button("Predict Engine Condition"):
|
| 27 |
+
input_df = pd.DataFrame([{
|
| 28 |
+
"Engine rpm": engine_rpm,
|
| 29 |
+
"Lub oil pressure": lub_oil_pressure,
|
| 30 |
+
"Fuel pressure": fuel_pressure,
|
| 31 |
+
"Coolant pressure": coolant_pressure,
|
| 32 |
+
"lub oil temp": lub_oil_temp,
|
| 33 |
+
"Coolant temp": coolant_temp
|
| 34 |
+
}])
|
| 35 |
+
|
| 36 |
+
prediction = model.predict(input_df)[0]
|
| 37 |
+
result = "⚠️ Faulty Engine" if prediction == 1 else "✅ Normal Engine"
|
| 38 |
+
st.subheader(result)
|