DRCT (fastforks)
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.
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/ming053l/DRCT at c0a8b51e6924.
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 |
|---|---|---|---|---|
drct-l-x4@1 |
DRCT-L_X4.pth | a99044c02756 |
MIT | yes |
drct-x4@1 |
DRCT_X4.pth | fe104903aa8f |
MIT | yes |
Licence
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: MIT. Licence files: LICENSE.
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.).
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)
Input size
any H x W >= 32, padded to a multiple of 32
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): drct-l-x4 1024x1024 (10.0 GiB peak allocated, 13.9 reserved); drct-x4 1024x1024 (10.0 GiB peak allocated, 13.9 reserved)
Speed and memory
Restoration, synthetic, 512x512
| model | time (ms): original fp32 | original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
|---|---|---|---|---|---|---|---|---|---|
drct-l-x4 |
β | 14651 | 1567 | 1314 | 11.2x | 1.2x | 5574 / 6926 | 1675 / 1950 | 1603 / 1790 |
drct-x4 |
β | 7492 | 810 | 674 | 11.1x | 1.2x | 3359 / 3944 | 1608 / 1888 | 1560 / 1748 |
Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|---|---|---|---|---|---|---|
drct-l-x4 |
2.09 | 0.79 | 1.84 | 15.38 | 1.70 | 1.45 |
drct-x4 |
1.88 | 0.39 | 1.32 | 8.66 | 1.02 | 0.77 |
torch.compile and TensorRT
| model | input | time: portable | compile | TensorRT (fp16 unless shown) | kernels | preparation: compile (cold first call) | ONNX + engine build | peak MiB (alloc / reserved): portable | compile | kernels | TensorRT (engine + torch) |
|---|---|---|---|---|---|---|---|---|---|---|---|
drct-l-x4 |
512x512 | 1567 ms | 1210 ms | 1412 ms | 1314 ms | 67.2 s | 236 s | 1675 / 1950 | 2005 / 2410 | 1603 / 1790 | 2031 / 2060 |
drct-l-x4 |
256x256 | 384 ms | β | 289 ms | β | β | 222 s | 766 / 1204 | β | β | 559 / 560 |
drct-x4 |
512x512 | 810 ms | 618 ms | 731 ms | 674 ms | 40.5 s | 187 s | 1608 / 1888 | 1938 / 2348 | 1560 / 1748 | 9684 / 9728 |
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. Every fourth DIV2K validation image, using aligned 256 x 256 LR center crops and their original HR targets. PSNR and SSIM use the Y channel after rounding the output to uint8 and cropping a four-pixel border. Original = the original code named under Details, same checkpoint and protocol.
| variant | dataset | original fp32 | portable | portable fp32 | kernels | TensorRT | 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 | ||
drct-l-x4 |
DIV2K validation, every fourth image, 256 x 256 LR crops, PSNR / SSIM (Y) | 29.91 / 0.8242 | 29.91 / 0.8242 |
Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 706c6828 / ba3a401e, 2026-11-14 to 2026-11-18; portable32: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 706c6828, 2026-11-14; kernels: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 706c6828, 2026-11-14; tensorrt: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks ba3a401e, 2026-11-18.
Parity with the original code
Every variant is checked against reference outputs of the original code at its pinned commit. 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).
Usage
from fastforks import restoration
model = restoration.load("drct-l-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: drct-l-x4, drct-x4.
Kernels backend
restoration.load("drct-l-x4", mode="kernels") runs our CUDA kernels (cudnn_hacc, sr_norm, shift_windows). 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.