def load_label(self, filename): """ Load a label image """ image = PIL.Image.open(filename) if self.userdata['colormap_method'] == "label": if image.mode not in ['P', 'L', '1']: raise ValueError("Labels are expected to be single-channel (paletted or " " grayscale) images - %s mode is '%s'" % (filename, image.mode)) else: if image.mode not in ['RGB']: raise ValueError("Labels are expected to be RGB images - %s mode is '%s'" % (filename, image.mode)) image = image.quantize(palette=self.palette_img) return image
def load_label(self, filename): """ Load a label image """ image = PIL.Image.open(filename) if self.userdata['colormap_method'] == "label": if image.mode not in ['P', 'L', '1']: raise ValueError( "Labels are expected to be single-channel (paletted or " " grayscale) images - %s mode is '%s'" % (filename, image.mode)) else: if image.mode not in ['RGB']: raise ValueError( "Labels are expected to be RGB images - %s mode is '%s'" % (filename, image.mode)) image = image.quantize(palette=self.palette_img) return image
def load_label(self, filename): """ Load a label image """ image = PIL.Image.open(filename) if self.userdata['colormap_method'] == "label": if image.mode not in ['P', 'L', '1']: raise ValueError("Labels are expected to be single-channel (paletted or " " grayscale) images - %s mode is '%s'. If your labels are " "RGB images then set the 'Color Map Specification' field " "to 'from text file' and provide a color map text file." % (filename, image.mode)) else: if image.mode not in ['RGB']: raise ValueError("Labels are expected to be RGB images - %s mode is '%s'. " "If your labels are palette or grayscale images then set " "the 'Color Map Specification' field to 'from label image'." % (filename, image.mode)) image = image.quantize(palette=self.palette_img) return image