Skip to content

[Stable Diffusion Inpaint & ControlNet inpaint] Correct timestep inpaint #3749

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

Merged
merged 6 commits into from
Jun 12, 2023

Conversation

patrickvonplaten
Copy link
Contributor

@patrickvonplaten patrickvonplaten commented Jun 12, 2023

Investigating it seems like taking the next timestep to generate the noise works better. Investigating after comment here:

Conclusion is that the timesteps for adding noise for SD inpainting indeed need to be changed. This was incorrectly implemented in #3533

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Jun 12, 2023

The documentation is not available anymore as the PR was closed or merged.

@patrickvonplaten
Copy link
Contributor Author

After investigating this closer, the timesteps for the two inpainting pipelines was indeed incorrect. Before this PR, we had the following logic:

The timesteps: [999, 699, 399, 1] were diffused. Before every diffusion step the area to be diffused was always filled with noise of strength of the prev timestep. This means that the timestep 699 tried to diffuse the original image + noise strength from step 999 instead of 699.

Instead we need to add noise from the previous step after every step so that it works correctly.

Great catch @https://github.com/ernestchu and @https://github.com/jackloomen . Instead of doing t-1 we need however to use the previous timestep which can be much smaller than -1.

Will make a patch release for this PR.

@patrickvonplaten patrickvonplaten changed the title Correct timestep inpaint [Stable Diffusion Inpaint & ControlNet inpaint] Correct timestep inpaint Jun 12, 2023
@patrickvonplaten patrickvonplaten merged commit 38adcd2 into main Jun 12, 2023
@patrickvonplaten patrickvonplaten deleted the correct_timesteps_inpaint branch June 12, 2023 11:59
patrickvonplaten added a commit that referenced this pull request Jun 12, 2023
…int (#3749)

* Correct timestep inpaint

* make style

* Fix

* Apply suggestions from code review

* make style
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
…int (huggingface#3749)

* Correct timestep inpaint

* make style

* Fix

* Apply suggestions from code review

* make style
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
…int (huggingface#3749)

* Correct timestep inpaint

* make style

* Fix

* Apply suggestions from code review

* make style
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.

2 participants