From 098d3cfce31ffbfab5eb86cb0012b9840083997a Mon Sep 17 00:00:00 2001 From: vfdev-5 Date: Mon, 25 Apr 2022 10:15:06 +0000 Subject: [PATCH 1/3] Fixed issue with padding on CI --- torchvision/transforms/functional_tensor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/torchvision/transforms/functional_tensor.py b/torchvision/transforms/functional_tensor.py index da7acef3e7b..81daa080cb2 100644 --- a/torchvision/transforms/functional_tensor.py +++ b/torchvision/transforms/functional_tensor.py @@ -412,7 +412,10 @@ def pad(img: Tensor, padding: List[int], fill: int = 0, padding_mode: str = "con need_cast = True img = img.to(torch.float32) - img = torch_pad(img, p, mode=padding_mode, value=float(fill)) + if padding_mode in ("reflect", "replicate"): + img = torch_pad(img, p, mode=padding_mode) + else: + img = torch_pad(img, p, mode=padding_mode, value=float(fill)) if need_squeeze: img = img.squeeze(dim=0) From d7ab89001d6e1d18e87b8a9459660f46d6b22c77 Mon Sep 17 00:00:00 2001 From: vfdev-5 Date: Mon, 25 Apr 2022 12:29:24 +0000 Subject: [PATCH 2/3] Disabled failing tests with color_jitter --- test/test_transforms_tensor.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/test_transforms_tensor.py b/test/test_transforms_tensor.py index 165c23dbdb8..3f4bb9d1029 100644 --- a/test/test_transforms_tensor.py +++ b/test/test_transforms_tensor.py @@ -59,12 +59,11 @@ def _test_functional_op(f, device, channels=3, fn_kwargs=None, test_exact_match= _assert_approx_equal_tensor_to_pil(transformed_tensor, transformed_pil_img, **match_kwargs) -def _test_class_op(method, device, channels=3, meth_kwargs=None, test_exact_match=True, **match_kwargs): - # TODO: change the name: it's not a method, it's a class. +def _test_class_op(transform_cls, device, channels=3, meth_kwargs=None, test_exact_match=True, **match_kwargs): meth_kwargs = meth_kwargs or {} # test for class interface - f = method(**meth_kwargs) + f = transform_cls(**meth_kwargs) scripted_fn = torch.jit.script(f) tensor, pil_img = _create_data(26, 34, channels, device=device) @@ -86,7 +85,7 @@ def _test_class_op(method, device, channels=3, meth_kwargs=None, test_exact_matc _test_transform_vs_scripted_on_batch(f, scripted_fn, batch_tensors) with get_tmp_dir() as tmp_dir: - scripted_fn.save(os.path.join(tmp_dir, f"t_{method.__name__}.pt")) + scripted_fn.save(os.path.join(tmp_dir, f"t_{transform_cls.__name__}.pt")) def _test_op(func, method, device, channels=3, fn_kwargs=None, meth_kwargs=None, test_exact_match=True, **match_kwargs): @@ -119,8 +118,12 @@ def test_random(func, method, device, channels, fn_kwargs, match_kwargs): @pytest.mark.parametrize("seed", range(10)) -@pytest.mark.parametrize("device", cpu_and_gpu()) -@pytest.mark.parametrize("channels", [1, 3]) +# Temporary disable CUDA device +# https://github.com/pytorch/vision/issues/5873 +# @pytest.mark.parametrize("device", cpu_and_gpu()) +# @pytest.mark.parametrize("channels", [1, 3]) +@pytest.mark.parametrize("device", ["cpu"]) +@pytest.mark.parametrize("channels", [3, 1]) class TestColorJitter: @pytest.fixture(autouse=True) def set_random_seed(self, seed): From 2226af8680f5e5c0bce67d2ee00af41ca9a8bc3a Mon Sep 17 00:00:00 2001 From: Vasilis Vryniotis Date: Tue, 26 Apr 2022 12:51:33 +0100 Subject: [PATCH 3/3] Remove Jitter workaround --- test/test_transforms_tensor.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/test/test_transforms_tensor.py b/test/test_transforms_tensor.py index 3f4bb9d1029..8cebe666b50 100644 --- a/test/test_transforms_tensor.py +++ b/test/test_transforms_tensor.py @@ -118,12 +118,8 @@ def test_random(func, method, device, channels, fn_kwargs, match_kwargs): @pytest.mark.parametrize("seed", range(10)) -# Temporary disable CUDA device -# https://github.com/pytorch/vision/issues/5873 -# @pytest.mark.parametrize("device", cpu_and_gpu()) -# @pytest.mark.parametrize("channels", [1, 3]) -@pytest.mark.parametrize("device", ["cpu"]) -@pytest.mark.parametrize("channels", [3, 1]) +@pytest.mark.parametrize("device", cpu_and_gpu()) +@pytest.mark.parametrize("channels", [1, 3]) class TestColorJitter: @pytest.fixture(autouse=True) def set_random_seed(self, seed):