Kandinsky ImageSR 2.0
Native-resolution enhancement and 2x/4x upscaling with Kandinsky ImageSR 2.0.
<a href="https://kandinskylab.ai/"><img alt="KandinskyLab" src="https://img.shields.io/badge/KandinskyLab-76E0B7?style=for-the-badge"></a> <a href="https://huggingface.co/spaces/kandinskylab/Kandinsky-ImageSR-2.0-Demo"><img alt="HF Demo" src="https://img.shields.io/badge/HF%20Demo-D9622B?style=for-the-badge"></a> <a href="https://huggingface.co/kandinskylab/Kandinsky-ImageSR-2.0"><img alt="HF Model" src="https://img.shields.io/badge/HF%20Model-FFD21E?style=for-the-badge"></a>
</div>Kandinsky ImageSR 2.0
Diffusers-native inference pipeline for the Kandinsky Image Super-Resolution 2.0 model.
A single transformer serves native-resolution enhancement (x1) and x2/x4
upscaling. The BF16 release includes precomputed zero-text conditioning and
visual modulation for 26 timesteps.
BF16 release revision · GGUF Q8_0 · Live demo · Comfy Registry · Benchmarks and compilation
ComfyUI
Search for Kandinsky ImageSR 2.0 in ComfyUI Manager or run
comfy node registry-install kandinsky-imagesr. Restart ComfyUI, then open the
example workflow.
See the ComfyUI setup guide for BF16 and GGUF.
Install
The pipeline uses the Kandinsky 5 transformer included in Diffusers 0.41 or newer.
Install with pip. Install the PyTorch build for your CUDA version, then install ImageSR.
# Replace cu128 with the PyTorch wheel index for your CUDA version.
pip install torch --index-url https://download.pytorch.org/whl/cu128
pip install git+https://github.com/kandinskylab/kandinsky-image-sr.git
Install from a clone. just uses
uv to install ImageSR and its development tools.
uv detects the NVIDIA driver and selects the matching PyTorch wheel index.
git clone https://github.com/kandinskylab/kandinsky-image-sr.git
cd kandinsky-image-sr
just setup # create .venv
just setup-conda # or install into the active conda environment
# force a specific build: just torch_backend=cu130 setup
FlashAttention-2 (optional)
Attention runs on PyTorch SDPA by default. To use FlashAttention-2 instead, install the
flash extra (Linux with CUDA; flash-attn is built from source and needs nvcc):
pip install "kandinsky-image-sr[flash] @ git+https://github.com/kandinskylab/kandinsky-image-sr.git"
# in a checkout: just setup flash (or just setup-conda flash)
and switch the transformer to it after loading the pipeline:
pipe.transformer.set_attention_backend("flash")
Inference
from pathlib import Path
import torch
from kandinsky_image_sr import KandinskyImageSRPipeline
from kandinsky_image_sr.png import save_png
pipe = KandinskyImageSRPipeline.from_pretrained(
"kandinskylab/Kandinsky-ImageSR-2.0",
revision="44f95143faaac940723baba66e82ad01e8f0cba7",
dtype=torch.bfloat16,
).to("cuda")
# Optional: FlashAttention-2 instead of PyTorch SDPA (needs the `flash` extra, see Install).
# pipe.transformer.set_attention_backend("flash")
result = pipe(
"input.png",
upscale_factor=4,
# Optional. Defaults: x1=0.05, x2=0.15, x4=0.244.
one_step_t=0.244,
)
save_png(result.images[0], Path("output.png"))
For the command-line example, download the
BF16 release snapshot and use its local directory.
The CLI uses PyTorch SDPA by default. Use --attention flash for FlashAttention-2
or --attention flash3 on a supported Hopper GPU with the flash3 extra installed.
python scripts/run_inference.py --model ./imagesr-bf16 --input input.png --output output.png \
--upscale-factor 1 --creativity 4
See notebooks/inference_example.ipynb for the notebook.
The CLI writes large RGB PNGs with parallel lossless compression and logs the save time separately. Other file formats use Pillow.
Use upscale_factor=1 with a bundle that lists x1 in model_index.json to enhance an
image at its original resolution. creativity accepts levels 0..8 for each supported
factor. Level 4 uses the default t. Baked bundles support the raw one_step_t values
listed in their transformer config.
| Factor | Default t | Calibrated creativity range |
|---:|---:|---:|
| x1 | 0.05 | 0.005–0.118 |
| x2 | 0.15 | 0.07–0.30 |
| x4 | 0.244 | 0.17–0.38 |
Choose lower levels for fine text and details you want to preserve.
The model processes 1024-pixel output tiles and blends overlaps with boundary-aware Hanning windows. Small inputs are replicate-padded and cropped back to the exact requested size.
H100 inference time
Median of three warmed runs on H100 80 GB with a 1024 × 1024 input,
25% overlap, and one tile per call. The x1 measurements used t = 0.025.
The x2 and x4 measurements used Creativity 4. The compiled columns use compiled DiT blocks,
a compiled VAE decoder, and FlashAttention-3. Timing excludes PNG export.
| Scale | Output | BF16 with baked modulation | BF16 compiled | GGUF Q8_0 compiled | |---|---:|---:|---:|---:| | ×1 | 1024 × 1024 | 0.327 s | 0.172 s | 0.178 s | | ×2 | 2048 × 2048 | 2.86 s | 1.46 s | 1.52 s | | ×4 | 4096 × 4096 | 7.96 s | 4.04 s | 4.25 s |
For 2048 × 2048 → 8192 × 8192 at ×4, a paired BF16 compiled run took
19.56 s on one H100 and 11.88 s on two H100s using 25% overlap.
See the full benchmark and compilation settings.
Use scripts/test.py to measure inference latency with PyTorch SDPA
or FlashAttention-2.
License
The code and model release use the MIT License, consistently with Kandinsky 5. The bundled
VAE is sourced from the Apache-2.0-licensed black-forest-labs/FLUX.1-schnell release.