🐛 Fix Broken Margin Behaviour#1067
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1067 +/- ##
===========================================
- Coverage 99.88% 99.77% -0.12%
===========================================
Files 85 85
Lines 11625 11658 +33
Branches 1524 1530 +6
===========================================
+ Hits 11612 11632 +20
- Misses 7 13 +6
- Partials 6 13 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Is this related to my issue with |
It fixed a similar-looking issue I was having when changing the margin (not the stride as in your case). What I was getting was basically the same error you saw: On some values, but when varying margin not stride. I was hoping it might fix your issue too, but tried it on the same slide as in your issue and it does not. So, similar symptoms but not the same cause. |
|
This PR now fixes #1071 too |
There was a problem hiding this comment.
Pull request overview
This PR fixes vertical probability-map merging behavior, especially when intermediate probability rows spill to Zarr during WSI segmentation, so later chunks continue appending instead of being dropped.
Changes:
- Adds generalized vertical chunk aggregation for semantic segmentation with multi-row overlap handling.
- Keeps and returns the opened Zarr group during multitask vertical probability spilling.
- Adds regression tests for multi-row overlap and continuing appends after Zarr spill.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
tiatoolbox/models/engine/semantic_segmentor.py |
Refactors vertical merging to aggregate active overlapping chunks and store finalized segments incrementally. |
tiatoolbox/models/engine/multi_task_segmentor.py |
Updates multitask probability spilling to retain the Zarr group for later appends. |
tests/engines/test_semantic_segmentor.py |
Adds coverage for a row overlapping multiple following rows. |
tests/engines/test_multi_task_segmentor.py |
Updates cache helper test and adds a regression test for post-spill appending. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| zarr_group=( | ||
| zarr_group if probabilities_zarr[idx] is not None else None | ||
| ), |
|
Looks good. |
Fixes a bug in MultiTaskSegmentor’s WSI probability-map vertical merging when spilling intermediate probability rows to Zarr. Previously, once a head spilled to Zarr, subsequent chunks for that same head could continue accumulating in memory instead of being appended to the Zarr. At finalization, the code preferred the Zarr array and discarded the in-memory chunks, producing truncated probability maps for only the heads that spilled resulting in the shape mismatch that was being seen by me and Jiaqi.
The fix keeps hold of the opened Zarr group after the first spill and routes later chunks for that head into the same Zarr dataset. This preserves the full merged probability-map height across all heads.