<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/models/blob/v2.20.0/official/vision/ops/iou_similarity.py#L100-L167) |

Class to compute similarity based on Intersection over Union (IOU) metric.

    tfm.vision.iou_similarity.IouSimilarity(
        mask_val=-1
    )

## Methods

### `__call__`

[View source](https://github.com/tensorflow/models/blob/v2.20.0/official/vision/ops/iou_similarity.py#L108-L167)

    __call__(
        boxes_1, boxes_2, boxes_1_masks=None, boxes_2_masks=None
    )

Compute pairwise IOU similarity between ground truth boxes and anchors.

B: batch_size
N: Number of groundtruth boxes.
M: Number of anchor boxes.

<br />

<br />

<br />

| Args ||
|---|---|
| `boxes_1` | a float Tensor with M or B \* M boxes. |
| `boxes_2` | a float Tensor with N or B \* N boxes, the rank must be less than or equal to rank of `boxes_1`. |
| `boxes_1_masks` | a boolean Tensor with M or B \* M boxes. Optional. |
| `boxes_2_masks` | a boolean Tensor with N or B \* N boxes. Optional. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A Tensor with shape \[M, N\] or \[B, M, N\] representing pairwise iou scores, anchor per row and groundtruth_box per colulmn. ||

<br />

<br />

<br />

<br />

| Input shape ||
|---|---|
| `boxes_1` | \[N, 4\], or \[B, N, 4\] |
| `boxes_2` | \[M, 4\], or \[B, M, 4\] |
| `boxes_1_masks` | \[N, 1\], or \[B, N, 1\] |
| `boxes_2_masks` | \[M, 1\], or \[B, M, 1\] |

<br />

<br />

<br />

<br />

| Output shape ||
|---|---|
| \[M, N\], or \[B, M, N\] ||

<br />