def __getitem__(self, index): """ Args: index (int): Index Returns: tuple: (image, target) where target is index of the target class. """ img_path, target = self.data_label_dict[index] if not self.create_lmdb: img = Image.open(img_path) # img = img_path else: img = util._read_lmdb_img(self.env, img_path) target = int(target) if self.transform is not None: img = self.transform(img) if self.target_transform is not None: target = self.target_transform(target) return img, target
def __getitem__(self, item): img_path, target = self.samples[item] if not self.create_lmdb: img = Image.open(img_path) # img = img_path else: img = util._read_lmdb_img(self.env, img_path) target = int(target) if self.transform is not None: img = self.transform(img) if self.target_transform is not None: target = self.target_transform(target) return img, target
def __getitem__(self, index): """ Args: index (int): Index Returns: tuple: (image, target) where target is index of the target class. """ img_path = self.img_list[index] if not self.create_lmdb: img = Image.open(img_path) else: img = util._read_lmdb_img(self.env, img_path) # img, target = self.test_data[index], self.test_labels[index] if self.transform is not None: img = self.transform(img) return img
def __getitem__(self, index): """__getitem__ :param index: """ img_path, target_path = self.data_label_dict[index] assert img_path == target_path or target_path == -1, "{} is not the same as {}".format( img_path, target_path) if not self.create_lmdb: img = Image.open(os.path.join(self.images_base, img_path)) target = Image.open( os.path.join(self.annotations_base, target_path)) else: img, target = util._read_lmdb_img(self.env, img_path, is_seg=True) # img.save('test.png') # target.save('label.png') target = self.encode_segmap(np.asarray(target, dtype=np.uint8)) img, target = self.pair_transform(img, target) return img, target