-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add SomeOf transform composer #6143
Conversation
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 your contribution! Just leave some comments in line.
@atbenmurray Is there anything we need to look at here relating to lazy transforms and/or random state? |
ce03892
to
f682caf
Compare
I'm taking a look now |
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.
In general, implementations cannot dynamically modify transform lists on a call by call basis without breaking in the general case. OneOf and RandomOrder are good examples of how to implement such a function in a way that the transform list remains static.
@tuanchien I realise I have dropped a lot of complexity on you here about all this. I am happy to discuss how you might achieve what you want with this PR using a |
@atbenmurray thanks for your offer. Will take a stab at it first. |
From my understanding, the differences between this implementation and the Albumentations version are: This version:
Albumentations:
|
58f2dfb
to
8d3e5dd
Compare
I've added a weights parameter with a similar normalisation to |
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.
Looking much better; a few edge cases in testing still to hit, but nearly there
00c4e08
to
ad419ef
Compare
Signed-off-by: Tuan Chien <[email protected]>
91e86b2
to
e84ee42
Compare
Signed-off-by: Tuan Chien <[email protected]>
Signed-off-by: Tuan Chien <[email protected]>
Signed-off-by: Tuan Chien <[email protected]>
Signed-off-by: Tuan Chien <[email protected]>
Signed-off-by: Tuan Chien <[email protected]>
hi @atbenmurray could you please finalize the review here? |
Taking a look now |
Signed-off-by: Wenqi Li <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>
/build |
good point, I think it should work by looking at the collate function: Lines 429 to 438 in b87375f
@tuanchien have you tried this transform in an end-to-end training example, with monai's dataloader and dataset? and @atbenmurray perhaps we can merge this PR now? I think this SomeOf is a good use case, if the collate function doesn't support it, we should improve the collate function... |
/build |
@wyli sorry for the late response. I have not looked at the collate function. But for what it's worth, the project I used SomeOf on was end-to-end using MONAI transforms, data loaders, and dataset classes. |
SomeOf transform composer ### Description Adds a new transform composer allowing the user to sample "some of" the transforms from a given list of transforms. Allows sampling a fixed number, or variable number of transforms within a configurable range. Sampling is uniform and without replacement. The Compose class does almost all of the heavy lifting. This class just replaces the list of transforms each time with a newly sampled list of transforms on each `__call__` invocation. The simple sampling entry point will allow for easy extension later in case there's a need to add support for other probability distributions. This allows users to compose MONAI transforms in a non sequential way without needing to write their own compositor, or wrapping compositors from frameworks like Albumentations. Maybe of interest to Issue Project-MONAI#5312 ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: Tuan Chien <[email protected]>
SomeOf transform composer ### Description Adds a new transform composer allowing the user to sample "some of" the transforms from a given list of transforms. Allows sampling a fixed number, or variable number of transforms within a configurable range. Sampling is uniform and without replacement. The Compose class does almost all of the heavy lifting. This class just replaces the list of transforms each time with a newly sampled list of transforms on each `__call__` invocation. The simple sampling entry point will allow for easy extension later in case there's a need to add support for other probability distributions. This allows users to compose MONAI transforms in a non sequential way without needing to write their own compositor, or wrapping compositors from frameworks like Albumentations. Maybe of interest to Issue Project-MONAI#5312 ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: Tuan Chien <[email protected]>
I'd like to offer our belated thanks for your contribution @tuanchien. I am sure people will find this very useful! |
SomeOf transform composer
Description
Adds a new transform composer allowing the user to sample "some of" the transforms from a given list of transforms. Allows sampling a fixed number, or variable number of transforms within a configurable range.
Sampling is uniform and without replacement.
The Compose class does almost all of the heavy lifting. This class just replaces the list of transforms each time with a newly sampled list of transforms on each
__call__
invocation. The simple sampling entry point will allow for easy extension later in case there's a need to add support for other probability distributions.This allows users to compose MONAI transforms in a non sequential way without needing to write their own compositor, or wrapping compositors from frameworks like Albumentations.
Maybe of interest to Issue #5312
Types of changes
./runtests.sh -f -u --net --coverage
../runtests.sh --quick --unittests --disttests
.make html
command in thedocs/
folder.