-
Notifications
You must be signed in to change notification settings - Fork 6k
Allow passing different prompts to each text_encoder
on stable_diffusion_xl
pipelines
#4156
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
Conversation
The documentation is not available anymore as the PR was closed or merged. |
text_encoder
on Stable Diffusion XL There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like how i was going to do that. thank you for tackling that one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Design looks great, just added lots of comments as I think it's slightly more readable to just add prompts to zip instead of starting to index.
If you run make fix-copies
all your changes should also be applied to the other SD-XL pipelines and then we only would have to add the names to the call function and some docstring
Finally could you also add a test here:
which can be very similar to this one:
def test_stable_diffusion_xl_offloads(self): |
But instead of testing different offloads, we test that:
a) providing the same prompt to "prompt" and "prompt_2" and "negative_prompt" and "negative_prompt_2" gives the same results as just providing one prompt
b) that providing different prompts to each gives different results than just providing one
If you want we could also add a quick bullet point to the tips section here:
- Stable Diffusion XL output image can be improved by making use of a refiner as shown below. |
src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py
Outdated
Show resolved
Hide resolved
src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py
Outdated
Show resolved
Hide resolved
src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py
Outdated
Show resolved
Hide resolved
src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py
Outdated
Show resolved
Hide resolved
src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py
Outdated
Show resolved
Hide resolved
src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py
Outdated
Show resolved
Hide resolved
src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
docs/source/en/api/pipelines/stable_diffusion/stable_diffusion_xl.mdx
Outdated
Show resolved
Hide resolved
docs/source/en/api/pipelines/stable_diffusion/stable_diffusion_xl.mdx
Outdated
Show resolved
Hide resolved
|
||
### Passing different prompts to each text-encoder | ||
|
||
Stable Diffusion XL as trained on two text-encoders. The default behavior is to pass the same prompt to each. But it is possible to pass a different prompt for each text-encoder, as [some users](https://github.com/huggingface/diffusers/issues/4004#issuecomment-1627764201) alledge it can boost quality. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stable Diffusion XL as trained on two text-encoders. The default behavior is to pass the same prompt to each. But it is possible to pass a different prompt for each text-encoder, as [some users](https://github.com/huggingface/diffusers/issues/4004#issuecomment-1627764201) alledge it can boost quality. | |
Stable Diffusion XL was trained on two text encoders. The default behavior is to pass the same prompt to each. But it is possible to pass a different prompt for each text-encoder, as [some users](https://github.com/huggingface/diffusers/issues/4004#issuecomment-1627764201) noted that it can boost quality. |
docs/source/en/api/pipelines/stable_diffusion/stable_diffusion_xl.mdx
Outdated
Show resolved
Hide resolved
docs/source/en/api/pipelines/stable_diffusion/stable_diffusion_xl.mdx
Outdated
Show resolved
Hide resolved
"The decode_latents method is deprecated and will be removed in a future version. Please" | ||
" use VaeImageProcessor instead", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be happening for a different version of black
installed on the local machine? This should not have happened.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This didn't happen with black but rather on make fix-copies
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed it now
"The decode_latents method is deprecated and will be removed in a future version. Please" | ||
" use VaeImageProcessor instead", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
Looking good to me. I agree with Patrick's suggestions, especially:
Let's ship this :) |
Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
…face/diffusers into diff_prompts_to_encoders
Let me know if you want a final review @apolinario :-) |
Now yes :) @patrickvonplaten Edit: tests are failing for image2image and in-painting pipelines. One of my tests should fail if the image is the same with or without a |
…fusion_xl` pipelines (huggingface#4156) * sdxl prompt2 * Improve checks * doc linting * whoops * remove cat * Apply suggestions from code review Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> * Add other pipelines and tests * Add multi-prompting to docs * doc and copies check * Fix copied froms * Apply suggestions from code review Co-authored-by: Sayak Paul <spsayakpaul@gmail.com> * Bring back the original code for unrelated files * Fix tests * Fix img2img * Fix all * fix --------- Co-authored-by: multimodalart <joaopaulo.passos+multimodal@gmail.com> Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
…fusion_xl` pipelines (huggingface#4156) * sdxl prompt2 * Improve checks * doc linting * whoops * remove cat * Apply suggestions from code review Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> * Add other pipelines and tests * Add multi-prompting to docs * doc and copies check * Fix copied froms * Apply suggestions from code review Co-authored-by: Sayak Paul <spsayakpaul@gmail.com> * Bring back the original code for unrelated files * Fix tests * Fix img2img * Fix all * fix --------- Co-authored-by: multimodalart <joaopaulo.passos+multimodal@gmail.com> Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
…fusion_xl` pipelines (huggingface#4156) * sdxl prompt2 * Improve checks * doc linting * whoops * remove cat * Apply suggestions from code review Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> * Add other pipelines and tests * Add multi-prompting to docs * doc and copies check * Fix copied froms * Apply suggestions from code review Co-authored-by: Sayak Paul <spsayakpaul@gmail.com> * Bring back the original code for unrelated files * Fix tests * Fix img2img * Fix all * fix --------- Co-authored-by: multimodalart <joaopaulo.passos+multimodal@gmail.com> Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
…fusion_xl` pipelines (huggingface#4156) * sdxl prompt2 * Improve checks * doc linting * whoops * remove cat * Apply suggestions from code review Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> * Add other pipelines and tests * Add multi-prompting to docs * doc and copies check * Fix copied froms * Apply suggestions from code review Co-authored-by: Sayak Paul <spsayakpaul@gmail.com> * Bring back the original code for unrelated files * Fix tests * Fix img2img * Fix all * fix --------- Co-authored-by: multimodalart <joaopaulo.passos+multimodal@gmail.com> Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
…fusion_xl` pipelines (huggingface#4156) * sdxl prompt2 * Improve checks * doc linting * whoops * remove cat * Apply suggestions from code review Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> * Add other pipelines and tests * Add multi-prompting to docs * doc and copies check * Fix copied froms * Apply suggestions from code review Co-authored-by: Sayak Paul <spsayakpaul@gmail.com> * Bring back the original code for unrelated files * Fix tests * Fix img2img * Fix all * fix --------- Co-authored-by: multimodalart <joaopaulo.passos+multimodal@gmail.com> Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com> Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
Fixes #4004 (issue)
This is a draft PR with an approach for allowing to pass
prompt_2
andnegative_prompt_2
to SDXL. If this approach sounds good, I will then do it for all SDXL pipelines and add necessary documentation and tests.documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@bghira @sayakpaul