From 52f04932f2ca9b5590f062315505f8c93ec866d1 Mon Sep 17 00:00:00 2001 From: Wenqi Li <831580+wyli@users.noreply.github.com> Date: Mon, 7 Aug 2023 09:33:50 +0100 Subject: [PATCH] unblock test_perceptual_loss.py, fixes #6824 Signed-off-by: Wenqi Li <831580+wyli@users.noreply.github.com> Signed-off-by: Wenqi Li <831580+wyli@users.noreply.github.com> --- tests/test_perceptual_loss.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test_perceptual_loss.py b/tests/test_perceptual_loss.py index 2f807d8222..ba613c3a4c 100644 --- a/tests/test_perceptual_loss.py +++ b/tests/test_perceptual_loss.py @@ -18,7 +18,7 @@ from monai.losses import PerceptualLoss from monai.utils import optional_import -from tests.utils import SkipIfBeforePyTorchVersion +from tests.utils import SkipIfBeforePyTorchVersion, skip_if_downloading_fails _, has_torchvision = optional_import("torchvision") TEST_CASES = [ @@ -59,13 +59,15 @@ def test_shape(self, input_param, input_shape, target_shape): @parameterized.expand(TEST_CASES) def test_identical_input(self, input_param, input_shape, target_shape): - loss = PerceptualLoss(**input_param) + with skip_if_downloading_fails(): + loss = PerceptualLoss(**input_param) tensor = torch.randn(input_shape) result = loss(tensor, tensor) self.assertEqual(result, torch.Tensor([0.0])) def test_different_shape(self): - loss = PerceptualLoss(spatial_dims=2, network_type="squeeze") + with skip_if_downloading_fails(): + loss = PerceptualLoss(spatial_dims=2, network_type="squeeze") tensor = torch.randn(2, 1, 64, 64) target = torch.randn(2, 1, 32, 32) with self.assertRaises(ValueError):