|
| 1 | +<!--Copyright 2026 Krea AI and The HuggingFace Team. All rights reserved. |
| 2 | +
|
| 3 | +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
| 4 | +the License. You may obtain a copy of the License at |
| 5 | +
|
| 6 | +http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +
|
| 8 | +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
| 9 | +an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 10 | +specific language governing permissions and limitations under the License. |
| 11 | +--> |
| 12 | + |
| 13 | +# Krea 2 |
| 14 | + |
| 15 | +Krea 2 (K2) is a flow-matching text-to-image model built around a single-stream MMDiT with grouped-query attention. A |
| 16 | +Qwen3-VL text encoder provides the conditioning: instead of the last hidden state, hidden states from twelve decoder |
| 17 | +layers are tapped per token and fused inside the transformer by a small text-fusion stage. Images are decoded with the |
| 18 | +Qwen-Image VAE. |
| 19 | + |
| 20 | +Two checkpoints are released, sharing the same architecture but with different recommended sampler settings: |
| 21 | + |
| 22 | +- **Base (midtrain)** — use the full sampler with classifier-free guidance: `num_inference_steps=28`, |
| 23 | + `guidance_scale=4.5`. |
| 24 | +- **TDM (distilled)** — distilled for few-step sampling, run with `num_inference_steps=8` and guidance disabled |
| 25 | + (`guidance_scale=0.0`). |
| 26 | + |
| 27 | +`guidance_scale` follows the Krea 2 convention: the velocity is computed as `cond + guidance_scale * (cond - uncond)` |
| 28 | +and guidance is enabled whenever `guidance_scale > 0` (this equals the usual CFG formulation with scale |
| 29 | +`1 + guidance_scale`). |
| 30 | + |
| 31 | +## Text-to-image |
| 32 | + |
| 33 | +```python |
| 34 | +import torch |
| 35 | +from diffusers import Krea2Pipeline |
| 36 | + |
| 37 | +# Load from a local directory produced by the Krea 2 conversion (no hub repo yet). |
| 38 | +pipe = Krea2Pipeline.from_pretrained("path/to/krea2-diffusers", torch_dtype=torch.bfloat16) |
| 39 | +pipe.to("cuda") |
| 40 | + |
| 41 | +prompt = "a fox in the snow" |
| 42 | +image = pipe( |
| 43 | + prompt, |
| 44 | + height=1024, |
| 45 | + width=1024, |
| 46 | + num_inference_steps=28, |
| 47 | + guidance_scale=4.5, |
| 48 | + generator=torch.Generator("cuda").manual_seed(0), |
| 49 | +).images[0] |
| 50 | +image.save("krea2.png") |
| 51 | +``` |
| 52 | + |
| 53 | +## Krea2Pipeline |
| 54 | + |
| 55 | +[[autodoc]] Krea2Pipeline |
| 56 | + - all |
| 57 | + - __call__ |
| 58 | + |
| 59 | +## Krea2PipelineOutput |
| 60 | + |
| 61 | +[[autodoc]] pipelines.krea2.pipeline_output.Krea2PipelineOutput |
0 commit comments