From dc6b5d06702d6ea7db4bd1868f77bdbac7147509 Mon Sep 17 00:00:00 2001 From: Pavel Iakubovskii Date: Wed, 1 May 2024 14:55:25 +0100 Subject: [PATCH] Use `.compute()` instead of `._compute()` (#2039) --- fine-tune-segformer.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/fine-tune-segformer.md b/fine-tune-segformer.md index 638a0186dc..8aa621abb5 100644 --- a/fine-tune-segformer.md +++ b/fine-tune-segformer.md @@ -315,15 +315,13 @@ def compute_metrics(eval_pred): ).argmax(dim=1) pred_labels = logits_tensor.detach().cpu().numpy() - # currently using _compute instead of compute - # see this issue for more info: https://github.com/huggingface/evaluate/pull/328#issuecomment-1286866576 - metrics = metric._compute( - predictions=pred_labels, - references=labels, - num_labels=len(id2label), - ignore_index=0, - reduce_labels=processor.do_reduce_labels, - ) + metrics = metric.compute( + predictions=pred_labels, + references=labels, + num_labels=len(id2label), + ignore_index=0, + reduce_labels=processor.do_reduce_labels, + ) # add per category metrics as individual key-value pairs per_category_accuracy = metrics.pop("per_category_accuracy").tolist()