Пример #1
0
    def __getitem__(self, index):
        datafiles = self.files[index]
        image = Image.open(datafiles["img"]).convert('RGB')
        label = Image.open(datafiles["label"])
        size = np.asarray(image).shape
        name = datafiles["name"]
        composed_transforms = transforms.Compose([
            tr.Normalize(mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)),
            tr.ToTensor()])
        sample = {'image': image, 'label': label}
        sampled = composed_transforms(sample)
        image, label = sampled['image'], sampled['label']

        return image, label, np.array(size), name
Пример #2
0
    def __getitem__(self, index):
        datafiles = self.files[index]
        image = Image.open(datafiles["img"]).convert('RGB')
        label = Image.open(datafiles["label"])
        size = np.asarray(image).shape
        name = datafiles["name"]

        composed_transforms = transforms.Compose([
            tr.RandomHorizontalFlip(),
            # tr.RandomRotate(180),
            tr.RandomScaleCrop(base_size=self.base_size, crop_size=self.crop_size, fill=255),
            tr.RandomGaussianBlur(),
            tr.Normalize(mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)),
            tr.ToTensor()])
        sample = {'image': image, 'label': label}
        sampled = composed_transforms(sample)
        image, label = sampled['image'], sampled['label']
        return image, label, np.array(size), name