DrSleep / light-weight-refinenet

Light-Weight RefineNet for Real-Time Semantic Segmentation
Other
739 stars 164 forks source link

class dictionary #63

Closed Frozenheart1998 closed 3 years ago

Frozenheart1998 commented 3 years ago

Hi! I used the scripts in the colab to infer nyuv2 dataset (https://colab.research.google.com/drive/1S5wvuukFM6GTLbj8VxZFdkFn2jhdhiES). I also noticed the label dictionary in #16. However, default results I got from colab are colored labels which I cannot relate rgb information to label indexes. Could you provide a 40-class dictionary with corresponding colors?

DrSleep commented 3 years ago

https://github.com/DrSleep/light-weight-refinenet/blob/master/utils/cmap.npy is the colourmap I am using

If you want to see the network's outputs before colouring, simply comment out segm = cmap[segm.argmax(axis=2).astype(np.uint8)] in the notebook

hyclover commented 3 years ago

I recently loaded the cmap.npy through numpy tool. I found that it was an array of form (256,3). However, should it be an array of form (40, 3) since it is the colourmap ? I am curious about what "256" means ?

DrSleep commented 3 years ago

256 just means that there are 256 different colours available. the NYUD colours only use the first 40 values; VOC -- 20 and etc.

what happens is the network predicts indices from 0 to num_classes, then each predicted index is replaced by a corresponding RGB vector from the cmap file; say, your network predicted indices [2, 3, 1] and the colourmap is [[0, 0, 0], [0, 0, 1], [0, 0, 2], [0, 0, 3]], then the output would be [[0, 0, 2], [0, 0, 3], [0, 0, 1]]

hope that makes it clearer

Frozenheart1998 commented 3 years ago

Thank you for your helping!