Replies: 6 comments 4 replies
-
Hi @Nic-Ma How about inspecting from monai.transforms import LoadImaged
load_image = LoadImaged(keys=["image", "seg"], meta_key_postfix="11")
print(load_image.__dict__)
>
{'keys': ('image', 'seg'), 'allow_missing_keys': False, '_loader': <monai.transforms.io.array.LoadImage object at 0x7f0082845eb0>, 'meta_key_postfix': '11', 'overwriting': False} |
Beta Was this translation helpful? Give feedback.
-
Hi @vfdev-5 , Thanks for your help here. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the explanation! Let me check what we are doing to check the signature...
This looks like about logging a configuration which I think this should be done separately:
|
Beta Was this translation helpful? Give feedback.
-
Hi @vfdev-5 , The main purpose of this feature is to export a config from a regular MONAI program which is based on pytorch and ignite. from monai.transforms import LoadImaged
load_image = LoadImaged(keys=["image", "seg"], meta_key_postfix="11")
net = ...
loss = ...
trainer =...
trainer.run()
# call export to get the config and save into JSON
export_config([trainer, net, loss, load_image]) Thanks. |
Beta Was this translation helpful? Give feedback.
-
perhaps you can trace the call like this one: https://stackoverflow.com/a/8315566 and filter the relevant constructor calls. (I'm converting the ticket to a discussion) |
Beta Was this translation helpful? Give feedback.
-
Another way would be to monkey-patch the constructor to capture arguments somewhere when called, using |
Beta Was this translation helpful? Give feedback.
-
Hi @ericspod @wyli @vfdev-5 ,
I got an important feature request from the internal team: how to get the init args and the values from a MONAI or ignite class instance and then used for logging or exporting to JSON files, etc.
For example:
How to get
{"keys": ["image", "seg"], "meta_key_postfix": "11"}
from theload_image
instance?I tried
inspect
, but seems it can only get the self.XXX instead of the real original init args, here is my test program:And the the output:
count and flag are not correct here.
Do you python experts have some cool ideas for this problem?
I am blocked by this problem and didn't get a good solution so far, appreciate any help here!
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions