diffusers
diffusers copied to clipboard
Stable-diffusion Image-to-image pipeline is broken for batch_size > 1
Describe the bug
When multiple images are passed to the init_image argument as a tensor, init_latents will have the same dimension 0 as init_images. But this line is further duplicating the init_latents by the batch size, which results in a mismatched tensor size.
https://github.com/huggingface/diffusers/blob/f3983d16eed57e46742d217363d8913bef7f748d/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py#L288
The fix is trivial:
init_latents = torch.cat([init_latents] * num_images_per_prompt, dim=0)
Reproduction
No response
Logs
No response
System Info
diffusers-0.5.0-dev (master)
+1
Thanks for the issue! Will open a PR now