Spaces:
Running
Running
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -271,9 +271,9 @@ def _to_tensor(spec) -> torch.Tensor:
|
|
| 271 |
|
| 272 |
|
| 273 |
def _normalize_label(val):
|
| 274 |
-
"""Convert labels to
|
| 275 |
if isinstance(val, (list, tuple)):
|
| 276 |
-
return
|
| 277 |
return str(val)
|
| 278 |
|
| 279 |
|
|
@@ -303,6 +303,9 @@ def compute_eval(task: str):
|
|
| 303 |
y_true.append(true)
|
| 304 |
y_pred.append(pred)
|
| 305 |
|
|
|
|
|
|
|
|
|
|
| 306 |
labels = sorted(list({*y_true, *y_pred}))
|
| 307 |
cm = confusion_matrix(y_true, y_pred, labels=labels)
|
| 308 |
f1 = f1_score(y_true, y_pred, labels=labels, average="macro", zero_division=0)
|
|
|
|
| 271 |
|
| 272 |
|
| 273 |
def _normalize_label(val):
|
| 274 |
+
"""Convert labels to a simple string for metrics."""
|
| 275 |
if isinstance(val, (list, tuple)):
|
| 276 |
+
return " | ".join(str(v) for v in val)
|
| 277 |
return str(val)
|
| 278 |
|
| 279 |
|
|
|
|
| 303 |
y_true.append(true)
|
| 304 |
y_pred.append(pred)
|
| 305 |
|
| 306 |
+
if not y_true or not y_pred:
|
| 307 |
+
raise RuntimeError("No samples were evaluated; check data or predictions.")
|
| 308 |
+
|
| 309 |
labels = sorted(list({*y_true, *y_pred}))
|
| 310 |
cm = confusion_matrix(y_true, y_pred, labels=labels)
|
| 311 |
f1 = f1_score(y_true, y_pred, labels=labels, average="macro", zero_division=0)
|