support using bitmask with LSJ
Summary:
`polygons_to_bitmask` fails with empty polygon which could happen with LSJ.
Pull Request resolved:
@@ -28,7 +28,9 @@ def polygons_to_bitmask(polygons: List[np.ndarray], height: int, width: int) ->
Returns:
ndarray: a bool mask of shape (height, width)
"""
- assert len(polygons) > 0, "COCOAPI does not support empty polygons"
+ if len(polygons) == 0:
+ # COCOAPI does not support empty polygons
+ return np.zeros((height, width)).astype(np.bool)
rles = mask_util.frPyObjects(polygons, height, width)
rle = mask_util.merge(rles)
return mask_util.decode(rle).astype(np.bool)
