mlvbench.metrics¶
Evaluation metrics.
intersection_over_union(prediction, target)
¶
Compute the intersection over union (IoU) of two binary masks.
\[
\mathrm{IoU} = \frac{|P \cap T|}{|P \cup T|}
\]
If both the prediction and target are empty (\(|P \cup T| = 0\)), this returns 1.0 since the prediction is correct.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prediction
|
Tensor
|
The predicted mask, a |
required |
target
|
Tensor
|
The target mask, a |
required |
Returns:
| Type | Description |
|---|---|
float
|
The IoU computed over all elements. Returns 1.0 if both masks are empty. |