nv-tlabs / GSCNN

Gated-Shape CNN for Semantic Segmentation (ICCV 2019)
https://nv-tlabs.github.io/GSCNN/
Other
915 stars 200 forks source link

Code error in GSCNN/datasets/edge_utils.py file? #19

Open lgqfhwy opened 4 years ago

lgqfhwy commented 4 years ago

Hello, I noticed in ./datasets/edge_utils.py file, the function mask_to_onehot may be error. the origin code is:

def mask_to_onehot(mask, num_classes):
    """
    Converts a segmentation mask (H,W) to (K,H,W) where the last dim is a one
    hot encoding vector
    """
    _mask = [mask == (i + 1) for i in range(num_classes)]
    return np.array(_mask).astype(np.uint8)

However, the content of mask should be in [0, 18], because you defined trainId in ./datasets/cityscapes_labels.py that trainId start from 0 and does not have 19. But the code mask == (i + 1) for i in range(num_classes) assume the content of mask in [1, 19], which does not correct. In my opinion, maybe you could change code :

def mask_to_onehot(mask, num_classes):
    """
    Converts a segmentation mask (H,W) to (K,H,W) where the last dim is a one
    hot encoding vector
    """
    _mask = [mask == i for i in range(num_classes)]
    return np.array(_mask).astype(np.uint8)

Thanks for your project!

tovacinni commented 4 years ago

Thanks for your interest in our work! Also sorry for the late reply, I've been quite busy lately. :(

That does seem like a bug however, but let me do a little bit more digging into the code to verify that it is in fact a bug. Perhaps there was a reason I wrote (i + 1) there...

Either way, thanks for pointing this out!

laojiangwei commented 4 years ago

That does seem like a bug however, but let me do a little bit more digging into the code to verify that it is in fact a bug. Perhaps there was a reason I wrote (i + 1) there...

hello,Have you found out the reason? Is this a bug?

JoJoNing25 commented 2 years ago

Hi, I am also confusing about this part, are there any updates about this issue?