Skip to content

Enable image resizing to adjust its height and width in StableDiffusionXLInstructPix2PixPipeline #6581

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

Conversation

sangyeon-k
Copy link
Contributor

What does this PR do?

Fixes #6570.
In StableDiffusionXLInstructPix2PixPipeline, a shape discrepancy between image_latents and latents can occur if the height and width parameters are not explicitly initialized by the user.

Therefore, to tackle this problem, this PR enables image resizing to adjust its height and width.

Before submitting

Who can review?

@sayakpaul

@@ -1109,7 +1109,7 @@ def collate_fn(examples):
progress_bar.set_postfix(**logs)

### BEGIN: Perform validation every `validation_epochs` steps
if global_step % args.validation_steps == 0 or global_step == 1:
Copy link
Contributor Author

@sangyeon-k sangyeon-k Jan 15, 2024

Choose a reason for hiding this comment

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

Do we have to perform validation at every step? I believe we might not need to.

This PR did not originally intend for this change, but what do you think about removing the condition global_step==1?

Copy link
Member

Choose a reason for hiding this comment

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

Seems reasonable. Thank you!

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

@@ -858,7 +858,7 @@ def __call__(
)

# 4. Preprocess image
image = self.image_processor.preprocess(image).to(device)
image = self.image_processor.preprocess(image, height=height, width=width).to(device)
Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

@sayakpaul sayakpaul merged commit 96d6e16 into huggingface:main Jan 16, 2024
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
…onXLInstructPix2PixPipeline (huggingface#6581)

* Enable image resizing to adjust its height and width in StableDiffusionXLInstructPix2PixPipeline

* Ensure that validation is performed at every 'validation_step', not at every step
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.

[StableDiffusionXLInstructPix2PixPipeline] RuntimeError: Sizes of tensors must match except in dimension 1
3 participants