pytorchcocotools.internal.mask_api.rle_encode
source module pytorchcocotools.internal.mask_api.rle_encode
Functions
-
rleEncode — Encode binary masks using RLE.
source rleEncode(mask: Annotated[tv.Mask, 'N H W'], *, device: TorchDevice | None = None, requires_grad: bool = False) → RLEs
Encode binary masks using RLE.
Uses vectorized transition detection and per-mask grouping via pre-sorted indices to avoid repeated boolean scans.
Parameters
-
mask : Annotated[tv.Mask, 'N H W'] — The binary masks to encode.
-
device : TorchDevice | None — The desired device of the bounding boxes.
-
requires_grad : bool — Whether the bounding boxes require gradients.
Returns
-
RLEs — Run length encoded masks.