🆕 Define MultiTaskSegmentor and NucleusInstanceSegmentor #981
🆕 Define MultiTaskSegmentor and NucleusInstanceSegmentor #981shaneahmed wants to merge 104 commits intodev-define-engines-abcfrom
MultiTaskSegmentor and NucleusInstanceSegmentor #981Conversation
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% 99.13% +3.80%
==========================================================
Files 79 80 +1
Lines 10001 10304 +303
Branches 1290 1355 +65
==========================================================
+ Hits 9534 10215 +681
+ Misses 431 60 -371
+ Partials 36 29 -7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ntor # Conflicts: # requirements/requirements.txt
There was a problem hiding this comment.
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.
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.
MultiTaskSegmentor and NucleusInstanceSegmentor
Summary
MultiTaskSegmentor, providing a simplified API for nucleus instance segmentation.multitask-segmentornucleus-instance-segment(now powered by the MultiTask engine)These updates significantly modernize the inference engine, unify multi‑task workflows, and prepare TIAToolbox for future segmentation models.
Key Changes
1) MultiTaskSegmentor
dict,.zarr, or AnnotationStore"task_type","predictions","info_dict").return_predictions.2) NucleusInstanceSegmentor (inherits MultiTaskSegmentor)
3) CLI Updates
multitask-segmentorcommand.nucleus-instance-segment:parse_bool_list) for--return-predictions.4) Model Architecture: HoVerNet & HoVerNetPlus
postprocnow returns task dictionaries, not positional arrays..tasksand.class_dict.contour→contours"box".5) EngineABC Improvements
run()now requiressave_dirwhenoutput_type = zarr|annotationstore._get_tasks_for_saving_zarrfor:6) Dependency Updates
>=2026.1.2.Breaking / Behavioral Changes
postprocoutput changed to structured task dictionaries.contourconsistently renamed tocontours.EngineABC.run()raises on missingsave_dirwhen using Zarr or AnnotationStore.NucleusInstanceSegmentoris now deprecated (internally uses MultiTaskSegmentor).Usage Examples
Patch Mode
WSI Mode (Zarr Output)
WSI + AnnotationStore
CLI