Real-ESRGAN (fastforks)
Real-ESRGAN (Wang et al., ICCVW 2021): practical blind super-resolution. ESRGAN's RRDBNet (23 residual-in-residual dense blocks of 3 x 3 convs, then two nearest x2 upsamplings with convs) trained with a GAN on synthetic real-world degradations (blur, noise, JPEG, two-stage). realesrgan-x4plus is the general x4 model, realesrgan-x2plus the x2 one (the input pixel-unshuffled first), realesrgan-x4plus-anime-6b a 6-block x4 model for anime images.
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/xinntao/Real-ESRGAN at a4abfb2979a7.
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 |
|---|---|---|---|---|
realesrgan-x2plus@1 |
RealESRGAN_x2plus.pth | 49fafd45f8fd |
BSD-3-Clause | yes |
realesrgan-x4plus@1 |
RealESRGAN_x4plus.pth | 4fa0d38905f7 |
BSD-3-Clause | yes |
realesrgan-x4plus-anime-6b@1 |
RealESRGAN_x4plus_anime_6B.pth | f872d837d3c9 |
BSD-3-Clause | yes |
Licence
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: BSD-3-Clause. Licence files: LICENSE, LICENSE-BasicSR.
Training data: DIV2K (NTIRE 2017 super-resolution, 1000 2K images), Flickr2K (2650 2K Flickr images, EDSR), OutdoorSceneTraining (OST, SFTGAN) (docs/Training.md: DF2K (DIV2K + Flickr2K) + OST, HR images only; the anime model: anime images (not named).).
Licence evidence: https://github.com/xinntao/Real-ESRGAN/blob/a4abfb2979a7bbff3f69f58f58ae324608821e27/LICENSE ; https://github.com/xinntao/Real-ESRGAN/releases ; https://github.com/XPixelGroup/BasicSR/blob/8d56e3a045f9fb3e1d8872f92ee4a4f07f886b0a/LICENSE.txt
Input size
any H x W >= 32, padded to a multiple of 32
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): realesrgan-x2plus 1988x2880 (11.9 GiB peak allocated, 14.6 reserved); realesrgan-x4plus 1024x2048 (12.7 GiB peak allocated, 14.9 reserved); realesrgan-x4plus-anime-6b 1024x2048 (12.7 GiB peak allocated, 14.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 |
|---|---|---|---|---|---|---|---|---|
realesrgan-x2plus |
128 | 97.0 | 80.2 | 1.6x | 1.2x | 592 / 656 | 333 / 394 | 333 / 394 |
realesrgan-x4plus |
631 | 471 | 403 | 1.6x | 1.2x | 2266 / 2496 | 1220 / 1454 | 1220 / 1434 |
realesrgan-x4plus-anime-6b |
205 | 155 | 132 | 1.6x | 1.2x | 2243 / 2472 | 1197 / 1430 | 1197 / 1410 |
Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|---|---|---|---|---|---|---|
realesrgan-x2plus |
1.54 | 0.25 | 1.26 | 0.42 | 0.26 | 0.11 |
realesrgan-x4plus |
1.62 | 0.20 | 2.43 | 1.64 | 0.62 | 0.43 |
realesrgan-x4plus-anime-6b |
1.30 | 0.10 | 1.30 | 0.50 | 0.23 | 0.15 |
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) |
|---|---|---|---|---|---|---|---|---|---|---|---|
realesrgan-x2plus |
512x512 | 97.0 ms | 85.2 ms | 59.7 ms | 80.2 ms | 33.2 s | 40.3 s | 333 / 394 | 323 / 394 | 333 / 394 | 476 / 500 |
realesrgan-x4plus |
512x512 | 471 ms | 354 ms | 273 ms | 403 ms | 29.9 s | 55.2 s | 1220 / 1454 | 1091 / 1394 | 1220 / 1434 | 1546 / 1594 |
realesrgan-x4plus-anime-6b |
512x512 | 155 ms | 114 ms | 83.1 ms | 132 ms | 10.0 s | 36.7 s | 1197 / 1430 | 1068 / 1370 | 1197 / 1410 | 1505 / 1552 |
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. Original = the original code named under Details, same checkpoint and protocol.
| variant | dataset | original fp32 | original fp16 | portable | kernels | note |
|---|---|---|---|---|---|---|
realesrgan-x4plus |
DIV2K validation (100 images), bicubic x4 LR -> HR, PSNR / SSIM (Y) | 26.64 / 0.7580 | 26.64 / 0.7580 | 26.64 / 0.7580 | 26.64 / 0.7580 | |
realesrgan-x2plus |
DIV2K validation (100 images), bicubic x2 LR -> HR, PSNR / SSIM (Y) | 30.03 / 0.8592 | 30.03 / 0.8592 | 30.03 / 0.8592 | 30.03 / 0.8591 | |
realesrgan-x4plus-anime-6b |
DIV2K validation (100 images), bicubic x4 LR -> HR, PSNR / SSIM (Y) | 25.66 / 0.7357 | 25.66 / 0.7357 | 25.66 / 0.7357 | 25.66 / 0.7356 |
Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 45a5c91f, 2026-11-13.
Parity with the original code
Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 1e-05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.02 and p99 <= 0.25 (absolute error of the output image).
Usage
from fastforks import restoration
model = restoration.load("realesrgan-x2plus") # 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: realesrgan-x2plus, realesrgan-x4plus, realesrgan-x4plus-anime-6b.
Kernels backend
restoration.load("realesrgan-x2plus", 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.