Error on transforms.RandomHorizontalFlip(p=0.5)

Hi, I’m a new fan of Pytorch and I’m trying to write some transforms on my dataset:

data_transforms = {
    'train': transforms.Compose([

but I get this error:

TypeError                                 Traceback (most recent call last)
<ipython-input-37-3baaf9faeff4> in <module>()
      6         transforms.Resize(256),
      7         transforms.RandomResizedCrop(224),
----> 8         transforms.RandomHorizontalFlip(0.5),
      9         transforms.RandomGrayscale(p=0.1),
     10         transforms.ColorJitter(brightness=0.1,constrast=0.1,saturation=0.1,hue=0.1),

TypeError: object() takes no parameters

Documentation though says that RandomHorizontalFlip takes one argument, the probability of flipping. Where’s my error?
(pytorch 0.3.1, torchvision 0.2.0)

EDIT: out of curiosity, I removed the problematic line and it throws an error now on the ColorJitter transform:

TypeError: __init__() got an unexpected keyword argument 'constrast'

Looks like a version problem but as I said before, upgrading does not change anything (“requirement already statisfied”). Any kind of hint would be greatly appreciated.

Change constrast to contrast.

1 Like

OMG, how embarrassing! :slight_smile:
I was so sure I had a problem with the version that I didn’t notice my typo, thanks Shani.
But the error with the argument to RandomHorizontalFlip remains…

The parameter was added to repo less than a month ago, and hasn’t been included in a release yet: You can remove the 0.5 for now.

1 Like

Thanks @SimonW for the info!