Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,7 +43,18 @@ model = _load_model()
|
|
| 43 |
# ---------- Features & Labels ----------
|
| 44 |
# If present, these files define exact column order and class names
|
| 45 |
feature_order: List[str] = json.load(open(FEATURES_PATH)) if os.path.exists(FEATURES_PATH) else []
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
# Fallback feature order (edit if needed; should match training names exactly)
|
| 49 |
fallback_features = [
|
|
|
|
| 43 |
# ---------- Features & Labels ----------
|
| 44 |
# If present, these files define exact column order and class names
|
| 45 |
feature_order: List[str] = json.load(open(FEATURES_PATH)) if os.path.exists(FEATURES_PATH) else []
|
| 46 |
+
|
| 47 |
+
if os.path.exists(LABELS_PATH):
|
| 48 |
+
raw_map = json.load(open(LABELS_PATH))
|
| 49 |
+
if isinstance(raw_map, dict):
|
| 50 |
+
# invert mapping → sort by value → get list of keys
|
| 51 |
+
labels: List[str] = [k.capitalize() for k, v in sorted(raw_map.items(), key=lambda x: x[1])]
|
| 52 |
+
elif isinstance(raw_map, list):
|
| 53 |
+
labels: List[str] = raw_map
|
| 54 |
+
else:
|
| 55 |
+
labels: List[str] = []
|
| 56 |
+
else:
|
| 57 |
+
labels: List[str] = ["Low", "Medium", "High"] # fallback
|
| 58 |
|
| 59 |
# Fallback feature order (edit if needed; should match training names exactly)
|
| 60 |
fallback_features = [
|