Models · Image restoration

SPAN

SPAN (Wan et al., NTIRE 2024 efficient SR winner): a small, fast x4 / x2 upscaler for clean (bicubic) images, convolutions with parameter-free attention. Apache-2.0 code and weights.

experimental Fork of hongyuanyu/SPAN@c77a591 · backends: portable, kernels

Checkpoint

Paper 2023 Added in 0.2.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 14.6 ms 512x512, fp16
vs the faster original 1.8× original fp16: 26.9 ms
Peak memory 487 MiB original: 611 MiB
Accuracy vs original fp32 ±0.00 kernels psnr, DIV2K validation (100 images) (30.47 original)

Use it

pip install fastforks

Lean install with only what this model needs: pip install fastforks-core

from fastforks import restoration

model = restoration.load("span-x4")  # kernels on a supported GPU, else portable PyTorch
result = model(image)
result.image
result.backend  # what ran: mode, device, dtype, kernels
fastforks bench span-x4

Times the model on this machine. load(…, mode="portable") or mode="kernels" picks a backend; usage guide.

Speed and memory

Every backend on one GPU (RTX 5060 Ti 16 GB) and the same input, the authors’ code included. Kernels runs fp16. Portable runs fp16 on CUDA.

Input: synthetic, 512x512 (the task’s standard size)

BackenddtypeTime per call (ms)vs original fp16Peak memory
allocated / reserved
Load (s)First call (s)
Original fp32fp32not measured ––––
Original fp16.half() on 1 modules, fp16 inputs; upstream SPAN eval mode, float32, net(lq) clampedfp16 26.9–611 MiB/648 MiB0.50.74
Portable fp32fp32not measured ––––
Portablefp16 24.21.1×607 MiB/662 MiB0.10.26
Kernelsfp16 14.61.8×487 MiB/522 MiB1.10.05
Portable + torch.compile 13.22.0×204 MiB/222 MiB5 (build)–
TensorRT fp16fp16 8.283.3×264 MiBenginenot comparable10 (build)–

Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-13. First call, 3 warm-up, peak reset, median of 3 rounds x median of 5. Ratios divide two times of this table (same GPU, same input). Original fp16 is the authors’ own precision option, else torch.autocast. torch.compile and TensorRT: build time instead of load time. TensorRT memory (engine, not comparable) is the GPU memory the engine took, read from the driver because TensorRT allocates outside PyTorch, so it can't be compared with the PyTorch peaks of the other rows.

Other devices

DeviceBackenddtypems / callPeak memoryOutput vs referenceInput
Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-14Originalfp32117 2,388 MiB process–512x512
Portablefp1689.0 1,296 MiB processmatches512x512
Portablefp32103 2,321 MiB processmatches512x512
Kernelsfp16not implemented–512x512

CUDA memory is torch’s peak allocated / reserved; Apple has no such counter, so the Mac rows show the process footprint (weights, Python and torch included). “Output vs reference” compares the device’s output with the stored golden output under the card’s tolerance; – = not checked on that device. Kernels “not implemented” = no kernels for this model on that backend yet: it runs portable there.

Licence and weights

Commercial use allowed

Code
Apache-2.0 LICENSE
Weights
Apache-2.0 source
Training data

Our reading of the licences, not legal advice.

Weights

spanx4_ch48.pth 18.0 MB· inside a 1.3 GB archive· hosted on Google Drive

fastforks downloads and checks these files on first use (fastforks download span-x4).

Accuracy

The test set through the authors’ code and through ours: same checkpoint, same protocol. The distance between the original’s fp32 and fp16 runs is what half precision alone costs; our runs should stay within it.

DIV2K validation (100 images)

bicubic x4 LR -> HR, PSNR / SSIM (Y)

Rundtypepsnr ↑ssim ↑Δ psnr vs fp32 originalimagesms / image
Original fp32fp3230.470.8382 reference 100 –
Original fp16not measured
Portable fp32fp3230.470.8382 ±0.00 100 –
Portablefp1630.470.8382 ±0.00 100 –
Kernelsfp1630.470.8382 ±0.00 100 –

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 authors’ code, same checkpoint and protocol. Measured on original fp32: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-13; portable fp32, portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 45a5c91f, 2026-11-13.

Closeness to the original

Beyond the test-set scores: the raw output of ours against the original’s fp32 output on the same input, pixel by pixel. 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).

CheckToleranceMeasured
CPU fp32, max |diff|≤ 0.00001 not recorded
GPU default dtypes, mean |diff|≤ 0.02 0.00074
GPU default dtypes, p99 |diff|≤ 0.25 0.00305

Recorded for span-x4 on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-13, with these kernels: cudnn_hacc

Details

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.

Input / output
Input: one RGB image. Output: the restored (upscaled) image, model.scale x the input size, RGB in [0, 1].
What the numbers mean, and which models need the camera focal length

tile= runs large images in overlapping tiles (as ComfyUI).

Input size
any H x W >= 4, resized or padded inside the model; tested up to 1988x2880 (12.9 GiB allocated)
Outputs
image
CUDA kernels
  • cudnn_haccconvolutions with fp16 accumulation (cuDNN)
Apple (MPS)
fp32, fp16
Full reference, generated from the repository

SPAN (Wan et al., NTIRE 2024 efficient SR winner): a small, fast x4 / x2 upscaler for clean (bicubic) images, convolutions with parameter-free attention. Apache-2.0 code and weights.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
span-x4synthetic (512x512)original
portable
kernels
portable + torch.compile
TensorRT fp16
26.9
24.2
14.6
13.2
8.28
611 / 648
607 / 662
487 / 522
204 / 222
319 / 346
span-x2synthetic (512x512)original
portable
kernels
portable + torch.compile
TensorRT fp16
24.6
23.5
14.9
13.2
7.98
611 / 648
607 / 662
487 / 522
204 / 222
243 / 266
Details
  • Original code: https://github.com/hongyuanyu/SPAN at c77a5917759f
  • Code licence: Apache-2.0 (permissive); files: LICENSE
  • Weights licence: Apache-2.0
  • Licence evidence: https://github.com/hongyuanyu/SPAN/blob/c77a5917759f09e66fbc7124220c5afc5ee221e5/LICENSE.txt ; https://github.com/hongyuanyu/SPAN/blob/c77a5917759f09e66fbc7124220c5afc5ee221e5/README.md
  • 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.)
  • Kernel libraries: cudnn_hacc
  • Variants: span-x4, span-x2
  • Outputs: image
  • Input size: any H x W >= 4, resized or padded inside the model
  • Tested up to (portable, fp16, RTX 5060 Ti 16 GB): span-x4 1988x2880 (12.9 GiB peak allocated, 14.0 reserved); span-x2 1988x2880 (12.9 GiB peak allocated, 14.0 reserved)
  • span-x4 512x512, first call: portable + torch.compile 5 s (cold Inductor cache), TensorRT fp16 10 s (ONNX + engine).
  • span-x2 512x512, first call: portable + torch.compile 7 s (cold Inductor cache), TensorRT fp16 10 s (ONNX + engine).
  • span-x4 original 512x512: .half() on 1 modules, fp16 inputs; upstream SPAN eval mode, float32, net(lq) clamped
  • span-x2 original 512x512: .half() on 1 modules, fp16 inputs; upstream SPAN eval mode, float32, net(lq) clamped
  • span-x4 load / first call: original 0.45 s / 0.585 s, portable 0.1 s / 0.264 s, kernels 1.11 s / 0.048 s
  • span-x2 load / first call: original 0.23 s / 0.322 s, portable 0.1 s / 0.258 s, kernels 2.88 s / 0.102 s
  • Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5

Measured

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.

variantdatasetoriginal fp32portableportable fp32kernelsnote
span-x4DIV2K validation (100 images), bicubic x4 LR -> HR, PSNR / SSIM (Y)30.47 / 0.838230.47 / 0.838230.47 / 0.838230.47 / 0.8382
span-x2DIV2K validation (100 images), bicubic x2 LR -> HR, PSNR / SSIM (Y)36.20 / 0.946036.20 / 0.946036.20 / 0.946036.20 / 0.9460

Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 45a5c91f, 2026-11-13.

Parity

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).

variantkernels error vs original, mean / p99GPU, torchkernels used
span-x40.00074 / 0.00305RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400
span-x20.00207 / 0.0225RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400

Example output

No example rendered for this checkpoint yet.