Hi,
I’m using a set of transformers defined like this for the train_dataset:
def train_transformer():
    """
    Train transformer.
    :return: a transformer
    """
    transformer = transforms.Compose([
        transforms.RandomCrop(size=(256, 256)),  # randomly crop am image
        transforms.RandomRotation(degrees=5),    # randomly rotate image
        transforms.RandomHorizontalFlip(),  # randomly flip image vertically
        transforms.RandomVerticalFlip(),    # randomly flip image horizontally
        transforms.ToTensor()])  # transform it into a torch tensor

    return transformer

When I try to use it just before returning the sample (dict containing ‘image’ and ‘mask’),

        sample = {'image': image,
                  'mask': mask}

        if self.transform:
            sample = self.transform(sample)

        return sample

I get the following error:
AttributeError: Traceback (most recent call last):
  File "/tool/python/conda/env/gis36/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 57, in _worker_loop
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "/tool/python/conda/env/gis36/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 57, in <listcomp>
    samples = collate_fn([dataset[i] for i in batch_indices])
  File "/project/geospatial/application/cs230-sifd/source/step/loader/sifd/dataset.py", line 375, in __getitem__
    sample = self.transform(sample)
  File "/tool/python/conda/env/gis36/lib/python3.6/site-packages/torchvision-0.2.1-py3.6.egg/torchvision/transforms/transforms.py", line 49, in __call__
    img = t(img)
  File "/tool/python/conda/env/gis36/lib/python3.6/site-packages/torchvision-0.2.1-py3.6.egg/torchvision/transforms/transforms.py", line 421, in __call__
    i, j, h, w = self.get_params(img, self.size)
  File "/tool/python/conda/env/gis36/lib/python3.6/site-packages/torchvision-0.2.1-py3.6.egg/torchvision/transforms/transforms.py", line 394, in get_params
    w, h = img.size
AttributeError: 'dict' object has no attribute 'size'