nutonomy / nuscenes-devkit

The devkit of the nuScenes dataset.
https://www.nuScenes.org
Other
2.24k stars 617 forks source link

Got 0xC0000005 when decode segmentation mask using pycocotools #898

Closed Forever518 closed 1 year ago

Forever518 commented 1 year ago

Hello, I am trying to decode the mask annotation from object_ann.json file using pycocotools. However I got error no matter what environment I used.

I am asking the question here just because it works on the samples from pycocotools itself. How can I decode it correctly?

Here is my code:


import pycocotools.mask
import numpy as np

before = np.random.rand(100, 100, 1) > 0.5
foo = pycocotools.mask.encode(np.asarray(before, order="F"))

# test pycocotools itself
print(foo)
after = pycocotools.mask.decode(foo)
print(after)

# test dataset's annotation
foo = [{'size': [900, 1600], 'counts': b'bWxcYzA3a2swO0U2SjJOM00yMTJNNExPMk4xMDBPMk4xTzEwM0xlMFtPMTBPMDFPMTBPMDEwTzAxMDBPTTNLNko1SjdKNkU7Qj5CPkE/Qj5CPUk4TzEwME8xTzFPMTAwTzAwMTFPMDAwMDAwMDAwMDBPMTAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDFPMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDFOMTAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDFPMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDFPMDAwMDAwMDFPMDAwMDAwMDAwMDAwMDAwMDEwTzAwMDAwMDAwMDAwMDAwMDAwMU8wMDAwMDAwMDAxTzAwMDAwMU8wMDAwMDAwMDAwMDAwMDAwMU8wMDAxME8wMDFPMDAwMDFPMDAxTzAwMDAxTzFPMU8yTjEwME8xTzFPMU8xTzAwMU9aTl5ZT2tNYGYwYDBWW09BZmgwMU0zSTZDPTBPMU8xMDBPMDAyTjEwME40TDRMNEtUXWtiMA=='}]

after = pycocotools.mask.decode(foo)  # got error here
print(after)
whyekit-motional commented 1 year ago

@Forever518 pls refer to mask_decode for an example regarding decoding the segmentation masks in nuImages: https://github.com/nutonomy/nuscenes-devkit/blob/9bc2f9e74d8a3dd27ef6ce83336508dd8926f867/python-sdk/nuimages/utils/utils.py#L35-L45