JuliaWolleb / Diffusion-based-Segmentation

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

About output channels setting #3

Closed qilicun closed 1 year ago

qilicun commented 2 years ago

Great job!

But I have some trouble when understanding the output channels for unet model. That is 'out_channels=2,#(3 if not learn_sigma else 6),', why set the output to 2 or six channels ? Is there any reference or formula to explain? Thanks a lot

JuliaWolleb commented 2 years ago

Thanks!

there are two possibilities:

  1. You set the learn_sigma=True, then you want to predict the mean and the variance. Consequently, the number of output channels=2*number of input channels. If your input image has 1 channel, then your unet model has 2 output channels.

  2. If you set learn_sigma=False, then you only predict the mean. Then, the number of output channels equals the number of input channels. If your images have 1 channel, then your unet model has 1 output channel.

Did that help? Let me know if you have further questions.

qilicun commented 2 years ago
You set the learn_sigma=True, then you want to predict the mean and the variance. Consequently, the number of output channels=2*number of input channels. If your input image has 1 channel, then your unet model has 2 output channels.

Great! That helps a lot! Thanks again!

qilicun commented 2 years ago

One more question. Is this a bug in line 186 and 188 of https://github.com/JuliaWolleb/Diffusion-based-Segmentation/blob/main/guided_diffusion/train_util.py#L188?

self.run_step(batch, cond)
sample = self.run_step(batch, cond)

run_step is executed twice?

JuliaWolleb commented 1 year ago

Hi Thanks for pointing this out, this is a mistake. You can delete the second line.