Skip to content

Commit ba11b0b

Browse files
datumboxfacebook-github-bot
authored andcommitted
[fbsync] revert 255 -> max_value fix (#6826)
Reviewed By: YosuaMichael Differential Revision: D40722909 fbshipit-source-id: 8086872b1eda8e66b7d4c10da0b284b13c657e76
1 parent 33316e8 commit ba11b0b

File tree

1 file changed

+3
-2
lines changed
  • torchvision/prototype/transforms/functional

1 file changed

+3
-2
lines changed

torchvision/prototype/transforms/functional/_color.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ def posterize(inpt: features.InputTypeJIT, bits: int) -> features.InputTypeJIT:
313313

314314

315315
def solarize_image_tensor(image: torch.Tensor, threshold: float) -> torch.Tensor:
316-
if threshold > _FT._max_value(image.dtype):
316+
bound = 1 if image.is_floating_point() else 255
317+
if threshold > bound:
317318
raise TypeError(f"Threshold should be less or equal the maximum value of the dtype, but got {threshold}")
318319

319320
return torch.where(image >= threshold, invert_image_tensor(image), image)
@@ -466,7 +467,7 @@ def invert_image_tensor(image: torch.Tensor) -> torch.Tensor:
466467
if image.dtype == torch.uint8:
467468
return image.bitwise_not()
468469
else:
469-
return _FT._max_value(image.dtype) - image # type: ignore[no-any-return]
470+
return (1 if image.is_floating_point() else 255) - image # type: ignore[no-any-return]
470471

471472

472473
invert_image_pil = _FP.invert

0 commit comments

Comments
 (0)