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

Add support for different model prediction types in DDIMInverseScheduler #2619

Merged
merged 16 commits into from
Mar 14, 2023

Conversation

clarencechen
Copy link
Contributor

Resolve alpha_prod_t_prev index issue for final step of inversion
@patrickvonplaten TODO: Update numerical tests to reflect two more steps of inversion

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Mar 9, 2023

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

Resolve alpha_prod_t_prev index issue for final step of inversion
@clarencechen clarencechen force-pushed the improve-ddim-inverse branch from 2b7a9dc to 3d93466 Compare March 9, 2023 20:17
@clarencechen clarencechen force-pushed the improve-ddim-inverse branch 5 times, most recently from 37f3096 to 01747ff Compare March 12, 2023 20:01
Derive predicted noise from model output before dist. regularization

Style cleanup
@clarencechen clarencechen force-pushed the improve-ddim-inverse branch from 01747ff to 1a0c13c Compare March 12, 2023 20:12
@clarencechen
Copy link
Contributor Author

@patrickvonplaten
Here is a notebook demonstrating a working run of the Pix2PixZero pipeline with Stable Diffusion 2. I find that the value of cross_attention_guidance_amount needs to be lowered to 0.01 or less in order to prevent loss explosion.

https://colab.research.google.com/gist/clarencechen/4166c7d1ad29b09940a13f62437de634/ddiminversetesting.ipynb

@sayakpaul
Copy link
Member

Thanks so much!

What's pending in this PR?

Maybe we should mention

I find that the value of cross_attention_guidance_amount needs to be lowered to 0.01 or less in order to prevent loss explosion.

in the Pix2PixZero docs?

Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for working on this!

I see some non-trivial changes in the scheduler script. Do you mind elaborating a bit more on those?

@clarencechen
Copy link
Contributor Author

Thanks so much!

What's pending in this PR?

Maybe we should mention

I find that the value of cross_attention_guidance_amount needs to be lowered to 0.01 or less in order to prevent loss explosion.

in the Pix2PixZero docs?

@sayakpaul I just need to add new tests for Pix2Pix Zero with Stable Diffusion V2, which require uploading target images that are slightly different from what exists for current tests, but which are semantically and stylistically nearly identical.

@sayakpaul
Copy link
Member

Sure, thanks for letting us know! Let us know if we can help in unblocking anything for you here.

@clarencechen clarencechen force-pushed the improve-ddim-inverse branch from 256042e to f029a4e Compare March 14, 2023 00:59
@clarencechen
Copy link
Contributor Author

clarencechen commented Mar 14, 2023

@sayakpaul @patrickvonplaten In order to upload expected results for a Pix2PixZero slow test with SD 2, I need to update the following repo:
https://huggingface.co/datasets/hf-internal-testing/diffusers-images
I created a new local branch with the new data, but I need push access to the hf-internal-testing org in order to push the branch to remote and open a PR there.

@clarencechen clarencechen requested review from sayakpaul and removed request for patrickvonplaten March 14, 2023 01:03
def test_stable_diffusion_2_pix2pix_full(self):
# numpy array of https://huggingface.co/datasets/hf-internal-testing/diffusers-images/blob/main/pix2pix/dog_2.png
expected_image = load_numpy(
"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/pix2pix/dog_2.npy"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this needs to be in https://huggingface.co/datasets/hf-internal-testing/diffusers-images/tree/main/pix2pix? Feel free to open a PR to the repository to add it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, could you maybe open a PR to add the numpy image? This would be very nice!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for opening it - merged it!

Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're in a very good shape to merge this. Thanks so much for this important PR :)

@sayakpaul
Copy link
Member

@sayakpaul @patrickvonplaten In order to upload expected results for a Pix2PixZero slow test with SD 2, I need to update the following repo: https://huggingface.co/datasets/hf-internal-testing/diffusers-images I created a new local branch with the new data, but I need push access to the hf-internal-testing org in order to push the branch to remote and open a PR there.

Yeah feel free to open a PR to https://huggingface.co/datasets/hf-internal-testing/diffusers-images following instructions from https://huggingface.co/datasets/hf-internal-testing/diffusers-images/discussions (Click on "New pull request" and follow the instructions).

@patrickvonplaten
Copy link
Contributor

Great work @clarencechen - thanks!

@patrickvonplaten patrickvonplaten merged commit ee71d9d into huggingface:main Mar 14, 2023
@clarencechen clarencechen deleted the improve-ddim-inverse branch March 14, 2023 20:43
w4ffl35 pushed a commit to w4ffl35/diffusers that referenced this pull request Apr 14, 2023
…ler (huggingface#2619)

* Add support for different model prediction types in DDIMInverseScheduler
Resolve alpha_prod_t_prev index issue for final step of inversion

* Fix old bug introduced when prediction type is "sample"

* Add support for sample clipping for numerical stability and deprecate old kwarg

* Detach sample, alphas, betas

Derive predicted noise from model output before dist. regularization

Style cleanup

* Log loss for debugging

* Revert "Log loss for debugging"

This reverts commit 76ea9c8.

* Add comments

* Add inversion equivalence test

* Add expected data for Pix2PixZero pipeline tests with SD 2

* Update tests/pipelines/stable_diffusion/test_stable_diffusion_pix2pix_zero.py

* Remove cruft and add more explanatory comments

---------

Co-authored-by: Patrick von Platen <[email protected]>
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
…ler (huggingface#2619)

* Add support for different model prediction types in DDIMInverseScheduler
Resolve alpha_prod_t_prev index issue for final step of inversion

* Fix old bug introduced when prediction type is "sample"

* Add support for sample clipping for numerical stability and deprecate old kwarg

* Detach sample, alphas, betas

Derive predicted noise from model output before dist. regularization

Style cleanup

* Log loss for debugging

* Revert "Log loss for debugging"

This reverts commit 76ea9c8.

* Add comments

* Add inversion equivalence test

* Add expected data for Pix2PixZero pipeline tests with SD 2

* Update tests/pipelines/stable_diffusion/test_stable_diffusion_pix2pix_zero.py

* Remove cruft and add more explanatory comments

---------

Co-authored-by: Patrick von Platen <[email protected]>
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
…ler (huggingface#2619)

* Add support for different model prediction types in DDIMInverseScheduler
Resolve alpha_prod_t_prev index issue for final step of inversion

* Fix old bug introduced when prediction type is "sample"

* Add support for sample clipping for numerical stability and deprecate old kwarg

* Detach sample, alphas, betas

Derive predicted noise from model output before dist. regularization

Style cleanup

* Log loss for debugging

* Revert "Log loss for debugging"

This reverts commit 76ea9c8.

* Add comments

* Add inversion equivalence test

* Add expected data for Pix2PixZero pipeline tests with SD 2

* Update tests/pipelines/stable_diffusion/test_stable_diffusion_pix2pix_zero.py

* Remove cruft and add more explanatory comments

---------

Co-authored-by: Patrick von Platen <[email protected]>
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