-
Notifications
You must be signed in to change notification settings - Fork 60
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
Adding transformation adaptor #193
Conversation
if k_output is None: | ||
ditems = ret | ||
else: | ||
if isinstance(ret, type(ditems[k_output])): |
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.
For my information, I'm not sure I understand this. Is the dictionary expected to already contain k_output
? And why do the types need to match? This seems overly restrictive—consider e.g. loading an image tensor from a path.
Another comment is that the MONAI docs suggest that transforms shouldn't modify input dictionaries in-place, but rather call ditems.copy()
before assigning the outputs.
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.
I think they're both good comments:
- correct we could extend this adaptor to be compatible with a broader set of transformations and also give the option to add a key rather than just overwriting. I wanted to keep this as simple as possible to solve our current case.
- do you know why MONAI suggest to copy? here I am a bit worried about memory consumption if every transformation is creating a copy but happy to follow up on this
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.
On the second point, it's just a shallow copy of the dictionary, in case the original needs to be used elsewhere (e.g. if passed to multiple parallel transformations).
PR to add a transformation adaptor to allow transformations working only on Tensors/Images to work with a dict in input