File size: 7,042 Bytes
0639817 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | ---
library_name: "fastforks"
pipeline_tag: "image-to-image"
license: "mit"
tags:
- "restoration"
- "super-resolution"
- "image-upscaling"
- "image-restoration"
- "cuda"
- "pytorch"
- "fastforks"
- "fastforks-card"
---
# 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`](https://github.com/kleinicke/fastforks/blob/main/src/fastforks/restoration/models/drct/card.toml).
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|---|---|---|---|---|
| `drct-l-x4@1` | [DRCT-L_X4.pth](https://drive.usercontent.google.com/download?export=download&confirm=t&id=1bVxvA6QFbne2se0CQJ-jyHFy94UOi3h5) | `a99044c02756` | MIT | yes |
| `drct-x4@1` | [DRCT_X4.pth](https://drive.usercontent.google.com/download?export=download&confirm=t&id=1jw2UWAersWZecPq-c_g5RM3mDOoc_cbd) | `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 | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `drct-l-x4` | 14651 | 1607 | 1399 | 10.5x | 1.1x | 5574 / 6926 | 2692 / 3110 | 2564 / 2850 |
| `drct-x4` | 7492 | 830 | 718 | 10.4x | 1.2x | 3359 / 3944 | 2626 / 3048 | 2498 / 2766 |
### 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 | kernels | preparation: compile (cold first call) | ONNX + engine build | peak MiB (alloc / reserved): portable | compile | kernels | TensorRT (engine + torch) |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `drct-l-x4` | 512x512 | 1607 ms | 1210 ms | deferred (build >5 min) | 1399 ms | 67.2 s | – | 2692 / 3110 | 2005 / 2410 | 2564 / 2850 | – |
| `drct-x4` | 512x512 | 830 ms | 618 ms | deferred (build >5 min) | 718 ms | 40.5 s | – | 2626 / 3048 | 1938 / 2348 | 2498 / 2766 | – |
Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
Hardware, protocol and caveats: [benchmarks](https://github.com/kleinicke/fastforks/blob/main/docs/benchmarks.md) (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 | portable | 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 | |
| `drct-l-x4` | DIV2K validation (every 2nd: 50 images), bicubic x4 LR -> HR, PSNR / SSIM (Y) | 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 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
```python
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`). 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.
<!-- staged from fastforks 1cbf1671 (2026-11-15) -->
|