Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/source/en/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@
title: JoyImageEditTransformer3DModel
- local: api/models/kandinsky6_transformer
title: Kandinsky 6 Transformers
- local: api/models/kandinsky_imagesr_transformer
title: KandinskyImageSRTransformer3DModel
- local: api/models/kandinsky_s2v_transformer
title: KandinskyS2VTransformer3DModel
- local: api/models/krea2_transformer2d
Expand Down Expand Up @@ -643,6 +645,8 @@
title: Kandinsky 3
- local: api/pipelines/kandinsky5_image
title: Kandinsky 5.0 Image
- local: api/pipelines/kandinsky_imagesr
title: Kandinsky ImageSR 2.0
- local: api/pipelines/kolors
title: Kolors
- local: api/pipelines/krea2
Expand Down
36 changes: 36 additions & 0 deletions docs/source/en/api/models/kandinsky_imagesr_transformer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!--Copyright 2026 The Kandinsky Team and The HuggingFace Team. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->

# KandinskyImageSRTransformer3DModel

The text-free Kandinsky 5 transformer used by [`KandinskyImageSRPipeline`] to correct one image tile latent in a
single flow step. The time embedding, the block modulation and the zero-text cross-attention are stored as tables
for the supported timesteps.

```python
import torch
from diffusers import KandinskyImageSRTransformer3DModel

transformer = KandinskyImageSRTransformer3DModel.from_pretrained(
"kandinskylab/Kandinsky-ImageSR-2.0-Diffusers", subfolder="transformer", dtype=torch.bfloat16
)
```

## KandinskyImageSRTransformer3DModel

[[autodoc]] KandinskyImageSRTransformer3DModel
- all
- forward

## KandinskyImageSRTransformer3DModelOutput

[[autodoc]] models.transformers.transformer_kandinsky_imagesr.KandinskyImageSRTransformer3DModelOutput
102 changes: 102 additions & 0 deletions docs/source/en/api/pipelines/kandinsky_imagesr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<!--Copyright 2026 The Kandinsky Team and The HuggingFace Team. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
-->

# Kandinsky ImageSR 2.0

Kandinsky ImageSR 2.0 is an image super-resolution model from [Kandinsky Lab](https://huggingface.co/kandinskylab).
A single text-free Kandinsky 5 transformer enhances an image at its original resolution (×1) or upscales it ×2 or
×4. The image is processed in overlapping 1024-pixel output tiles: every tile is encoded with the FLUX VAE, corrected
by one flow step, decoded, and blended back with boundary-aware Hann windows.

## Available models

| Model | Notes |
|---|---|
| [`kandinskylab/Kandinsky-ImageSR-2.0-Diffusers`](https://huggingface.co/kandinskylab/Kandinsky-ImageSR-2.0-Diffusers) | BF16 transformer and VAE |
| [`kandinskylab/Kandinsky-ImageSR-2.0-GGUF`](https://huggingface.co/kandinskylab/Kandinsky-ImageSR-2.0-GGUF) | GGUF Q8_0 transformer, see [GGUF checkpoint](#gguf-checkpoint) |

## Super-resolution

```python
import torch
from diffusers import KandinskyImageSRPipeline
from diffusers.utils import load_image

pipe = KandinskyImageSRPipeline.from_pretrained(
"kandinskylab/Kandinsky-ImageSR-2.0-Diffusers", dtype=torch.bfloat16
)
pipe.to("cuda")

image = load_image("input.png")
pipe(image, upscale_factor=4, creativity=4).images[0].save("output.png")
```

`creativity` selects one of nine calibrated flow timesteps for the chosen scale. Lower levels preserve fine text and
details; higher levels synthesize more texture. `one_step_t` sets the timestep directly and must be one of
`pipe.transformer.config.baked_timesteps`.

| Scale | Creativity range (`t`) | Default (level 4) |
|---:|---:|---:|
| ×1 | 0.005–0.118 | 0.05 |
| ×2 | 0.07–0.30 | 0.15 |
| ×4 | 0.17–0.38 | 0.244 |

Inputs are treated as sRGB; convert images with an embedded color profile beforehand.

## Speed

Compile the repeated transformer blocks and the VAE decoder for repeated inference. Every tile has the same shape, so
the compiled graphs are reused across tiles and images.

```python
pipe.transformer.compile_repeated_blocks(fullgraph=True)
pipe.vae.decoder.compile()
```

Attention runs on PyTorch SDPA by default. Switch to FlashAttention-2, or FlashAttention-3 on a supported Hopper GPU,
with [`~ModelMixin.set_attention_backend`]:

```python
pipe.transformer.set_attention_backend("flash") # or "_flash_3_hub"
```

## GGUF checkpoint

The GGUF Q8_0 transformer loads with [`~loaders.FromOriginalModelMixin.from_single_file`]. Pass the
transformer to the pipeline, which supplies the VAE and the scheduler.

```python
import torch
from diffusers import GGUFQuantizationConfig, KandinskyImageSRPipeline, KandinskyImageSRTransformer3DModel

transformer = KandinskyImageSRTransformer3DModel.from_single_file(
"https://huggingface.co/kandinskylab/Kandinsky-ImageSR-2.0-GGUF/blob/main/Kandinsky-ImageSR-2.0-x1-Q8_0.gguf",
config="kandinskylab/Kandinsky-ImageSR-2.0-Diffusers",
subfolder="transformer",
quantization_config=GGUFQuantizationConfig(compute_dtype=torch.bfloat16),
dtype=torch.bfloat16,
)
pipe = KandinskyImageSRPipeline.from_pretrained(
"kandinskylab/Kandinsky-ImageSR-2.0-Diffusers", transformer=transformer, dtype=torch.bfloat16
)
pipe.to("cuda")
```

## KandinskyImageSRPipeline

[[autodoc]] KandinskyImageSRPipeline
- all
- __call__

## KandinskyImageSRPipelineOutput

[[autodoc]] pipelines.kandinsky_imagesr.pipeline_output.KandinskyImageSRPipelineOutput
6 changes: 6 additions & 0 deletions src/diffusers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@
"Kandinsky6SRTransformer3DModel",
"Kandinsky6SRVAE",
"Kandinsky6Transformer3DModel",
"KandinskyImageSRTransformer3DModel",
"KandinskyS2VTransformer3DModel",
"Krea2Transformer2DModel",
"LatteTransformer3DModel",
Expand Down Expand Up @@ -461,6 +462,8 @@
"DiffusionPipeline",
"DiTPipeline",
"ImagePipelineOutput",
"KandinskyImageSRPipeline",
"KandinskyImageSRPipelineOutput",
"KarrasVePipeline",
"LDMPipeline",
"LDMSuperResolutionPipeline",
Expand Down Expand Up @@ -1268,6 +1271,7 @@
Kandinsky6SRTransformer3DModel,
Kandinsky6SRVAE,
Kandinsky6Transformer3DModel,
KandinskyImageSRTransformer3DModel,
KandinskyS2VTransformer3DModel,
Krea2Transformer2DModel,
LatteTransformer3DModel,
Expand Down Expand Up @@ -1389,6 +1393,8 @@
DiffusionPipeline,
DiTPipeline,
ImagePipelineOutput,
KandinskyImageSRPipeline,
KandinskyImageSRPipelineOutput,
KarrasVePipeline,
LDMPipeline,
LDMSuperResolutionPipeline,
Expand Down
4 changes: 4 additions & 0 deletions src/diffusers/loaders/single_file_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@
"checkpoint_mapping_fn": convert_minimax_h3_transformer_checkpoint_to_diffusers,
"default_subfolder": "transformer",
},
"KandinskyImageSRTransformer3DModel": {
"checkpoint_mapping_fn": lambda checkpoint, **kwargs: checkpoint,
"default_subfolder": "transformer",
},
}


Expand Down
2 changes: 2 additions & 0 deletions src/diffusers/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
_import_structure["transformers.transformer_kandinsky"] = ["Kandinsky5Transformer3DModel"]
_import_structure["transformers.transformer_kandinsky6"] = ["Kandinsky6Transformer3DModel"]
_import_structure["transformers.transformer_kandinsky6_sr"] = ["Kandinsky6SRTransformer3DModel"]
_import_structure["transformers.transformer_kandinsky_imagesr"] = ["KandinskyImageSRTransformer3DModel"]
_import_structure["transformers.transformer_kandinsky_s2v"] = ["KandinskyS2VTransformer3DModel"]
_import_structure["transformers.transformer_krea2"] = ["Krea2Transformer2DModel"]
_import_structure["transformers.transformer_longcat_audio_dit"] = ["LongCatAudioDiTTransformer"]
Expand Down Expand Up @@ -338,6 +339,7 @@
Kandinsky5Transformer3DModel,
Kandinsky6SRTransformer3DModel,
Kandinsky6Transformer3DModel,
KandinskyImageSRTransformer3DModel,
KandinskyS2VTransformer3DModel,
Krea2Transformer2DModel,
LatteTransformer3DModel,
Expand Down
1 change: 1 addition & 0 deletions src/diffusers/models/transformers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
from .transformer_kandinsky import Kandinsky5Transformer3DModel
from .transformer_kandinsky6 import Kandinsky6Transformer3DModel
from .transformer_kandinsky6_sr import Kandinsky6SRTransformer3DModel
from .transformer_kandinsky_imagesr import KandinskyImageSRTransformer3DModel
from .transformer_kandinsky_s2v import KandinskyS2VTransformer3DModel
from .transformer_krea2 import Krea2Transformer2DModel
from .transformer_longcat_audio_dit import LongCatAudioDiTTransformer
Expand Down
Loading