Models · Image restoration

DAT

DAT (Chen et al., ICCV 2023): a x4 upscaler for clean (bicubic) images that alternates spatial and channel attention, in three sizes (DAT, DAT-2, DAT-light). Apache-2.0 code and weights.

experimental Fork of zhengchen1999/DAT@1645c64 · backends: portable, kernels

Checkpoint

Paper 2023 Added in 0.2.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 1391 ms 512x512, fp16
vs the faster original 6.9× original fp16: 9564 ms
Peak memory 2,282 MiB original: 2,443 MiB
Accuracy vs original fp32 −0.02 kernels psnr, DIV2K validation (every 4th: 25 images) (31.03 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("dat-x4")  # kernels on a supported GPU, else portable PyTorch
result = model(image)
result.image
result.backend  # what ran: mode, device, dtype, kernels
fastforks bench dat-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 dat_model.py test, float32, no chopfp16 9564–2,443 MiB/2,528 MiB2.27.78
Portable fp32fp32not measured ––––
Portablefp16 15656.1×2,552 MiB/2,624 MiB3.02.31
Kernelsfp16 13916.9×2,282 MiB/2,384 MiB1.22.14
Portable + torch.compile 10639.0×2,552 MiB/2,606 MiB43 (build)–
TensorRT fp16fp16 10019.6×8,334 MiBenginenot comparable191 (build)–

Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-13 to 2026-11-15. 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-14Originalfp3218351 13.2 GiB process–512x512
Portablefp1610512 10.4 GiB processmatches512x512
Portablefp3221047 12.9 GiB 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

DAT_x4.pth 155 MB· hosted on Google Drive

fastforks downloads and checks these files on first use (fastforks download dat-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 (every 4th: 25 images)

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

Rundtypepsnr ↑ssim ↑Δ psnr vs fp32 originalimagesms / image
Original fp32fp3231.030.8498 reference 25 –
Original fp16not measured
Portable fp32fp3231.030.8498 ±0.00 25 –
Portablefp1631.030.8498 ±0.00 25 –
Kernelsfp1631.010.8498 −0.02 25 –

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 f33b2772, 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| <= 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).

CheckToleranceMeasured
CPU fp32, max |diff|≤ 0.0000036 not recorded
GPU default dtypes, mean |diff|≤ 0.0012 0.00051
GPU default dtypes, p99 |diff|≤ 0.0044 0.00191

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

Details

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.

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 >= 32, padded to a multiple of 32; tested up to 1024x1024 (10.1 GiB allocated)
Outputs
image
CUDA kernels
  • cudnn_haccconvolutions with fp16 accumulation (cuDNN)
Apple (MPS)
fp32, fp16
Full reference, generated from the repository

DAT (Chen et al., ICCV 2023): a x4 upscaler for clean (bicubic) images that alternates spatial and channel attention, in three sizes (DAT, DAT-2, DAT-light). Apache-2.0 code and weights.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
dat-x4synthetic (512x512)original
portable
kernels
portable + torch.compile
TensorRT fp16
9564
1565
1391
1063
1001
2443 / 2528
2552 / 2624
2282 / 2384
2552 / 2606
9010 / 9056
dat-2-x4synthetic (512x512)original
portable
kernels
portable + torch.compile
TensorRT fp16
4880
1312
1221
964
921
2436 / 2518
2276 / 2378
2276 / 2378
2546 / 2598
9001 / 9048
dat-light-x4synthetic (512x512)original
portable
kernels
portable + torch.compile
TensorRT fp16
2204
268
264
158
136
1606 / 1656
1535 / 1552
1445 / 1472
1385 / 1412
4144 / 4192
Details
  • Original code: https://github.com/zhengchen1999/DAT at 1645c64fad7c
  • Code licence: Apache-2.0 (permissive); files: LICENSE
  • Weights licence: Apache-2.0
  • 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)
  • 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.)
    • dat-2-x4: DIV2K (NTIRE 2017 super-resolution, 1000 2K images), Flickr2K (2650 2K Flickr images, EDSR) (options/Train/train_DAT_2_x4.yml: DF2K (DIV2K + Flickr2K), bicubic-downsampled, fine-tuned from the x2 model.)
    • dat-light-x4: DIV2K (NTIRE 2017 super-resolution, 1000 2K images), Flickr2K (2650 2K Flickr images, EDSR) (options/Train/train_DAT_light_x4.yml: DF2K (DIV2K + Flickr2K), bicubic-downsampled, fine-tuned from the x2 model.)
  • Kernel libraries: cudnn_hacc
  • Variants: dat-x4, dat-2-x4, dat-light-x4
  • Outputs: image
  • Input size: any H x W >= 32, padded to a multiple of 32
  • Tested up to (portable, fp16, RTX 5060 Ti 16 GB): dat-x4 1024x1024 (10.1 GiB peak allocated, 14.9 reserved); 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 512x512, first call: portable + torch.compile 43 s (cold Inductor cache), TensorRT fp16 191 s (ONNX + engine).
  • dat-2-x4 512x512, first call: portable + torch.compile 44 s (cold Inductor cache), TensorRT fp16 206 s (ONNX + engine).
  • dat-light-x4 512x512, first call: portable + torch.compile 37 s (cold Inductor cache), TensorRT fp16 75 s (ONNX + engine).
  • dat-x4 original 512x512: .half() on 1 modules, fp16 inputs; upstream dat_model.py test, float32, no chop
  • dat-2-x4 original 512x512: .half() on 1 modules, fp16 inputs; upstream dat_model.py test, float32, no chop
  • dat-light-x4 original 512x512: .half() on 1 modules, fp16 inputs; upstream dat_model.py test, float32, no chop
  • dat-x4 load / first call: original 2.2 s / 6.13 s, portable 2.99 s / 2.307 s, kernels 0.71 s / 2.149 s
  • dat-2-x4 load / first call: original 2.04 s / 5.516 s, portable 0.71 s / 2.136 s, kernels 0.72 s / 2.006 s
  • dat-light-x4 load / first call: original 3.48 s / 2.721 s, portable 0.21 s / 1.304 s, kernels 1.25 s / 1.152 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
dat-x4DIV2K validation (every 4th: 25 images), bicubic x4 LR -> HR, PSNR / SSIM (Y)31.03 / 0.849831.03 / 0.849831.03 / 0.849831.01 / 0.8498
dat-2-x4DIV2K validation (every 4th: 25 images), bicubic x4 LR -> HR, PSNR / SSIM (Y)30.99 / 0.849230.99 / 0.849330.99 / 0.849230.97 / 0.8492
dat-light-x4DIV2K validation (every 4th: 25 images), bicubic x4 LR -> HR, PSNR / SSIM (Y)30.48 / 0.837930.48 / 0.837930.48 / 0.837930.46 / 0.8375

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

Parity

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

variantkernels error vs original, mean / p99GPU, torchkernels used
dat-x40.00051 / 0.00191RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400
dat-2-x40.00065 / 0.00241RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400
dat-light-x40.00079 / 0.00288RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400

Example output

No example rendered for this checkpoint yet.