Skip to content

Commit 3306159

Browse files
Yosua Michael Maranathafacebook-github-bot
authored andcommitted
[fbsync] Minor perf on saturation uint8 (#6940)
Reviewed By: NicolasHug Differential Revision: D41265192 fbshipit-source-id: 2f9b157934d97790082fac56bd300dc7be8f30cf
1 parent be42ae3 commit 3306159

File tree

1 file changed

+5
-1
lines changed
  • torchvision/prototype/transforms/functional

1 file changed

+5
-1
lines changed

torchvision/prototype/transforms/functional/_color.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ def adjust_saturation_image_tensor(image: torch.Tensor, saturation_factor: float
5353
if c == 1: # Match PIL behaviour
5454
return image
5555

56-
return _blend(image, _rgb_to_gray(image), saturation_factor)
56+
grayscale_image = _rgb_to_gray(image, cast=False)
57+
if not image.is_floating_point():
58+
grayscale_image = grayscale_image.floor_()
59+
60+
return _blend(image, grayscale_image, saturation_factor)
5761

5862

5963
adjust_saturation_image_pil = _FP.adjust_saturation

0 commit comments

Comments
 (0)