JuliaWolleb / diffusion-anomaly

Anomaly detection with diffusion models
MIT License
119 stars 23 forks source link

high resolution training #15

Open Junhyuk93 opened 1 year ago

Junhyuk93 commented 1 year ago

hello!

I am interested in modifying your paper to a resolution of 1024 and have encountered an error related to channel size when training at this resolution. Could you kindly provide me with some guidance on this matter?

Thank you in advance for your assistance.

JuliaWolleb commented 1 year ago

Hi What do you mean by a resolution of 1024? You mean the image dimensions are of size (1024,1024)? What are your channel dimensions and what is the error message?

Junhyuk93 commented 1 year ago

ooh, I'm really sorry, I made a mistake. It seems that the error occurred because I didn't convert the image to npy with a size of 1024x1024. And currently, in the code, we are using a channel_mult of 256x256 for the create_classifier function to train. Have you ever trained with an image size of 1024x1024?

JuliaWolleb commented 1 year ago

I have never trained with images of size 1024x1024. But as long as you do not encouter an "out of memory" error on your GPU, it should work fine.

Junhyuk93 commented 1 year ago

This error popped up, does name mean the file name? And in "gaussian_diffusion.py", can you tell me what final 0,1,2,3 in lines 922~924 mean? Chest Xray image is being used, so Cheexpert dataset is being used.

Traceback (most recent call last):
  File "scripts/classifier_sample_known.py", line 215, in <module>
    main()
  File "scripts/classifier_sample_known.py", line 167, in main
    viz.image(visualize(sample[0, ...]), opts=dict(caption="sampled output"+str(name)))
NameError: name 'name' is not defined

There seems to be enough memory and no problem. Thank you for your concern.

JuliaWolleb commented 1 year ago

Oh, sorry for that, you don't need to specify the name. You can change the line to viz.image(visualize(sample[0, ...]), opts=dict(caption="sampled output"))

in case of the chexpert dataset, in the file gaussian_diffusion.py in line 922, you can just put viz.image(visualize(final["sample"].cpu()[0,0, ...]), opts=dict(caption="final 0" )) . You can omit final 1,2,3. This was used for the brats dataset, where we have the channels 0,1,2,3. However, in the chexpert dataset, you only have the channel 0.

Junhyuk93 commented 1 year ago

As per your solution, it worked fine. My custom data has a resolution of 1024*1024, so when I run it with the recommended parameters, I couldn't find a special anomaly in Chest X-ray, so I was learning while adjusting attention resolution, but I couldn't find a meaningful anomaly. Perhaps, in my opinion, the attetion resolution can be given up to 128 compared to the high resolution of the image, so I tried to give it up to 128, but it seems that the performance does not appear well because it is a relatively small value compared to the image. The picture is one of my custom data examples.

8d626cce-3639-4654-93a3-0410b6576f67