Instructions to use kandinskylab/Kandinsky-ImageSR-2.0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use kandinskylab/Kandinsky-ImageSR-2.0 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("kandinskylab/Kandinsky-ImageSR-2.0", dtype=torch.bfloat16, device_map="cuda") prompt = "Turn this cat into a dog" input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe(image=input_image, prompt=prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Kandinsky ImageSR 2.0
Kandinsky Image Super-Resolution 2.0 as a Diffusers bundle. A single set of transformer
weights serves both x2 and x4. The release uses pre-baked zero-text conditioning: the
text tower and all 50 cross-attention layers are replaced by small per-timestep Safetensors
tables.
This repository contains all components needed for inference with from_pretrained.
Install
# install torch built for your CUDA first; replace cu128 with the index URL for your driver
pip install torch --index-url https://download.pytorch.org/whl/cu128
pip install git+https://github.com/kandinskylab/kandinsky-image-sr.git
The pipeline uses the Kandinsky 5 transformer included in Diffusers 0.41 or newer.
Inference
import torch
from kandinsky_image_sr import KandinskyImageSRPipeline
pipe = KandinskyImageSRPipeline.from_pretrained(
"kandinskylab/Kandinsky-ImageSR-2.0",
dtype=torch.bfloat16,
).to("cuda")
result = pipe(
"input.png",
upscale_factor=4,
# Optional. Defaults: x2=0.15, x4=0.244.
one_step_t=0.244,
)
result.images[0].save("output.png")
For calibrated UI controls, creativity accepts levels 0..8 at x2 and x4; level 4
corresponds to the default t. The release accepts the defaults and the 18 creativity
values listed in its config; other raw one_step_t values are not supported.
| Factor | Default t |
Calibrated creativity range |
|---|---|---|
| x2 | 0.15 | 0.07β0.30 |
| x4 | 0.244 | 0.17β0.38 |
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.
Inference time
Measured on an NVIDIA H100 80GB (SXM) with square images: bfloat16, torch 2.13.0 (CUDA 12.9),
default settings (tile_batch_size=1). Each time is the median of 5 full pipe(...) calls
after 2 warm-up calls.
| Input resolution | Upscale | Output resolution | Tile grid | Time per image |
|---|---|---|---|---|
| 1K (1024 Γ 1024) | Γ2 | 2K (2048 Γ 2048) | 3 Γ 3 | 2.78 s |
| 1K (1024 Γ 1024) | Γ4 | 4K (4096 Γ 4096) | 5 Γ 5 | 7.80 s |
| 2K (2048 Γ 2048) | Γ2 | 4K (4096 Γ 4096) | 5 Γ 5 | 7.84 s |
| 2K (2048 Γ 2048) | Γ4 | 8K (8192 Γ 8192) | 11 Γ 11 | 37.5 s |
| 4K (4096 Γ 4096) | Γ2 | 8K (8192 Γ 8192) | 11 Γ 11 | 37.7 s |
Reproduce with scripts/test.py from the GitHub repository:
CUDA_VISIBLE_DEVICES=0 python scripts/test.py --image photo.jpg --backend native
License
The transformer and pipeline code are released under 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.
- Downloads last month
- 4