grkavi0912 commited on
Commit
982aa70
·
verified ·
1 Parent(s): bfcd5cd

Update deployment files (app.py, Dockerfile, requirements.txt, .streamlit)

Browse files
Files changed (3) hide show
  1. Dockerfile +1 -4
  2. app.py +5 -2
  3. requirements.txt +1 -1
Dockerfile CHANGED
@@ -7,12 +7,9 @@ WORKDIR /app
7
  #copy all the 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 pip install -r requirements.txt
12
 
13
- # Copy Streamlit configuration
14
- COPY .streamlit /root/.streamlit
15
-
16
  RUN useradd -m -u 1000 user
17
  USER user
18
  ENV HOME=/home/user \
 
7
  #copy all the files from the current directory on the host to the container's /app directory
8
  COPY . .
9
 
10
+ #Install python dependencies listed in requirements.text
11
  RUN pip install -r requirements.txt
12
 
 
 
 
13
  RUN useradd -m -u 1000 user
14
  USER user
15
  ENV HOME=/home/user \
app.py CHANGED
@@ -2,6 +2,7 @@ import streamlit as st
2
  import pandas as pd
3
  import joblib
4
  import os
 
5
 
6
  # Set page config
7
  st.set_page_config(
@@ -12,7 +13,7 @@ st.set_page_config(
12
  )
13
 
14
  # --- Paths to model and data ---
15
- MODEL_PATH = os.path.join(os.path.dirname(__file__), 'engine/model', 'tuned_xgboost_model.pkl')
16
 
17
  # Create dummy model directory if it doesn't exist (for local testing)
18
  # In a real deployment, these paths would be correctly set within the Docker container
@@ -24,7 +25,9 @@ if not os.path.exists(os.path.join(os.path.dirname(__file__), 'engine/model')):
24
  @st.cache_resource
25
  def load_model(path):
26
  try:
27
- model = joblib.load(path)
 
 
28
  return model
29
  except Exception as e:
30
  st.error(f"Error loading model: {e}")
 
2
  import pandas as pd
3
  import joblib
4
  import os
5
+ import xgboost as xgb # Import xgboost for model loading
6
 
7
  # Set page config
8
  st.set_page_config(
 
13
  )
14
 
15
  # --- Paths to model and data ---
16
+ MODEL_PATH = os.path.join(os.path.dirname(__file__), 'engine/model', 'tuned_xgboost_model.json') # Update to .json
17
 
18
  # Create dummy model directory if it doesn't exist (for local testing)
19
  # In a real deployment, these paths would be correctly set within the Docker container
 
25
  @st.cache_resource
26
  def load_model(path):
27
  try:
28
+ # Load model using native XGBoost method
29
+ model = xgb.XGBClassifier() # Initialize an empty model
30
+ model.load_model(path) # Load the saved parameters
31
  return model
32
  except Exception as e:
33
  st.error(f"Error loading model: {e}")
requirements.txt CHANGED
@@ -3,5 +3,5 @@ huggingface_hub==0.32.6
3
  streamlit==1.43.2
4
  joblib==1.5.1
5
  scikit-learn==1.6.1
6
- xgboost==2.1.4
7
  mlflow==3.0.1
 
3
  streamlit==1.43.2
4
  joblib==1.5.1
5
  scikit-learn==1.6.1
6
+ xgboost==1.7.6 # Pin to an older version or the version used for training to match save_model compatibility
7
  mlflow==3.0.1