Skip to content

Commit c37991a

Browse files
committed
perspective verified
1 parent 22068c7 commit c37991a

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

test/test_transforms_v2.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5256,11 +5256,8 @@ def test_image_functional_correctness(self, coefficients, interpolation, fill, m
52565256
image, startpoints=None, endpoints=None, coefficients=coefficients, interpolation=interpolation, fill=fill
52575257
)
52585258
if make_input is make_image_cvcuda:
5259-
actual = F.cvcuda_to_tensor(actual).to(device="cpu")
5260-
actual = actual.squeeze(0)
5261-
# drop the batch dimension
5262-
image = F.cvcuda_to_tensor(image).to(device="cpu")
5263-
image = image.squeeze(0)
5259+
actual = cvcuda_to_pil_compatible_tensor(actual)
5260+
image = cvcuda_to_pil_compatible_tensor(image)
52645261

52655262
expected = F.to_image(
52665263
F.perspective(
@@ -5286,7 +5283,7 @@ def test_image_functional_correctness(self, coefficients, interpolation, fill, m
52865283
# visually the results are the same on real images,
52875284
# realistically, the diff is not visible to the human eye
52885285
tolerance = 255 if interpolation is transforms.InterpolationMode.NEAREST else 125
5289-
torch.testing.assert_close(actual, expected, rtol=0, atol=tolerance)
5286+
assert_close(actual, expected, rtol=0, atol=tolerance)
52905287

52915288
def _reference_perspective_bounding_boxes(self, bounding_boxes, *, startpoints, endpoints):
52925289
format = bounding_boxes.format

torchvision/transforms/v2/_geometry.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,8 @@ class RandomPerspective(_RandomApplyTransform):
944944

945945
_v1_transform_cls = _transforms.RandomPerspective
946946

947+
_transformed_types = _RandomApplyTransform._transformed_types + (is_cvcuda_tensor,)
948+
947949
def __init__(
948950
self,
949951
distortion_scale: float = 0.5,

0 commit comments

Comments
 (0)