Commit b542c9a
## Summary of Changes
### Major Additions
- **Dask Integration:**
- Added `dask` as a dependency and integrated Dask arrays and lazy computation throughout the engine and patch predictor code.
- Added Dask-based merging, chunking, and memory-aware processing for large images and WSIs.
- **Zarr Output Support:**
- Added support for saving model predictions and intermediate results directly to Zarr format.
- New CLI options and internal logic for Zarr output, including memory thresholding and chunked writes.
- **SemanticSegmentor Engine:**
- Added a new `SemanticSegmentor` engine with Dask/Zarr support and new test coverage (`test_semantic_segmentor.py`).
- Added CLI entrypoint for `semantic_segmentor` and removed the old `semantic_segment` CLI.
- **Enhanced CLI and Config:**
- Added CLI options for memory threshold, unified worker options, and improved mask handling.
- Updated YAML configs and sample data for new models and test images.
- **Utilities and Validation:**
- Added utility functions for minimal dtype casting, patch/stride validation, and improved error handling (e.g., `DimensionMismatchError`).
- Improved annotation store conversion for Dask arrays and Zarr-backed outputs.
- **Changes to `kwarg`**
- Add `memory-threshold`
- Unified `num-loader-workers` and `num-postproc-workers` into `num-workers`
- Removed `cache_mode` as cache mode is automatically handled.
---
### Major Removals/Refactors
- **Removed Old CLI and Redundant Code:**
- Deleted the old `semantic_segment.py` CLI and replaced it with `semantic_segmentor.py`.
- Removed legacy cache mode and patch prediction Zarr store tests.
- **Refactored Model and Dataset APIs:**
- Unified and simplified model inference APIs to always return arrays (not dicts) for batch outputs.
- Refactored dataset classes to enforce patch shape validation and remove legacy “mode” logic.
- **Test Cleanup:**
- Removed or updated tests that relied on old APIs or cache mode.
- Refactored test assertions for new output types and Dask array handling.
- **API Consistency:**
- Standardized function and argument names across engines, CLI, and utility modules.
- Updated docstrings and type hints for clarity and consistency.
---
### Notable File Changes
- **New:**
- `tiatoolbox/cli/semantic_segmentor.py`
- `tests/engines/test_semantic_segmentor.py`
- **Removed:**
- `tiatoolbox/cli/semantic_segment.py`
- Old cache mode and patch Zarr store tests
- **Heavily Modified:**
- `engine_abc.py`, `patch_predictor.py`, `semantic_segmentor.py`
- CLI modules and test suites
- Dataset and utility modules for Dask/Zarr compatibility
---
### Impact
- Enables scalable, parallel, and memory-efficient inference and output saving for large images.
- Simplifies downstream analysis by supporting Zarr as a native output format.
- Lays the groundwork for further Dask-based optimizations in TIAToolbox.
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 31b7995 commit b542c9a
File tree
29 files changed
+3318
-2742
lines changed- requirements
- tests
- engines
- models
- tiatoolbox
- cli
- data
- models
- architecture
- dataset
- engine
- utils
29 files changed
+3318
-2742
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
534 | 534 | | |
535 | 535 | | |
536 | 536 | | |
| 537 | + | |
537 | 538 | | |
538 | 539 | | |
539 | 540 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | | - | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
| |||
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
82 | | - | |
| 84 | + | |
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
| |||
169 | 171 | | |
170 | 172 | | |
171 | 173 | | |
172 | | - | |
| 174 | + | |
173 | 175 | | |
174 | 176 | | |
175 | 177 | | |
176 | 178 | | |
177 | | - | |
| 179 | + | |
178 | 180 | | |
179 | 181 | | |
180 | 182 | | |
181 | 183 | | |
182 | | - | |
| 184 | + | |
183 | 185 | | |
184 | 186 | | |
185 | 187 | | |
186 | | - | |
| 188 | + | |
187 | 189 | | |
188 | 190 | | |
189 | 191 | | |
190 | 192 | | |
191 | | - | |
| 193 | + | |
192 | 194 | | |
193 | 195 | | |
194 | 196 | | |
| |||
209 | 211 | | |
210 | 212 | | |
211 | 213 | | |
212 | | - | |
| 214 | + | |
213 | 215 | | |
214 | 216 | | |
215 | 217 | | |
216 | 218 | | |
217 | | - | |
| 219 | + | |
218 | 220 | | |
219 | 221 | | |
220 | 222 | | |
221 | 223 | | |
222 | | - | |
| 224 | + | |
223 | 225 | | |
224 | 226 | | |
225 | 227 | | |
226 | 228 | | |
227 | | - | |
| 229 | + | |
228 | 230 | | |
229 | 231 | | |
230 | 232 | | |
231 | 233 | | |
232 | 234 | | |
233 | | - | |
| 235 | + | |
234 | 236 | | |
235 | 237 | | |
236 | 238 | | |
237 | 239 | | |
238 | 240 | | |
239 | 241 | | |
240 | | - | |
| 242 | + | |
241 | 243 | | |
242 | 244 | | |
243 | 245 | | |
244 | 246 | | |
245 | 247 | | |
246 | 248 | | |
247 | 249 | | |
248 | | - | |
| 250 | + | |
249 | 251 | | |
250 | 252 | | |
251 | 253 | | |
| |||
362 | 364 | | |
363 | 365 | | |
364 | 366 | | |
365 | | - | |
| 367 | + | |
366 | 368 | | |
367 | 369 | | |
368 | 370 | | |
369 | 371 | | |
370 | 372 | | |
371 | 373 | | |
372 | | - | |
| 374 | + | |
373 | 375 | | |
374 | | - | |
| 376 | + | |
375 | 377 | | |
376 | 378 | | |
377 | 379 | | |
| |||
457 | 459 | | |
458 | 460 | | |
459 | 461 | | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | 462 | | |
492 | 463 | | |
493 | 464 | | |
| |||
514 | 485 | | |
515 | 486 | | |
516 | 487 | | |
517 | | - | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
518 | 491 | | |
519 | 492 | | |
520 | 493 | | |
521 | 494 | | |
522 | 495 | | |
523 | 496 | | |
524 | | - | |
| 497 | + | |
525 | 498 | | |
526 | 499 | | |
527 | 500 | | |
528 | 501 | | |
529 | 502 | | |
530 | 503 | | |
531 | | - | |
| 504 | + | |
532 | 505 | | |
533 | 506 | | |
534 | 507 | | |
535 | 508 | | |
536 | | - | |
| 509 | + | |
537 | 510 | | |
538 | 511 | | |
539 | 512 | | |
540 | | - | |
| 513 | + | |
541 | 514 | | |
542 | 515 | | |
543 | 516 | | |
544 | 517 | | |
545 | 518 | | |
546 | 519 | | |
547 | | - | |
| 520 | + | |
548 | 521 | | |
549 | 522 | | |
550 | | - | |
| 523 | + | |
551 | 524 | | |
552 | 525 | | |
553 | | - | |
| 526 | + | |
554 | 527 | | |
555 | 528 | | |
556 | 529 | | |
557 | 530 | | |
558 | | - | |
| 531 | + | |
559 | 532 | | |
560 | 533 | | |
561 | | - | |
562 | | - | |
| 534 | + | |
| 535 | + | |
563 | 536 | | |
564 | | - | |
| 537 | + | |
565 | 538 | | |
566 | 539 | | |
567 | 540 | | |
568 | 541 | | |
569 | | - | |
| 542 | + | |
570 | 543 | | |
571 | 544 | | |
572 | 545 | | |
573 | 546 | | |
574 | | - | |
| 547 | + | |
575 | 548 | | |
576 | 549 | | |
577 | 550 | | |
578 | 551 | | |
579 | 552 | | |
580 | | - | |
| 553 | + | |
581 | 554 | | |
582 | 555 | | |
583 | | - | |
| 556 | + | |
584 | 557 | | |
585 | 558 | | |
586 | 559 | | |
587 | 560 | | |
588 | | - | |
| 561 | + | |
589 | 562 | | |
590 | 563 | | |
591 | 564 | | |
592 | | - | |
| 565 | + | |
593 | 566 | | |
594 | 567 | | |
595 | 568 | | |
| |||
618 | 591 | | |
619 | 592 | | |
620 | 593 | | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
0 commit comments