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

Revert RePaint scheduler 'fix' #10644

Merged
merged 1 commit into from
Jan 27, 2025
Merged

Conversation

GiusCat
Copy link
Contributor

@GiusCat GiusCat commented Jan 24, 2025

What does this PR do?

Reverts 'fix' introduced by pull request #10185; the PR adjusted the code accordingly to Algorithm 1 Line 5 of the RePaint paper (https://arxiv.org/pdf/2201.09865.pdf), however that line is reported incorrectly in the paper itself.

Algorithm 1 Line 5 refers to formula 8a of the same paper

$$x_{t-1}^{\text{known}} \sim \mathcal{N}(\sqrt{\bar{\alpha}} x_0, (1 - \bar{\alpha}) \mathbf{I})$$

which tells to sample from a Gaussian distribution $\mathcal{N}(\mu, \sigma^2)$ with $\mu = \sqrt{\bar{\alpha}} x_0$ and $\sigma^2 = (1 - \bar{\alpha})$. In order to obtain this result, the standard Gaussian distribution $\epsilon \sim \mathcal{N}(\mathbf{0}, \mathbf{I})$ should be stretched by a factor $\sigma$ and translated by a factor $\mu$ (source: Wikipedia). The correct operation should therefore be

$$x_{t-1}^{\text{known}} = \sqrt{\bar{\alpha}} x_0 + \sqrt{(1 - \bar{\alpha})} \epsilon$$

as it was indeed calculated before the change; Algorithm 1 Line 5 wrongly reports a stretching factor of $\sigma^2$. This PR restores the previous (correct) computation and adds some comments on the subject.

Fixes degraded performance using RePaint. Below are examples obtained using the example code in the documentation.

Diffusers v0.31.0 (before the 'fix')

inference_0-31-0

Diffusers v0.32.1 (after the 'fix')

inference_0-32-1

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@yiyixuxu
Copy link
Collaborator

thanks @GiusCat

@yiyixuxu
Copy link
Collaborator

cc @hlky here too

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@yiyixuxu yiyixuxu merged commit fb42066 into huggingface:main Jan 27, 2025
12 checks passed
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

Successfully merging this pull request may close these issues.

4 participants