Shalyn commited on
Commit
4deaab1
·
verified ·
1 Parent(s): e313dc3

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. DockerFile +23 -0
  2. app.py +43 -0
  3. requirements.txt +7 -3
DockerFile ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Create base image with Python 3.9 installed
2
+ from PYTHON:3.9
3
+
4
+ #Setting working directory
5
+ WORKDIR \app
6
+
7
+ #Copying files from current directory on the host to the container
8
+ COPY..
9
+
10
+ #Installing requirements from requirements.txt
11
+ RUN pip 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
+ #Making streamlit app to run locally on port 8501 and make it access 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,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 model from model hub
7
+ model_path = hf_hub_download(repo_id="Shalyn/PredictiveMaintanence-model",filename="engine_condition_model_v1.joblib")
8
+
9
+ #loading the model
10
+ model = joblib.load(model_path)
11
+
12
+ #Building Streamlit app UI
13
+ st.title("Predictive Maintanence Prediction Tool")
14
+ st.write("This tool helps to forecast potential failures in vehicles before they occur.")
15
+ st.write("Kindly enter the vehicle sensor values to predict if the vehicle needs maintanence.")
16
+
17
+ #collect user input
18
+ Engine_RPM = st.number_input("Engine_RPM(The number of revolutions per minute (RPM) of the engine, indicating engine speed. It is defined in Revolutions per Minute (RPM))")
19
+ Lub_Oil_Pressure = st.number_input("Lub_Oil_Pressure (The pressure of the lubricating oil in the engine, essential for reducing friction and wear. It is defined in bar or kilopascals (kPa))")
20
+ Fuel_Pressure = st.number_input("Fuel_Pressure (The pressure at which fuel is supplied to the engine, critical for proper combustion. It is defined in bar or kilopascals (kPa))")
21
+ Coolant_Pressure = st.number_input("Coolant_Pressure (The pressure of the engine coolant, affecting engine temperature regulation. It is defined in bar or kilopascals (kPa) )")
22
+ Lub_Oil_Temperature = st.number_input("Lub_Oil_Temperature (The temperature of the lubricating oil, which impacts viscosity and engine performance. It is defined in degrees Celsius (°C) )")
23
+ Coolant_Temperature = st.number_input("Coolant_Temperature (The temperature of the engine coolant, crucial for preventing overheating. It is defined in degrees Celsius (°C))")
24
+
25
+ #Converting the inputs to match training datarow
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_Temperature,
32
+ 'Coolant temp': Coolant_Temperature
33
+ }])
34
+
35
+ #setting up classification threshold
36
+ classification_threshold = 0.45
37
+
38
+ #Creating prediction button
39
+ if st.button("Predict"):
40
+ prediction_prob = model.predict_proba(input_data)[0,1]
41
+ prediction = (prediction_prob>classification_threshold).astype(int)
42
+ result = "Off/False/Active" if prediction == 0 else "On/True/Faulty"
43
+ st.write(f"Based on the given input the vehicle is {result}")
requirements.txt CHANGED
@@ -1,3 +1,7 @@
1
- altair
2
- pandas
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
6
+ xgboost==2.1.4
7
+ mlflow==3.0.1