Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
4d21d22
:new: Define New MultiTaskSegmentor
shaneahmed Jan 8, 2026
fef42ea
:construction: Add functionalities
shaneahmed Jan 8, 2026
ab5cf7c
:fire: Remove previous codes
shaneahmed Jan 8, 2026
eab6db0
:fire: Remove previous codes
shaneahmed Jan 8, 2026
f8ff99c
:white_check_mark: Add initialization test
shaneahmed Jan 8, 2026
17c7a8a
:boom: Add patch segmentation test
shaneahmed Jan 8, 2026
ced4924
:boom: Update loop for postprocessing
shaneahmed Jan 8, 2026
8ea1056
:boom: Work in progress
shaneahmed Jan 9, 2026
1b9d254
Merge branch 'dev-define-engines-abc' into dev-define-multitask-segme…
shaneahmed Jan 9, 2026
335aa07
:construction: Update multitask post processing outputs.
shaneahmed Jan 9, 2026
3447495
:construction: Update postprocessing to incorporate dictionary outputs
shaneahmed Jan 12, 2026
84a717d
:white_check_mark: Add test for dictionary output
shaneahmed Jan 12, 2026
6065409
:bug: Fix hovernet and hovernetplus tests
shaneahmed Jan 12, 2026
1c6619b
Merge branch 'dev-define-engines-abc' into dev-define-multitask-segme…
shaneahmed Jan 12, 2026
bd6d4b7
:white_check_mark: Add tests for zarr output
shaneahmed Jan 12, 2026
c7238b2
:bug: Fix deepsource errors
shaneahmed Jan 12, 2026
fa3dcc1
:white_check_mark: Add test for single output.
shaneahmed Jan 13, 2026
b042e86
:white_check_mark: Add test for save_dir and None output_type
shaneahmed Jan 13, 2026
47efdd1
:white_check_mark: Improve test coverage.
shaneahmed Jan 13, 2026
618f123
Merge branch 'dev-define-engines-abc' into dev-define-multitask-segme…
shaneahmed Jan 13, 2026
645986d
:white_check_mark: Add test for annotationstore single output.
shaneahmed Jan 13, 2026
d9953cc
Merge branch 'dev-define-engines-abc' into dev-define-multitask-segme…
shaneahmed Jan 13, 2026
e86e176
:white_check_mark: Add tests for multitask annotation store
shaneahmed Jan 13, 2026
4247afa
:white_check_mark: Test output of layer and nuclei segmentation for a…
shaneahmed Jan 13, 2026
94f427e
:white_check_mark: Test output of layer and nuclei segmentation for a…
shaneahmed Jan 13, 2026
b16b57b
:bug: Read image at correct resolution
shaneahmed Jan 13, 2026
8aebbaf
:bug: Fix saving annotationstore using zarr
shaneahmed Jan 13, 2026
e4392c9
:white_check_mark: Add test for logger.
shaneahmed Jan 13, 2026
f9f5f69
:bug: Fix deepsource error `PTC-W0060`
shaneahmed Jan 14, 2026
84a4611
:white_check_mark: Use file paths for a test
shaneahmed Jan 14, 2026
6e1b55f
:bug: Fix paths to input files in test
shaneahmed Jan 14, 2026
99e2352
Merge branch 'dev-define-engines-abc' into dev-define-multitask-segme…
shaneahmed Jan 14, 2026
ff804db
:construction: Add zarr output for WSIs
shaneahmed Jan 16, 2026
04dada4
:bug: Fix deepsource error
shaneahmed Jan 19, 2026
a8ca393
:bug: Fix deepsource error
shaneahmed Jan 19, 2026
a336569
add type annotation utils.transforms.py
Jiaqi-Lv Jan 19, 2026
5717512
:sparkles: Add WSI AnnotationStore support
shaneahmed Jan 19, 2026
568964d
:white_check_mark: Add check for single task and class_dict
shaneahmed Jan 19, 2026
943aebf
:white_check_mark: Add check for single task and class_dict support
shaneahmed Jan 19, 2026
e3830b1
:bug: Fix PY-W0070 deep source error
shaneahmed Jan 19, 2026
528b72e
:zap: Use smaller images for faster test runs.
shaneahmed Jan 19, 2026
8e5578a
:bug: Fix memory check for saving arrays
shaneahmed Jan 20, 2026
60faab5
:lipstick: Update logic for better readability
shaneahmed Jan 20, 2026
ddc2a54
:bug: Remove residual canvas and count keys
shaneahmed Jan 20, 2026
8cd457c
:bug: Fix deepsource errors
shaneahmed Jan 20, 2026
e715f1b
Merge branch 'dev-define-engines-abc' into dev-define-multitask-segme…
shaneahmed Jan 22, 2026
4bb4900
:bug: Fix count in merge_predictions
shaneahmed Jan 23, 2026
5e659c0
:bug: Fix count in merge_predictions
shaneahmed Jan 23, 2026
c0decb6
:bug: Fix HoVerNetPlus postprocessing.
shaneahmed Jan 25, 2026
d934167
:construction: Merge using tile outputs.
shaneahmed Jan 26, 2026
e660bb3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 26, 2026
be79c7f
[skip ci] :construction: Restructure dictionary output
shaneahmed Jan 26, 2026
55f7d7f
[skip ci] :construction: Fix structure of the output
shaneahmed Jan 26, 2026
7a2fb6c
[skip ci] :construction: Fix structure of the output
shaneahmed Jan 26, 2026
e63385d
Merge branch 'dev-define-engines-abc' into dev-define-multitask-segme…
shaneahmed Jan 28, 2026
189d5b3
:memo: Add docstring for `_get_inst_info_dicts`
shaneahmed Jan 29, 2026
13aa48c
:construction: Working on testing tile based output
shaneahmed Jan 29, 2026
44456a7
:construction: Finalise wsi_info_dict structure to work with save_pre…
shaneahmed Jan 29, 2026
4dbf9c4
:white_check_mark: Update hovernet postprocessing to be compatible wi…
shaneahmed Jan 29, 2026
eb60aa1
:construction: Initial implementation of merged predictions
shaneahmed Jan 30, 2026
820bb6e
:construction: Initial implementation of merged predictions
shaneahmed Jan 30, 2026
30c2ae7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 30, 2026
2c0dccd
:white_check_mark: Add support for tile based "predictions" output
shaneahmed Jan 30, 2026
c963514
:white_check_mark: Add support for tile based "predictions" output
shaneahmed Jan 30, 2026
0aaaf5b
:bug: Fix deepsource error
shaneahmed Jan 30, 2026
e3f9458
:bug: Fix deepsource error
shaneahmed Jan 30, 2026
f5fe072
:bug: Fix `mypy` error
shaneahmed Jan 30, 2026
4683416
:bug: Fix deepsource errors
shaneahmed Jan 30, 2026
af8b67b
:bug: Fix coverage for `misc.py`
shaneahmed Jan 30, 2026
5820182
:bug: Fix coverage for `multi_task_segmentor.py`
shaneahmed Jan 30, 2026
ce865bd
:memo: Update docstrings.
shaneahmed Jan 30, 2026
260bbc9
:memo: Update docstrings.
shaneahmed Jan 30, 2026
21b3398
:memo: Update docstrings.
shaneahmed Jan 30, 2026
c6b7d72
:memo: Update docstrings.
shaneahmed Jan 30, 2026
c2f0ac6
:memo: Update docstrings.
shaneahmed Jan 30, 2026
d8ed2f5
:pushpin: Pin `dask>=2026.1.2`
shaneahmed Jan 30, 2026
ccc7fd4
:white_check_mark: Add CLI support.
shaneahmed Jan 31, 2026
4ac2ef4
:white_check_mark: Update CLI tests.
shaneahmed Jan 31, 2026
1cbb01b
:bug: Fix ARG001 error
shaneahmed Jan 31, 2026
7801944
:bug: Fix deepsource and `mypy` errors.
shaneahmed Jan 31, 2026
60852ea
Merge branch 'dev-define-engines-abc' into dev-define-multitask-segme…
shaneahmed Jan 31, 2026
3cf8504
:green_heart: Address Co-Pilot review comments.
shaneahmed Feb 2, 2026
1e52eca
Merge branch 'dev-define-engines-abc' into dev-define-multitask-segme…
shaneahmed Feb 2, 2026
9ecddab
Merge branch 'dev-define-engines-abc' into dev-define-multitask-segme…
shaneahmed Feb 3, 2026
46eb4dc
:green_heart: Address Co-Pilot comments
shaneahmed Feb 3, 2026
a60b50f
:zap: Use `prepare_full_batch` from `semantic_segmentor`.
shaneahmed Feb 3, 2026
3a68f0a
:zap: Use `save_to_cache` from `semantic_segmentor`.
shaneahmed Feb 3, 2026
1836816
:zap: Use `max(vm.available, 1)` to calculate memory usage.
shaneahmed Feb 3, 2026
9fb9ea6
:zap: Use `merge_horizontal` from `semantic_segmentor`.
shaneahmed Feb 3, 2026
f7e35be
:bug: Fix saving and deletion of temp_zarr name.
shaneahmed Feb 3, 2026
dd3e5a5
:white_check_mark: Use `hovernet_original-kumar`
shaneahmed Feb 3, 2026
27d6161
:white_check_mark: Update `NucleusInstanceSegmentor`.
shaneahmed Feb 3, 2026
86111a6
:white_check_mark: Add tests for io_config.
shaneahmed Feb 3, 2026
de65370
:white_check_mark: Add `cli` for `nucleus_instance_segmentor`.
shaneahmed Feb 3, 2026
52e21e6
:white_check_mark: Add tests for cli
shaneahmed Feb 3, 2026
151b61e
:white_check_mark: Add tests for cli coverage.
shaneahmed Feb 3, 2026
6015d5f
:white_check_mark: Add progress bar for saving annotationstore.
shaneahmed Feb 4, 2026
a0ae9d1
:white_check_mark: Update ioconfig
shaneahmed Feb 4, 2026
f48c4e0
:white_check_mark: Update batchsize for cli and tests
shaneahmed Feb 4, 2026
e962fe5
:bug: Fix deepsource bug
shaneahmed Feb 4, 2026
73f7d61
:bug: Fix tests
shaneahmed Feb 5, 2026
aae3529
:lipstick: Update description for tqdm
shaneahmed Feb 5, 2026
322f4f6
:lipstick: Update description for tqdm
shaneahmed Feb 5, 2026
7c62b3d
:white_check_mark: Add tests for improved coverage
shaneahmed Feb 5, 2026
199aeb9
:zap: Use dask delayed for parallel post-processing.
shaneahmed Feb 5, 2026
20a2a84
:lipstick: Replace `tqdm.write` with `tqdm.desc`
shaneahmed Feb 6, 2026
63d9157
:bug: Fix failing test for DummyTQDM
shaneahmed Feb 6, 2026
9fda536
:zap: Use dask delayed to save annotations.
shaneahmed Feb 6, 2026
bbb1bbf
:lipstick: Add tqdm to creating list of tasks
shaneahmed Feb 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions tests/engines/test_engine_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,38 @@ def test_incorrect_output_type() -> NoReturn:
)


def test_incorrect_output_type_save_dir() -> NoReturn:
"""Test EngineABC for None output_type and output type zarr/annotationstore."""
pretrained_model = "alexnet-kather100k"

# Test engine run without ioconfig
eng = TestEngineABC(model=pretrained_model)

with pytest.raises(
ValueError,
match=r".*Please provide save_dir for output_type=zarr*",
):
_ = eng.run(
images=np.zeros((10, 224, 224, 3), dtype=np.uint8),
on_gpu=False,
patch_mode=True,
ioconfig=None,
output_type="zarr",
)

with pytest.raises(
ValueError,
match=r".*Please provide save_dir for output_type=annotationstore*",
):
_ = eng.run(
images=np.zeros((10, 224, 224, 3), dtype=np.uint8),
on_gpu=False,
patch_mode=True,
ioconfig=None,
output_type="annotationstore",
)


def test_pretrained_ioconfig() -> NoReturn:
"""Test EngineABC initialization with pretrained model name in the toolbox."""
pretrained_model = "alexnet-kather100k"
Expand Down
100 changes: 99 additions & 1 deletion tests/engines/test_ioconfig.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Tests for IOconfig."""

import numpy as np
import pytest

from tiatoolbox.models import ModelIOConfigABC
from tiatoolbox.models import IOSegmentorConfig, ModelIOConfigABC


def test_validation_error_io_config() -> None:
Expand All @@ -21,3 +22,100 @@ def test_validation_error_io_config() -> None:
input_resolutions=[{"units": "level", "resolution": 1.0}],
patch_input_shape=(224, 224),
)


def test_scale_to_highest_mpp() -> None:
"""Mpp → min(old_vals) / old_vals."""
resolutions = [
{"units": "mpp", "resolution": 0.25},
{"units": "mpp", "resolution": 0.5},
]
result = ModelIOConfigABC.scale_to_highest(resolutions, units="mpp")

expected = np.array([1.0, 0.5]) # 0.25 / [0.25, 0.5]
np.testing.assert_allclose(result, expected)


def test_scale_to_highest_mpp_reversed_order() -> None:
"""Ensure order is preserved even when resolutions are reversed."""
resolutions = [
{"units": "mpp", "resolution": 0.5},
{"units": "mpp", "resolution": 0.25},
]
result = ModelIOConfigABC.scale_to_highest(resolutions, units="mpp")

expected = np.array([0.5, 1.0]) # 0.25 / [0.5, 0.25]
np.testing.assert_allclose(result, expected)


def test_scale_to_highest_baseline() -> None:
"""Baseline → identity."""
resolutions = [
{"units": "baseline", "resolution": 2.0},
{"units": "baseline", "resolution": 4.0},
]
result = ModelIOConfigABC.scale_to_highest(resolutions, units="baseline")

expected = [2.0, 4.0]
assert result == expected


def test_scale_to_highest_power() -> None:
"""Power → old_vals / max(old_vals)."""
resolutions = [
{"units": "power", "resolution": 10},
{"units": "power", "resolution": 5},
]
result = ModelIOConfigABC.scale_to_highest(resolutions, units="power")

expected = np.array([1.0, 0.5]) # [10, 5] / 10
np.testing.assert_allclose(result, expected)


def test_scale_to_highest_invalid_units() -> None:
"""Test ModelIOConfigABC for unknown units."""
resolutions = [{"units": "mpp", "resolution": 1.0}]
with pytest.raises(ValueError, match="Unknown units"):
ModelIOConfigABC.scale_to_highest(resolutions, units="unknown")


def test_modelio_to_baseline_without_save_resolution() -> None:
"""Test ModelIOConfigABC when save_resolution is None.

Ensure ModelIOConfigABC.to_baseline does NOT add or convert
save_resolution when it is None.

"""
cfg = ModelIOConfigABC(
input_resolutions=[{"units": "mpp", "resolution": 0.5}],
output_resolutions=[{"units": "mpp", "resolution": 1.0}],
patch_input_shape=(224, 224),
stride_shape=(224, 224),
)

new_cfg = cfg.to_baseline()

# save_resolution should not appear in the new config
assert not hasattr(new_cfg, "save_resolution") or new_cfg.save_resolution is None


def test_ios_to_baseline_without_save_resolution() -> None:
"""Test IOSegmentorConfig when save_resolution is None.

Ensure IOSegmentorConfig.to_baseline leaves save_resolution=None
when no save_resolution is provided.

"""
cfg = IOSegmentorConfig(
input_resolutions=[{"units": "mpp", "resolution": 0.5}],
output_resolutions=[{"units": "mpp", "resolution": 1.0}],
patch_input_shape=(224, 224),
patch_output_shape=(112, 112),
stride_shape=(224, 224),
save_resolution=None,
)

new_cfg = cfg.to_baseline()

# save_resolution should remain None after conversion
assert new_cfg.save_resolution is None
Loading