Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

DDIM reversed_step alpha_prod_t_next bug #446

@matanat

Description

@matanat

There's a bug in how the DDIM scheduler computes the next alpha_prod in reversed_step() for the first timestamp (last in self.timesteps).
alpha_prod_t_prev = self.alphas_cumprod[prev_timestep] if prev_timestep >= 0 else self.final_alpha_cumprod
This line was just copied from the step() function (parameter names were copied, making it even more confusing), but this should treat the first alpha (last in the alphas_cumprod array). Otherwise, you get an exception when trying to invert an image all the way through the timestamps.

I think this should be:
alpha_prod_t_next = self.alphas_cumprod[next_timestep] if next_timestep < len(self.alphas_cumprod) else self.first_alpha_cumprod
And we should set the following:
self.first_alpha_cumprod = torch.tensor(.0)
Or the last alpha_cumprod in the array (should probably be controllable)

Wdyt? Should I create a pull request to fix this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions