-
Couldn't load subscription status.
- Fork 6.5k
unet's sample_size attribute is to accept tuple(h, w) in StableDiffusionPipeline
#10181
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
unet's sample_size attribute is to accept tuple(h, w) in StableDiffusionPipeline
#10181
Conversation
|
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. |
|
Hey @Foundsheep it would be great if you write a test for testing unet's |
|
@SahilCarterr thanks. That makes perfect sense, and actually I made my own script to test it and removed it after the test, since the script did not seem to fit with the original code. I'm wondering, where would the test code be placed in the repository if I should make one? |
|
You can write the test here. Check out other tests for reference Also this PR is not tagged with the corresponding Issue.
Remove parenthesis to tag it. |
|
@SahilCarterr thanks. I edited the tag. But I'm a bit confused about writing the test code. Am I supposed to add a method in the |
|
Yes, add test here |
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 lit! Thank you!
| def test_pipeline_accept_tuple_type_unet_sample_size(self): | ||
| # the purpose of this test is to see whether the pipeline would accept a unet with the tuple-typed sample size | ||
| sd_repo_id = "stable-diffusion-v1-5/stable-diffusion-v1-5" | ||
| sample_size = [60, 80] | ||
| customised_unet = UNet2DConditionModel(sample_size=sample_size) | ||
| pipe = StableDiffusionPipeline.from_pretrained(sd_repo_id, unet=customised_unet) | ||
| assert pipe.unet.config.sample_size == sample_size |
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 we use a smaller checkpoint?
https://huggingface.co/hf-internal-testing/tiny-sd-pipe
What does this PR do?
Fixes #10139
UNet2DConditionmodel can be passed forsample_sizeparameter withintorTuple[int, int]types inunet_2d_condition.py. However,StableDiffusionPipelinewas not compatible with that aspect and assumed the argument would be onlyinttype.StableDiffusionPipelinecan expectsample_sizefor unet which is then to be passed asheightandwidthto be not just a single number, but also two different numbers in a tuple or list.StableDiffusionPipelinewould be instantiated without an error in that case.Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
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.
@yiyixuxu @hlky