Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Conversation

@JuliaWolleb
Copy link
Contributor

Draft pull request for issue 155: add tutorial about diffusion models for medical anomaly detection using gradient guidance.

@JuliaWolleb JuliaWolleb linked an issue Jan 16, 2023 that may be closed by this pull request
@JuliaWolleb JuliaWolleb marked this pull request as draft January 16, 2023 10:52
@SANCHES-Pedro
Copy link
Contributor

Hi @JuliaWolleb, I've written the code for getting the Brats 2D as used in papers for anomaly detection. I can push it later today so you can use it as well.

I guess the code will be fairly similar for our two tutorials ;)

@JuliaWolleb
Copy link
Contributor Author

Hi @SANCHES-Pedro
That would be great, thanks a lot!

@SANCHES-Pedro
Copy link
Contributor

Hi @JuliaWolleb,

You can find the loader in this commit:

4d9c30d

@JuliaWolleb
Copy link
Contributor Author

Hi @SANCHES-Pedro

I started implementing the tutorial for anomaly detection with gradient guidance, the training works fine now. Thanks for the brats loader, that helped :)
Now for sampling, I need to run the reversed DDIM sampling scheme to encode an image in noise. I think you need the same for your method. Have you had a look at that already? Do you know whether it is implemented somewhere?

Best,
Julia

@SANCHES-Pedro
Copy link
Contributor

Great, I'm glad that was useful.

Yes, I started implementing the reverse DDIM, but haven't committed it yet. It hasn't been implemented anywhere else just yet.

I'm on holiday until next week, I let you know once it's done.

Best,
Pedro

@JuliaWolleb
Copy link
Contributor Author

Hi

Great, I have also started implementing it, so no pressure :)
But maybe we can compare our approaches once we are done?

Have nice holidays!
Julia

@JuliaWolleb
Copy link
Contributor Author

Hi @SANCHES-Pedro
I pushed my tutorial to the branch 155, everything should be there.
I still need to check whether the trained models are good enough like that, and some cleaning up is also required.
Should we discuss at some point whether we have similar approaches?

Best,
Julia

@SANCHES-Pedro
Copy link
Contributor

Hi @JuliaWolleb,

Awesome. Yes, it would be great to have a discussion about it.

I will check the code and I let you know ;)

Best,
Pedro

@JuliaWolleb
Copy link
Contributor Author

Great, thanks a lot @SANCHES-Pedro

Be aware that it is not a cleaned-up version yet, so just look at the general structure, and we can discuss how to make it clearer.

Best,
Julia

@JuliaWolleb
Copy link
Contributor Author

Hi @SANCHES-Pedro

I just wanted to check how it is going with the anomaly detection tutorial.
Did you already have time to look at the structure?

Best,
Julia

@SANCHES-Pedro
Copy link
Contributor

Hi @JuliaWolleb ,

yes, I had a chance to check it out. It looks great, good to see that it's working fine. The DDIM with reverse_step is working well!

A few comments:

  1. Shall we create a folder tutorials/anomaly_detection instead of including it on tutorials/generative
  2. You might want to clean up all the saving in .pt files that is done along the code.
  3. Shall we quickly verify that the diffusion model is generating (visually ) "good" images before running the anomaly detection?

@JuliaWolleb
Copy link
Contributor Author

Hi @SANCHES-Pedro

Great, thanks a lot for checking :)

  1. Yes, I think it would be good to have a folder tutorials/anomaly_detection. Would this also be ok for you @Warvito ?
  2. Sure, I will omit the saving of the models. There is also a local path that I will need to delete.
  3. That's a good idea, I will include a code block to see whether the diffusion model is working fine.

@Warvito
Copy link
Collaborator

Warvito commented Mar 10, 2023

  1. Yes, I think it would be good to have a folder tutorials/anomaly_detection. Would this also be ok for you @Warvito ?

Yes, would be okay to have it at tutorials/anomaly_detection.

@Warvito
Copy link
Collaborator

Warvito commented Mar 15, 2023

  1. Yes, I think it would be good to have a folder tutorials/anomaly_detection. Would this also be ok for you @Warvito ?

Yes, would be okay to have it at tutorials/anomaly_detection.

Sorry, I thought tutorials//generative/anomaly_detection. Hum, my idea was to move everything inside the tutorial directory to the tutorials repository later (https://github.com/Project-MONAI/tutorials). I was thinking of having everything using generative models inside a generative folder there (similar to the monai label, model zoo). But would you prefer to have it in a folder in the project root there?

@JuliaWolleb JuliaWolleb requested a review from Warvito March 15, 2023 09:59
@JuliaWolleb JuliaWolleb marked this pull request as ready for review March 15, 2023 10:03
@JuliaWolleb
Copy link
Contributor Author

Ah I see, sure this is fine with me. i think Pedro then also needs to change it in his pull request

Copy link
Collaborator

@Warvito Warvito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @JuliaWolleb !! The tutorial and the results look very cool!! I added a few comments regarding the new network and the dataloader in the tutorial. They are similar to what I proposed to Pedro in #306 (review)
In Pedro PR, I also added a few comments regarding the reversed_step.

Please, let me know your thoughts about the data loading, and after performing the changes I will help with the conflict with the commits of the main branch. Again, thanks for helping with this tutorial! ^^

JuliaWolleb and others added 11 commits March 17, 2023 16:21
Co-authored-by: Walter Hugo Lopez Pinaya <ianonimato@hotmail.com>
Co-authored-by: Walter Hugo Lopez Pinaya <ianonimato@hotmail.com>
Co-authored-by: Walter Hugo Lopez Pinaya <ianonimato@hotmail.com>
Co-authored-by: Walter Hugo Lopez Pinaya <ianonimato@hotmail.com>
Co-authored-by: Walter Hugo Lopez Pinaya <ianonimato@hotmail.com>
Co-authored-by: Walter Hugo Lopez Pinaya <ianonimato@hotmail.com>
Co-authored-by: Walter Hugo Lopez Pinaya <ianonimato@hotmail.com>
Co-authored-by: Walter Hugo Lopez Pinaya <ianonimato@hotmail.com>
…maly-detection' of github.com:Project-MONAI/GenerativeModels into 155-add-tutorial-about-diffusion-models-for-medical-anomaly-detection

-m 'get changes'

i get changes from github
esc
:wq
@JuliaWolleb
Copy link
Contributor Author

Hi @Warvito
I included all changes you suggested, now this branch should be up-to-date. What can/should I do such that you can merge it to the main branch?
Ah, and one thing: my tutorial is now in the folder tutorials/generative/anomaly_detection/classifier_guidance_anomalydetection/... . Should I move them one folder up?

@Warvito
Copy link
Collaborator

Warvito commented Mar 22, 2023

Hi @Warvito I included all changes you suggested, now this branch should be up-to-date. What can/should I do such that you can merge it to the main branch?

Hi @JuliaWolleb . Thank you for the changes! It looks great. I saw that you merged the main into the branch as expected, but the branch still changing a few things that it should not. Do you mind if I add a commit to fix that?

Ah, and one thing: my tutorial is now in the folder tutorials/generative/anomaly_detection/classifier_guidance_anomalydetection/... . Should I move them one folder up?

Yes, I guess it will be okay to have the 3 methods in the tutorials/generative/anomaly_detection

@JuliaWolleb
Copy link
Contributor Author

JuliaWolleb commented Mar 22, 2023

Hi @Warvito
Sure, just add any commit to fix the issues. Is there anything I still need to do, or are we done then?

Warvito added 3 commits March 22, 2023 12:13
Signed-off-by: Walter Hugo Lopez Pinaya <ianonimato@hotmail.com>
Signed-off-by: Walter Hugo Lopez Pinaya <ianonimato@hotmail.com>
Signed-off-by: Walter Hugo Lopez Pinaya <ianonimato@hotmail.com>
Copy link
Collaborator

@Warvito Warvito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this tutorial @JuliaWolleb ! It is looking great. I fixed the files that it was complaining about, moved the tutorial one folder up and it is ready for merge ^^

@Warvito Warvito merged commit 829ce42 into main Mar 22, 2023
@Warvito Warvito deleted the 155-add-tutorial-about-diffusion-models-for-medical-anomaly-detection branch March 31, 2023 18:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add tutorial about "Diffusion Models for Medical Anomaly Detection"

4 participants