Skip to content

update StableDiffusion3Img2ImgPipeline.add image size validation#10166

Merged
yiyixuxu merged 8 commits intohuggingface:mainfrom
ZHJ19970917:main
Dec 12, 2024
Merged

update StableDiffusion3Img2ImgPipeline.add image size validation#10166
yiyixuxu merged 8 commits intohuggingface:mainfrom
ZHJ19970917:main

Conversation

@ZHJ19970917
Copy link
Contributor

What does this PR do?

Fixes #10153
Add support for height and width parameters in the call() method of the StableDiffusion3Img2ImgPipeline. Users can specify the output image size by providing these parameters. Additionally, implement input validation for height and width.

Referencing StableDiffusion3Pipeline, if height and width are not provided, default sizes should be calculated as:

height = height or self.default_sample_size * self.vae_scale_factor
width = width or self.default_sample_size * self.vae_scale_factor

instead of using the dimensions of the input image by default. This prevents errors in vector calculations caused by incompatible height and width values from the input image.

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.

Copy link
Contributor

@hlky hlky left a comment

Choose a reason for hiding this comment

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

Thanks @ZHJ19970917! I've ran make style, and the only suggestion is to use keyword args to be consistent with other pipelines usage of self.image_processor.preprocess

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

Copy link
Contributor

@hlky hlky left a comment

Choose a reason for hiding this comment

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

We also need to replicate these changes to src/diffusers/pipelines/pag/pipeline_pag_sd_3_img2img.py and src/diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_inpaint.py due to Copied from

…fusion_3_img2img.py

Co-authored-by: hlky <hlky@hlky.ac>
@ZHJ19970917
Copy link
Contributor Author

ok,I will replicate these changes to src/diffusers/pipelines/pag/pipeline_pag_sd_3_img2img.py and src/diffusers/pipelines/stable_diffusion_3/pipeline_stable_diffusion_3_inpaint.py

@yiyixuxu yiyixuxu merged commit bdbaea8 into huggingface:main Dec 12, 2024
12 checks passed
@yiyixuxu
Copy link
Collaborator

thanks @ZHJ19970917 and @hlky !

sayakpaul pushed a commit that referenced this pull request Dec 23, 2024
)

* update StableDiffusion3Img2ImgPipeline.add image size validation

---------

Co-authored-by: hlky <hlky@hlky.ac>
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.

In the StableDiffusion3Img2ImgPipeline, the height dimension of latents is odd, which may cause a mismatch with the height dimension of noise_pred.

4 participants