Skip to content

Commit

Permalink
Speeding up mean_iou metric computation (#569)
Browse files Browse the repository at this point in the history
* Change Features from Sequence to Image

* Fix example
  • Loading branch information
qubvel authored Apr 18, 2024
1 parent 04c7588 commit edb83af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions metrics/mean_iou/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ For binary (two classes) or multi-class segmentation, the *mean IoU* of the imag

## How to Use

The Mean IoU metric takes two numeric arrays as input corresponding to the predicted and ground truth segmentations:
The Mean IoU metric takes two lists of numeric 2D arrays as input corresponding to the predicted and ground truth segmentations:
```python
>>> import numpy as np
>>> mean_iou = evaluate.load("mean_iou")
>>> predicted = np.array([[2, 2, 3], [8, 2, 4], [3, 255, 2]])
>>> ground_truth = np.array([[1, 2, 2], [8, 2, 1], [3, 255, 1]])
>>> results = mean_iou.compute(predictions=predicted, references=ground_truth, num_labels=10, ignore_index=255)
>>> results = mean_iou.compute(predictions=[predicted], references=[ground_truth], num_labels=10, ignore_index=255)
```

### Inputs
Expand Down
5 changes: 2 additions & 3 deletions metrics/mean_iou/mean_iou.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,9 @@ def _info(self):
citation=_CITATION,
inputs_description=_KWARGS_DESCRIPTION,
features=datasets.Features(
# 1st Seq - height dim, 2nd - width dim
{
"predictions": datasets.Sequence(datasets.Sequence(datasets.Value("uint16"))),
"references": datasets.Sequence(datasets.Sequence(datasets.Value("uint16"))),
"predictions": datasets.Image(),
"references": datasets.Image(),
}
),
reference_urls=[
Expand Down

0 comments on commit edb83af

Please sign in to comment.