Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- Dockerfile +20 -12
- app.py +91 -0
- requirements.txt +7 -2
Dockerfile
CHANGED
|
@@ -1,20 +1,28 @@
|
|
| 1 |
-
FROM python:3.13.5-slim
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
|
| 14 |
-
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
-
|
|
|
|
| 19 |
|
| 20 |
-
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
|
|
|
|
|
|
| 1 |
|
| 2 |
+
# Use Python base image
|
| 3 |
+
FROM python:3.9
|
| 4 |
+
|
| 5 |
+
# Set working directory
|
| 6 |
WORKDIR /app
|
| 7 |
|
| 8 |
+
# Copy project files
|
| 9 |
+
COPY . .
|
| 10 |
+
|
| 11 |
+
# Install dependencies
|
| 12 |
+
RUN pip install -r requirements.txt
|
| 13 |
+
|
| 14 |
+
# Create non-root user
|
| 15 |
+
RUN useradd -m -u 1000 user
|
| 16 |
+
|
| 17 |
+
USER user
|
| 18 |
|
| 19 |
+
ENV HOME=/home/user \
|
| 20 |
+
PATH=/home/user/.local/bin:$PATH
|
| 21 |
|
| 22 |
+
WORKDIR $HOME/app
|
| 23 |
|
| 24 |
+
COPY --chown=user . $HOME/app
|
| 25 |
|
| 26 |
+
# Run Streamlit application
|
| 27 |
+
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
|
| 28 |
|
|
|
app.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import pandas as pd
|
| 4 |
+
import joblib
|
| 5 |
+
|
| 6 |
+
from huggingface_hub import hf_hub_download
|
| 7 |
+
|
| 8 |
+
# =========================================
|
| 9 |
+
# Load Model from Hugging Face Hub
|
| 10 |
+
# =========================================
|
| 11 |
+
|
| 12 |
+
model_path = hf_hub_download(
|
| 13 |
+
repo_id="geniusut/engine-predictive-maintenance-model",
|
| 14 |
+
filename="best_model.pkl"
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
model = joblib.load(model_path)
|
| 18 |
+
|
| 19 |
+
# =========================================
|
| 20 |
+
# Streamlit UI
|
| 21 |
+
# =========================================
|
| 22 |
+
|
| 23 |
+
st.title("Engine Predictive Maintenance")
|
| 24 |
+
|
| 25 |
+
st.write(
|
| 26 |
+
"Enter engine operational parameters "
|
| 27 |
+
"to predict maintenance requirements."
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
# =========================================
|
| 31 |
+
# User Inputs
|
| 32 |
+
# =========================================
|
| 33 |
+
|
| 34 |
+
engine_rpm = st.number_input(
|
| 35 |
+
"Engine RPM",
|
| 36 |
+
value=800.0
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
lub_oil_pressure = st.number_input(
|
| 40 |
+
"Lub Oil Pressure",
|
| 41 |
+
value=3.5
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
fuel_pressure = st.number_input(
|
| 45 |
+
"Fuel Pressure",
|
| 46 |
+
value=6.5
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
coolant_pressure = st.number_input(
|
| 50 |
+
"Coolant Pressure",
|
| 51 |
+
value=2.5
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
lub_oil_temp = st.number_input(
|
| 55 |
+
"Lub Oil Temperature",
|
| 56 |
+
value=75.0
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
coolant_temp = st.number_input(
|
| 60 |
+
"Coolant Temperature",
|
| 61 |
+
value=80.0
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
# =========================================
|
| 65 |
+
# Prepare Input Data
|
| 66 |
+
# =========================================
|
| 67 |
+
|
| 68 |
+
input_data = pd.DataFrame([{
|
| 69 |
+
"Engine_RPM": engine_rpm,
|
| 70 |
+
"Lub_Oil_Pressure": lub_oil_pressure,
|
| 71 |
+
"Fuel_Pressure": fuel_pressure,
|
| 72 |
+
"Coolant_Pressure": coolant_pressure,
|
| 73 |
+
"Lub_Oil_Temperature": lub_oil_temp,
|
| 74 |
+
"Coolant_Temperature": coolant_temp
|
| 75 |
+
}])
|
| 76 |
+
|
| 77 |
+
# =========================================
|
| 78 |
+
# Predict
|
| 79 |
+
# =========================================
|
| 80 |
+
|
| 81 |
+
if st.button("Predict"):
|
| 82 |
+
|
| 83 |
+
prediction = model.predict(input_data)[0]
|
| 84 |
+
|
| 85 |
+
result = (
|
| 86 |
+
"Maintenance Required"
|
| 87 |
+
if prediction == 1
|
| 88 |
+
else "Engine Operating Normally"
|
| 89 |
+
)
|
| 90 |
+
|
| 91 |
+
st.success(f"Prediction Result: {result}")
|
requirements.txt
CHANGED
|
@@ -1,3 +1,8 @@
|
|
| 1 |
-
|
| 2 |
pandas
|
| 3 |
-
streamlit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
pandas
|
| 3 |
+
streamlit
|
| 4 |
+
huggingface_hub
|
| 5 |
+
joblib
|
| 6 |
+
scikit-learn
|
| 7 |
+
xgboost
|
| 8 |
+
mlflow
|