Pass transformation to Cityscapes dataset

Hi, greetings, i want to transform both image and mask. I tried this way

from torchvision.datasets import Cityscapes
from torchvision import transforms as T
dataset = Cityscapes('../data/', split='val', mode='fine',

but it gives me following error

TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_348578/ in <module>
      7                      target_type='semantic',transforms=aug)
----> 9 out= dataset[2]
     10 print(out[0].size,out[1].size)
     11 #img,seg=augment(np.array(out[0]),np.array(out[1]))

~/venv/lib/python3.8/site-packages/torchvision/datasets/ in __getitem__(self, index)
    191         if self.transforms is not None:
--> 192             image, target = self.transforms(image, target)
    194         return image, target

TypeError: __call__() takes 2 positional arguments but 3 were given

A little late, but maybe someone will read it. You could try removing the keyword transforms=aug. Instead try Cityscapes(...., transform=aug, target_transform=aug). Note that there are transform and transforms as two different keywords.

If that doesnt work, you could try removing aug=T.Compose(...), and instead create a class.

class CityTransform:
    def __call__(self, image, target):
        image = *your transformation*  (image)
        target = *your transformation* (target)
        return image, target

then insert it

dataset = Cityscapes('../data/', split='val', mode='fine',