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

fix to_grayscale deprecation warning (#7702)

parent d814772e
......@@ -10,15 +10,10 @@ 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:
call = ", num_output_channels=3" if num_output_channels == 3 else ""
replacement = "convert_color_space(..., color_space=datapoints.ColorSpace.GRAY)"
if num_output_channels == 3:
replacement = f"convert_color_space({replacement}, color_space=datapoints.ColorSpace.RGB)"
warnings.warn(
f"The function `to_grayscale(...{call})` is deprecated in will be removed in a future release. "
f"Instead, please use `{replacement}`.",
"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)
......
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