Skip to content

Commit a05a13b

Browse files
NicolasHugfacebook-github-bot
authored andcommitted
[fbsync] fix to_grayscale deprecation warning (#7702)
Reviewed By: vmoens Differential Revision: D47186572 fbshipit-source-id: 3818db074027c4643f33255ddd1df90f936d15e9
1 parent e5ab448 commit a05a13b

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)