nansri commited on
Commit
921c256
·
verified ·
1 Parent(s): 3af58ee

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. Dockerfile +1 -0
  2. app.py +14 -22
  3. best_model.joblib +3 -0
  4. requirements.txt +0 -1
Dockerfile CHANGED
@@ -7,6 +7,7 @@ COPY requirements.txt .
7
  RUN pip install --no-cache-dir -r requirements.txt
8
 
9
  COPY app.py .
 
10
 
11
  EXPOSE 7860
12
 
 
7
  RUN pip install --no-cache-dir -r requirements.txt
8
 
9
  COPY app.py .
10
+ COPY best_model.joblib .
11
 
12
  EXPOSE 7860
13
 
app.py CHANGED
@@ -1,20 +1,13 @@
 
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(page_title="Predictive Maintenance App", layout="centered")
7
 
8
- MODEL_REPO_ID = "nansri/engine-predictive-maintenance-model"
9
-
10
  @st.cache_resource
11
  def load_model():
12
- model_path = hf_hub_download(
13
- repo_id=MODEL_REPO_ID,
14
- filename="best_model.joblib",
15
- repo_type="model"
16
- )
17
- return joblib.load(model_path)
18
 
19
  st.title("Predictive Maintenance for Engine Health")
20
  st.write("Enter the engine sensor values below to predict engine condition.")
@@ -28,19 +21,18 @@ coolant_temp = st.number_input("Coolant Temperature", min_value=0.0, value=80.5)
28
 
29
  if st.button("Predict Engine Condition"):
30
  try:
31
- with st.spinner("Loading model and generating prediction..."):
32
- model = load_model()
33
 
34
- input_df = pd.DataFrame([{
35
- "Engine_rpm": engine_rpm,
36
- "Lub_oil_pressure": lub_oil_pressure,
37
- "Fuel_pressure": fuel_pressure,
38
- "Coolant_pressure": coolant_pressure,
39
- "lub_oil_temp": lub_oil_temp,
40
- "Coolant_temp": coolant_temp
41
- }])
42
 
43
- prediction = model.predict(input_df)[0]
44
 
45
  if prediction == 1:
46
  st.error("Prediction: Engine may require maintenance.")
@@ -49,6 +41,6 @@ if st.button("Predict Engine Condition"):
49
 
50
  st.write("Input dataframe used for prediction:")
51
  st.dataframe(input_df)
52
-
53
  except Exception as e:
54
- st.error(f"Prediction failed: {e}")
 
1
+
2
  import streamlit as st
3
  import pandas as pd
4
  import joblib
 
5
 
6
  st.set_page_config(page_title="Predictive Maintenance App", layout="centered")
7
 
 
 
8
  @st.cache_resource
9
  def load_model():
10
+ return joblib.load("best_model.joblib")
 
 
 
 
 
11
 
12
  st.title("Predictive Maintenance for Engine Health")
13
  st.write("Enter the engine sensor values below to predict engine condition.")
 
21
 
22
  if st.button("Predict Engine Condition"):
23
  try:
24
+ model = load_model()
 
25
 
26
+ input_df = 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
+ prediction = model.predict(input_df)[0]
36
 
37
  if prediction == 1:
38
  st.error("Prediction: Engine may require maintenance.")
 
41
 
42
  st.write("Input dataframe used for prediction:")
43
  st.dataframe(input_df)
44
+
45
  except Exception as e:
46
+ st.error(f"Prediction failed: {e}")
best_model.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4c93788dcb2a026a9b78690d25140233dc908baae3a2c21232dad97051b09c55
3
+ size 65796
requirements.txt CHANGED
@@ -1,5 +1,4 @@
1
  streamlit==1.44.1
2
  pandas==2.2.3
3
  joblib==1.4.2
4
- huggingface_hub==0.30.2
5
  scikit-learn==1.6.1
 
1
  streamlit==1.44.1
2
  pandas==2.2.3
3
  joblib==1.4.2
 
4
  scikit-learn==1.6.1