Skip to content

Bitmask decoding #1005

@noachr

Description

@noachr

Decoding thousands of bitmasks quickly can get slow with the current python loop based implementation. A numpy based encoding method has been added, but not yet a decoding method. Recommend adding the following to encord.common.bitmask_operations.bitmask_operations_numpy

def _rle_to_mask(rle: List[int], size: int) -> bytes:
    """COCO-compatible RLE to bitmask"""

    ones_zeros = np.arange(len(rle)) % 2
    res = np.repeat(ones_zeros, rle, dtype=np.uint8)
    if len(res) < size:
        res = np.pad(res, (0, size - len(res)), mode='constant', constant_values=0)
    return res.tobytes()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions