Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use joint transform in Cityscapes #1024

Merged
merged 2 commits into from
Jun 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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