'Load label image as 1 x height x width integer array of label indices.
The leading singleton dimension is required by the loss.
The full 400 labels are translated to the 59 class task labels.'

def load_label(self, idx):

    label_400 = scipy.io.loadmat('{}/trainval/{}.mat'.format(self.context_dir, idx))['LabelMap']
    label = np.zeros_like(label_400, dtype=np.uint8)
    for (idx, l) in enumerate(self.labels_59):
        idx_400 = (self.labels_400.index(l) + 1)
        label[(label_400 == idx_400)] = (idx + 1)
    label = label[np.newaxis, ...]
    return label
