MHuzaifaa commited on
Commit
e7caa96
·
verified ·
1 Parent(s): c2eba4e

Update src/app.py

Browse files
Files changed (1) hide show
  1. src/app.py +6 -3
src/app.py CHANGED
@@ -133,7 +133,8 @@ st.markdown("""
133
  """, unsafe_allow_html=True)
134
 
135
  # Load Resources
136
- @st.cache_resource def load_resources():
 
137
  # CHANGE: Remove '../' because 'models' is now a subdirectory of 'src'
138
  models_dir = os.path.join(os.path.dirname(__file__), 'models')
139
  model_path = os.path.join(models_dir, 'best_model.pkl')
@@ -148,7 +149,8 @@ st.markdown("""
148
  kmeans = joblib.load(kmeans_path)
149
  return model, encoders, kmeans
150
 
151
- @st.cache_resource def load_new_artifacts():
 
152
  try:
153
  # CHANGE: Remove '../'
154
  models_dir = os.path.join(os.path.dirname(__file__), 'models')
@@ -159,7 +161,8 @@ st.markdown("""
159
  st.error(f"❌ Artifact loading error: {e}")
160
  return None
161
 
162
- @st.cache_data def load_data_sample():
 
163
  # CHANGE: Keep '../' to go up to the root, then look for 'data'
164
  data_dir = os.path.join(os.path.dirname(__file__), '../data/crimedataset')
165
  try:
 
133
  """, unsafe_allow_html=True)
134
 
135
  # Load Resources
136
+ @st.cache_resource
137
+ def load_resources():
138
  # CHANGE: Remove '../' because 'models' is now a subdirectory of 'src'
139
  models_dir = os.path.join(os.path.dirname(__file__), 'models')
140
  model_path = os.path.join(models_dir, 'best_model.pkl')
 
149
  kmeans = joblib.load(kmeans_path)
150
  return model, encoders, kmeans
151
 
152
+ @st.cache_resource
153
+ def load_new_artifacts():
154
  try:
155
  # CHANGE: Remove '../'
156
  models_dir = os.path.join(os.path.dirname(__file__), 'models')
 
161
  st.error(f"❌ Artifact loading error: {e}")
162
  return None
163
 
164
+ @st.cache_data
165
+ def load_data_sample():
166
  # CHANGE: Keep '../' to go up to the root, then look for 'data'
167
  data_dir = os.path.join(os.path.dirname(__file__), '../data/crimedataset')
168
  try: