Skip to content

Commit 0cc9080

Browse files
authored
Minor perf on saturation uint8 (#6940)
1 parent 98f1a40 commit 0cc9080

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)