Fail with Transfer Learning with Unet Multiclass, Color Images, Semantic Segmentation

UPDATE

I decided to go back to what works and do small steps from there. I went back to a working version of the original unmodified unet_isbi notebook.

Then, I made by dataset have the same specs as the ISBI dataset: all images are grayscale 512X512, and the masks have label values of 0 for background, and value 255 for foreground!!!

This experiment gave be excellent results, all worked!!! But why?? AS you explained it must be labels 0 and 1, as described in the specs??

data_class_config {
  target_classes {
    name: "foreground"
    mapping_class: "foreground"
    label_id: 0
  }
  target_classes {
    name: "background"
    mapping_class: "background"
    label_id: 1 "<<<-------  Actual value in the mask is 255!!!!!!!!!
  }
}

AND, when I change the masks to 0 for background and 1 for foreground, the training now fails with nan evaluations.

The original masks for the ISBI dataset are 0 and 255. Despite the labels defined as 0 and 1 in the original example. If I modify those masks to 0 and 1, I get a bad nan evaluation.

I have no idea what to do to go from a 0, 255 binary segmentation to a 0, 1, 2, 3, 4 multiclass segmentation. Please help!

I attach one of the original ISBI masks. Here the values are 0 or 255!