Unverified Commit 1c1cd68b authored by Philip Meier's avatar Philip Meier Committed by GitHub
Browse files

undeprecate to_grayscale (#7707)

parent 25c8a3a2
......@@ -539,6 +539,7 @@ class TestDispatchers:
(F.to_pil_image, F.to_image_pil),
(F.elastic_transform, F.elastic),
(F.convert_image_dtype, F.convert_dtype_image_tensor),
(F.to_grayscale, F.rgb_to_grayscale),
]
],
)
......
......@@ -1248,7 +1248,7 @@ def affine(
# Looks like to_grayscale() is a stand-alone functional that is never called
# from the transform classes. Perhaps it's still here for BC? I can't be
# bothered to dig. Anyway, this can be deprecated as we migrate to V2.
# bothered to dig.
@torch.jit.unused
def to_grayscale(img, num_output_channels=1):
"""Convert PIL image of any mode (RGB, HSV, LAB, etc) to grayscale version of image.
......
......@@ -76,6 +76,7 @@ from ._color import (
solarize_image_pil,
solarize_image_tensor,
solarize_video,
to_grayscale,
)
from ._geometry import (
affine,
......@@ -168,4 +169,4 @@ from ._misc import (
from ._temporal import uniform_temporal_subsample, uniform_temporal_subsample_video
from ._type_conversion import pil_to_tensor, to_image_pil, to_image_tensor, to_pil_image
from ._deprecated import get_image_size, to_grayscale, to_tensor # usort: skip
from ._deprecated import get_image_size, to_tensor # usort: skip
......@@ -56,6 +56,11 @@ def rgb_to_grayscale(
)
# `to_grayscale` actually predates `rgb_to_grayscale` in v1, but only handles PIL images. Since `rgb_to_grayscale` is a
# superset in terms of functionality and has the same signature, we alias here to avoid disruption.
to_grayscale = rgb_to_grayscale
def _blend(image1: torch.Tensor, image2: torch.Tensor, ratio: float) -> torch.Tensor:
ratio = float(ratio)
fp = image1.is_floating_point()
......
import warnings
from typing import Any, List, Union
import PIL.Image
import torch
from torchvision import datapoints
from torchvision.transforms import functional as _F
@torch.jit.unused
def to_grayscale(inpt: PIL.Image.Image, num_output_channels: int = 1) -> PIL.Image.Image:
warnings.warn(
"The function `to_grayscale` is deprecated in will be removed in a future release. "
"Instead, please use `rgb_to_grayscale`.",
)
return _F.to_grayscale(inpt, num_output_channels=num_output_channels)
@torch.jit.unused
def to_tensor(inpt: Any) -> torch.Tensor:
warnings.warn(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment