Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
skps
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed May 5, 2023
1 parent 3cde441 commit d8d2dbe
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 24 deletions.
6 changes: 2 additions & 4 deletions tests/image/semantic_segm/test_backbones.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@

@pytest.mark.parametrize(
["backbone"],
[
pytest.param("resnet50", marks=pytest.mark.skipif(not _SEGMENTATION_MODELS_AVAILABLE, reason="No SMP")),
pytest.param("dpn131", marks=pytest.mark.skipif(not _SEGMENTATION_MODELS_AVAILABLE, reason="No SMP")),
],
["resnet50", "dpn131"],
)
@pytest.mark.skipif(not _SEGMENTATION_MODELS_AVAILABLE, reason="No SMP")
def test_semantic_segmentation_backbones_registry(backbone):
backbone = SEMANTIC_SEGMENTATION_BACKBONES.get(backbone)()
assert backbone
Expand Down
9 changes: 1 addition & 8 deletions tests/image/semantic_segm/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,14 @@ def create_random_data(image_files: List[str], label_files: List[str], size: Tup
_rand_labels(size, num_classes).save(label_file)


@pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, reason="image libraries aren't installed.")
class TestSemanticSegmentationData:
@staticmethod
@pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, reason="image libraries aren't installed.")
def test_smoke():
dm = SemanticSegmentationData(batch_size=1)
assert dm is not None

@staticmethod
@pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, reason="image libraries aren't installed.")
def test_from_folders(tmpdir):
tmp_dir = Path(tmpdir)

Expand Down Expand Up @@ -120,7 +119,6 @@ def test_from_folders(tmpdir):
assert labels.shape == (2, 128, 128)

@staticmethod
@pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, reason="image libraries aren't installed.")
def test_from_folders_different_extensions(tmpdir):
tmp_dir = Path(tmpdir)

Expand Down Expand Up @@ -182,7 +180,6 @@ def test_from_folders_different_extensions(tmpdir):
assert labels.shape == (2, 128, 128)

@staticmethod
@pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, reason="image libraries aren't installed.")
def test_from_folders_error(tmpdir):
tmp_dir = Path(tmpdir)

Expand Down Expand Up @@ -217,7 +214,6 @@ def test_from_folders_error(tmpdir):
)

@staticmethod
@pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, reason="image libraries aren't installed.")
def test_from_files(tmpdir):
tmp_dir = Path(tmpdir)

Expand Down Expand Up @@ -276,7 +272,6 @@ def test_from_files(tmpdir):
assert labels.shape == (2, 128, 128)

@staticmethod
@pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, reason="image libraries aren't installed.")
def test_from_files_warning(tmpdir):
tmp_dir = Path(tmpdir)

Expand Down Expand Up @@ -310,7 +305,6 @@ def test_from_files_warning(tmpdir):
)

@staticmethod
@pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, reason="image libraries aren't installed.")
@pytest.mark.skipif(not _FIFTYONE_AVAILABLE, reason="fiftyone is not installed for testing")
def test_from_fiftyone(tmpdir):
tmp_dir = Path(tmpdir)
Expand Down Expand Up @@ -380,7 +374,6 @@ def test_from_fiftyone(tmpdir):
assert imgs.shape == (2, 3, 128, 128)

@staticmethod
@pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, reason="image libraries aren't installed.")
@pytest.mark.skipif(not _MATPLOTLIB_AVAILABLE, reason="matplotlib isn't installed.")
def test_map_labels(tmpdir):
tmp_dir = Path(tmpdir)
Expand Down
10 changes: 2 additions & 8 deletions tests/image/semantic_segm/test_heads.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,8 @@
from flash.image.segmentation.heads import SEMANTIC_SEGMENTATION_HEADS


@pytest.mark.parametrize(
"head",
[
pytest.param("fpn", marks=pytest.mark.skipif(not _SEGMENTATION_MODELS_AVAILABLE, reason="No SMP")),
pytest.param("deeplabv3", marks=pytest.mark.skipif(not _SEGMENTATION_MODELS_AVAILABLE, reason="No SMP")),
pytest.param("unet", marks=pytest.mark.skipif(not _SEGMENTATION_MODELS_AVAILABLE, reason="No SMP")),
],
)
@pytest.mark.parametrize("head", ["fpn", "deeplabv3", "unet"])
@pytest.mark.skipif(not _SEGMENTATION_MODELS_AVAILABLE, reason="No SMP")
def test_semantic_segmentation_heads_registry(head):
img = torch.rand(1, 3, 32, 32)
backbone = SEMANTIC_SEGMENTATION_BACKBONES.get("resnet50")(pretrained=False)
Expand Down
5 changes: 1 addition & 4 deletions tests/image/semantic_segm/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@
from flash.image.segmentation.output import FiftyOneSegmentationLabelsOutput, SegmentationLabelsOutput


@pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, "image libraries aren't installed.")
class TestSemanticSegmentationLabelsOutput:
@pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, "image libraries aren't installed.")
@staticmethod
def test_smoke():
serial = SegmentationLabelsOutput()
assert serial is not None
assert serial.labels_map is None
assert serial.visualize is False

@pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, "image libraries aren't installed.")
@staticmethod
def test_exception():
serial = SegmentationLabelsOutput()
Expand All @@ -41,7 +40,6 @@ def test_exception():
sample = torch.zeros(2, 3)
serial.transform(sample)

@pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, "image libraries aren't installed.")
@staticmethod
def test_serialize():
serial = SegmentationLabelsOutput()
Expand All @@ -54,7 +52,6 @@ def test_serialize():
assert torch.tensor(classes)[1, 2] == 1
assert torch.tensor(classes)[0, 1] == 3

@pytest.mark.skipif(not _TOPIC_IMAGE_AVAILABLE, reason="image libraries aren't installed.")
@pytest.mark.skipif(not _FIFTYONE_AVAILABLE, reason="fiftyone is not installed for testing")
@staticmethod
def test_serialize_fiftyone():
Expand Down

0 comments on commit d8d2dbe

Please sign in to comment.