Skip to content

Commit 77c8c91

Browse files
vfdev-5datumbox
andauthored
[proto] Ported all transforms to the new API (#6305)
* [proto] Added few transforms tests, part 1 (#6262) * Added supported/unsupported data checks in the tests for cutmix/mixup * Added RandomRotation, RandomAffine transforms tests * Added tests for RandomZoomOut, Pad * Update test_prototype_transforms.py * Added RandomCrop transform and tests (#6271) * [proto] Added GaussianBlur transform and tests (#6273) * Added GaussianBlur transform and tests * Fixing code format * Copied correctness test * [proto] Added random color transforms and tests (#6275) * Added random color transforms and tests * Disable smoke test for RandomSolarize, RandomAdjustSharpness * Added RandomPerspective and tests (#6284) - replaced real image creation by mocks for other tests * Added more functional tests (#6285) * [proto] Added elastic transform and tests (#6295) * WIP [proto] Added functional elastic transform with tests * Added more functional tests * WIP on elastic op * Added elastic transform and tests * Added tests * Added tests for ElasticTransform * Try to format code as in #5106 * Fixed bug in affine get_params test * Implemented RandomErase on PIL input as fallback to tensors (#6309) Added tests * Added image_size computation for BoundingBox.rotate if expand (#6319) * Added image_size computation for BoundingBox.rotate if expand * Added tests * Added erase_image_pil and eager/jit erase_image_tensor test (#6320) * Updates according to the review Co-authored-by: Vasilis Vryniotis <[email protected]>
1 parent 0ed5d81 commit 77c8c91

22 files changed

+1550
-88
lines changed

test/test_functional_tensor.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,16 +1352,24 @@ def test_ten_crop(device):
13521352
assert_equal(transformed_batch, s_transformed_batch)
13531353

13541354

1355+
def test_elastic_transform_asserts():
1356+
with pytest.raises(TypeError, match="Argument displacement should be a Tensor"):
1357+
_ = F.elastic_transform("abc", displacement=None)
1358+
1359+
with pytest.raises(TypeError, match="img should be PIL Image or Tensor"):
1360+
_ = F.elastic_transform("abc", displacement=torch.rand(1))
1361+
1362+
img_tensor = torch.rand(1, 3, 32, 24)
1363+
with pytest.raises(ValueError, match="Argument displacement shape should"):
1364+
_ = F.elastic_transform(img_tensor, displacement=torch.rand(1, 2))
1365+
1366+
13551367
@pytest.mark.parametrize("device", cpu_and_gpu())
13561368
@pytest.mark.parametrize("interpolation", [NEAREST, BILINEAR, BICUBIC])
13571369
@pytest.mark.parametrize("dt", [None, torch.float32, torch.float64, torch.float16])
13581370
@pytest.mark.parametrize(
13591371
"fill",
1360-
[
1361-
None,
1362-
[255, 255, 255],
1363-
(2.0,),
1364-
],
1372+
[None, [255, 255, 255], (2.0,)],
13651373
)
13661374
def test_elastic_transform_consistency(device, interpolation, dt, fill):
13671375
script_elastic_transform = torch.jit.script(F.elastic_transform)

0 commit comments

Comments
 (0)