Skip to content

Add generative model metrics notebook #1771

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

Merged
merged 14 commits into from
Aug 19, 2024

Conversation

yiheng-wang-nv
Copy link
Contributor

@yiheng-wang-nv yiheng-wang-nv commented Aug 7, 2024

Fixes #1770 .

Description

A few sentences describing the changes proposed in this pull request.

Checks

  • 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: Yiheng Wang <vennw@nvidia.com>
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@yiheng-wang-nv
Copy link
Contributor Author

Hi @ericspod @KumoLiu
the model weights used in this tutorial is removed, and the url mentioned in the original repo does not exist:
https://github.com/marksgraham/pretrained_generative_models/blob/main/models/ddpm_2d.py#L34

Do you have any suggestions? Can we use other weights to replace it?
The cell shows:

if use_pre_trained:
    unet = torch.hub.load("marksgraham/pretrained_generative_models:v0.2", model="ddpm_2d", verbose=True)
    unet = unet.to(device)
else:
    model_path = Path.cwd() / Path("tutorials/generative/2d_ldm/best_aeutoencoderkl.pth")
    autoencoderkl.load_state_dict(torch.load(str(model_path)))
    model_path = Path.cwd() / Path("tutorials/generative/2d_ldm/best_unet.pth")
    unet.load_state_dict(torch.load(str(model_path)))

it seems the 2d_ldm weights can be used, can we prepare a copy for users to download?

@ericspod
Copy link
Member

@marksgraham would you have the file that was stored in your google drive? We can rehost it somewhere else perhaps and get this added.

@marksgraham
Copy link
Contributor

Sorry I deleted them in a bulk drive clearout, without realising they were still being used here.

It is easy to regenerate the checkpoint by running the tutorial with use_pretrained=False. Then it can be stored somewhere more permanent..

@yiheng-wang-nv
Copy link
Contributor Author

Sorry I deleted them in a bulk drive clearout, without realising they were still being used here.

It is easy to regenerate the checkpoint by running the tutorial with use_pretrained=False. Then it can be stored somewhere more permanent..

Hi @marksgraham , thanks for the info. Can I confirm that we at least need to use trained 2d_ldm weights?

@marksgraham
Copy link
Contributor

Sorry I deleted them in a bulk drive clearout, without realising they were still being used here.
It is easy to regenerate the checkpoint by running the tutorial with use_pretrained=False. Then it can be stored somewhere more permanent..

Hi @marksgraham , thanks for the info. Can I confirm that we at least need to use trained 2d_ldm weights?

Hi @yiheng-wang-nv yes they will need to be trained too. You should be able to get trained versions for both of the sets of weights using this tutorial

@yiheng-wang-nv
Copy link
Contributor Author

Thanks @marksgraham , I will run 2d_ldm tutorial, and save weights into https://github.com/Project-MONAI/MONAI-extra-test-data, then we can use that links in the metric tutorial. cc @ericspod @KumoLiu

Signed-off-by: Yiheng Wang <vennw@nvidia.com>
Signed-off-by: Yiheng Wang <vennw@nvidia.com>
@yiheng-wang-nv yiheng-wang-nv marked this pull request as ready for review August 15, 2024 06:36
pre-commit-ci bot and others added 3 commits August 15, 2024 06:37
Signed-off-by: Yiheng Wang <vennw@nvidia.com>
Signed-off-by: Yiheng Wang <vennw@nvidia.com>
@yiheng-wang-nv
Copy link
Contributor Author

Hi @ericspod , do you have any experiences on this error: https://github.com/Project-MONAI/tutorials/actions/runs/10400120252/job/28800115713?pr=1771#step:5:710
Run the notebook locally does not bring me same error.

Signed-off-by: Yiheng Wang <vennw@nvidia.com>
Signed-off-by: Yiheng Wang <vennw@nvidia.com>
@yiheng-wang-nv
Copy link
Contributor Author

Hi @ericspod , do you have any experiences on this error: https://github.com/Project-MONAI/tutorials/actions/runs/10400120252/job/28800115713?pr=1771#step:5:710 Run the notebook locally does not bring me same error.

I guess the CI machine may have some issues when load radimagenet weights, I changed to use torchvision's resnet50 as the feature extractor, and now tests pass.

@KumoLiu
Copy link
Contributor

KumoLiu commented Aug 15, 2024

I guess the CI machine may have some issues when load radimagenet weights, I changed to use torchvision's resnet50 as the feature extractor, and now tests pass.

I think the update here should be fine since the notebook is mainly talk about the metric used in the generative model. What do you think? @ericspod

@ericspod
Copy link
Member

Hi @ericspod , do you have any experiences on this error: https://github.com/Project-MONAI/tutorials/actions/runs/10400120252/job/28800115713?pr=1771#step:5:710
Run the notebook locally does not bring me same error.

If you can get it to work with another network let's go with that. For the future this is related to numerical error with scipy.linalg.sqrtm in the FID calculation that's somewhat documented in other implementations, such as here. It appears to be sensitive to the version of scipy being used or other libraries it relies on.

KumoLiu and others added 2 commits August 16, 2024 19:40
Signed-off-by: Yiheng Wang <vennw@nvidia.com>
@KumoLiu KumoLiu merged commit 88d22e8 into Project-MONAI:main Aug 19, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

realism_diversity_metrics
4 participants