Models · Image restoration

DRCT

DRCT (Hsu et al., CVPRW 2024): a x4 upscaler for clean (bicubic) images, Swin Transformer blocks with dense connections inside each group, in two sizes (DRCT, DRCT-L). MIT code and weights.

experimental Fork of ming053l/DRCT@c0a8b51 · backends: portable, kernels

Checkpoint

Paper 2024 Added in 0.2.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 718 ms 512x512, fp16
vs the faster original 10.4× original fp16: 7492 ms
Peak memory 2,498 MiB original: 3,359 MiB
Accuracy vs original fp32 ±0.00 kernels psnr, DIV2K validation (every 2nd: 50 images) (30.76 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("drct-x4")  # kernels on a supported GPU, else portable PyTorch
result = model(image)
result.image
result.backend  # what ran: mode, device, dtype, kernels
fastforks bench drct-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 drct_model.py test, float32, no tilefp16 7492–3,359 MiB/3,944 MiB0.47.43
Portable fp32fp32not measured ––––
Portablefp16 8309.0×2,626 MiB/3,048 MiB0.41.02
Kernelsfp16 71810×2,498 MiB/2,766 MiB0.70.76
Portable + torch.compile 61812×1,938 MiB/2,348 MiB40 (build)–
TensorRT fp16fp16 73110×9,402 MiBenginenot comparable187 (build)–

Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-14 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-14Originalfp32out of memory–512x512
Portablefp16out of memory–512x512
Portablefp32out of memory–512x512
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
MIT LICENSE
Weights
MIT source
Training data

Our reading of the licences, not legal advice.

Weights

DRCT_X4.pth 246 MB· hosted on Google Drive

fastforks downloads and checks these files on first use (fastforks download drct-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 2nd: 50 images)

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

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

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-16; portable fp32, portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 706c6828, 2026-11-14.

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| <= 2e-06 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.00071 and p99 <= 0.0027 (absolute error of the output image).

CheckToleranceMeasured
CPU fp32, max |diff|≤ 0.000002 not recorded
GPU default dtypes, mean |diff|≤ 0.00071 0.00043
GPU default dtypes, p99 |diff|≤ 0.0027 0.00158

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

Details

DRCT (Hsu et al., CVPRW 2024): image super-resolution with residual dense groups of Swin Transformer layers (16 x 16 window attention, shifted every second layer) whose inputs grow by 32 channels per layer (dense connections). `drct-x4` is the classical x4 model (6 groups), `drct-l-x4` the large one (12 groups); both bicubic, PSNR-trained.

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,202 MiB allocated)
Outputs
image
CUDA kernels
  • cudnn_haccconvolutions with fp16 accumulation (cuDNN)
Apple (MPS)
fp32, fp16
Full reference, generated from the repository

DRCT (Hsu et al., CVPRW 2024): a x4 upscaler for clean (bicubic) images, Swin Transformer blocks with dense connections inside each group, in two sizes (DRCT, DRCT-L). MIT code and weights.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
drct-x4synthetic (512x512)original
portable
kernels
portable + torch.compile
TensorRT fp16
7492
830
718
618
731
3359 / 3944
2626 / 3048
2498 / 2766
1938 / 2348
9684 / 9728
drct-l-x4synthetic (512x512)original
portable
kernels
portable + torch.compile
TensorRT fp16
14651
1607
1399
1210
fails: TensorRT engine build failed
5574 / 6926
2692 / 3110
2564 / 2850
2005 / 2410
–
Details
  • Original code: https://github.com/ming053l/DRCT at c0a8b51e6924
  • Code licence: MIT (permissive); files: LICENSE
  • Weights licence: MIT
  • Licence evidence: https://github.com/ming053l/DRCT/blob/c0a8b51e69241cf7f8ae598053235ff498517935/LICENSE ; https://github.com/ming053l/DRCT/blob/c0a8b51e69241cf7f8ae598053235ff498517935/README.md (model zoo: https://drive.google.com/drive/folders/1QJHdSfo-0eFNb96i8qzMJAPw31u9qZ7U)
  • Training data: ImageNet-1k (ILSVRC 2012 classification), DIV2K (NTIRE 2017 super-resolution, 1000 2K images), Flickr2K (2650 2K Flickr images, EDSR) (Paper / options/train/train_DRCT_SRx4_finetune_from_ImageNet_pretrain.yml: pretrained on ImageNet, fine-tuned on DF2K (DIV2K + Flickr2K), bicubic-downsampled. The README does not say which training option produced the released files.)
  • Kernel libraries: cudnn_hacc
  • Variants: drct-x4, drct-l-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): drct-x4 1024x1024 (10.0 GiB peak allocated, 13.9 reserved); drct-l-x4 1024x1024 (10.0 GiB peak allocated, 13.9 reserved)
  • drct-x4 512x512, first call: portable + torch.compile 40 s (cold Inductor cache), TensorRT fp16 187 s (ONNX + engine).
  • drct-l-x4 512x512, first call: portable + torch.compile 67 s (cold Inductor cache).
  • drct-x4 original 512x512: .half() on 1 modules, fp16 inputs; upstream drct_model.py test, float32, no tile
  • drct-l-x4 original 512x512: torch.autocast(float16) around the call; upstream drct_model.py test, float32, no tile
  • drct-x4 load / first call: original 1.88 s / 8.657 s, portable 0.39 s / 1.018 s, kernels 1.32 s / 0.773 s
  • drct-l-x4 load / first call: original 2.09 s / 15.382 s, portable 0.79 s / 1.698 s, kernels 1.84 s / 1.454 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
drct-x4DIV2K validation (every 2nd: 50 images), bicubic x4 LR -> HR, PSNR / SSIM (Y)30.76 / 0.838830.76 / 0.838830.76 / 0.838830.76 / 0.8388
drct-l-x4DIV2K validation (every 2nd: 50 images), bicubic x4 LR -> HR, PSNR / SSIM (Y)31.00 / 0.843431.00 / 0.843431.00 / 0.843431.00 / 0.8434

Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 706c6828, 2026-11-14.

Parity

CPU, float32: max |diff| <= 2e-06 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.00071 and p99 <= 0.0027 (absolute error of the output image).

variantkernels error vs original, mean / p99GPU, torchkernels used
drct-x40.00043 / 0.00158RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400
drct-l-x40.00047 / 0.00175RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400

Example output

No example rendered for this checkpoint yet.