You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both UnionDataset and IntersectionDataset don't have a way to add transforms neither call self.transforms in their __get_item__ method. The transforms from the merged or intersected datasets are called in their own __get_item__ methods, but there are situations where having it on the UnionDataset or IntersectionDataset is more convenient and useful.
Rationale
In some situations having transforms on each merged or intersected dataset might be enough, but here's a couple of cases where this is needed:
Using the IntersectionDataset to add a mask to an image. For the transforms where information information from both mask and image are needed (i.e. filter mask where image has no data).
Using UnionDataset to merge multiple RasterDatasets (or IntersectionDatasets) and add only one transforms to the whole dataset instead of on each one.
Implementation
One possible way would be to just add the call to self.transforms in UnionDataset and IntersectionDataset:
if self.transforms is not None:
sample = self.transforms(sample)
And let people assign a transform after doing the intersection/union by doing my_dataset.transforms = my_transforms. Or adding an add_transforms method to IntersectionDataset and UnionDataset to make it more explicit.
Alternatives
One alternative is to add a transforms parameter to IntersectionDataset and UnionDataset, and also call it on __get_item__. But this forces people to use the constructor directly instead of doing & or |.
Another option is to create a TransformableDataset that takes a dataset and transforms as parameters. Calls the underlying datasets __get_item__ and then transforms in its __get_item__.
Additional information
No response
The text was updated successfully, but these errors were encountered:
I like this idea. Another reason this is important is for things like random flips/rotations that need to be applied uniformly to both images and target labels.
One possible way would be to just add the call to self.transforms in UnionDataset and IntersectionDataset... And let people assign a transform after doing the intersection/union by doing my_dataset.transforms = my_transforms
One alternative is to add a transforms parameter to IntersectionDataset and UnionDataset
I like both of these ideas, and I don't see any reason why we can't do both. Want to submit a PR?
Summary
Both UnionDataset and IntersectionDataset don't have a way to add transforms neither call
self.transforms
in their__get_item__
method. The transforms from the merged or intersected datasets are called in their own__get_item__
methods, but there are situations where having it on the UnionDataset or IntersectionDataset is more convenient and useful.Rationale
In some situations having transforms on each merged or intersected dataset might be enough, but here's a couple of cases where this is needed:
Implementation
One possible way would be to just add the call to self.transforms in UnionDataset and IntersectionDataset:
And let people assign a transform after doing the intersection/union by doing
my_dataset.transforms = my_transforms
. Or adding anadd_transforms
method to IntersectionDataset and UnionDataset to make it more explicit.Alternatives
One alternative is to add a transforms parameter to IntersectionDataset and UnionDataset, and also call it on
__get_item__
. But this forces people to use the constructor directly instead of doing & or |.Another option is to create a TransformableDataset that takes a dataset and transforms as parameters. Calls the underlying datasets
__get_item__
and then transforms in its__get_item__
.Additional information
No response
The text was updated successfully, but these errors were encountered: