Spaces:
Sleeping
Sleeping
Commit
·
26a71ad
1
Parent(s):
01f4084
Fixed6
Browse files- routes/offline_detection.py +1 -0
- utils/model_selector.py +12 -0
routes/offline_detection.py
CHANGED
|
@@ -13,6 +13,7 @@ from utils.model_selector import load_model
|
|
| 13 |
|
| 14 |
offline_bp = Blueprint("offline_bp", __name__)
|
| 15 |
|
|
|
|
| 16 |
# --- CONFIGURATION ---
|
| 17 |
UPLOAD_DIR = "uploads"
|
| 18 |
SAMPLE_DIR = "sample"
|
|
|
|
| 13 |
|
| 14 |
offline_bp = Blueprint("offline_bp", __name__)
|
| 15 |
|
| 16 |
+
|
| 17 |
# --- CONFIGURATION ---
|
| 18 |
UPLOAD_DIR = "uploads"
|
| 19 |
SAMPLE_DIR = "sample"
|
utils/model_selector.py
CHANGED
|
@@ -4,6 +4,8 @@ import threading
|
|
| 4 |
import traceback
|
| 5 |
from huggingface_hub import hf_hub_download
|
| 6 |
import sklearn.utils
|
|
|
|
|
|
|
| 7 |
# --- CONFIGURATION ---
|
| 8 |
HF_REPO_ID = "CodebaseAi/netraids-ml-models" # Replace with your actual public repo ID
|
| 9 |
# ---------------------
|
|
@@ -12,6 +14,16 @@ ACTIVE_MODEL = "bcc"
|
|
| 12 |
_ACTIVE_LOCK = threading.Lock()
|
| 13 |
_MODEL_CACHE = {}
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
# --- PATCH FOR SKLEARN 1.6+ COMPATIBILITY ---
|
| 16 |
# This fixes the "cannot import name 'parse_version' from 'sklearn.utils'" error
|
| 17 |
if not hasattr(sklearn.utils, 'parse_version'):
|
|
|
|
| 4 |
import traceback
|
| 5 |
from huggingface_hub import hf_hub_download
|
| 6 |
import sklearn.utils
|
| 7 |
+
|
| 8 |
+
|
| 9 |
# --- CONFIGURATION ---
|
| 10 |
HF_REPO_ID = "CodebaseAi/netraids-ml-models" # Replace with your actual public repo ID
|
| 11 |
# ---------------------
|
|
|
|
| 14 |
_ACTIVE_LOCK = threading.Lock()
|
| 15 |
_MODEL_CACHE = {}
|
| 16 |
|
| 17 |
+
|
| 18 |
+
try:
|
| 19 |
+
# We reach into the sub-module to find the "hidden" function
|
| 20 |
+
import sklearn.utils._column_transformer as ct_utils
|
| 21 |
+
|
| 22 |
+
if not hasattr(sklearn.utils, '_get_column_indices'):
|
| 23 |
+
sklearn.utils._get_column_indices = ct_utils._get_column_indices
|
| 24 |
+
print("[Patch] Successfully injected _get_column_indices into sklearn.utils")
|
| 25 |
+
except ImportError:
|
| 26 |
+
print("[Patch] Could not find _column_transformer sub-module, skipping...")
|
| 27 |
# --- PATCH FOR SKLEARN 1.6+ COMPATIBILITY ---
|
| 28 |
# This fixes the "cannot import name 'parse_version' from 'sklearn.utils'" error
|
| 29 |
if not hasattr(sklearn.utils, 'parse_version'):
|