diff --git a/test/test_transforms_v2_refactored.py b/test/test_transforms_v2_refactored.py index 59d30d482e2..41aa9b50c30 100644 --- a/test/test_transforms_v2_refactored.py +++ b/test/test_transforms_v2_refactored.py @@ -675,7 +675,7 @@ def test_functional_pil_antialias_warning(self): def test_max_size_error(self, size, make_input): if isinstance(size, int) or len(size) == 1: max_size = (size if isinstance(size, int) else size[0]) - 1 - match = "must be strictly greater than the requested size" + match = "must be strictly greater than or equal to the requested size" else: # value can be anything other than None max_size = -1 diff --git a/torchvision/transforms/functional.py b/torchvision/transforms/functional.py index 8517cf42599..348e43d0c79 100644 --- a/torchvision/transforms/functional.py +++ b/torchvision/transforms/functional.py @@ -374,9 +374,9 @@ def _compute_resized_output_size( new_short, new_long = requested_new_short, int(requested_new_short * long / short) if max_size is not None: - if max_size <= requested_new_short: + if max_size < requested_new_short: raise ValueError( - f"max_size = {max_size} must be strictly greater than the requested " + f"max_size = {max_size} must be strictly greater than or equal to the requested " f"size for the smaller edge size = {size}" ) if new_long > max_size: