Project-MONAI / MONAI

AI Toolkit for Healthcare Imaging
https://monai.io/
Apache License 2.0
5.89k stars 1.09k forks source link

Refactor additions from Generative module #7227

Open marksgraham opened 1 year ago

marksgraham commented 1 year ago

After merging MONAI Generative into core issue some refactoring is needed to reduce repeat code, see discussion here.

Until this is done any blocks from Generative that are likely to be removed will be marked as private.

Will update the list of items needing refactoring here as I go along:

vikashg commented 10 months ago

Closing @marksgraham as it seems to be completed and merged.

marksgraham commented 10 months ago

Hi @vikashg afraid this is still pending so re-opening!

KumoLiu commented 10 months ago

Add here as a reminder. https://github.com/Project-MONAI/MONAI/pull/7346#discussion_r1444749763 https://github.com/Project-MONAI/MONAI/pull/7346#discussion_r1444207936

vgrau98 commented 10 months ago

I can start working on SABlock, integrating the private block and making refacto if needed if this is ok for you @marksgraham

marksgraham commented 9 months ago

Hi @vgrau98 yes that would be great! One thing to bear in mind is that ideally, a DiffusionModelUnet trained before the refactor should be able to load the same weights post-refactor. Happy to chat about this more if you want.

marksgraham commented 8 months ago

I can start working on SABlock, integrating the private block and making refacto if needed if this is ok for you @marksgraham

Hi @vgrau98 I'm getting back to this refactor now. Wondering if you managed to make any progress on the SABlock refactor?

ericspod commented 3 months ago

@virginiafdez we should come back to the last two items here to see if we want to address anything next.

KumoLiu commented 3 months ago

Hi @ericspod @virginiafdez, during refactoring MAISI with the latest components in the core we also find that some refactor here may not achieve similar performance as before. Such as we use one linear to replace three linear used in generative repo. Although the weights can be loaded correctly, but the result show much difference. https://github.com/Project-MONAI/MONAI/blob/139b62c4aa161969ad1126c4feeec88c9833d4ef/monai/networks/blocks/selfattention.py#L89

https://github.com/Project-MONAI/GenerativeModels/blob/7428fce193771e9564f29b91d29e523dd1b6b4cd/generative/networks/blocks/selfattention.py#L80-L83

Before doing further refactor, I would suggest we may need to verify several tutorials to see whether we can achieve the similar the performance as before. What do you think?