Multi-image example

#6
by juanquivilla - opened

Does anyone have any examples on how to do multi-image editing/reference in diffusers with this model? Thanks!

I got it to work simply by loading multiple images and putting them into the standard pipeline as "image" hyperparameter.

Like this:

import torch
from diffusers import Flux2KleinPipeline

device = "cuda"
dtype = torch.bfloat16

pipe = Flux2KleinPipeline.from_pretrained("black-forest-labs/FLUX.2-klein-9B", torch_dtype=dtype)
pipe.enable_model_cpu_offload() # save some VRAM by offloading the model to CPU

init_img = Image.open("1.jpg").convert("RGB").resize((1024, 1024))
init_img2 = Image.open("2.jpg").convert("RGB").resize((1024, 1024))

image = pipe(
prompt="A man standing next to a mascot",
image=[init_img, init_img2],
height=1024,
width=1024,
guidance_scale=1.0,
num_inference_steps=4,
generator=torch.Generator(device=device).manual_seed(0)
).images[0]
image

Sign up or log in to comment