1: rle to mask
If it is in rle format, it is a dictionary containing two keys, size and counts, in the form of:
rle = {'size':[512,512],'counts': 'A very long string of garbled characters'}
How to convert it into a trainable mask at this time?
Very simple, import pycocotools.mask as mask_utils:
Directly use the following command to get the binary mask
a = np.array(mask_util.decode(rle), dtype=np.float32)
2: mask to rle
Reference from: Three representations of Segmentaion tags: poly, mask, rle_Adenialzz's Blog - CSDN Blog
————————————————
Original link: https://blog.csdn.net/xx_xjm/article/details/126608359