Skip to content

Added Community pipeline for comparing Stable Diffusion v1.1-4 checkpoints #1584

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 14 commits into from
Dec 13, 2022
Merged

Added Community pipeline for comparing Stable Diffusion v1.1-4 checkpoints #1584

merged 14 commits into from
Dec 13, 2022

Conversation

suvadityamuk
Copy link
Contributor

Fixes #873 to add a Community pipeline that will perform a comparison between the Stable Diffusion v1.1-v1.4 checkpoints parallely.
Takes a general prompt as input and returns a formatted StableDiffusionPipelineOutput with the result of each of the four checkpoints.

Signed-off-by: Suvaditya Mukherjee [email protected]

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Dec 7, 2022

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

@suvadityamuk
Copy link
Contributor Author

suvadityamuk commented Dec 7, 2022

Hi, @patrickvonplaten!

Could you possibly guide me on this issue and let me know if my approach towards solving #873 is correct or are we looking for something else altogether?

Thank you for your time!

@patrickvonplaten
Copy link
Contributor

Thanks for the PR - could you also add an example here: https://github.com/huggingface/diffusers/blob/main/examples/community/README.md :-)

@suvadityamuk
Copy link
Contributor Author

Sure thing, will do in a while!

@suvadityamuk
Copy link
Contributor Author

It seems that DiffusionPipeline.from_pretrained() only accepts one string for the pretrained-model path, but here we need 4. What should I do in this case, in your opinion?

@suvadityamuk
Copy link
Contributor Author

One possible solution is to accept only the v1.4 model string while using the v1.1-3 models internally. Should I do that instead?

@suvadityamuk
Copy link
Contributor Author

suvadityamuk commented Dec 7, 2022

Would this be an apt example as shown below, in your opinion?

It seems that due to the excessive requirement of memory needed to lead 4 Stable Diffusion models into memory, even Google Colab is unable to handle the requirements and goes on to crash (even with torch.no_grad() on all graphed functions)

from diffusers import DiffusionPipeline
import matplotlib.pyplot as plt

pipe = DiffusionPipeline.from_pretrained('CompVis/stable-diffusion-v1-4', custom_pipeline='suvadityamuk/StableDiffusionComparison')
pipe.enable_attention_slicing()
pipe = pipe.to('cuda')
prompt = "an astronaut riding a horse on mars"
output = pipe(prompt)

plt.subplots(2,2,1)
plt.imshow(output.images[0])
plt.title('Stable Diffusion v1.1')
plt.axis('off')
plt.subplots(2,2,2)
plt.imshow(output.images[1])
plt.title('Stable Diffusion v1.2')
plt.axis('off')
plt.subplots(2,2,3)
plt.imshow(output.images[2])
plt.title('Stable Diffusion v1.3')
plt.axis('off')
plt.subplots(2,2,4)
plt.imshow(output.images[3])
plt.title('Stable Diffusion v1.4')
plt.axis('off')

plt.show()

@suvadityamuk
Copy link
Contributor Author

Have added the code example and the updated file for the Pipeline where it accepts the v1.4 checkpoint and installs the v1.1-3 checkpoints internally. Is that fine?

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a comment

Choose a reason for hiding this comment

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

Great!

@patrickvonplaten
Copy link
Contributor

Thanks a lot for adding this!

@patrickvonplaten patrickvonplaten merged commit 40c16ed into huggingface:main Dec 13, 2022
sliard pushed a commit to sliard/diffusers that referenced this pull request Dec 21, 2022
…oints (huggingface#1584)

* Added Community pipeline for comparing Stable Diffusion v1.1-4

Signed-off-by: Suvaditya Mukherjee <[email protected]>

* Made changes to provide support for current iteration of from_pretrained and added example

Signed-off-by: Suvaditya Mukherjee <[email protected]>

* updated a small spelling error

Signed-off-by: Suvaditya Mukherjee <[email protected]>

* added pipeline entry to table

Signed-off-by: Suvaditya Mukherjee <[email protected]>

Signed-off-by: Suvaditya Mukherjee <[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.

[Community Pipelines] SD v1-v4 compare
3 participants