Skip to content

Commit c9ac3a5

Browse files
authored
fix to_grayscale deprecation warning (#7702)
1 parent d814772 commit c9ac3a5

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

torchvision/transforms/v2/functional/_deprecated.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,10 @@
1010

1111
@torch.jit.unused
1212
def to_grayscale(inpt: PIL.Image.Image, num_output_channels: int = 1) -> PIL.Image.Image:
13-
call = ", num_output_channels=3" if num_output_channels == 3 else ""
14-
replacement = "convert_color_space(..., color_space=datapoints.ColorSpace.GRAY)"
15-
if num_output_channels == 3:
16-
replacement = f"convert_color_space({replacement}, color_space=datapoints.ColorSpace.RGB)"
1713
warnings.warn(
18-
f"The function `to_grayscale(...{call})` is deprecated in will be removed in a future release. "
19-
f"Instead, please use `{replacement}`.",
14+
"The function `to_grayscale` is deprecated in will be removed in a future release. "
15+
"Instead, please use `rgb_to_grayscale`.",
2016
)
21-
2217
return _F.to_grayscale(inpt, num_output_channels=num_output_channels)
2318

2419

0 commit comments

Comments
 (0)