Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port Existing Generative Tutorials #1769

Open
15 of 20 tasks
ericspod opened this issue Aug 5, 2024 · 10 comments
Open
15 of 20 tasks

Port Existing Generative Tutorials #1769

ericspod opened this issue Aug 5, 2024 · 10 comments

Comments

@ericspod
Copy link
Member

ericspod commented Aug 5, 2024

Is your feature request related to a problem? Please describe.
We have the following to port:

Let's divide amongst assignees and go from there. For each tutorial in the generative repo we should:

  1. Copy over the .ipynb file and not the .py file made with papermill, only those .py files that were written as such (I think distributed_training/ddpm_training_ddp.py is the only one).
  2. Change references from components in GenerativeModels to those in MONAI.
  3. Verify the tutorial still works.
  4. Fix any bugs.
@virginiafdez
Copy link
Contributor

Most of the tutorials merely require the changes mentioned above except for the following:

  • 3d_brainmask_controlnet: this tutorial is using synthetic 3D images generated by the model zoo LDM. The reason why we did that is that ControlNet requires to train an autoencoder, a diffusion model and then the controlnet network. In 3D, this is cumbersome - especially from a notebook tutorial. To shortcut this, we used the pre-trained LDM model (which includes the autoencoder and diffusion models), so that we only need to train the controlnet bit. However, this model is trained on T1 images. To have something to condition on, we decided to use the easiest form of condition we could do for the synthesis of T1 images, which are just brain masks. These masks and the specific training set we had to get them from somewhere, hence the current set-up where we use images from a Drive folder. Though implying the tutorial would change substantially, we could re-design this experiment. Perhaps we could train a very low dimension AE, LDM and Controlnet on BraTS.
  • 2d_spade_gan and 2D_spade_ldm: SPADE works better when a lot of semantic coverage is offered. This makes BraTS not a suitable dataset for it, cause it has only tumour segmentation masks. This prompted the use of another small version of a dataset for which we had associated segmentations (of GM, WM, DGM etc.) generated with GIF. Nonetheless, this dataset is not straightforward open-source, so we should not use it. I suggest using BraTS instead. I have a 2mm isotropic version of 25 T1 volumes from BraTS with associated semantic maps that can be used. It would be hosted from my Drive, at least from early on. It occupies approximately 25MB. I've already checked it works.

@Nic-Ma
Copy link
Contributor

Nic-Ma commented Aug 6, 2024

Hi @ericspod ,

As our ETA is end of this month, could you please help split the tasks directly based on the effort in your mind?
@virginiafdez @yiheng-wang-nv should be the experts to help here.

Thanks in advance.

@virginiafdez
Copy link
Contributor

I will take on the porting of 2d_spade_gan and 2D_spade_ldm, as well as 3d_brainsmask_controlnet from August 17th onwards, as per what I discussed in my previous comment.

@Nic-Ma
Copy link
Contributor

Nic-Ma commented Aug 6, 2024

I will take on the porting of 2d_spade_gan and 2D_spade_ldm, as well as 3d_brainsmask_controlnet from August 17th onwards, as per what I discussed in my previous comment.

Hi @yiheng-wang-nv , could you please help also pick several of the tutorials to port?

Thanks in advance.

@ericspod
Copy link
Member Author

ericspod commented Aug 6, 2024

I'm going to start with the 2D and 3D LDM tutorials in GenerativeModels. These are single notebooks which differ significantly in content from the existing LDM tutorials (https://github.com/Project-MONAI/tutorials/tree/main/generative/2d_ldm and https://github.com/Project-MONAI/tutorials/tree/main/generative/3d_ldm), so we have 4 tutorials here to check. I'll make sure the ones from GenerativeModels work first then those already here, and see how to best combine both.

@yiheng-wang-nv
Copy link
Contributor

I will work in the order of:

  • realism_diversity_metrics
  • image_to_image_translation
  • distributed_training
    -...

Will update this ticket when having any progrsses

@Nic-Ma
Copy link
Contributor

Nic-Ma commented Aug 7, 2024

Hi @ericspod ,

Thanks for your testing here, may I know why you want to test the "2D and 3D LDM tutorials in GenerativeModels"? I think maybe we can start the MONAI tutorials directly?

Thanks.

@ericspod
Copy link
Member Author

ericspod commented Aug 7, 2024

may I know why you want to test the "2D and 3D LDM tutorials in GenerativeModels"?

These should be fast to check and then move over, the ones in tutorials are move involved and I need to go over them at the same time to be sure they aren't essentially duplicating what is being demonstrated.

@ericspod ericspod mentioned this issue Aug 9, 2024
5 tasks
ericspod added a commit that referenced this issue Aug 13, 2024
Addresses part of #1769.

### Description
This updates the tutorials for LDM models and copies over the notebooks
from the GenerativeModels repo. These notebooks have been checked, the
3D one has its code updated but cell outputs left as-is to save time so
may need checking later. The MAISI tutorial was untouched but should be
updated as well.

### Checks
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [ ] Avoid including large-size files in the PR.
- [ ] Clean up long text outputs from code cells in the notebook.
- [ ] For security purposes, please check the contents and remove any
sensitive info such as user names and private key.
- [ ] Ensure (1) hyperlinks and markdown anchors are working (2) use
relative paths for tutorial repo files (3) put figure and graphs in the
`./figure` folder
- [ ] Notebook runs automatically `./runner.sh -t <path to .ipynb file>`

---------

Signed-off-by: Eric Kerfoot <eric.kerfoot@kcl.ac.uk>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@pedrob37
Copy link
Contributor

I'll start working on anomaly_detection for now, and I'll likely get around to a few more next week

@ericspod ericspod mentioned this issue Sep 4, 2024
5 tasks
@ericspod
Copy link
Member Author

ericspod commented Sep 4, 2024

I'm going to pick up the other 2D tutorials, hopefully these will be fast. the 3D DDPM tutorial works but I can't get good results out of it for some reason so far.

ericspod added a commit that referenced this issue Sep 6, 2024
Address some of #1769.

### Description
These are the 2D ~~and 3D~~ DDPM tutorials. I have run them again to
verify they work. ~~The 2D ones are fine but the 3D tutorial keeps
having mode collapse or some other issue resulting in bad results. Work
is ongoing on this one.~~ I have left the 3D tutorial off since it's not
training stably and needs some revamp to be a proper and useful tutorial
for users.

### Checks
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Avoid including large-size files in the PR.
- [x] Clean up long text outputs from code cells in the notebook.
- [x] For security purposes, please check the contents and remove any
sensitive info such as user names and private key.
- [x] Ensure (1) hyperlinks and markdown anchors are working (2) use
relative paths for tutorial repo files (3) put figure and graphs in the
`./figure` folder
- [x] Notebook runs automatically `./runner.sh -t <path to .ipynb file>`

---------

Signed-off-by: Eric Kerfoot <eric.kerfoot@kcl.ac.uk>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
pedrob37 pushed a commit to virginiafdez/tutorials that referenced this issue Sep 6, 2024
Address some of Project-MONAI#1769.

### Description
These are the 2D ~~and 3D~~ DDPM tutorials. I have run them again to
verify they work. ~~The 2D ones are fine but the 3D tutorial keeps
having mode collapse or some other issue resulting in bad results. Work
is ongoing on this one.~~ I have left the 3D tutorial off since it's not
training stably and needs some revamp to be a proper and useful tutorial
for users.

### Checks
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Avoid including large-size files in the PR.
- [x] Clean up long text outputs from code cells in the notebook.
- [x] For security purposes, please check the contents and remove any
sensitive info such as user names and private key.
- [x] Ensure (1) hyperlinks and markdown anchors are working (2) use
relative paths for tutorial repo files (3) put figure and graphs in the
`./figure` folder
- [x] Notebook runs automatically `./runner.sh -t <path to .ipynb file>`

---------

Signed-off-by: Eric Kerfoot <eric.kerfoot@kcl.ac.uk>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
ericspod added a commit that referenced this issue Sep 6, 2024
Address some of #1769.

### Description
This adds a few more tutorials from the GenerativeModels Repo

### Checks
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [ ] Avoid including large-size files in the PR.
- [ ] Clean up long text outputs from code cells in the notebook.
- [ ] For security purposes, please check the contents and remove any
sensitive info such as user names and private key.
- [ ] Ensure (1) hyperlinks and markdown anchors are working (2) use
relative paths for tutorial repo files (3) put figure and graphs in the
`./figure` folder
- [ ] Notebook runs automatically `./runner.sh -t <path to .ipynb file>`

---------

Signed-off-by: Eric Kerfoot <eric.kerfoot@kcl.ac.uk>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

No branches or pull requests

6 participants