Skip to content

Commit a43e534

Browse files
committed
Add pad and crop tests
1 parent 34ba90c commit a43e534

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

test/test_transforms_v2.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3332,6 +3332,13 @@ def test_kernel_bounding_boxes(self, kwargs, format, dtype, device):
33323332
bounding_boxes = make_bounding_boxes(self.INPUT_SIZE, format=format, dtype=dtype, device=device)
33333333
check_kernel(F.crop_bounding_boxes, bounding_boxes, format=format, **kwargs)
33343334

3335+
@pytest.mark.parametrize("kwargs", CORRECTNESS_CROP_KWARGS)
3336+
@pytest.mark.parametrize("dtype", [torch.float32, torch.int64])
3337+
@pytest.mark.parametrize("device", cpu_and_cuda())
3338+
def test_kernel_keypoints(self, kwargs, dtype, device):
3339+
keypoints = make_keypoints(self.INPUT_SIZE, dtype=dtype, device=device)
3340+
check_kernel(F.crop_keypoints, keypoints, **kwargs)
3341+
33353342
@pytest.mark.parametrize("make_mask", [make_segmentation_mask, make_detection_masks])
33363343
def test_kernel_mask(self, make_mask):
33373344
check_kernel(F.crop_mask, make_mask(self.INPUT_SIZE), **self.MINIMAL_CROP_KWARGS)
@@ -3341,7 +3348,7 @@ def test_kernel_video(self):
33413348

33423349
@pytest.mark.parametrize(
33433350
"make_input",
3344-
[make_image_tensor, make_image_pil, make_image, make_bounding_boxes, make_segmentation_mask, make_video],
3351+
[make_image_tensor, make_image_pil, make_image, make_bounding_boxes, make_segmentation_mask, make_video, make_keypoints],
33453352
)
33463353
def test_functional(self, make_input):
33473354
check_functional(F.crop, make_input(self.INPUT_SIZE), **self.MINIMAL_CROP_KWARGS)
@@ -3376,7 +3383,7 @@ def test_functional_image_correctness(self, kwargs):
33763383
)
33773384
@pytest.mark.parametrize(
33783385
"make_input",
3379-
[make_image_tensor, make_image_pil, make_image, make_bounding_boxes, make_segmentation_mask, make_video],
3386+
[make_image_tensor, make_image_pil, make_image, make_bounding_boxes, make_segmentation_mask, make_video, make_keypoints],
33803387
)
33813388
def test_transform(self, param, value, make_input):
33823389
input = make_input(self.INPUT_SIZE)
@@ -4466,7 +4473,7 @@ def test_kernel_video(self):
44664473

44674474
@pytest.mark.parametrize(
44684475
"make_input",
4469-
[make_image_tensor, make_image_pil, make_image, make_bounding_boxes, make_segmentation_mask, make_video],
4476+
[make_image_tensor, make_image_pil, make_image, make_bounding_boxes, make_segmentation_mask, make_video, make_keypoints],
44704477
)
44714478
def test_functional(self, make_input):
44724479
check_functional(F.pad, make_input(), padding=[1])
@@ -4491,7 +4498,7 @@ def test_functional_signature(self, kernel, input_type):
44914498

44924499
@pytest.mark.parametrize(
44934500
"make_input",
4494-
[make_image_tensor, make_image_pil, make_image, make_bounding_boxes, make_segmentation_mask, make_video],
4501+
[make_image_tensor, make_image_pil, make_image, make_bounding_boxes, make_segmentation_mask, make_video, make_keypoints],
44954502
)
44964503
def test_transform(self, make_input):
44974504
check_transform(transforms.Pad(padding=[1]), make_input())
@@ -4565,6 +4572,7 @@ def test_bounding_boxes_correctness(self, padding, format, dtype, device, fn):
45654572
expected = self._reference_pad_bounding_boxes(bounding_boxes, padding=padding)
45664573

45674574
assert_equal(actual, expected)
4575+
#TODOKP need keypoint correctness tests
45684576

45694577

45704578
class TestCenterCrop:

0 commit comments

Comments
 (0)