JuliaWolleb / diffusion-anomaly

Anomaly detection with diffusion models
MIT License
115 stars 24 forks source link

Input and Output of the "classifier_sample_known.py" are different from each other. #25

Open rreezN opened 2 months ago

rreezN commented 2 months ago

Hi @JuliaWolleb ,

Thanks for your awesome publication!

I am currently looking at trying to train and sample with the framework you have made, and the training process seems to work just fine. While reading the paper and trying to look at the code, a few questions arose. The first one is regarding what you write in your paper, where you state that you normalise the data to values between 0 and 1. I have tried to look at code but I can't find it, and I probably just overlooked it, but could you point out where in the code you have it implemented?

I have managed to train on a subset of brats21 (approx. 1200 cases), and I can sample brain MR images. One example is shown here, image As you can see, the model is not quite as good as the one from your paper in detecting anomalies, and I have some worries in regards to that which I do not quite know how to answer myself.

Problem 1

First of all, the generated brain does not, purely by visual inspection, resemble the input brain, which I find slightly troublesome as that yields a heat map for the mean absolute difference between the four channels with little to no detection of the anomaly.

Problem 2

Another thing that I noticed was that by looking at the individual absolute difference between the four channels, t2 seems to have an inverse heatmap signature when compared to the others. This is also seen by the colour of the lateral ventricles in the first plot shown. image Did you account for this in any specific way? Becuse if I try to inverse the heatmap of t1 I get this:

image Which makes the anomaly slightly more prominent.

Thanks in advance!

JuliaWolleb commented 2 months ago

Hi

Thanks for your interest.

  1. Regarding the normalization: I normalized the BRATS dataset before storing it, so it is not in the code. If you want to implement it in the code, you should add it to the class BRATSDataset in the file bratsloader.py.
  2. Regarding your healthy reconstruction: Can you tell me how you chose your hyperparameters L and s? It seems like both of them might be too high, as the image is changed quite a bit. This results in a non-specific anomaly map.
rreezN commented 2 months ago

Hi,

Thank you for the response!

I use the parameters as provided in your README.md file, so --classifier_scale 100 --noise_level 500.

I will try and rerun the training of the classifier and diffusion model with the normalised data, and then test it out by sampling with some different values of L and s.

I will keep this issue updated.