Spaces:
Runtime error
Runtime error
Rename app.py to streamlit_app.py for Streamlit loading
Browse files- Dockerfile +4 -14
- requirements.txt +7 -3
- streamlit_app.py +57 -0
Dockerfile
CHANGED
|
@@ -1,20 +1,10 @@
|
|
| 1 |
-
FROM python:3.
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
|
| 6 |
-
build-essential \
|
| 7 |
-
curl \
|
| 8 |
-
git \
|
| 9 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
-
|
| 11 |
-
COPY requirements.txt ./
|
| 12 |
-
COPY src/ ./src/
|
| 13 |
-
|
| 14 |
RUN pip3 install -r requirements.txt
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
| 19 |
|
| 20 |
-
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
COPY requirements.txt .
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
RUN pip3 install -r requirements.txt
|
| 7 |
|
| 8 |
+
COPY . .
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
|
requirements.txt
CHANGED
|
@@ -1,3 +1,7 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pandas==2.2.2
|
| 2 |
+
numpy==2.0.2
|
| 3 |
+
scikit-learn==1.6.1
|
| 4 |
+
xgboost==2.1.4
|
| 5 |
+
joblib==1.4.2
|
| 6 |
+
streamlit==1.43.2
|
| 7 |
+
huggingface_hub==0.29.3
|
streamlit_app.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import joblib
|
| 4 |
+
from huggingface_hub import hf_hub_download
|
| 5 |
+
|
| 6 |
+
# Hugging Face Model Repo
|
| 7 |
+
MODEL_REPO = "Vignesh-vigu/PM-XGBoost-Model"
|
| 8 |
+
MODEL_FILE = "best_xgb_model.joblib"
|
| 9 |
+
|
| 10 |
+
# Download and Load Model
|
| 11 |
+
@st.cache_resource
|
| 12 |
+
def load_model():
|
| 13 |
+
model_path = hf_hub_download(
|
| 14 |
+
repo_id=MODEL_REPO,
|
| 15 |
+
filename=MODEL_FILE,
|
| 16 |
+
repo_type="model"
|
| 17 |
+
)
|
| 18 |
+
return joblib.load(model_path)
|
| 19 |
+
|
| 20 |
+
model = load_model()
|
| 21 |
+
|
| 22 |
+
# Page Config
|
| 23 |
+
st.set_page_config(page_title="Engine Predictive Maintenance",
|
| 24 |
+
page_icon="⚙️", layout="wide")
|
| 25 |
+
|
| 26 |
+
st.title("🚗 Engine Predictive Maintenance System")
|
| 27 |
+
st.write("Predict whether an engine requires maintenance using sensor data.")
|
| 28 |
+
|
| 29 |
+
# Sidebar Inputs
|
| 30 |
+
st.sidebar.header("📍 Engine Sensor Inputs")
|
| 31 |
+
|
| 32 |
+
rpm = st.sidebar.number_input("Engine RPM", min_value=0, max_value=4000, value=750)
|
| 33 |
+
oil_pressure = st.sidebar.number_input("Lub Oil Pressure (bar)", min_value=0.0, max_value=15.0, value=3.0)
|
| 34 |
+
fuel_pressure = st.sidebar.number_input("Fuel Pressure (bar)", min_value=0.0, max_value=30.0, value=5.0)
|
| 35 |
+
coolant_pressure = st.sidebar.number_input("Coolant Pressure (bar)", min_value=0.0, max_value=20.0, value=2.0)
|
| 36 |
+
oil_temp = st.sidebar.number_input("Lub Oil Temperature (°C)", min_value=0.0, max_value=200.0, value=75.0)
|
| 37 |
+
cool_temp = st.sidebar.number_input("Coolant Temperature (°C)", min_value=0.0, max_value=250.0, value=80.0)
|
| 38 |
+
|
| 39 |
+
if st.sidebar.button("🔍 Predict Engine Condition"):
|
| 40 |
+
input_df = pd.DataFrame([[
|
| 41 |
+
rpm, oil_pressure, fuel_pressure,
|
| 42 |
+
coolant_pressure, oil_temp, cool_temp
|
| 43 |
+
]], columns=[
|
| 44 |
+
"Engine rpm", "Lub oil pressure", "Fuel pressure",
|
| 45 |
+
"Coolant pressure", "lub oil temp", "Coolant temp"
|
| 46 |
+
])
|
| 47 |
+
|
| 48 |
+
prediction = model.predict(input_df)[0]
|
| 49 |
+
status = ("⚠️ Faulty Engine — Maintenance Required!"
|
| 50 |
+
if prediction == 1
|
| 51 |
+
else "✅ Normal Engine — No Action Required")
|
| 52 |
+
|
| 53 |
+
st.subheader("🧾 Prediction Result:")
|
| 54 |
+
st.markdown(f"### {status}")
|
| 55 |
+
|
| 56 |
+
st.write("### 🔍 Input Data")
|
| 57 |
+
st.dataframe(input_df, use_container_width=True)
|