Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -26,8 +26,8 @@ def load_model():
|
|
| 26 |
|
| 27 |
# ------------------------------------------------------------------
|
| 28 |
# Patch for xgboost version mismatch:
|
| 29 |
-
# some older models don't have .use_label_encoder,
|
| 30 |
-
# but newer xgboost expects
|
| 31 |
# ------------------------------------------------------------------
|
| 32 |
try:
|
| 33 |
from xgboost import XGBClassifier
|
|
@@ -40,11 +40,14 @@ def load_model():
|
|
| 40 |
elif isinstance(model, XGBClassifier):
|
| 41 |
xgb_clf = model
|
| 42 |
|
| 43 |
-
if isinstance(xgb_clf, XGBClassifier)
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
| 48 |
except Exception:
|
| 49 |
# If anything goes wrong with the patch, don't break the app
|
| 50 |
pass
|
|
|
|
| 26 |
|
| 27 |
# ------------------------------------------------------------------
|
| 28 |
# Patch for xgboost version mismatch:
|
| 29 |
+
# some older models don't have .use_label_encoder or .gpu_id,
|
| 30 |
+
# but newer xgboost expects them.
|
| 31 |
# ------------------------------------------------------------------
|
| 32 |
try:
|
| 33 |
from xgboost import XGBClassifier
|
|
|
|
| 40 |
elif isinstance(model, XGBClassifier):
|
| 41 |
xgb_clf = model
|
| 42 |
|
| 43 |
+
if isinstance(xgb_clf, XGBClassifier):
|
| 44 |
+
# attribute added/changed between versions
|
| 45 |
+
if not hasattr(xgb_clf, "use_label_encoder"):
|
| 46 |
+
xgb_clf.use_label_encoder = False
|
| 47 |
+
# attribute introduced in newer XGBModel
|
| 48 |
+
if not hasattr(xgb_clf, "gpu_id"):
|
| 49 |
+
# -1 or 0 are both fine for CPU usage
|
| 50 |
+
xgb_clf.gpu_id = -1
|
| 51 |
except Exception:
|
| 52 |
# If anything goes wrong with the patch, don't break the app
|
| 53 |
pass
|