takimailto / BerDiff

21 stars 1 forks source link

q_sample results look different to paper #3

Open mattia-git opened 8 months ago

mattia-git commented 8 months ago

Hi,

I am trying to use your code to apply the noising forward process to a binary segmentation mask. Following the same setup as the paper (schedule=linear, T=1000, background=0, ROI=1, shape=(N, 1, H, W)), I get the following noising process which looks different to the output shown in your paper:

Screenshot 2024-02-25 at 22 13 20

Is this the expected output, or am I doing something wrong?

takimailto commented 7 months ago

Hello, thank you for your attention, can you give the code?

LiangBinCams commented 1 month ago

I had the same problem. Did you fix it?

LiangBinCams commented 1 month ago

Hi,

I am trying to use your code to apply the noising forward process to a binary segmentation mask. Following the same setup as the paper (schedule=linear, T=1000, background=0, ROI=1, shape=(N, 1, H, W)), I get the following noising process which looks different to the output shown in your paper:

Screenshot 2024-02-25 at 22 13 20

Is this the expected output, or am I doing something wrong?

I had the same problem. Did you fix it?

LiangBinCams commented 1 month ago

Hi, I am trying to use your code to apply the noising forward process to a binary segmentation mask. Following the same setup as the paper (schedule=linear, T=1000, background=0, ROI=1, shape=(N, 1, H, W)), I get the following noising process which looks different to the output shown in your paper: Screenshot 2024-02-25 at 22 13 20 Is this the expected output, or am I doing something wrong?

I had the same problem. Did you fix it?

I figured out the problem. The reason is here:

def q_mean(self, x_start, t):
    """
    Get the distribution q(x_t | x_0).

    :param x_start: the [N x C x ...] tensor of noiseless inputs.
    :param t: the number of diffusion steps (minus 1). Here, 0 means one step.
    :return: Binomial distribution parameters, of x_start's shape.
    """
    mean = _extract_into_tensor(self.alphas_cumprod, t, x_start.shape) * x_start 
    + (1 - _extract_into_tensor(self.alphas_cumprod, t, x_start.shape)) / 2

    return mean

this function returns is only _extract_into_tensor(self.alphas_cumprod, t, x_start.shape) * x_start !!