-
Notifications
You must be signed in to change notification settings - Fork 3
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
Refactor TiledDataset
into TiledDataset
and TiledMaskedDataset
#32
Refactor TiledDataset
into TiledDataset
and TiledMaskedDataset
#32
Conversation
This is obsolete code that is never called, as `using_qlty` is set to `False` by default and and is also set to `False` in the only place where it is specified.
Obsolete code that is never applied.
New structure easily enables inference on a subset of the data.
Note: `partial_inference` function currently has no test.
TiledDataset
into TiledDataset
and `TiledMaskedDatasetTiledDataset
into TiledDataset
and TiledMaskedDataset
Circumvents `AttributeError: 'PatchedStreamingResponse' object has no attribute 'background'`, updating Tiled to `v0.1.0b8` will resolve this too.
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.
Thanks for the hard work, the redesigned classes does clearly separate out cases for train vs full inference, and pytests run properly on my end.
In order to let the real pipeline run properly, one minor changes are needed:
image = dataset[idx]
a further slice is needed to take only the image part from the image mask pair tuple.
assert io_parameters.mask_tiled_uri, "Mask URI not provided for training."
mask_tiled_uri should no longer be checked as this won't be provided for the full inference anymore, thus this should be taken out.
With that, I believe this PR is ready to be merged to the refactor branch.
instead of `TiledDataset`
Thanks for taking a look and testing the full pipeline on your end! I would like to defer the correct initialization of |
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.
Nice catch. Tested the train + quick inference and it runs properly on my end.
I agree that further refactor of the full inference part should be deferred.
This PR is ready to be merged.
The previous iteration of
TiledDataset
used boolean parametersis_full_segmentation
andis_training
, as well as the setting attributesmask_client
andmask_idx
toNone
if no Tiled client with mask information was provided.This refactor converts
TiledDataset
to be equivalent to have the functionality previously used withis_full_segmentation
. It is defined based on a Tiled client with data. Optionally a set of indices can be provided. This is useful for crafting data sets with any subsets of indices, but is also applied when mask information is given during training.TiledMaskedDataset
is a subclass ofTiledDataset
that additionally requires a Tiled client with mask information. This client is expected to contain a list of integers in within.metadata["mask_idx"]
, and contain actual mask data under the key"mask"
. Presence of both is asserted.The parameter
is_training
is still in use for the functioninitialize_tiled_datasets
(which has been moved fromutils.py
totiled_dataset.py
), but this may change in upcoming refactoring ofIOParameters
.To summarize:
-
TiledDataset(data_client, mask_client=None, is_training=False, is_full_segmentation=True)
→TiledDataset(data_client)
-
TiledDataset(data_client, mask_client, is_training=False, is_full_segmentation=False)
→TiledDataset(data_client, mask_client.metadata["mask_idx"])
-
TiledDataset(data_client, mask_client, is_training=True, is_full_segmentation=False)
→TiledMaskedDataset(data_client, mask_client)
We may need to consider bringing back the
transform
parameter that used to convert totorch.Tensor
and adapt downstream procedures to operate on tensors rather thannp.array
.