Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

q_sample can only generate noise image. #131

Open
lvyufeng opened this issue Nov 27, 2022 · 5 comments
Open

q_sample can only generate noise image. #131

lvyufeng opened this issue Nov 27, 2022 · 5 comments

Comments

@lvyufeng
Copy link

I have reproduced the ddpm with MindSpore, all Modules and initialized methods are the same, but the q_sample method can not generate an ordinary image but always returns a noise. I have check the flax implementation in denoising-diffusion-flax and found the code snippet:

    for t in reversed(jnp.arange(timesteps)):
        rng, *step_rng = jax.random.split(rng, num=jax.local_device_count() + 1)
        step_rng = jnp.asarray(step_rng)
        x, x0 = p_sample_step(state, step_rng, x, jax_utils.replicate(t), x0)
        list_x0.append(x0)
    # normalize to [0,1]
    img = unnormalize_to_zero_to_one(jnp.asarray(x0))

but found the pytorch code:

        for t in tqdm(reversed(range(0, self.num_timesteps)), desc = 'sampling loop time step', total = self.num_timesteps):
            self_cond = x_start if self.self_condition else None
            img, x_start = self.p_sample(img, t, self_cond)

        img = unnormalize_to_zero_to_one(img)

it seems the final image use x_start not img.

The other problem is that I have tried x_start or img, both of them can only return noise image.

@lhaippp
Copy link
Contributor

lhaippp commented Dec 2, 2022

did you produce the colored noise such as:
ezgif com-gif-maker (3)
I think I have also failed to produce a normal image

@lvyufeng
Copy link
Author

lvyufeng commented Dec 5, 2022

did you produce the colored noise such as: ezgif com-gif-maker (3) ezgif com-gif-maker (3) I think I have also failed to produce a normal image

exactly same.

@lhaippp
Copy link
Contributor

lhaippp commented Dec 6, 2022

issue62
as mentioned, I solved the problem, hope it help

@Ludrasaum
Copy link

It might be useful to set EMA to False

@AdamWojtczak
Copy link

AdamWojtczak commented Jan 31, 2023

@Ludrasaum
Hi, How to set EMA to False?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants