Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,7 @@ def test_random_crop():
assert result.size(1) == height + 1
assert result.size(2) == width + 1

t = transforms.RandomCrop(48)
t = transforms.RandomCrop(33)
img = torch.ones(3, 32, 32)
with pytest.raises(ValueError, match=r"Required crop size .+ is larger than input image size .+"):
t(img)
Expand Down
2 changes: 1 addition & 1 deletion torchvision/prototype/transforms/_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def _get_params(self, sample: Any) -> Dict[str, Any]:
if height < output_height:
height += 2 * (output_height - height)

if height + 1 < output_height or width + 1 < output_width:
if height < output_height or width < output_width:
raise ValueError(
f"Required crop size {(output_height, output_width)} is larger then input image size {(height, width)}"
)
Expand Down
2 changes: 1 addition & 1 deletion torchvision/transforms/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ def get_params(img: Tensor, output_size: Tuple[int, int]) -> Tuple[int, int, int
_, h, w = F.get_dimensions(img)
th, tw = output_size

if h + 1 < th or w + 1 < tw:
if h < th or w < tw:
raise ValueError(f"Required crop size {(th, tw)} is larger than input image size {(h, w)}")

if w == tw and h == th:
Expand Down