Skip to content

🎨 Refactor ModelABC to Help Use Default Torch Models#867

Draft
shaneahmed wants to merge 189 commits intodevelopfrom
dev-convert-modelabc-to-torch-nn-model
Draft

🎨 Refactor ModelABC to Help Use Default Torch Models#867
shaneahmed wants to merge 189 commits intodevelopfrom
dev-convert-modelabc-to-torch-nn-model

Conversation

@shaneahmed
Copy link
Member

  • Refactor ModelABC to Help Use Default Torch Models
  • Remove infer_batch from ModelABC

shaneahmed and others added 30 commits March 24, 2023 11:18
- Use `pyproject.toml` for `bdist_wheel` configuration
- Improve `Engines` performance and implementation
- Refactor engines_abc.py
…618)

- Moved all ioconfigs to a single file.
- Used dataclass to define ioconfig.
- Refactor base code from `IOSegmentorConfig` to `ModelIOConfigABC`
- Use `ModelIOConfigABC` for `PatchPredictor` instead of `IOSegmentorConfig`

---------

Signed-off-by: Shan E Ahmed Raza <13048456+shaneahmed@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: John Pocock <John-P@users.noreply.github.com>
Co-authored-by: Mark Eastwood <20169086+measty@users.noreply.github.com>
Co-authored-by: Mostafa Jahanifar <74412979+mostafajahanifar@users.noreply.github.com>
Co-authored-by: Adam Shephard <39619155+adamshephard@users.noreply.github.com>
- Move `WSIStreamDataset`, `PatchDatasetABC` and `WSIPatchDataset` to `dataset_abc.py`

---------

Signed-off-by: Shan E Ahmed Raza <13048456+shaneahmed@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
shaneahmed and others added 26 commits June 16, 2025 11:46
# Conflicts:
#	tests/models/test_feature_extractor.py
#	tiatoolbox/models/models_abc.py
# Conflicts:
#	tiatoolbox/cli/common.py
#	tiatoolbox/cli/nucleus_instance_segment.py
#	tiatoolbox/cli/patch_predictor.py
#	tiatoolbox/models/engine/semantic_segmentor.py
* ⚡ Make WSIPatchDataset Pickleable to Support Windows Multithreading (#947)

This PR makes the WSIPatchDataset class picklable by delaying the creation of the reader object until the first call to `__getitem__`. This enables the use of multiple loader workers on Windows without errors and provides significant performance improvements.

- Delays reader object instantiation to the first `__getitem__` call instead of during initialization
- Extracts reader creation logic into a separate `_get_reader` method
- Stores image path and mode as instance variables for lazy initialization

Speedup for the WSI prediction cell of the patch_prediction example notebook: 
2min 48 sec with 0 loader workers -> 1min 13 sec with 4 workers.

Note: this PR doesn't have any effect for Linux as the multi-threading already works fine there because Linux multithreading doesn't require things to be pickleable

* 🔀 Merge branch develop into dev-engine-abc

* 🐛 Fix reader_info read

---------

Co-authored-by: Mark Eastwood <20169086+measty@users.noreply.github.com>
# Conflicts:
#	tiatoolbox/models/dataset/classification.py
# Conflicts:
#	tests/models/test_patch_predictor.py
@shaneahmed shaneahmed linked an issue Feb 27, 2026 that may be closed by this pull request
8 tasks
@shaneahmed shaneahmed changed the base branch from dev-define-engines-abc to develop March 5, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Models Inconsistency

3 participants