SPAN (fastforks)
SPAN (Wan et al., CVPRW 2024; NTIRE 2024 efficient super-resolution winner): a small bicubic super-resolution network (about 0.4 M parameters at inference) of six parameter-free attention blocks (re-parameterised 3 x 3 convs, attention = sigmoid(features) - 0.5) and a pixel-shuffle upsampler, trained for PSNR. span-x4 and span-x2 are the 48-channel release models.
This repo is the model card only: it holds no weights. fastforks downloads the authors' weights from the links below and checks them against the SHA-256 in the model card. Code: https://github.com/kleinicke/fastforks. Kernels for the kernels backend: https://huggingface.co/fastforks/kernels. Original code: https://github.com/hongyuanyu/SPAN at c77a5917759f.
Task: restoration. Tier: experimental. Outputs: image. Backends: portable, kernels.
Input: one RGB image. Output: the restored (upscaled) image, model.scale x the input size, RGB in [0, 1]. tile= runs large images in overlapping tiles (as ComfyUI).
Variants
Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in card.toml.
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|---|---|---|---|---|
span-x2@1 |
spanx2_ch48.pth | 561fd5cf419a |
Apache-2.0 | yes |
span-x4@1 |
spanx4_ch48.pth | 28fef8c6c845 |
Apache-2.0 | yes |
Licence
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Licence files: LICENSE.
Training data: DIV2K (NTIRE 2017 super-resolution, 1000 2K images), Flickr2K (2650 2K Flickr images, EDSR) (Paper Sec. 4.1: DF2K (DIV2K + Flickr2K) HR images, bicubic-downsampled.).
Licence evidence: https://github.com/hongyuanyu/SPAN/blob/c77a5917759f09e66fbc7124220c5afc5ee221e5/LICENSE.txt ; https://github.com/hongyuanyu/SPAN/blob/c77a5917759f09e66fbc7124220c5afc5ee221e5/README.md
Input size
any H x W >= 4, resized or padded inside the model
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): span-x2 1988x2880 (12.9 GiB peak allocated, 14.0 reserved); span-x4 1988x2880 (12.9 GiB peak allocated, 14.0 reserved)
Speed and memory
Restoration, synthetic, 512x512
| model | time (ms): original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
|---|---|---|---|---|---|---|---|---|
span-x2 |
24.6 | 23.5 | 14.9 | 1.6x | 1.6x | 611 / 648 | 607 / 662 | 487 / 522 |
span-x4 |
26.9 | 24.2 | 14.6 | 1.8x | 1.7x | 611 / 648 | 607 / 662 | 487 / 522 |
Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|---|---|---|---|---|---|---|
span-x2 |
0.23 | 0.10 | 2.88 | 0.32 | 0.26 | 0.10 |
span-x4 |
0.45 | 0.10 | 1.11 | 0.58 | 0.26 | 0.05 |
torch.compile and TensorRT
| model | input | time: portable | compile | TensorRT fp16 | kernels | preparation: compile (cold first call) | ONNX + engine build | peak MiB (alloc / reserved): portable | compile | kernels | TensorRT (engine + torch) |
|---|---|---|---|---|---|---|---|---|---|---|---|
span-x2 |
512x512 | 23.5 ms | 13.2 ms | 7.98 ms | 14.9 ms | 7.26 s | 9.60 s | 607 / 662 | 204 / 222 | 487 / 522 | 243 / 266 |
span-x4 |
512x512 | 24.2 ms | 13.2 ms | 8.28 ms | 14.6 ms | 4.57 s | 9.80 s | 607 / 662 | 204 / 222 | 487 / 522 | 319 / 346 |
Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
Hardware, protocol and caveats: benchmarks (RTX 5060 Ti 16 GB, sm_120). Original = the original code named above at the precision of portable (fp16, or (fp32) where fp16 is unsupported or not finite); original fp32 = its default fp32 run. Peak memory is the torch allocator's.
Accuracy
On public datasets
DIV2K validation HR images and the official bicubic LR images (x4 or x2, the model's scale), one pass without tiles; PSNR and SSIM (Gaussian 11 x 11, sigma 1.5) on the Y channel (BT.601) of the output rounded to uint8, scale px border cropped, averaged over the images. Real-ESRGAN is trained for real-world degradations, not bicubic, so its PSNR is low: the numbers compare our modes with the original, not with PSNR-oriented upscalers. Original = the original code named under Details, same checkpoint and protocol.
| variant | dataset | original fp32 | portable | kernels | note |
|---|---|---|---|---|---|
span-x4 |
DIV2K validation (100 images), bicubic x4 LR -> HR, PSNR / SSIM (Y) | 30.47 / 0.8382 | 30.47 / 0.8382 | 30.47 / 0.8382 | |
span-x2 |
DIV2K validation (100 images), bicubic x2 LR -> HR, PSNR / SSIM (Y) | 36.20 / 0.9460 | 36.20 / 0.9460 | 36.20 / 0.9460 |
Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 45a5c91f, 2026-11-13.
Parity with the original code
Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 1e-05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.02 and p99 <= 0.25 (absolute error of the output image).
Usage
from fastforks import restoration
model = restoration.load("span-x2") # mode="auto": the preferred backend from recorded measurements
result = model("photo.png") # tile=512 for large images
result.image # [3, sH, sW] float32 RGB in [0, 1], s = model.scale
result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
Install with pip install fastforks (see https://github.com/kleinicke/fastforks). Other variants: span-x2, span-x4.
Kernels backend
restoration.load("span-x2", mode="kernels") runs our CUDA kernels (cudnn_hacc). It needs a prebuilt kernel for your GPU architecture (downloaded from https://huggingface.co/fastforks/kernels on first use) and a recent NVIDIA driver; if there is none it raises BackendUnavailableError with the reason and never falls back silently. mode="auto" picks kernels when it can run and logs the choice.