jpkarthikeyan commited on
Commit
ca7ef6d
·
verified ·
1 Parent(s): e1f6c48

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +1 -1
  2. app.py +6 -6
  3. requirements.txt +2 -3
Dockerfile CHANGED
@@ -4,7 +4,7 @@ FROM python:3.12-slim
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
 
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
app.py CHANGED
@@ -2,13 +2,13 @@ import streamlit as st
2
  import pandas as pd
3
  import joblib
4
  import os
5
- import dill
6
  import logging
7
  from huggingface_hub import login,hf_hub_download
8
- from xgboost import XGBClassifier
9
 
10
  logging.basicConfig(level=logging.INFO)
11
  logger = logging.getLogger(__name__)
 
12
  cache_dir = "/tmp/hf_cache"
13
  os.environ["HF_HOME"] = cache_dir
14
  os.environ["HUGGINGFACE_HUB_CACHE"] = cache_dir
@@ -55,7 +55,7 @@ class PredictorTourism:
55
  try:
56
  logger.info("Loading best model")
57
  model_path = hf_hub_download(
58
- repo_id = self.repoID,filename = f'Model_Dump_JOBLIB/BestModel_XGBoostingClassifier.joblib',
59
  repo_type = 'model')
60
  threshold_path = hf_hub_download(
61
  repo_id = self.repoID, filename=f'Model_Dump_JOBLIB/best_threshold.txt',
@@ -64,9 +64,9 @@ class PredictorTourism:
64
  logger.info(f"Model path: {model_path}")
65
  logger.info(f"Threshold path: {threshold_path}")
66
 
67
- #self.model = joblib.load(model_path)
68
- with open(model_path, 'rb') as f:
69
- self.model = joblib.load(f)
70
  with open(threshold_path,'r') as f:
71
  self.best_threshold = float(f.read())
72
  st.success("Model and threshold loaded successfully")
 
2
  import pandas as pd
3
  import joblib
4
  import os
 
5
  import logging
6
  from huggingface_hub import login,hf_hub_download
7
+
8
 
9
  logging.basicConfig(level=logging.INFO)
10
  logger = logging.getLogger(__name__)
11
+ os.environ["STREAMLIT_CONFIG_DIR"] = "/tmp/.streamlit"
12
  cache_dir = "/tmp/hf_cache"
13
  os.environ["HF_HOME"] = cache_dir
14
  os.environ["HUGGINGFACE_HUB_CACHE"] = cache_dir
 
55
  try:
56
  logger.info("Loading best model")
57
  model_path = hf_hub_download(
58
+ repo_id = self.repoID,filename = f'Model_Dump_JOBLIB/BestModel_GradientBoostingClassifier.joblib',
59
  repo_type = 'model')
60
  threshold_path = hf_hub_download(
61
  repo_id = self.repoID, filename=f'Model_Dump_JOBLIB/best_threshold.txt',
 
64
  logger.info(f"Model path: {model_path}")
65
  logger.info(f"Threshold path: {threshold_path}")
66
 
67
+ self.model = joblib.load(model_path)
68
+ # with open(model_path, 'rb') as f:
69
+ # self.model = joblib.load(f)
70
  with open(threshold_path,'r') as f:
71
  self.best_threshold = float(f.read())
72
  st.success("Model and threshold loaded successfully")
requirements.txt CHANGED
@@ -1,8 +1,7 @@
1
  pandas
2
  numpy
3
- scikit-learn
4
  joblib
5
  streamlit
6
  huggingface_hub
7
- xgboost
8
- dill
 
1
  pandas
2
  numpy
3
+ scikit-learn==1.6.1
4
  joblib
5
  streamlit
6
  huggingface_hub
7
+ setuptools