<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/mask_ops.py#L191-L267) |

Calculates the IoUs and IoAs between the detection masks and the ground truth masks.

    tfm.vision.mask_ops.instance_masks_overlap(
        boxes: tf.Tensor,
        masks: tf.Tensor,
        gt_boxes: tf.Tensor,
        gt_masks: tf.Tensor,
        output_size: List[int],
        mask_binarize_threshold: float = 0.5
    ) -> Tuple[tf.Tensor, tf.Tensor]

IoU: intersection over union.
IoA: intersection over the area of the detection masks.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `boxes` | a tensor with a shape of \[batch_size, N, 4\]. The last dimension is the pixel coordinates in \[ymin, xmin, ymax, xmax\] form. |
| `masks` | a float tensor with a shape of \[batch_size, N, mask_height, mask_width\] representing the instance masks w.r.t. the `boxes`. |
| `gt_boxes` | a tensor with a shape of \[batch_size, M, 4\]. The last dimension is the pixel coordinates in \[ymin, xmin, ymax, xmax\] form. |
| `gt_masks` | a float tensor with a shape of \[batch_size, M, gt_mask_height, gt_mask_width\] representing the instance masks w.r.t. the `gt_boxes`. |
| `output_size` | two integers that represent the height and width of the output masks. |
| `mask_binarize_threshold` | a float representing the threshold for binarizing mask values. Default value is 0.5. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| `iou` | a tensor with as a shape of \[batch_size, N, M\]. |

<br />