Zeyadd-Mostaffa commited on
Commit
11d6e4a
Β·
verified Β·
1 Parent(s): 46c621f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -4,18 +4,25 @@ import pandas as pd
4
  import joblib
5
  import os
6
  import warnings
 
7
 
8
  warnings.filterwarnings("ignore")
9
 
10
- # Load Ensemble Model
11
  def load_model():
12
- model_path = "final_ensemble_model.pkl" # Must match your saved model name
13
- if os.path.exists(model_path):
14
- model = joblib.load(model_path)
15
- print("βœ… Ensemble model loaded successfully.")
 
 
 
 
 
 
 
16
  return model
17
- else:
18
- print("❌ Model file not found.")
19
  return None
20
 
21
  model = load_model()
 
4
  import joblib
5
  import os
6
  import warnings
7
+ import zipfile
8
 
9
  warnings.filterwarnings("ignore")
10
 
 
11
  def load_model():
12
+ zip_path = "final_ensemble_model.zip"
13
+ pkl_path = "final_ensemble_model.pkl"
14
+
15
+ if not os.path.exists(pkl_path):
16
+ print("πŸ“¦ Extracting model from zip...")
17
+ with zipfile.ZipFile(zip_path, 'r') as zip_ref:
18
+ zip_ref.extractall(".")
19
+
20
+ try:
21
+ model = joblib.load(pkl_path)
22
+ print("βœ… Ensemble model loaded.")
23
  return model
24
+ except Exception as e:
25
+ print(f"❌ Failed to load model: {e}")
26
  return None
27
 
28
  model = load_model()