multimodalart/Krea-2-Image-Reference
Krea 2 Image Reference
Training-free style transfer for Krea 2, porting Untwisting RoPE: Frequency Control for Shared Attention in DiTs (originally a ComfyUI node) to 🧨 diffusers.
Give a reference image (the style) and a prompt (the content). At every denoising step the transformer runs on a [target, reference] cross-batch; inside each attention block, after rotary position embedding, the reference image's keys are rescaled per frequency band (high_scale for fine structure, low_scale for global style) and the target attends to those rescaled reference keys/values. Optional AdaIN aligns color/contrast statistics.
No training, no LoRA. Runs eager (the attention-processor swap is incompatible with AOTI-compiled blocks).
krea2_untwist.py is a standalone module — import style_transfer to use it with any Krea2Pipeline.
Use it in code
krea2_untwist.py works with plain diffusers. Full snippet + module in this [gist](https://gist.github.com/apolinario/9ecc9e0efffbbf133fe997b7181b6cfa) (the module is also here in the Space: raw).
pip install "transformers>=4.57.0" accelerate sentencepiece \
git+https://github.com/huggingface/diffusers.gitimport torch
from diffusers import Krea2Pipeline
from diffusers.utils import load_image
from krea2_untwist import style_transfer
pipe = Krea2Pipeline.from_pretrained("krea/Krea-2-Turbo", torch_dtype=torch.bfloat16).to("cuda")
image = style_transfer(
pipe,
prompt="a red fox sitting in a snowy forest, soft winter light",
reference_image=load_image("your_style_reference.png"),
num_inference_steps=8,
beta=2.25,
low_scale_start=1.0, low_scale_end=2.75, # style strength
high_scale_start=1.0, high_scale_end=0.0, # structure decays -> prompt keeps composition
adain_strength=0.75,
blocks=(7, 27),
)
image.save("out.png")