def __getitem__(self, index): path = self.imgs[index] img = Image.open(path) ann_path = path.replace(self.split, self.split + 'annot').replace('.jpg', '.png') target = Image.open(ann_path) if self.joint_transform_img is not None: [img] = self.joint_transform_img([img]) if self.transform is not None: img = self.transform(img) transform_maks = transforms.Compose([joint_transforms.MaskResize(112)]) [target_c] = transform_maks([target]) target = self.target_transform(target_c) return img, target
def __getitem__(self, index): path = self.imgs[index] img = Image.open(path) ann_path = path.replace(self.split, self.split + 'annot') target = Image.open(ann_path) if self.joint_transform_img is not None: [img, target] = self.joint_transform_img([img, target]) if self.transform is not None: img = self.transform(img) targets = [] if self.mask_size_list is not None: for size in self.mask_size_list: transform_maks = transforms.Compose([joint_transforms.MaskResize(size)]) [target_c] = transform_maks([target]) targets.append(self.target_transform(target_c)) return img, targets
def __getitem__(self, index): path = self.imgs[index] # print(path) img = Image.open(path) # gt ann_path = path.replace(self.split, self.split + 'annot') target = Image.open(ann_path) target = target.point(lambda i: i * 255) # context image cont_path = path.replace(self.split, self.split + 'cont') img_cont = Image.open(cont_path) # box fomask_path = path.replace(self.split, self.split + 'fomask') fomask = Image.open(fomask_path) # box context comask_path = path.replace(self.split, self.split + 'comask') comask = Image.open(comask_path) if self.joint_transform is not None: img, target, img_cont, fomask, comask = self.joint_transform( [img, target, img_cont, fomask, comask]) if self.transform is not None: img = self.transform(img) img_cont = self.transform(img_cont) fomask = self.transform(fomask) comask = self.transform(comask) targets = [] if self.mask_size_list is not None: for size in self.mask_size_list: transform_maks = transforms.Compose( [joint_transforms.MaskResize(size)]) [target_c] = transform_maks([target]) targets.append(self.target_transform(target_c)) return img, targets, img_cont, fomask, comask