From 93672872c6f54aa996e945c67d0f3f61ac3e3597 Mon Sep 17 00:00:00 2001 From: Yonghye Kwon Date: Sat, 23 Sep 2023 17:08:02 +0900 Subject: [PATCH 1/2] Update error condition for 'max_size' in '_compute_resized_output_size' --- torchvision/transforms/functional.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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: From db49103f7c8e508bc26d499fa4fe549d695ce32e Mon Sep 17 00:00:00 2001 From: Yonghye Kwon Date: Sun, 24 Sep 2023 22:49:30 +0900 Subject: [PATCH 2/2] update match via fixing error message --- test/test_transforms_v2_refactored.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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