Spaces:
Sleeping
Sleeping
Commit
·
33278a3
1
Parent(s):
5c58259
model_path
Browse files- app.py +2 -5
- 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 |
-
|
29 |
-
|
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 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
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
|