I’m trying to RandomRotate a greyscale images using transform. But it won’t let me!
can someone please help?
Note: It works fine with RGB based tensors
Code and error message below
> img = torch.randn(1,224,224)
> tfms = Compose([ToPILImage(),RandomRotation(20)])
TypeError: function takes exactly 1 argument (3 given)
It looks like this might be a bug in
torchvision.transforms.functional.rotate(), but you can work around it by defining your
RandomRotation transform like so:
RandomRotation(20, fill=(0,)). The problem is that by default
rotate() passes to PIL the three-channel fill value
(0, 0, 0) which of course breaks on one-channel images.
It looks like this was fixed in torchvision
master seven days ago.
it’s worth visiting new
same transforms as torchvision but for torch tensors