Anusha3 commited on
Commit
0078684
·
verified ·
1 Parent(s): 416cefa

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +23 -0
  2. app.py +68 -0
  3. requirements.txt +7 -0
Dockerfile ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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="Anusha3/ab_predictive_maintenance", filename="Gradient_Boosting.joblib")
8
+
9
+ # Load the model
10
+ model = joblib.load(model_path)
11
+
12
+ # Streamlit UI for Predictive Maintence Prediction
13
+ st.set_page_config(page_title="Predictive Maintenance - Engine Failure")
14
+ st.title("Aircraft Engine Predictive Maintenance")
15
+
16
+ st.write("Enter sensor readings below to predict engine failure probability.")
17
+
18
+ # ----------------------------
19
+ # Input Features (Based on Engine Dataset)
20
+ # ----------------------------
21
+
22
+ operational_setting_1 = st.number_input("Operational Setting 1", value=0.0)
23
+ operational_setting_2 = st.number_input("Operational Setting 2", value=0.0)
24
+ operational_setting_3 = st.number_input("Operational Setting 3", value=0.0)
25
+
26
+ sensor_1 = st.number_input("Sensor Measurement 1", value=0.0)
27
+ sensor_2 = st.number_input("Sensor Measurement 2", value=0.0)
28
+ sensor_3 = st.number_input("Sensor Measurement 3", value=0.0)
29
+ sensor_4 = st.number_input("Sensor Measurement 4", value=0.0)
30
+ sensor_5 = st.number_input("Sensor Measurement 5", value=0.0)
31
+ sensor_6 = st.number_input("Sensor Measurement 6", value=0.0)
32
+ sensor_7 = st.number_input("Sensor Measurement 7", value=0.0)
33
+ sensor_8 = st.number_input("Sensor Measurement 8", value=0.0)
34
+ sensor_9 = st.number_input("Sensor Measurement 9", value=0.0)
35
+ sensor_10 = st.number_input("Sensor Measurement 10", value=0.0)
36
+
37
+ # ----------------------------
38
+ # Prepare Input DataFrame
39
+ # ----------------------------
40
+
41
+ input_data = pd.DataFrame([{
42
+ "operational_setting_1": operational_setting_1,
43
+ "operational_setting_2": operational_setting_2,
44
+ "operational_setting_3": operational_setting_3,
45
+ "sensor_1": sensor_1,
46
+ "sensor_2": sensor_2,
47
+ "sensor_3": sensor_3,
48
+ "sensor_4": sensor_4,
49
+ "sensor_5": sensor_5,
50
+ "sensor_6": sensor_6,
51
+ "sensor_7": sensor_7,
52
+ "sensor_8": sensor_8,
53
+ "sensor_9": sensor_9,
54
+ "sensor_10": sensor_10
55
+ }])
56
+
57
+ # ----------------------------
58
+ # Prediction Section
59
+ # ----------------------------
60
+
61
+ if st.button("Predict Engine Failure"):
62
+
63
+ prediction = model.predict(input_data)[0]
64
+
65
+ if prediction == 1:
66
+ st.error("🚨 High Risk: Engine Failure Likely. Immediate Maintenance Recommended.")
67
+ else:
68
+ st.success("✅ Engine Operating Normally. No Immediate Maintenance Required.")
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
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
7
+ mlflow==3.0.1