Skip to content
프로젝트

소개

Diffusers pipeline for Kandinsky Image Super-Resolution 2.0

디자인 및 미디어

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
+8
in 7 days
기록 수집 중
in 15 days
기록 수집 중
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original


KandinskyLab HF Demo HF Model

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 · INT8 ConvRot · W4A8 ConvRot · Live demo · Comfy Registry · Benchmarks and compilation

For video upscaling, see Kandinsky 6.0 Video Super-Resolution. Demo · Model · GitHub

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, GGUF, INT8 ConvRot, and W4A8 ConvRot.

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

For CPU inference with the BF16 bundle, add --device cpu and use the default PyTorch SDPA.

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.

관련 프로젝트 살펴보기

불러오는 중…