From 03c3a5ffacfe8a396930f4cf03a5d2f46da3ee54 Mon Sep 17 00:00:00 2001 From: Jirka Date: Sat, 6 May 2023 01:12:54 +0200 Subject: [PATCH] skps --- tests/examples/test_scripts.py | 2 +- tests/image/semantic_segm/test_data.py | 2 ++ tests/image/semantic_segm/test_heads.py | 5 ++--- tests/image/semantic_segm/test_model.py | 17 +++++++++-------- tests/image/semantic_segm/test_output.py | 3 ++- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/tests/examples/test_scripts.py b/tests/examples/test_scripts.py index c90e411e13..f1af15529b 100644 --- a/tests/examples/test_scripts.py +++ b/tests/examples/test_scripts.py @@ -79,7 +79,7 @@ marks=[ pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, reason="image libraries aren't installed"), pytest.mark.skipif(not _ICEDATA_AVAILABLE, reason="icedata package isn't installed"), - pytest.xfail() # ToDo + pytest.xfail(), # ToDo ], ), pytest.param( diff --git a/tests/image/semantic_segm/test_data.py b/tests/image/semantic_segm/test_data.py index d227dcb742..0c07e99fb0 100644 --- a/tests/image/semantic_segm/test_data.py +++ b/tests/image/semantic_segm/test_data.py @@ -12,6 +12,7 @@ _FIFTYONE_AVAILABLE, _MATPLOTLIB_AVAILABLE, _PIL_AVAILABLE, + _SEGMENTATION_MODELS_AVAILABLE, _TOPIC_IMAGE_AVAILABLE, ) from flash.image import SemanticSegmentation, SemanticSegmentationData @@ -375,6 +376,7 @@ def test_from_fiftyone(tmpdir): @staticmethod @pytest.mark.skipif(not _MATPLOTLIB_AVAILABLE, reason="matplotlib isn't installed.") + @pytest.mark.skipif(not _SEGMENTATION_MODELS_AVAILABLE, reason="No SMP") def test_map_labels(tmpdir): tmp_dir = Path(tmpdir) diff --git a/tests/image/semantic_segm/test_heads.py b/tests/image/semantic_segm/test_heads.py index 0bc2ef3dcf..851182361c 100644 --- a/tests/image/semantic_segm/test_heads.py +++ b/tests/image/semantic_segm/test_heads.py @@ -16,7 +16,7 @@ import pytest import torch -from flash.core.utilities.imports import _SEGMENTATION_MODELS_AVAILABLE, _TOPIC_IMAGE_AVAILABLE +from flash.core.utilities.imports import _SEGMENTATION_MODELS_AVAILABLE from flash.image.segmentation import SemanticSegmentation from flash.image.segmentation.backbones import SEMANTIC_SEGMENTATION_BACKBONES from flash.image.segmentation.heads import SEMANTIC_SEGMENTATION_HEADS @@ -37,8 +37,7 @@ def test_semantic_segmentation_heads_registry(head): assert res.shape[1] == 10 -@pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, reason="image libraries aren't installed.") -@unittest.mock.patch("flash.image.segmentation.heads.smp") +@pytest.mark.skipif(not _SEGMENTATION_MODELS_AVAILABLE, reason="No SMP") def test_pretrained_weights(mock_smp): mock_smp.create_model = unittest.mock.MagicMock() available_weights = SemanticSegmentation.available_pretrained_weights("resnet18") diff --git a/tests/image/semantic_segm/test_model.py b/tests/image/semantic_segm/test_model.py index 03069563a5..941b812306 100644 --- a/tests/image/semantic_segm/test_model.py +++ b/tests/image/semantic_segm/test_model.py @@ -21,12 +21,13 @@ from flash import Trainer from flash.core.data.io.input import DataKeys -from flash.core.utilities.imports import _TOPIC_IMAGE_AVAILABLE, _TOPIC_SERVE_AVAILABLE +from flash.core.utilities.imports import _SEGMENTATION_MODELS_AVAILABLE, _TOPIC_IMAGE_AVAILABLE from flash.image import SemanticSegmentation from flash.image.segmentation.data import SemanticSegmentationData from tests.helpers.task_tester import TaskTester +@pytest.mark.skipif(not _SEGMENTATION_MODELS_AVAILABLE, reason="No SMP") class TestSemanticSegmentation(TaskTester): task = SemanticSegmentation task_args = (2,) @@ -59,13 +60,13 @@ def example_test_sample(self): return self.example_train_sample -@pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, reason="image libraries aren't installed.") +@pytest.mark.skipif(not _SEGMENTATION_MODELS_AVAILABLE, reason="No SMP") def test_non_existent_backbone(): with pytest.raises(KeyError): SemanticSegmentation(2, "i am never going to implement this lol") -@pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, reason="image libraries aren't installed.") +@pytest.mark.skipif(not _SEGMENTATION_MODELS_AVAILABLE, reason="No SMP") def test_freeze(): model = SemanticSegmentation(2) model.freeze() @@ -73,7 +74,7 @@ def test_freeze(): assert p.requires_grad is False -@pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, reason="image libraries aren't installed.") +@pytest.mark.skipif(not _SEGMENTATION_MODELS_AVAILABLE, reason="No SMP") def test_unfreeze(): model = SemanticSegmentation(2) model.unfreeze() @@ -81,7 +82,7 @@ def test_unfreeze(): assert p.requires_grad is True -@pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, reason="image libraries aren't installed.") +@pytest.mark.skipif(not _SEGMENTATION_MODELS_AVAILABLE, reason="No SMP") def test_predict_tensor(): img = torch.rand(1, 3, 64, 64) model = SemanticSegmentation(2, backbone="mobilenetv3_large_100") @@ -93,7 +94,7 @@ def test_predict_tensor(): assert len(out[0][0][0]) == 64 -@pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, reason="image libraries aren't installed.") +@pytest.mark.skipif(not _SEGMENTATION_MODELS_AVAILABLE, reason="No SMP") def test_predict_numpy(): img = np.ones((1, 3, 64, 64)) model = SemanticSegmentation(2, backbone="mobilenetv3_large_100") @@ -105,7 +106,7 @@ def test_predict_numpy(): assert len(out[0][0][0]) == 64 -@pytest.mark.skipif(not _TOPIC_SERVE_AVAILABLE, reason="serve libraries aren't installed.") +@pytest.mark.skipif(not _SEGMENTATION_MODELS_AVAILABLE, reason="No SMP") @mock.patch("flash._IS_TESTING", True) def test_serve(): model = SemanticSegmentation(2) @@ -113,6 +114,6 @@ def test_serve(): model.serve() -@pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, reason="image libraries aren't installed.") +@pytest.mark.skipif(not _SEGMENTATION_MODELS_AVAILABLE, reason="No SMP") def test_available_pretrained_weights(): assert SemanticSegmentation.available_pretrained_weights("resnet18") == ["imagenet", "ssl", "swsl"] diff --git a/tests/image/semantic_segm/test_output.py b/tests/image/semantic_segm/test_output.py index 6c774a6cb6..43d676fb81 100644 --- a/tests/image/semantic_segm/test_output.py +++ b/tests/image/semantic_segm/test_output.py @@ -15,11 +15,12 @@ import torch from flash.core.data.io.input import DataKeys -from flash.core.utilities.imports import _FIFTYONE_AVAILABLE, _TOPIC_IMAGE_AVAILABLE +from flash.core.utilities.imports import _FIFTYONE_AVAILABLE, _SEGMENTATION_MODELS_AVAILABLE, _TOPIC_IMAGE_AVAILABLE from flash.image.segmentation.output import FiftyOneSegmentationLabelsOutput, SegmentationLabelsOutput @pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, "image libraries aren't installed.") +@pytest.mark.skipif(not _SEGMENTATION_MODELS_AVAILABLE, reason="No SMP") class TestSemanticSegmentationLabelsOutput: @staticmethod def test_smoke():