From 0f6b692437e45dc6d245c0dbeecb4964110d1072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=B6sel?= Date: Fri, 14 Jun 2019 18:20:49 +0200 Subject: [PATCH 1/2] Use joint transform in Cityscapes --- torchvision/datasets/cityscapes.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/torchvision/datasets/cityscapes.py b/torchvision/datasets/cityscapes.py index 4c801577a0d..ea1d0f757fd 100644 --- a/torchvision/datasets/cityscapes.py +++ b/torchvision/datasets/cityscapes.py @@ -95,8 +95,8 @@ class Cityscapes(VisionDataset): ] def __init__(self, root, split='train', mode='fine', target_type='instance', - transform=None, target_transform=None): - super(Cityscapes, self).__init__(root) + transform=None, target_transform=None, transforms=None): + super(Cityscapes, self).__init__(root, transforms, transform, target_transform) self.transform = transform self.target_transform = target_transform self.mode = 'gtFine' if mode == 'fine' else 'gtCoarse' @@ -163,11 +163,8 @@ def __getitem__(self, index): target = tuple(targets) if len(targets) > 1 else targets[0] - if self.transform: - image = self.transform(image) - - if self.target_transform: - target = self.target_transform(target) + if self.transforms is not None: + image, target = self.transforms(image, target) return image, target From f6fa580dc0de97f7d9d383d11928265f7ca428aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=B6sel?= Date: Thu, 20 Jun 2019 15:46:31 +0200 Subject: [PATCH 2/2] Add transforms doc --- torchvision/datasets/cityscapes.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/torchvision/datasets/cityscapes.py b/torchvision/datasets/cityscapes.py index ea1d0f757fd..08994f29915 100644 --- a/torchvision/datasets/cityscapes.py +++ b/torchvision/datasets/cityscapes.py @@ -21,6 +21,8 @@ class Cityscapes(VisionDataset): and returns a transformed version. E.g, ``transforms.RandomCrop`` target_transform (callable, optional): A function/transform that takes in the target and transforms it. + transforms (callable, optional): A function/transform that takes input sample and its target as entry + and returns a transformed version. Examples: