Turns one or more
character reference images (neutral pose, plain light-gray
background, eye-level) into a
full illustrated scene with those characters,
preserving identity and art style. Trained with
DiffSynth-Studio on 179
reference->scene pairs (stylized Western digital art).
1import torch
2from PIL import Image
3from diffsynth.pipelines.qwen_image import QwenImagePipeline, ModelConfig
4
5pipe = QwenImagePipeline.from_pretrained(
6 torch_dtype=torch.bfloat16, device="cuda",
7 model_configs=[
8 ModelConfig(model_id="Qwen/Qwen-Image-Edit-2511", origin_file_pattern="transformer/diffusion_pytorch_model*.safetensors"),
9 ModelConfig(model_id="Qwen/Qwen-Image", origin_file_pattern="text_encoder/model*.safetensors"),
10 ModelConfig(model_id="Qwen/Qwen-Image", origin_file_pattern="vae/diffusion_pytorch_model.safetensors"),
11 ],
12 tokenizer_config=None,
13 processor_config=ModelConfig(model_id="Qwen/Qwen-Image-Edit", origin_file_pattern="processor/"),
14)
15pipe.load_lora(pipe.dit, "checkpoints/epoch-4.safetensors")
16ref = Image.open("reference.jpeg")
17img = pipe("Using the character from Image 1, create a full illustrated scene: ...",
18 edit_image=[ref], seed=0, num_inference_steps=40,
19 height=1328, width=1024, zero_cond_t=True) # zero_cond_t is REQUIRED for 2511
19 held-out prompts x 3 checkpoints (epochs 2-4) in
val_samples/ -
characters never seen in training; includes single-character, multi-character
composite (one input) and multi-image (separate inputs) modes. Prompts:
val_samples/prompts.json. Examples (epoch-4):
One training pair in
dataset_example/: reference
(model input), scene (target) and the caption (
pair.json).