Upload folder using huggingface_hub
Browse files- Dockerfile +16 -12
- app.py +43 -0
- requirements.txt +7 -3
Dockerfile
CHANGED
|
@@ -1,20 +1,24 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
| 2 |
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 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 |
-
|
| 19 |
|
| 20 |
-
|
|
|
|
|
|
| 1 |
+
#Creating the dockerfile
|
| 2 |
+
# Use a minimal base image with Python 3.9 installed
|
| 3 |
+
FROM python:3.9
|
| 4 |
|
| 5 |
+
# Set the working directory inside the container to /app
|
| 6 |
WORKDIR /app
|
| 7 |
|
| 8 |
+
# Copy all files from the current directory on the host to the container's /app directory
|
| 9 |
+
COPY . .
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
# Install Python dependencies listed in requirements.txt
|
| 12 |
RUN pip3 install -r requirements.txt
|
| 13 |
|
| 14 |
+
RUN useradd -m -u 1000 user
|
| 15 |
+
USER user
|
| 16 |
+
ENV HOME=/home/user \
|
| 17 |
+
PATH=/home/user/.local/bin:$PATH
|
| 18 |
+
|
| 19 |
+
WORKDIR $HOME/app
|
| 20 |
|
| 21 |
+
COPY --chown=user . $HOME/app
|
| 22 |
|
| 23 |
+
# Define the command to run the Streamlit app on port "8501" and make it accessible externally
|
| 24 |
+
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
|
app.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
from huggingface_hub import hf_hub_download
|
| 4 |
+
import joblib
|
| 5 |
+
|
| 6 |
+
# Download the saved model from the Hugging Face model hub
|
| 7 |
+
model_path = hf_hub_download(repo_id="adityasharma0511/predictive-maintenance-model", filename="best_predict_model.joblib")
|
| 8 |
+
|
| 9 |
+
# Load the saved model from the Hugging Face model hub
|
| 10 |
+
model = joblib.load(model_path)
|
| 11 |
+
|
| 12 |
+
# Streamlit UI for Customer Churn Prediction
|
| 13 |
+
st.title("Engine Predictive Maintenance App")
|
| 14 |
+
st.write("Engine Predictive Maintenance App is a tool to predicts whether an engine will fail or not based on the engine health parameters.")
|
| 15 |
+
st.write("Kindly enter the enging parameters.")
|
| 16 |
+
|
| 17 |
+
# Get the inputs and save them into a dataframe
|
| 18 |
+
Engine_rpm = st.number_input("Engine rpms", min_value=0, max_value=5000, value=500)
|
| 19 |
+
Lub_oil_pressure = st.number_input("Lub oil pressure(in kPa)", min_value=1, max_value=5, value=3)
|
| 20 |
+
Fuel_pressure = st.number_input("Fuel pressure (in kPa)", min_value=0, max_value=100, value=50)
|
| 21 |
+
Coolant_pressure = st.number_input("Coolant pressure (in kPa)", min_value=0, max_value=50, value=1)
|
| 22 |
+
lub_oil_temp = st.number_input("Lub oil temprature (in °C)", min_value=0, max_value=50, value=1)
|
| 23 |
+
Coolant_temp = st.number_input("Coolant temprature (in °C)", min_value=1, max_value=5, value=3)
|
| 24 |
+
|
| 25 |
+
# Save the inputs into a Dataframe. Convert categorical inputs to match model training
|
| 26 |
+
input_data = pd.DataFrame([{
|
| 27 |
+
'Engine rpm': Engine_rpm,
|
| 28 |
+
'Lub oil pressure': Lub_oil_pressure,
|
| 29 |
+
'Fuel pressure': Fuel_pressure,
|
| 30 |
+
'Coolant pressure': Coolant_pressure,
|
| 31 |
+
'lub oil temp': lub_oil_temp,
|
| 32 |
+
'Coolant temp': Coolant_temp
|
| 33 |
+
}])
|
| 34 |
+
|
| 35 |
+
# Set the classification threshold
|
| 36 |
+
classification_threshold = 0.45
|
| 37 |
+
|
| 38 |
+
# Predict button
|
| 39 |
+
if st.button("Predict"):
|
| 40 |
+
prediction_proba = model.predict_proba(input_data)[0, 1]
|
| 41 |
+
prediction = (prediction_proba >= classification_threshold).astype(int)
|
| 42 |
+
result = "Fali" if prediction == 1 else "Not Fail"
|
| 43 |
+
st.write(f"Based on the information provided, the engine is likely to {result}.")
|
requirements.txt
CHANGED
|
@@ -1,3 +1,7 @@
|
|
| 1 |
-
|
| 2 |
-
pandas
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#Creating the dependency file
|
| 2 |
+
pandas==2.2.2
|
| 3 |
+
huggingface_hub==0.32.6
|
| 4 |
+
streamlit==1.43.2
|
| 5 |
+
joblib==1.5.1
|
| 6 |
+
scikit-learn==1.6.0
|
| 7 |
+
xgboost==2.1.4
|