-
Notifications
You must be signed in to change notification settings - Fork 102
🆕 Define MultiTaskSegmentor #981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev-define-engines-abc
Are you sure you want to change the base?
🆕 Define MultiTaskSegmentor #981
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev-define-engines-abc #981 +/- ##
==========================================================
+ Coverage 95.33% 96.79% +1.46%
==========================================================
Files 79 80 +1
Lines 10001 10513 +512
Branches 1290 1378 +88
==========================================================
+ Hits 9534 10176 +642
+ Misses 431 295 -136
- Partials 36 42 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ntor # Conflicts: # requirements/requirements.txt
- dask version 2026.1.2 has breaking changes
|
New release of dask has changed the API for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a comprehensive MultiTaskSegmentor engine for TIAToolbox that handles multi-head segmentation models (HoVerNet/HoVerNetPlus) with both patch and WSI inference capabilities. The implementation adds memory-aware processing with automatic Zarr spillover for large slides and refactors model post-processing into a unified, task-centric structure.
Changes:
- Adds new
MultiTaskSegmentorengine with patch/WSI modes, memory-aware Zarr caching, and support for dict/zarr/annotationstore outputs - Introduces CLI command
tiatoolbox multitask-segmentorfor terminal-based multi-task model execution - Refactors HoVerNet/HoVerNetPlus postprocessing to return task-centric dictionaries and renames
contour→contours - Updates
EngineABCto support Zarr task grouping and addssave_dirvalidation for zarr/annotationstore outputs - Adds
create_smart_arrayutility for memory-aware NumPy/Zarr allocation
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| tiatoolbox/models/engine/multi_task_segmentor.py | New multi-task segmentation engine with comprehensive inference, post-processing, and saving capabilities |
| tiatoolbox/models/engine/engine_abc.py | Enhanced base engine with Zarr task grouping, save_dir validation, and dask config changes |
| tiatoolbox/models/architecture/hovernet.py | Updated postproc to return task dictionaries, renamed contour→contours, added dask support |
| tiatoolbox/models/architecture/hovernetplus.py | Extended hovernet changes with layer segmentation task and bounding boxes |
| tiatoolbox/cli/multitask_segmentor.py | New CLI command for multi-task segmentation |
| tiatoolbox/cli/common.py | Added parse_bool_list callback and cli_return_predictions for tuple[bool] parsing |
| tiatoolbox/cli/init.py | Registered new multitask-segmentor CLI command |
| tiatoolbox/utils/misc.py | Added create_smart_array for memory-aware array allocation with psutil |
| tests/* | Comprehensive test coverage for new functionality |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ntor # Conflicts: # tests/test_utils.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 13 out of 14 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
This PR introduces a new MultiTaskSegmentor engine that supports multi‑head models (e.g., HoVerNet/HoVerNetPlus) across both patch and WSI inference workflows. It adds a dedicated CLI entry point, implements memory‑aware processing with automatic Zarr spillover for large slides, and refactors HoVerNet/HoVerNetPlus post‑processing into a unified, task‑centric structure.
Key Changes
1) New engine:
tiatoolbox.models.engine.multi_task_segmentordict,zarr, orannotationstore2) CLI:
tiatoolbox multitask-segmentor3) Model architecture updates (HoVerNet & HoVerNetPlus)
postprocto return task‑centric dictionaries with keys such as"task_type","predictions", and"info_dict".tasksandclass_dictattributes to both architectures for unified downstream handling.contour→contoursand ensures Dask compatibility for large outputs.4) EngineABC enhancements
task_namefor multi‑task layouts.save_dirforzarrandannotationstoreoutputs; missing directories now raise a clearValueError.class_dictdefaults tomodel.class_dictwhen missing.5) Dependency updates
dask>=2025.12.0→dask>=2026.1.2.Required to support newer dask APIs used in Zarr spillover and array operations.
Breaking / Behavioral Changes
postprocnow return task dictionaries instead of positional tuples; downstream consumers must update accordingly."contours"consistently.EngineABC.runrequiressave_dirforzarrandannotationstoreoutputs; omitting it raises aValueError.multitask-segmentorcommand for multi‑task models.Usage examples
Patch mode:
WSI mode (Zarr output):
WSI + AnnotationStore:
CLI: