Skip to content

Run FluxKontextPipeline with multi-images input, But An error occurred #11824

Open
@veridone

Description

@veridone

Describe the bug

I Use this examples:

conditioning_images = [
Image.open("image1.jpg").convert("RGB").resize((512, 512)),
Image.open("image2.jpg").convert("RGB").resize((512, 512)),
]
output = pipe(
prompt="A surreal fusion of the input images in a fantasy environment",
image=conditioning_images,
guidance_scale=4.0
).images[0]

And error occurred:

File "/home/work/test.py", line 30, in
output = pipe(
File "/home/work/anaconda3/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
return func(*args, **kwargs)
File "/home/work/anaconda3/lib/python3.10/site-packages/diffusers/pipelines/flux/pipeline_flux_kontext.py", line 972, in call
latents, image_latents, latent_ids, image_ids = self.prepare_latents(
File "/home/work/anaconda3/lib/python3.10/site-packages/diffusers/pipelines/flux/pipeline_flux_kontext.py", line 687, in prepare_latents
image_latents = self._pack_latents(
File "/home/work/anaconda3/lib/python3.10/site-packages/diffusers/pipelines/flux/pipeline_flux_kontext.py", line 574, in _pack_latents
latents = latents.view(batch_size, num_channels_latents, height // 2, 2, width // 2, 2)
RuntimeError: shape '[1, 16, 64, 2, 64, 2]' is invalid for input of size 524288

Reproduction

My Code is:

from diffusers import FluxKontextPipeline
from PIL import Image
pipe = FluxKontextPipeline.from_pretrained(
"stabilityai/flux-kontext",
torch_dtype=torch.float16,
).to("cuda")
conditioning_images = [
Image.open("image1.jpg").convert("RGB").resize((512, 512)),
Image.open("image2.jpg").convert("RGB").resize((512, 512)),
]
prompt = "A surreal fusion of the input images in a fantasy environment"
output = pipe(
prompt=prompt,
image=conditioning_images,
guidance_scale=4.0
).images[0]

Logs

System Info

python: 3.10
diffusers: 0.35.0.dev0

Who can help?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions