I have been using your code for a while, and I noticed that object that have a inside ring, this inside ring gets ignored and only keeps the exterior contours.
Example
here is the submask generated for a category by your code
![image](https://user-images.githubusercontent.com/49212088/162347594-4b6123c6-b0b6-4048-a87c-7d9378c9e367.png)
after all the code is executed, I tried to reconstruct the mask from the segmentation generated using the following code
from pycocotools import mask as maskUtils
def annToRLE( ann, height, width):
"""
Convert annotation which can be polygons, uncompressed RLE to RLE.
:return: binary mask (numpy 2D array)
"""
segm = ann['segmentation']
if isinstance(segm, list):
# polygon -- a single object might consist of multiple parts
# we merge all parts into one mask rle code
rles = maskUtils.frPyObjects(segm, height, width)
rle = maskUtils.merge(rles)
elif isinstance(segm['counts'], list):
# uncompressed RLE
rle = maskUtils.frPyObjects(segm, height, width)
else:
# rle
rle = ann['segmentation']
return rle
def annToMask( ann, height, width):
"""
Convert annotation which can be polygons, uncompressed RLE, or RLE to binary mask.
:return: binary mask (numpy 2D array)
"""
rle = annToRLE(ann, height, width)
m = maskUtils.decode(rle)
return m