tensorflow / models

Models and examples built with TensorFlow
Other
77.16k stars 45.75k forks source link

[Deeplab] Label index does not match with code for dataset ADE20k? #4067

Open haichaoyu opened 6 years ago

haichaoyu commented 6 years ago

Hello,

I tried to fine-tune Deeplab v3+ on ADE20k. I just found that in ADE20k, ignore_label is set to 0, while in the code the ignore label is set to 255. Directly setting ignore_label to 0 in code might not work because the label index counts from 0.

Just want to confirm that this "problem" exists. Please correct me if I a wrong.

Thanks.

aquariusjay commented 6 years ago

Hi haichaoyu,

Each dataset has its own labeling convention. For example, Cityscapes has different training label vs. evaluation label. The original codebase does not include ADE20K support (i.e., you may need to handle ADE20K's labeling convention by yourself). The instruction about ADE20K is checked-in by @walkerlala, who may provide some feedback. We will take a careful look about ADE20K support in the future.

Thanks,

walkerlala commented 6 years ago

@haichaoyu Can you provide any reference for that (ie, ignore_label=0)? I would like to have further investigation.

And, @aquariusjay is it possible for me to subscribe to issues which are tagged with [deeplab] on GitHub? That will enable to keep track on interesting deeplab-related issues.

haichaoyu commented 6 years ago

@walkerlala Hello,

Sorry for my late reply. Please refer to Ade20k dev kit and search 'ignore'. Also we can also find some hints in the evaluation code here. I also checked the raw annotation images. The intensities range from 0 to 150.

To make things easier (try to avoid modifying the deeplab code), currently I choose to pre-process the ade20k label images like this:

label[label == 0] = 255
label = label  - 1
label[label==254] = 255

Haichao

bleedingfight commented 6 years ago

@haichaoyu Thanks for your share,But I don't understand your said,I thinks ingore_label=255 stand dor the mask image's pixle is 255 the pixel will not be deal with,For my simple task have object and background,I set object label in mask is 1,background label is 0,if I set ingore_label=255 it will not effect my task.Can you tell me is my opinion right or not?

in your example,I think the labels is 0-150,0 stand for background,so I don't understand your code.Can you tell me more detail about ignore_label?thanks for your help.

haichaoyu commented 6 years ago

Hello @bleedingfight,

My task: scene parsing. No background classes. Wall, sky, sea etc. are all what the model should care. My dataset: In ADE20K dataset, pixels are labeled with [0, 151]. 0 stands for "others" which include trivial things such as tomb. Such regions are ignored in training and not evaluated at all in testing. Therefore, I replace 0 with 255 to adapt to the Deeplab code.

You task: If your model is required to classify "background" as "background", i.e., background area is also evaluated, 0-region should not be regarded as ignore_mask. Maybe things that do not exist in the class set and you do not want to put it in background class should be set as ignore_label.

Hope it helps.

Thanks, Haichao

bleedingfight commented 6 years ago

@haichaoyu thanks for your help,In your sence,you set 0-151 as your mask's label,0 stand for others,I your sence,you didn't need others,so you set it ignore,In your deeplabv3+,0 label will be ignore,so in your network 1-151label will be used.If I am understanding is right?but your classes is 150,even so your classes labels is 1-151,you will have 151 classes,why you have one another classes?

In my task I want use it in image to get lane's pixel,Should I set backgroud as others like your(olny one class) or I set it to as background to from a image get background and lane(two classes)?

Eavis commented 5 years ago

Hi @walkerlala, ADE20K dataset description in https://github.com/tensorflow/models/blob/master/research/deeplab/datasets/segmentation_dataset.py set ignore_label = 0 I think the dataset segmentation mask set background as 0 as well. I also see post suggest that ignore_label should be different from background label. Is that correct? I am quite confused in this case.

My task is to decrease the number of categories in the segmentation masks, so I only keep a few categories within 150 and set all others as background(0) Should I set ignore_label=0?

Thanks!

marlexct commented 4 years ago

Hi @walkerlala, ADE20K dataset description in https://github.com/tensorflow/models/blob/master/research/deeplab/datasets/segmentation_dataset.py set ignore_label = 0 I think the dataset segmentation mask set background as 0 as well. I also see post suggest that ignore_label should be different from background label. Is that correct? I am quite confused in this case.

My task is to decrease the number of categories in the segmentation masks, so I only keep a few categories within 150 and set all others as background(0) Should I set ignore_label=0?

Thanks!

Hi, did you get an answer? I am trying to retrain Deeplab with ade20k, I did it with ignore_label = 0, but during training the loss just felt down oscillating between 0.2 and 0.3, then during evaluation I had bad results, miou very low =(, also vis.py brought some results, it wasn't the best.