Is your feature request related to a problem? Please describe.
Hi @ericspod @wyli @rijobro ,
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.
Is your feature request related to a problem? Please describe.
Hi @ericspod @wyli @rijobro ,
The problem and idea is that:
currently, MONAI post transforms(independent with ignite) execute on the
engine.state.outputdict, the post transforms can't get some useful information inengine.state.batch, for example, the meta_dict of images or some transform information we put in theengine.state.batch. As @vfdev-5 and I discussed in the ignite ticket: pytorch/ignite#1923, I think we need to shallow-copy the data ofengine.state.batchintoengine.state.output, thenpost transformsandhandlerscan 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_transformandoutput_transform) in handlers, we can usekeysto get expected data directly.I didn't find any benefit to split the data flow into
state.batchandstate.outputin 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:
Then we can use
engine.state.outputin post transforms and handlers as the overall data flow, and no need to get data fromengine.state.batchanymore.Do you guys have any comments?
Thanks in advance.