Spaces:
Sleeping
Sleeping
Commit
·
fca3ef1
1
Parent(s):
33278a3
verify
Browse files- app.py +18 -3
- verify_model.py +24 -4
app.py
CHANGED
@@ -23,10 +23,25 @@ def extract_features_in_parallel(urls):
|
|
23 |
# Load the CatBoost model for inference
|
24 |
def predict_with_catboost(features_df, model_path):
|
25 |
try:
|
|
|
|
|
|
|
|
|
26 |
model = CatBoostClassifier()
|
27 |
-
# Try loading
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
predictions = model.predict(features_df)
|
31 |
return predictions
|
32 |
except Exception as e:
|
|
|
23 |
# Load the CatBoost model for inference
|
24 |
def predict_with_catboost(features_df, model_path):
|
25 |
try:
|
26 |
+
print(f"Attempting to load model from: {model_path}")
|
27 |
+
print(f"File exists: {os.path.exists(model_path)}")
|
28 |
+
print(f"File size: {os.path.getsize(model_path)}")
|
29 |
+
|
30 |
model = CatBoostClassifier()
|
31 |
+
# Try different loading approaches
|
32 |
+
try:
|
33 |
+
print("Attempting to load model without format...")
|
34 |
+
model.load_model(model_path)
|
35 |
+
except Exception as e1:
|
36 |
+
print(f"First attempt failed: {str(e1)}")
|
37 |
+
try:
|
38 |
+
print("Attempting to load model with format='binnar'...")
|
39 |
+
model.load_model(model_path, format='binnar')
|
40 |
+
except Exception as e2:
|
41 |
+
print(f"Second attempt failed: {str(e2)}")
|
42 |
+
print("Attempting final load with format='binary'...")
|
43 |
+
model.load_model(model_path, format='binary')
|
44 |
+
|
45 |
predictions = model.predict(features_df)
|
46 |
return predictions
|
47 |
except Exception as e:
|
verify_model.py
CHANGED
@@ -1,7 +1,27 @@
|
|
1 |
from catboost import CatBoostClassifier
|
2 |
import os
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
print("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from catboost import CatBoostClassifier
|
2 |
import os
|
3 |
|
4 |
+
def verify_model():
|
5 |
+
model_path = os.path.join(os.getcwd(), "catboost_model.bin")
|
6 |
+
print(f"Model path: {model_path}")
|
7 |
+
print(f"Current working directory: {os.getcwd()}")
|
8 |
+
print(f"File exists: {os.path.exists(model_path)}")
|
9 |
+
if os.path.exists(model_path):
|
10 |
+
print(f"File size: {os.path.getsize(model_path)}")
|
11 |
+
|
12 |
+
model = CatBoostClassifier()
|
13 |
+
formats = [None, 'binary', 'binnar', 'json']
|
14 |
+
|
15 |
+
for fmt in formats:
|
16 |
+
try:
|
17 |
+
if fmt is None:
|
18 |
+
model.load_model(model_path)
|
19 |
+
else:
|
20 |
+
model.load_model(model_path, format=fmt)
|
21 |
+
print(f"Successfully loaded model with format: {fmt}")
|
22 |
+
return
|
23 |
+
except Exception as e:
|
24 |
+
print(f"Failed to load with format {fmt}: {str(e)}")
|
25 |
+
|
26 |
+
if __name__ == "__main__":
|
27 |
+
verify_model()
|