project-lighter / lighter

Config-based framework for organized and reproducible deep learning. MONAI Bundle + PyTorch Lightning.
https://project-lighter.github.io/lighter
MIT License
22 stars 2 forks source link

Apply `postproceessing` functions individually on batch items #91

Closed surajpaib closed 11 months ago

surajpaib commented 11 months ago

🚀 Feature Request

Currently, the postpostprocessing applies to the entire batch with [N,C,D,H,W] being passed as input. Because of that postprocessing won't support MONAI postprocessing transforms.

I suggest making it work individually on batch items so it can use monai's [C,D,H,W] supported transforms directly. I do not see any benefit in operating over a whole batch.

ibro45 commented 11 months ago

I'm not sure if we can make sure that decollate will work in all cases. Also, would we collate them into a batch after decollated postprocessing? It could bring more issues if the applied postprocessing prevents the examples from collating (e.g., different shape). On the other hand, if we don't collate it after postprocessing, then that's a problem for the criterion, possibly for the metrics too - in the best case, it would hurt only the time it takes because you'd have to loop over individual examples in the batch. Also, we would have to rewrite how loggers and writers handle data (e.g. https://github.com/project-lighter/lighter/blob/e64694230e74f5dd6e7e29fbdc532346401219d6/lighter/callbacks/utils.py#L18).

surajpaib commented 11 months ago

Nvm mind actually, I realized that this only makes sense for certain things.

I'm adding a transform myself to decollate and collate.