-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Provide all available data in engine.state.output of workflows #2026
Description
Is your feature request related to a problem? Please describe.
The problem and idea is that:
currently, MONAI post transforms(independent with ignite) execute on the engine.state.output dict, the post transforms can't get some useful information in engine.state.batch, for example, the meta_dict of images or some transform information we put in the engine.state.batch. As @vfdev-5 and I discussed in the ignite ticket: pytorch/ignite#1923, I think we need to shallow-copy the data of engine.state.batch into engine.state.output, then post transforms and handlers can get all the available data from only 1 dict.
The data flow can run through all the components and no need to write 2 lambda funs (batch_transform and output_transform) in handlers, we can use keys to get expected data directly.
I didn't find any benefit to split the data flow into state.batch and state.output in MONAI.
For the first step, I plan to change this line as aligned with @vfdev-5 :
https://github.com/Project-MONAI/MONAI/blob/master/monai/engines/trainer.py#L160
into:
engine.state.output = dict(engine.state.batch)
engine.state.output.update({Keys.IMAGE: inputs, Keys.LABEL: targets})Then we can use engine.state.output in post transforms and handlers as the overall data flow, and no need to get data from engine.state.batch anymore.
Do you guys have any comments?
Thanks in advance.