Closed leandro-svg closed 1 year ago
Hey @leandro-svg, thanks for the question!
We recommend using Scalabel's utilities function to convert RLE to bit masks. You could find an example used in code below: https://github.com/SysCV/shift-dev/blob/c54c1b0746ebb485779177fd7932bb0325f79bdf/shift_dev/vis/utils.py#L480
Ok, I indeed didn't see those codes. Thank you!
Dear authors, Thank you for your work.
Would you mind explain to me how would we go from the RLE bitmask 'counts' to a binary mask in the instance segmentation labels ? The RLE shouldn't be a list of integers ?
FYI, I have used this following piece of code to go from RLE to binary mask :
def rleToMask(img, rleString,height,width): rows,cols = height,width rleNumbers = [int(numstring) for numstring in rleString.split(' ')] rlePairs = np.array(rleNumbers).reshape(-1,2) for index,length in rlePairs: index -= 1 img[index:index+length] = 255 img = img.reshape(cols,rows) img = img.T return img
The returned error is the following :
I have also tried the _mask.decode function from pycocotools but it returns me a zeros-bitmask :
def decode(rleObjs): if type(rleObjs) == list: return _mask.decode(rleObjs) else: return _mask.decode([rleObjs])[:,:,0] mask = (mask_utils.decode(dict(rle)) > 0).astype( np.uint8, copy=False )
Looking forward to hear from you soon.