Ejemplo n.º 1
0
    def test_read_label(self):
        if self.dtype == np.int32:
            img = read_label(self.file)
        else:
            img = read_label(self.file, dtype=self.dtype)

        self.assertEqual(img.shape, self.size)
        self.assertEqual(img.dtype, self.dtype)

        if self.format in {'bmp', 'png'}:
            np.testing.assert_equal(img, self.img.astype(self.dtype))
 def _load_label_inst(self, data_id):
     label_file = os.path.join(self.data_dir, 'SegmentationClass',
                               data_id + '.png')
     inst_file = os.path.join(self.data_dir, 'SegmentationObject',
                              data_id + '.png')
     label_img = read_label(label_file, dtype=np.int32)
     label_img[label_img == 255] = -1
     inst_img = read_label(inst_file, dtype=np.int32)
     inst_img[inst_img == 0] = -1
     inst_img[inst_img == 255] = -1
     return label_img, inst_img
 def _get_label(self, i):
     label_path = os.path.join(self.data_dir, 'SegmentationClass',
                               self.ids[i] + '.png')
     label = read_label(label_path, dtype=np.int32)
     label[label == 255] = -1
     # (1, H, W) -> (H, W)
     return label
 def _get_label(self, i):
     label_path = os.path.join(
         self.data_dir, self.loader.get_label_path(i))
     label = read_label(label_path, dtype=np.int32)
     label[label == 255] = -1
     label = self.loader.ade_label_to_voc_label(label)
     # (1, H, W) -> (H, W)
     return label
Ejemplo n.º 5
0
 def _get_label(self, i):
     label_orig = read_label(self.label_paths[i], dtype=np.int32)
     if self.ignore_labels:
         label_out = np.ones(label_orig.shape, dtype=np.int32) * -1
         for label in cityscapes_labels:
             if not label.ignoreInEval:
                 label_out[label_orig == label.id] = label.trainId
     else:
         label_out = label_orig
     return label_out
Ejemplo n.º 6
0
 def _get_prob_map(self, i):
     prob_map = utils.read_label(self.prob_map_paths[i], dtype=np.uint8)
     prob_map = prob_map.astype(np.float32) / 255  # [0, 255] -> [0, 1]
     return prob_map
Ejemplo n.º 7
0
 def test_read_label_mutable(self):
     img = read_label(self.file, dtype=self.dtype)
     img[:] = 0
     np.testing.assert_equal(img, 0)
 def _get_label(self, i):
     label = read_label(self.label_paths[i], dtype=np.int32)
     # [-1, n_class - 1]
     return label - 1
Ejemplo n.º 9
0
 def _get_label(self, i):
     _, label_path = self.paths[i]
     label = read_label(label_path, dtype=np.int32)
     # Label id 11 is for unlabeled pixels.
     label[label == 11] = -1
     return label