From fd002187829c7a943d5c2ca3f8560710a9f00a1d Mon Sep 17 00:00:00 2001 From: Hao Date: Mon, 20 Jan 2020 16:28:49 +1300 Subject: [PATCH] make "rotate" function support grayscale images fix issue #1776 --- torchvision/transforms/functional.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchvision/transforms/functional.py b/torchvision/transforms/functional.py index 8ae75f84c5b..c1a350955db 100644 --- a/torchvision/transforms/functional.py +++ b/torchvision/transforms/functional.py @@ -724,7 +724,7 @@ def rotate(img, angle, resample=False, expand=False, center=None, fill=0): raise TypeError('img should be PIL Image. Got {}'.format(type(img))) if isinstance(fill, int): - fill = tuple([fill] * 3) + fill = tuple([fill] * len(img.getbands())) return img.rotate(angle, resample, expand, center, fillcolor=fill)