Skip to content

Update transforms for PIL deprecation #5898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 9, 2022
8 changes: 4 additions & 4 deletions torchvision/transforms/functional_pil.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ def hflip(img: Image.Image) -> Image.Image:
if not _is_pil_image(img):
raise TypeError(f"img should be PIL Image. Got {type(img)}")

return img.transpose(Image.FLIP_LEFT_RIGHT)
return img.transpose(Image.Transpose.FLIP_LEFT_RIGHT)


@torch.jit.unused
def vflip(img: Image.Image) -> Image.Image:
if not _is_pil_image(img):
raise TypeError(f"img should be PIL Image. Got {type(img)}")

return img.transpose(Image.FLIP_TOP_BOTTOM)
return img.transpose(Image.Transpose.FLIP_TOP_BOTTOM)


@torch.jit.unused
Expand Down Expand Up @@ -323,7 +323,7 @@ def affine(

output_size = img.size
opts = _parse_fill(fill, img)
return img.transform(output_size, Image.AFFINE, matrix, interpolation, **opts)
return img.transform(output_size, Image.Transform.AFFINE, matrix, interpolation, **opts)


@torch.jit.unused
Expand Down Expand Up @@ -356,7 +356,7 @@ def perspective(

opts = _parse_fill(fill, img)

return img.transform(img.size, Image.PERSPECTIVE, perspective_coeffs, interpolation, **opts)
return img.transform(img.size, Image.Transform.PERSPECTIVE, perspective_coeffs, interpolation, **opts)


@torch.jit.unused
Expand Down