Upload folder using huggingface_hub
Browse files- Dockerfile +15 -12
- app.py +40 -0
- requirements.txt +6 -3
Dockerfile
CHANGED
|
@@ -1,20 +1,23 @@
|
|
| 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 |
+
# Use a minimal base image with Python 3.9 installed
|
| 2 |
+
FROM python:3.9
|
| 3 |
|
| 4 |
+
# Set the working directory inside the container to /app
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Copy all files from the current directory on the host to the container's /app directory
|
| 8 |
+
COPY . .
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
# Install Python dependencies listed in requirements.txt
|
| 11 |
RUN pip3 install -r requirements.txt
|
| 12 |
|
| 13 |
+
RUN useradd -m -u 1000 user
|
| 14 |
+
USER user
|
| 15 |
+
ENV HOME=/home/user \
|
| 16 |
+
PATH=/home/user/.local/bin:$PATH
|
| 17 |
+
|
| 18 |
+
WORKDIR $HOME/app
|
| 19 |
|
| 20 |
+
COPY --chown=user . $HOME/app
|
| 21 |
|
| 22 |
+
# Define the command to run the Streamlit app on port "8501" and make it accessible externally
|
| 23 |
+
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
|
app.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 model from the Model Hub
|
| 7 |
+
model_path = hf_hub_download(repo_id="nv185001/pred-model", filename="best_engine_failure_predictor_model.joblib")
|
| 8 |
+
# Load the model
|
| 9 |
+
model = joblib.load(model_path)
|
| 10 |
+
|
| 11 |
+
# Streamlit UI for Engine Failure Prediction
|
| 12 |
+
st.title("Engine Failure Prediction App")
|
| 13 |
+
st.write("The Engine Failure Prediction App is an internal tool to predict whether engine would fail due to current vital parameters.")
|
| 14 |
+
st.write("Kindly enter different parameters of engine to check whether they are likely to fail or not")
|
| 15 |
+
|
| 16 |
+
Engine_rpm = st.number_input("Engine RPM", min_value=0 )
|
| 17 |
+
Lub_oil_pressure = st.number_input("Lub Oil Pressure", min_value=0)
|
| 18 |
+
Fuel_pressure = st.number_input("Fuel Pressure", min_value=0)
|
| 19 |
+
Coolant_pressure = st.number_input("Coolant Pressure", min_value=0)
|
| 20 |
+
lub_oil_temp = st.number_input("Lub Oil Temperature", min_value=0)
|
| 21 |
+
Coolant_temp = st.number_input("Coolant Temperature", min_value=0)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
input_data = pd.DataFrame([{
|
| 25 |
+
'Engine_rpm': Engine_rpm,
|
| 26 |
+
'Lub_oil_pressure': Lub_oil_pressure,
|
| 27 |
+
'Fuel_pressure': Fuel_pressure,
|
| 28 |
+
'Coolant_pressure': Coolant_pressure,
|
| 29 |
+
'lub_oil_temp': lub_oil_temp,
|
| 30 |
+
'Coolant_temp': Coolant_temp
|
| 31 |
+
}])
|
| 32 |
+
|
| 33 |
+
# Set the classification threshold
|
| 34 |
+
classification_threshold = 0.45
|
| 35 |
+
|
| 36 |
+
# Predict button
|
| 37 |
+
if st.button("Predict"):
|
| 38 |
+
prediction_proba = model.predict_proba(input_data)[0, 1]
|
| 39 |
+
result = "to shutdown soon, due to inconsistent paramters" if prediction_proba == 1 else "to work fine"
|
| 40 |
+
st.write(f"Based on the information provided, the machine is likely {result}.")
|
requirements.txt
CHANGED
|
@@ -1,3 +1,6 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
streamlit
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pandas==2.2.2
|
| 2 |
+
huggingface_hub==0.32.6
|
| 3 |
+
streamlit==1.43.2
|
| 4 |
+
joblib==1.5.1
|
| 5 |
+
scikit-learn==1.6.0
|
| 6 |
+
xgboost==2.1.4
|