77
88import numpy as np
99from PIL import Image
10+ import pytest
1011
1112from model_api .models .result import (
1213 AnomalyResult ,
@@ -71,7 +72,8 @@ def test_detection_scene(mock_image: Image, tmpdir: Path):
7172 assert Path (tmpdir / "detection_scene.jpg" ).exists ()
7273
7374
74- def test_segmentation_scene (mock_image : Image , tmpdir : Path ):
75+ @pytest .mark .parametrize ("with_saliency_map" , [True , False ])
76+ def test_segmentation_scene (mock_image : Image , tmpdir : Path , with_saliency_map : bool ):
7577 """Test if the segmentation scene is created."""
7678 visualizer = Visualizer ()
7779
@@ -85,7 +87,9 @@ def test_segmentation_scene(mock_image: Image, tmpdir: Path):
8587 ),
8688 scores = np .array ([0.85 , 0.75 ]),
8789 label_names = ["person" , "car" ],
88- saliency_map = [np .ones ((128 , 128 ), dtype = np .uint8 ) * 255 ],
90+ saliency_map = [np .ones ((128 , 128 ), dtype = np .uint8 ) * 255 ]
91+ if with_saliency_map
92+ else None ,
8993 feature_vector = np .array ([1 , 2 , 3 , 4 ]),
9094 )
9195
@@ -104,7 +108,9 @@ def test_segmentation_scene(mock_image: Image, tmpdir: Path):
104108 soft_prediction = np .ones (
105109 (3 , 3 , 3 ), dtype = np .float32
106110 ), # 3 classes, 3x3 prediction
107- saliency_map = np .ones ((3 , 3 ), dtype = np .uint8 ) * 255 ,
111+ saliency_map = np .ones ((3 , 3 ), dtype = np .uint8 ) * 255
112+ if with_saliency_map
113+ else None ,
108114 feature_vector = np .array ([1 , 2 , 3 , 4 ]),
109115 )
110116
0 commit comments