Spaces:
Sleeping
Sleeping
anish commited on
Commit ·
6ea7430
1
Parent(s): 7c8dec7
Add workaround: patch check_array to handle force_all_finite compatibility issue
Browse files- predict.py +19 -0
predict.py
CHANGED
|
@@ -58,6 +58,25 @@ def _load():
|
|
| 58 |
break
|
| 59 |
if clf_path is None:
|
| 60 |
raise FileNotFoundError(f"No classifier found in {MODELS_DIR}; looked for: {clf_candidates}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
_m['clf'] = load(clf_path)
|
| 62 |
|
| 63 |
scaler_path = os.path.join(MODELS_DIR, "signal_scaler.joblib")
|
|
|
|
| 58 |
break
|
| 59 |
if clf_path is None:
|
| 60 |
raise FileNotFoundError(f"No classifier found in {MODELS_DIR}; looked for: {clf_candidates}")
|
| 61 |
+
|
| 62 |
+
# Workaround for sklearn 1.8.0 + numpy 2.0 compatibility issue
|
| 63 |
+
# Patch check_array to handle force_all_finite parameter
|
| 64 |
+
try:
|
| 65 |
+
from sklearn.utils.validation import check_array
|
| 66 |
+
import inspect
|
| 67 |
+
# Check if check_array supports force_all_finite
|
| 68 |
+
sig = inspect.signature(check_array)
|
| 69 |
+
if 'force_all_finite' not in sig.parameters:
|
| 70 |
+
# Patch it to accept but ignore the parameter
|
| 71 |
+
original_check_array = check_array
|
| 72 |
+
def patched_check_array(*args, **kwargs):
|
| 73 |
+
kwargs.pop('force_all_finite', None)
|
| 74 |
+
return original_check_array(*args, **kwargs)
|
| 75 |
+
import sklearn.utils.validation
|
| 76 |
+
sklearn.utils.validation.check_array = patched_check_array
|
| 77 |
+
except Exception as e:
|
| 78 |
+
print(f"Warning: Could not patch check_array: {e}")
|
| 79 |
+
|
| 80 |
_m['clf'] = load(clf_path)
|
| 81 |
|
| 82 |
scaler_path = os.path.join(MODELS_DIR, "signal_scaler.joblib")
|