DAT (fastforks)

DAT (Chen et al., ICCV 2023): image super-resolution with residual groups that alternate spatial window attention (8 x 32 rectangle windows) and channel attention, each with a convolution branch and adaptive interaction, and a spatial-gate feed-forward network. dat-x4 is the main x4 model, dat-2-x4 its variant with a 2x feed-forward expansion, dat-light-x4 the lightweight one (60 channels, one-step upsampler); all trained on DF2K, bicubic x4.

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/zhengchen1999/DAT at 1645c64fad7c.

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
dat-2-x4@1 DAT_2_x4.pth 05b5c17bb5d1 Apache-2.0 yes
dat-light-x4@1 DAT_light_x4.pth e18223fc4150 Apache-2.0 yes
dat-x4@1 DAT_x4.pth 391a6ce69899 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) (options/Train/train_DAT_x4.yml: DF2K (DIV2K + Flickr2K), bicubic-downsampled, fine-tuned from the x2 model.).

Licence evidence: https://github.com/zhengchen1999/DAT/blob/1645c64fad7c94d94abd090bd1319eec1f26f7cc/LICENSE ; https://github.com/zhengchen1999/DAT/blob/1645c64fad7c94d94abd090bd1319eec1f26f7cc/README.md (pretrained models: https://drive.google.com/drive/folders/1iBdf_-LVZuz_PAbFtuxSKd_11RL1YKxM)

Input size

any H x W >= 32, padded to a multiple of 32 Tested up to (portable, fp16, RTX 5060 Ti 16 GB): dat-2-x4 1024x1024 (10.1 GiB peak allocated, 14.1 reserved); dat-light-x4 1024x1024 (6.3 GiB peak allocated, 7.4 reserved); dat-x4 1024x1024 (10.1 GiB peak allocated, 14.9 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
dat-2-x4 4880 1312 1221 4.0x 1.1x 2436 / 2518 2276 / 2378 2276 / 2378
dat-light-x4 2204 268 264 8.3x 1.0x 1606 / 1656 1535 / 1552 1445 / 1472
dat-x4 9564 1565 1391 6.9x 1.1x 2443 / 2528 2552 / 2624 2282 / 2384

Startup and first call

model load (s): original portable kernels first call (s): original portable kernels
dat-2-x4 2.04 0.71 0.72 5.52 2.14 2.01
dat-light-x4 3.48 0.21 1.25 2.72 1.30 1.15
dat-x4 2.20 2.99 0.71 6.13 2.31 2.15

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)
dat-2-x4 512x512 1312 ms 964 ms deferred (build >5 min) 1221 ms 44.3 s – 2276 / 2378 2546 / 2598 2276 / 2378 –
dat-light-x4 512x512 268 ms 158 ms 136 ms 264 ms 36.7 s 74.8 s 1535 / 1552 1385 / 1412 1445 / 1472 4144 / 4192
dat-x4 512x512 1565 ms 1063 ms deferred (build >5 min) 1391 ms 43.1 s – 2552 / 2624 2552 / 2606 2282 / 2384 –

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
dat-x4 DIV2K validation (every 4th: 25 images), bicubic x4 LR -> HR, PSNR / SSIM (Y) 31.03 / 0.8498 31.03 / 0.8498 31.01 / 0.8498
dat-2-x4 DIV2K validation (every 4th: 25 images), bicubic x4 LR -> HR, PSNR / SSIM (Y) 30.99 / 0.8492 30.99 / 0.8493 30.97 / 0.8492
dat-light-x4 DIV2K validation (every 4th: 25 images), bicubic x4 LR -> HR, PSNR / SSIM (Y) 30.48 / 0.8379 30.48 / 0.8379 30.46 / 0.8375

Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks f33b2772, 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| <= 3.6e-06 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.0012 and p99 <= 0.0044 (absolute error of the output image).

Usage

from fastforks import restoration

model = restoration.load("dat-2-x4")  # 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: dat-2-x4, dat-light-x4, dat-x4.

Kernels backend

restoration.load("dat-2-x4", 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.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Collection including fastforks/dat