Skip to content

Commit f1fc3b5

Browse files
committed
✅ Add test for a tile image
1 parent 42a5114 commit f1fc3b5

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

tests/engines/test_semantic_segmentor.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
merge_vertical_chunkwise,
2525
)
2626
from tiatoolbox.utils import env_detection as toolbox_env
27-
from tiatoolbox.utils.misc import imread
27+
from tiatoolbox.utils.misc import download_data, imread
2828
from tiatoolbox.wsicore import WSIReader
2929

3030
if TYPE_CHECKING:
@@ -150,6 +150,38 @@ def _test_store_output_patch(output: Path) -> None:
150150
assert annotations_properties is not None
151151

152152

153+
def test_semantic_segmentor_tiles(track_tmp_path: Path) -> None:
154+
"""Tests SemanticSegmentor on image tiles with no mpp metadata."""
155+
segmentor = SemanticSegmentor(
156+
model="fcn-tissue_mask", batch_size=32, verbose=False, device=device
157+
)
158+
159+
sample_image = track_tmp_path / "breast_tissue.jpg"
160+
161+
download_data(
162+
"https://tiatoolbox.dcs.warwick.ac.uk/sample_imgs/breast_tissue.jpg",
163+
sample_image,
164+
)
165+
166+
inputs = [sample_image]
167+
168+
output = segmentor.run(
169+
images=inputs,
170+
device=device,
171+
patch_mode=False,
172+
auto_get_mask=False,
173+
save_dir=track_tmp_path / "output",
174+
input_resolutions=[{"units": "baseline", "resolution": 1.0}],
175+
patch_input_shape=(1024, 1024),
176+
)
177+
178+
output = zarr.open(output[sample_image], mode="r")
179+
180+
assert output["predictions"].shape == (2048, 3584)
181+
182+
sample_image.unlink()
183+
184+
153185
def test_save_annotation_store(remote_sample: Callable, track_tmp_path: Path) -> None:
154186
"""Test for saving output as annotation store."""
155187
segmentor = SemanticSegmentor(

0 commit comments

Comments
 (0)