<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/spatial_transform_ops.py#L447-L525) |

Crop masks in target boxes.

    tfm.vision.spatial_transform_ops.crop_mask_in_target_box(
        masks: tf.Tensor,
        boxes: tf.Tensor,
        target_boxes: tf.Tensor,
        output_size: int,
        sample_offset: float = 0.0,
        use_einsum: bool = True
    ) -> tf.Tensor

<br />

<br />

<br />

| ## Args ||
|---|---|
| `masks` | A tensor with a shape of \[batch_size, num_masks, height, width\]. |
| `boxes` | a float tensor representing box cooridnates that tightly enclose masks with a shape of \[batch_size, num_masks, 4\] in un-normalized coordinates. A box is represented by \[ymin, xmin, ymax, xmax\]. |
| `target_boxes` | a float tensor representing target box cooridnates for masks with a shape of \[batch_size, num_masks, 4\] in un-normalized coordinates. A box is represented by \[ymin, xmin, ymax, xmax\]. |
| `output_size` | A scalar to indicate the output crop size. It currently only supports to output a square shape outputs. |
| `sample_offset` | a float number in \[0, 1\] indicates the subpixel sample offset from grid point. |
| `use_einsum` | Use einsum to replace gather in selective_crop_and_resize. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A 4-D tensor representing feature crop of shape \[batch_size, num_boxes, output_size, output_size\]. ||

<br />