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()
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