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
I'd like to be able to put my preprocessing steps in Hydra, so preproc.yaml would contain:
- _target_: monai.transforms.lambdadkeys: ["image", "mask"]func: | lambda x: x.unsqueeze(-1) if x.ndim == 2 else x
as part of a list with all of my preprocessing steps. Full example preproc.yaml is below.
The Issue
Hydra instantiates the list without raising any errors, but when I try to use the instantiated transforms, I get the following errors (full traceback below).
The func arg is being initialized as a string, not callable.
TypeError: func must be None or callable but is str.
And Hydra is actually parsing the string incorrectly.
RuntimeError: applying transform <monai.transforms.utility.dictionary.Lambdad object at 0x000001C296533C80>
('lambda x: x.unsqueeze(-1) if x.ndim == 2 else x\n',
'lambda x: x.unsqueeze(-1) if x.ndim == 2 else x\n')
Is what I'm trying to do possible with Hydra? Or can it not parse the YAML literal as Python and initialize the func arg with that code? Thanks in advance!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
This is a long one, sorry 😬.
The Goal
In my current setup, I use MONAI's Lambdad class as:
I'd like to be able to put my preprocessing steps in Hydra, so
preproc.yaml
would contain:as part of a list with all of my preprocessing steps. Full example
preproc.yaml
is below.The Issue
Hydra instantiates the list without raising any errors, but when I try to use the instantiated transforms, I get the following errors (full traceback below).
The
func
arg is being initialized as a string, not callable.And Hydra is actually parsing the string incorrectly.
Is what I'm trying to do possible with Hydra? Or can it not parse the YAML literal as Python and initialize the
func
arg with that code? Thanks in advance!Full
preproc.yaml
filePython code to instantiate and use preproc transforms with Hydra
I can't provide example image and mask files since they're proprietary for work, sorry.
Full traceback
Beta Was this translation helpful? Give feedback.
All reactions