<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/keras-team/keras/tree/v3.15.1/keras/src/layers/preprocessing/image_preprocessing/bounding_boxes/iou.py#L55-L173) |

Computes a lookup table vector containing the ious for a given set boxes.

    tf.keras.utils.bounding_boxes.compute_iou(
        boxes1,
        boxes2,
        bounding_box_format,
        use_masking=False,
        mask_val=-1,
        image_shape=None
    )

The lookup vector is to be indexed by \[`boxes1_index`,`boxes2_index`\] if
boxes are unbatched and by \[`batch`, `boxes1_index`,`boxes2_index`\] if the
boxes are batched.

The users can pass `boxes1` and `boxes2` to be different ranks. For example:

1) `boxes1`: \[batch_size, M, 4\], `boxes2`: \[batch_size, N, 4\] -\> return
\[batch_size, M, N\].
2) `boxes1`: \[batch_size, M, 4\], `boxes2`: \[N, 4\] -\> return
\[batch_size, M, N\]
3) `boxes1`: \[M, 4\], `boxes2`: \[batch_size, N, 4\] -\> return
\[batch_size, M, N\]
4) `boxes1`: \[M, 4\], `boxes2`: \[N, 4\] -\> return \[M, N\]

<br />

<br />

<br />

| ## Args ||
|---|---|
| `boxes1` | a list of bounding boxes in 'corners' format. Can be batched or unbatched. |
| `boxes2` | a list of bounding boxes in 'corners' format. Can be batched or unbatched. |
| `bounding_box_format` | a case-insensitive string which is one of `"xyxy"`, `"rel_xyxy"`, `"xyWH"`, `"center_xyWH"`, `"yxyx"`, `"rel_yxyx"`. For detailed information on the supported format, see the |
| `use_masking` | whether masking will be applied. This will mask all `boxes1` or `boxes2` that have values less than 0 in all its 4 dimensions. Default to `False`. |
| `mask_val` | int to mask those returned IOUs if the masking is True, defaults to -1. |
| `image_shape` | `Tuple[int]`. The shape of the image (height, width, 3). When using relative bounding box format for `box_format` the `image_shape` is used for normalization. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| `iou_lookup_table` | a vector containing the pairwise ious of boxes1 and boxes2. |

<br />