Converts COCO-style polygon segmentation annotations from target $segmentation variable into boolean mask tensors as target $masks variable in order to ease later-on visualisation via draw_segmentation_mask(). Use as target_transform in coco_segmentation_dataset().

target_transform_coco_masks(y)

# S3 method for class 'segmentation_target'
target_transform_coco_masks(y)

Arguments

y

a segmentation_target, as returned by the .getitem() method of coco_segmentation_dataset(), or a bare list with names segmentation, image_height, image_width.

Value

Modified y list with added masks field (N, H, W) boolean tensor, N being the number of classes.

See also

Other target_transforms_segmentation: target_transform_trimap_masks()

Examples

if (FALSE) { # \dontrun{
ds <- coco_segmentation_dataset(
  root = "data",
  target_transform = target_transform_coco_masks
)
item <- ds[1]
draw_segmentation_masks(item)
} # }