File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
torchvision/prototype/transforms/functional Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -313,7 +313,8 @@ def posterize(inpt: features.InputTypeJIT, bits: int) -> features.InputTypeJIT:
313
313
314
314
315
315
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 :
317
318
raise TypeError (f"Threshold should be less or equal the maximum value of the dtype, but got { threshold } " )
318
319
319
320
return torch .where (image >= threshold , invert_image_tensor (image ), image )
@@ -466,7 +467,7 @@ def invert_image_tensor(image: torch.Tensor) -> torch.Tensor:
466
467
if image .dtype == torch .uint8 :
467
468
return image .bitwise_not ()
468
469
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]
470
471
471
472
472
473
invert_image_pil = _FP .invert
You can’t perform that action at this time.
0 commit comments