Vignesh-vigu commited on
Commit
f4ce365
·
verified ·
1 Parent(s): c17d4ec

Initial Docker-based Streamlit deployment

Browse files
Files changed (4) hide show
  1. Dockerfile +13 -0
  2. README.md +7 -9
  3. app.py +52 -0
  4. requirements.txt +7 -0
Dockerfile ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ WORKDIR /app
4
+
5
+ COPY requirements.txt .
6
+
7
+ RUN pip install --no-cache-dir -r requirements.txt
8
+
9
+ COPY app.py .
10
+
11
+ EXPOSE 7860
12
+
13
+ CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
README.md CHANGED
@@ -1,10 +1,8 @@
1
- ---
2
- title: Engine Predictive Maintenance App
3
- emoji: ⚡
4
- colorFrom: yellow
5
- colorTo: purple
6
- sdk: docker
7
- pinned: false
8
- ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
1
+ # Engine Predictive Maintenance App
 
 
 
 
 
 
 
2
 
3
+ This Streamlit application predicts whether an engine requires maintenance
4
+ based on real-time sensor inputs such as RPM, pressure, and temperature.
5
+
6
+ The machine learning model is trained using XGBoost and hosted on the
7
+ Hugging Face Model Hub. The application is deployed using Docker on
8
+ Hugging Face Spaces.
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import joblib
4
+ from huggingface_hub import hf_hub_download
5
+
6
+ st.set_page_config(
7
+ page_title="Engine Predictive Maintenance",
8
+ layout="centered"
9
+ )
10
+
11
+ st.title("🔧 Engine Predictive Maintenance System")
12
+ st.write(
13
+ "Predict whether an engine requires maintenance "
14
+ "based on sensor inputs."
15
+ )
16
+
17
+ # Load model from Hugging Face Model Hub
18
+ MODEL_REPO = "Vignesh-vigu/engine-predictive-maintenance-model"
19
+ MODEL_FILE = "xgboost_model.pkl"
20
+
21
+ model_path = hf_hub_download(
22
+ repo_id=MODEL_REPO,
23
+ filename=MODEL_FILE
24
+ )
25
+
26
+ model = joblib.load(model_path)
27
+
28
+ st.subheader("Enter Engine Sensor Values")
29
+
30
+ engine_rpm = st.number_input("Engine RPM", min_value=0, max_value=3000, value=1000)
31
+ lub_oil_pressure = st.number_input("Lub Oil Pressure", value=3.0)
32
+ fuel_pressure = st.number_input("Fuel Pressure", value=10.0)
33
+ coolant_pressure = st.number_input("Coolant Pressure", value=2.5)
34
+ lub_oil_temp = st.number_input("Lub Oil Temperature (°C)", value=80.0)
35
+ coolant_temp = st.number_input("Coolant Temperature (°C)", value=85.0)
36
+
37
+ input_df = pd.DataFrame([{
38
+ "engine_rpm": engine_rpm,
39
+ "lub_oil_pressure": lub_oil_pressure,
40
+ "fuel_pressure": fuel_pressure,
41
+ "coolant_pressure": coolant_pressure,
42
+ "lub_oil_temp": lub_oil_temp,
43
+ "coolant_temp": coolant_temp
44
+ }])
45
+
46
+ if st.button("Predict Engine Condition"):
47
+ prediction = model.predict(input_df)[0]
48
+
49
+ if prediction == 1:
50
+ st.error("⚠️ Engine requires maintenance!")
51
+ else:
52
+ st.success("✅ Engine is operating normally.")
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ streamlit==1.43.2
2
+ pandas==2.2.2
3
+ numpy==2.0.2
4
+ scikit-learn==1.6.1
5
+ xgboost==2.1.4
6
+ joblib==1.4.2
7
+ huggingface_hub>=0.34.0