-
Notifications
You must be signed in to change notification settings - Fork 92
✨ Define SemanticSegmentor
with the New EngineABC
#866
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?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev-define-engines-abc #866 +/- ##
==========================================================
+ Coverage 91.77% 91.86% +0.08%
==========================================================
Files 73 74 +1
Lines 9345 9436 +91
Branches 1222 1234 +12
==========================================================
+ Hits 8576 8668 +92
Misses 756 756
+ Partials 13 12 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
for more information, see https://pre-commit.ci
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
- Use `input_resolutions` instead of resolution to make engines outputs compatible with ioconfig. - Uses input resolution as a list of dictionaries on units and resolution.
- Use `input_resolutions` instead of resolution to make engines outputs compatible with ioconfig. - Uses input resolution as a list of dictionaries on units and resolution.
…mentor # Conflicts: # tests/engines/test_engine_abc.py # tests/engines/test_patch_predictor.py # tiatoolbox/models/engine/engine_abc.py # tiatoolbox/models/engine/io_config.py # tiatoolbox/models/engine/patch_predictor.py
…929) - This PR saves a NumPy or Zarr Array to OME tiff. This will help to save probability maps from deep learning models as ome.tiff which can be visualized using TIAViz. - The image is written as tiles and stitched in OME tiff along with associated necessary metadata for heatmaps generated by segmentation engine. #866 - Reading with QuPath and TIAViz has been tested.
# Conflicts: # tests/test_utils.py # tiatoolbox/utils/misc.py
# Conflicts: # tests/test_utils.py # tiatoolbox/utils/misc.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
This PR integrates a new EngineABC
into the library by defining SemanticSegmentor
and refactors related utilities to support patch-based segmentation consistently.
- Renames and refactors
dict_to_store
→dict_to_store_patch_predictions
and updates looping logic indict_to_zarr
- Adds
patch_input_shape
validation inPatchDataset
via a newDimensionMismatchError
- Introduces
argmax_last_axis
util and replaces inline post-processing in UNet/vanilla architectures - Updates tests and sample data to exercise the new
SemanticSegmentor
and shape checks
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
tiatoolbox/utils/transforms.py | Expanded imresize interpolation type to accept int or str . |
tiatoolbox/utils/misc.py | Renamed dict_to_store , refactored dict_to_zarr to loop keys. |
tiatoolbox/utils/exceptions.py | Added DimensionMismatchError for shape mismatches. |
tiatoolbox/models/engine/engine_abc.py | Updated calls to new store function, propagate ioconfig . |
tiatoolbox/models/dataset/dataset_abc.py | Added patch_input_shape param and runtime shape check. |
tiatoolbox/models/architecture/utils.py | New argmax_last_axis util. |
tiatoolbox/models/architecture/vanilla.py | Replaced inline postproc with argmax_last_axis . |
tiatoolbox/models/architecture/unet.py | Switched batch output to dict, added pad and postproc method. |
tiatoolbox/data/remote_samples.yaml | Added a new thumbnail sample. |
tests/ | Updated tests to use new functions, added dimension-mismatch tests. |
Comments suppressed due to low confidence (3)
tiatoolbox/utils/misc.py:1643
- Within the loop you cast
raw_predictions[key]
toarray
but then pass the originalvalue
. You should passarray
to thedata
parameter to ensure the dataset uses the NumPy array with the correct shape.
z.create_dataset(name=key, data=value, compression=compressor, shape=array.shape,)
tiatoolbox/utils/transforms.py:97
- [nitpick] The signature now allows
interpolation
to be anint
orstr
. Please update the function docstring to reflect that both types are accepted.
output_size: int | tuple[int, int] | None = None,
tests/test_utils.py:1650
- Add a test to verify that
dict_to_zarr
correctly creates all datasets for each key inraw_predictions
, including optionalchunks
parameters if those are expected.
# test dict_to_zarr with multiple keys
@@ -609,6 +617,18 @@ def __getitem__(self: PatchDataset, idx: int) -> dict: | |||
if not self.data_is_npy_alike: | |||
patch = self.load_img(patch) | |||
|
|||
if patch.shape[:-1] != tuple(self.patch_input_shape): |
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.
[nitpick] If patch_input_shape
is None
, calling tuple(self.patch_input_shape)
will raise a TypeError
. Consider validating or requiring patch_input_shape
in the constructor and raising a clear error if not provided.
Copilot uses AI. Check for mistakes.
SemanticSegmentor
with the NewEngineABC