Views
No views yet
ostris/Krea2OstrisEdit
reference-image ("edit") workflow for Krea 2, loadable as remote code on top of stock diffusers.1import torch
2from transformers import Qwen3VLProcessor
3from diffusers import ClassifierFreeGuidance
4from diffusers.modular_pipelines import ModularPipelineBlocks
5
6blocks = ModularPipelineBlocks.from_pretrained("diffusers-modular/krea2-edit", trust_remote_code=True)
7pipe = blocks.init_pipeline("krea/Krea-2-Turbo") # weights from the base repo
8pipe.load_components(torch_dtype=torch.bfloat16)
9pipe.update_components(processor=Qwen3VLProcessor.from_pretrained("Qwen/Qwen3-VL-4B-Instruct"))
10pipe.update_components(guider=ClassifierFreeGuidance(guidance_scale=0.0, use_original_formulation=True))
11pipe.to("cuda")
12
13from PIL import Image
14image = pipe(
15 prompt="a white yeti with horns reading a book",
16 image=Image.open("reference.png"), # one or more reference images
17 num_inference_steps=8, mu=1.15, output="images",
18)[0]Krea2Transformer2DModel adds a small, backward-compatible ref_seq_len argument to the
Krea 2 transformer forward (t=0 modulation of the reference span; those tokens are excluded from the
predicted velocity). With ref_seq_len=0 it is numerically identical to plain Krea 2 text-to-image.block.py — entry point (Krea2EditBlocks), referenced by config.json's auto_map.transformer_krea2.py — the Krea 2 transformer (with the ref_seq_len edit path).modular_blocks_krea2*.py, encoders.py, before_denoise.py, denoise.py, decoders.py,
inputs.py, modular_pipeline.py — the modular blocks.