(self, masks, size)
Arguments:
                masks: Either torch.tensor of [num_instances, H, W]
                    or list of torch.tensors of [H, W] with num_instances elems,
                    or RLE (Run Length Encoding) - interpreted as list of dicts,
                    or BinaryMaskList.
                size: absolute image size, width first

            After initialization, a hard copy will be made, to leave the
            initializing source data intact.
Arguments:
                masks: Either torch.tensor of [num_instances, H, W]
                    or list of torch.tensors of [H, W] with num_instances elems,
                    or RLE (Run Length Encoding) - interpreted as list of dicts,
                    or BinaryMaskList.
                size: absolute image size, width first
Arguments : masks : Either torch . tensor of [ num_instances H W ] or list of torch . tensors of [ H W ] with num_instances elems or RLE ( Run Length Encoding ) - interpreted as list of dicts or BinaryMaskList . size : absolute image size width first
def __init__(self, masks, size):
        """
            Arguments:
                masks: Either torch.tensor of [num_instances, H, W]
                    or list of torch.tensors of [H, W] with num_instances elems,
                    or RLE (Run Length Encoding) - interpreted as list of dicts,
                    or BinaryMaskList.
                size: absolute image size, width first

            After initialization, a hard copy will be made, to leave the
            initializing source data intact.
        """

        if isinstance(masks, torch.Tensor):
            # The raw data representation is passed as argument
            masks = masks.clone()
        elif isinstance(masks, (list, tuple)):
            if isinstance(masks[0], torch.Tensor):
                masks = torch.stack(masks, dim=2).clone()
            elif isinstance(masks[0], dict) and "count" in masks[0]:
                # RLE interpretation

                masks = mask_utils
            else:
                RuntimeError(
                    "Type of `masks[0]` could not be interpreted: %s" % type(masks)
                )
        elif isinstance(masks, BinaryMaskList):
            # just hard copy the BinaryMaskList instance's underlying data
            masks = masks.masks.clone()
        else:
            RuntimeError(
                "Type of `masks` argument could not be interpreted:%s" % type(masks)
            )

        if len(masks.shape) == 2:
            # if only a single instance mask is passed
            masks = masks[None]

        assert len(masks.shape) == 3
        assert masks.shape[1] == size[1], "%s != %s" % (masks.shape[1], size[1])
        assert masks.shape[2] == size[0], "%s != %s" % (masks.shape[2], size[0])

        self.masks = masks
        self.size = tuple(size)
def __init__ ( self , masks , size ) : if isinstance ( masks , torch . Tensor ) : # The raw data representation is passed as argument masks = masks . clone ( ) elif isinstance ( masks , ( list , tuple ) ) : if isinstance ( masks [ 0 ] , torch . Tensor ) : masks = torch . stack ( masks , dim = 2 ) . clone ( ) elif isinstance ( masks [ 0 ] , dict ) and "count" in masks [ 0 ] : # RLE interpretation masks = mask_utils else : RuntimeError ( "Type of `masks[0]` could not be interpreted: %s" % type ( masks ) ) elif isinstance ( masks , BinaryMaskList ) : # just hard copy the BinaryMaskList instance's underlying data masks = masks . masks . clone ( ) else : RuntimeError ( "Type of `masks` argument could not be interpreted:%s" % type ( masks ) ) if len ( masks . shape ) == 2 : # if only a single instance mask is passed masks = masks [ None ] assert len ( masks . shape ) == 3 assert masks . shape [ 1 ] == size [ 1 ] , "%s != %s" % ( masks . shape [ 1 ] , size [ 1 ] ) assert masks . shape [ 2 ] == size [ 0 ] , "%s != %s" % ( masks . shape [ 2 ] , size [ 0 ] ) self . masks = masks self . size = tuple ( size )