Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -59,8 +59,10 @@ def predict(text: str):
|
|
| 59 |
return "⚠️ Please enter a reaction description.", None, None
|
| 60 |
|
| 61 |
# ── 1. Severity prediction ──
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
| 64 |
|
| 65 |
# Normalise to expected label keys
|
| 66 |
# The model may emit "LABEL_0"/"LABEL_1" or "Non-Severe"/"Severe"
|
|
|
|
| 59 |
return "⚠️ Please enter a reaction description.", None, None
|
| 60 |
|
| 61 |
# ── 1. Severity prediction ──
|
| 62 |
+
raw = clf_pipeline(text)
|
| 63 |
+
# Handle both [[{...}]] and [{...}] shapes
|
| 64 |
+
results = raw[0] if isinstance(raw[0], list) else raw
|
| 65 |
+
scores = {r["label"]: r["score"] for r in results}
|
| 66 |
|
| 67 |
# Normalise to expected label keys
|
| 68 |
# The model may emit "LABEL_0"/"LABEL_1" or "Non-Severe"/"Severe"
|