Skip to content

Commit

Permalink
Use joint transform in Cityscapes (#1024)
Browse files Browse the repository at this point in the history
* Use joint transform in Cityscapes

* Add transforms doc
  • Loading branch information
TheCodez authored and fmassa committed Jun 20, 2019
1 parent ae2cb6e commit ec20315
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions torchvision/datasets/cityscapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -95,8 +97,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'
Expand Down Expand Up @@ -163,11 +165,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

Expand Down

0 comments on commit ec20315

Please sign in to comment.