JuliaWolleb / Diffusion-based-Segmentation

This is the official Pytorch implementation of the paper "Diffusion Models for Implicit Image Segmentation Ensembles".
MIT License
272 stars 35 forks source link

Input Channel Settings #6

Closed popleyi closed 1 year ago

popleyi commented 1 year ago

Thanks for sharing the code.

I tried to apply the source code on my own dataset. I changed the data loader following the BRATS example to have one channel as the input and the segmentation as the second channel. Then I changed the "in_channels=5" to "in_channels=2" for the UNetModel. However, it shows the error that the expected input channel should be 3.

In addition, gaussian_diffusion.py file, the it has been set to img.shape != (1, 5, 224, 224). what's this mean?

Any suggestions will be much appreciated. Thanks!

JuliaWolleb commented 1 year ago

Where did you change "in_channels=2"? In the file _scriptutil.py? Then it should work with a 2-channel input. Could you show me the detailed error message?

As for the second point, this means that if your image is already of the shape [conditional image, segmentation mask at time t], then you skip this step. Otherwise, you need to concatenate the original input image with the segmentation mask at time t. In your case, you would need to change this line to: img.shape != (1, 2, image_height, image_width)

popleyi commented 1 year ago

I misinterpreted the bratsloader.py . All the problems have been solved.

Thanks for your reply.