HARISH20205 commited on
Commit
33278a3
·
1 Parent(s): 5c58259

model_path

Browse files
Files changed (2) hide show
  1. app.py +2 -5
  2. test_model.py +13 -7
app.py CHANGED
@@ -25,11 +25,8 @@ def predict_with_catboost(features_df, model_path):
25
  try:
26
  model = CatBoostClassifier()
27
  # Try loading without format specification first
28
- try:
29
- model.load_model(model_path)
30
- except:
31
- # If that fails, try with explicit format
32
- model.load_model(model_path, format='binary')
33
  predictions = model.predict(features_df)
34
  return predictions
35
  except Exception as e:
 
25
  try:
26
  model = CatBoostClassifier()
27
  # Try loading without format specification first
28
+ print(model_path)
29
+ model.load_model(model_path)
 
 
 
30
  predictions = model.predict(features_df)
31
  return predictions
32
  except Exception as e:
test_model.py CHANGED
@@ -8,16 +8,22 @@ def test_model_loading():
8
  "catboost_model.bin"
9
  ]
10
 
 
 
11
  for path in possible_paths:
12
  if os.path.exists(path):
13
  print(f"Found model at: {path}")
14
- model = CatBoostClassifier()
15
- try:
16
- model.load_model(path)
17
- print(f"Successfully loaded model from {path}")
18
- return True
19
- except Exception as e:
20
- print(f"Failed to load from {path}: {str(e)}")
 
 
 
 
21
 
22
  print("Model not found in any location")
23
  return False
 
8
  "catboost_model.bin"
9
  ]
10
 
11
+ formats_to_try = [None, 'binnar', 'json', 'coreml']
12
+
13
  for path in possible_paths:
14
  if os.path.exists(path):
15
  print(f"Found model at: {path}")
16
+ for format in formats_to_try:
17
+ model = CatBoostClassifier()
18
+ try:
19
+ if format is None:
20
+ model.load_model(path)
21
+ else:
22
+ model.load_model(path, format=format)
23
+ print(f"Successfully loaded model from {path} with format {format}")
24
+ return True
25
+ except Exception as e:
26
+ print(f"Failed to load from {path} with format {format}: {str(e)}")
27
 
28
  print("Model not found in any location")
29
  return False