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
- Paper DRCT: Saving Image Super-resolution away from Information Bottleneck CVPR 2024 Workshops (NTIRE) · first released 31 Mar 2024
Paper 2024 Added in 0.2.0 Evaluated with 0.2.0
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)
| Backend | dtype | Time per call (ms) | vs original fp16 | Peak memory allocated / reserved | Load (s) | First call (s) |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | not measured | – | – | – | – |
| Original fp16.half() on 1 modules, fp16 inputs; upstream drct_model.py test, float32, no tile | fp16 | 7492 | – | 3,359 MiB/3,944 MiB | 0.4 | 7.43 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 830 | 9.0× | 2,626 MiB/3,048 MiB | 0.4 | 1.02 |
| Kernels | fp16 | 718 | 10× | 2,498 MiB/2,766 MiB | 0.7 | 0.76 |
| Portable + torch.compile | 618 | 12× | 1,938 MiB/2,348 MiB | 40 (build) | – | |
| TensorRT fp16 | fp16 | 731 | 10× | 9,402 MiBenginenot comparable | 187 (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
| Device | Backend | dtype | ms / call | Peak memory | Output vs reference | Input |
|---|---|---|---|---|---|---|
| Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-14 | Original | fp32 | out of memory | – | 512x512 | |
| Portable | fp16 | out of memory | – | 512x512 | ||
| Portable | fp32 | out of memory | – | 512x512 | ||
| Kernels | fp16 | not 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
-
- ImageNet-1k (ILSVRC 2012 classification) noncommercial, non-commercial
- DIV2K (NTIRE 2017 super-resolution, 1000 2K images) research-only, non-commercial
- Flickr2K (2650 2K Flickr images, EDSR) not stated
Our reading of the licences, not legal advice.
Weights
DRCT_X4.pth 246 MB· hosted on Google Drivefastforks 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)
| Run | dtype | psnr ↑ | ssim ↑ | Δ psnr vs fp32 original | images | ms / image |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 30.76 | 0.8388 | reference | 50 | – |
| Original fp16 | not measured | |||||
| Portable fp32 | fp32 | 30.76 | 0.8388 | ±0.00 | 50 | – |
| Portable | fp16 | 30.76 | 0.8388 | ±0.00 | 50 | – |
| Kernels | fp16 | 30.76 | 0.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).
| Check | Tolerance | Measured |
|---|---|---|
| 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.scalex 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.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
drct-x4 | synthetic (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-x4 | synthetic (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-x41024x1024 (10.0 GiB peak allocated, 13.9 reserved);drct-l-x41024x1024 (10.0 GiB peak allocated, 13.9 reserved) drct-x4512x512, first call: portable + torch.compile 40 s (cold Inductor cache), TensorRT fp16 187 s (ONNX + engine).drct-l-x4512x512, first call: portable + torch.compile 67 s (cold Inductor cache).drct-x4original 512x512: .half() on 1 modules, fp16 inputs; upstream drct_model.py test, float32, no tiledrct-l-x4original 512x512: torch.autocast(float16) around the call; upstream drct_model.py test, float32, no tiledrct-x4load / first call: original 1.88 s / 8.657 s, portable 0.39 s / 1.018 s, kernels 1.32 s / 0.773 sdrct-l-x4load / 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.
| variant | dataset | original fp32 | portable | portable fp32 | kernels | note |
|---|---|---|---|---|---|---|
drct-x4 | DIV2K validation (every 2nd: 50 images), bicubic x4 LR -> HR, PSNR / SSIM (Y) | 30.76 / 0.8388 | 30.76 / 0.8388 | 30.76 / 0.8388 | 30.76 / 0.8388 | |
drct-l-x4 | DIV2K validation (every 2nd: 50 images), bicubic x4 LR -> HR, PSNR / SSIM (Y) | 31.00 / 0.8434 | 31.00 / 0.8434 | 31.00 / 0.8434 | 31.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).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
drct-x4 | 0.00043 / 0.00158 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400 |
drct-l-x4 | 0.00047 / 0.00175 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400 |
Example output
No example rendered for this checkpoint yet.