Real-ESRGAN
Real-ESRGAN (Wang et al., Tencent ARC, 2021): upscales real-world photos (x4, x2) and anime images (x4) with an RRDB network trained on synthetic degradations (blur, noise, JPEG); the classic ComfyUI upscaler. BSD-3-Clause code and weights.
experimental Fork of xinntao/Real-ESRGAN@a4abfb2 · backends: portable, kernels
- Paper Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data ICCVW 2021 · first released 22 Jul 2021
Paper 2021 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("realesrgan-x4plus") # kernels on a supported GPU, else portable PyTorch
result = model(image)
result.image
result.backend # what ran: mode, device, dtype, kernels fastforks bench realesrgan-x4plus 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 fp16the authors' mixed-precision option (float16); upstream RealESRGANer pre_pad 0, no tile, on the float image, half (the default) | fp16 | 631 | – | 2,266 MiB/2,496 MiB | 1.7 | 0.73 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 471 | 1.3× | 1,220 MiB/1,454 MiB | 0.2 | 0.62 |
| Kernels | fp16 | 403 | 1.6× | 1,220 MiB/1,434 MiB | 2.4 | 0.43 |
| Portable + torch.compile | 354 | 1.8× | 1,091 MiB/1,394 MiB | 30 (build) | – | |
| TensorRT fp16 | fp16 | 273 | 2.3× | 1,460 MiBenginenot comparable | 55 (build) | – |
Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-13. 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 | 2991 | 4,713 MiB process | – | 512x512 |
| Portable | fp16 | 2066 | 2,466 MiB process | matches | 512x512 | |
| Portable | fp32 | 3022 | 4,546 MiB process | matches | 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
- BSD-3-Clause LICENSELICENSE-BasicSR
- Weights
- BSD-3-Clause source
- Training data
-
- DIV2K (NTIRE 2017 super-resolution, 1000 2K images) research-only, non-commercial
- Flickr2K (2650 2K Flickr images, EDSR) not stated
- OutdoorSceneTraining (OST, SFTGAN) not stated
Our reading of the licences, not legal advice.
Weights
RealESRGAN_x4plus.pth 67.0 MB· hosted on GitHubfastforks downloads and checks these files on first use (fastforks download realesrgan-x4plus).
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 (100 images)
bicubic x4 LR -> HR, PSNR / SSIM (Y)
| Run | dtype | psnr ↑ | ssim ↑ | Δ psnr vs fp32 original | images | ms / image |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | 26.64 | 0.7580 | reference | 100 | – |
| Original fp16 | fp16 | 26.64 | 0.7580 | ±0.00 | 100 | – |
| Portable fp32 | fp32 | 26.64 | 0.7580 | ±0.00 | 100 | – |
| Portable | fp16 | 26.64 | 0.7580 | ±0.00 | 100 | – |
| Kernels | fp16 | 26.64 | 0.7580 | ±0.00 | 100 | – |
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, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-13; portable fp32: RTX 5060 Ti, torch 2.14.1+cu130, fastforks dc38c37c, 2026-11-17; portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 45a5c91f, 2026-11-13.
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| <= 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).
| Check | Tolerance | Measured |
|---|---|---|
| CPU fp32, max |diff| | ≤ 0.00001 | not recorded |
| GPU default dtypes, mean |diff| | ≤ 0.02 | 0.00112 |
| GPU default dtypes, p99 |diff| | ≤ 0.25 | 0.00681 |
Recorded for realesrgan-x4plus on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-13, with these kernels: cudnn_hacc
Details
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.
- 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 1024x2048 (12.7 GiB allocated)
- Outputs
image- CUDA kernels
cudnn_haccconvolutions with fp16 accumulation (cuDNN)
- Apple (MPS)
- fp32, fp16
Full reference, generated from the repository
Real-ESRGAN (Wang et al., Tencent ARC, 2021): upscales real-world photos (x4, x2) and anime images (x4) with an RRDB network trained on synthetic degradations (blur, noise, JPEG); the classic ComfyUI upscaler. BSD-3-Clause code and weights.
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
realesrgan-x4plus | synthetic (512x512) | original portable kernels portable + torch.compile TensorRT fp16 | 631 471 403 354 273 | 2266 / 2496 1220 / 1454 1220 / 1434 1091 / 1394 1546 / 1594 |
realesrgan-x2plus | synthetic (512x512) | original portable kernels portable + torch.compile TensorRT fp16 | 128 97.0 80.2 85.2 59.7 | 592 / 656 333 / 394 333 / 394 323 / 394 476 / 500 |
realesrgan-x4plus-anime-6b | synthetic (512x512) | original portable kernels portable + torch.compile TensorRT fp16 | 205 155 132 114 83.1 | 2243 / 2472 1197 / 1430 1197 / 1410 1068 / 1370 1505 / 1552 |
Details
- Original code: https://github.com/xinntao/Real-ESRGAN at
a4abfb2979a7 - Code licence: BSD-3-Clause (permissive); files:
LICENSE,LICENSE-BasicSR - Weights licence: BSD-3-Clause
- 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
- 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).)
- Kernel libraries:
cudnn_hacc - Variants:
realesrgan-x4plus,realesrgan-x2plus,realesrgan-x4plus-anime-6b - 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):
realesrgan-x4plus1024x2048 (12.7 GiB peak allocated, 14.9 reserved);realesrgan-x2plus1988x2880 (11.9 GiB peak allocated, 14.6 reserved);realesrgan-x4plus-anime-6b1024x2048 (12.7 GiB peak allocated, 14.9 reserved) realesrgan-x4plus512x512, first call: portable + torch.compile 30 s (cold Inductor cache), TensorRT fp16 55 s (ONNX + engine).realesrgan-x2plus512x512, first call: portable + torch.compile 33 s (cold Inductor cache), TensorRT fp16 40 s (ONNX + engine).realesrgan-x4plus-anime-6b512x512, first call: portable + torch.compile 10 s (cold Inductor cache), TensorRT fp16 37 s (ONNX + engine).realesrgan-x4plusoriginal 512x512: the authors' mixed-precision option (float16); upstream RealESRGANer pre_pad 0, no tile, on the float image, half (the default)realesrgan-x2plusoriginal 512x512: the authors' mixed-precision option (float16); upstream RealESRGANer pre_pad 0, no tile, on the float image, half (the default)realesrgan-x4plus-anime-6boriginal 512x512: the authors' mixed-precision option (float16); upstream RealESRGANer pre_pad 0, no tile, on the float image, half (the default)realesrgan-x4plusload / first call: original 1.62 s / 1.641 s, portable 0.2 s / 0.624 s, kernels 2.43 s / 0.435 srealesrgan-x2plusload / first call: original 1.54 s / 0.417 s, portable 0.25 s / 0.259 s, kernels 1.26 s / 0.106 srealesrgan-x4plus-anime-6bload / first call: original 1.3 s / 0.497 s, portable 0.1 s / 0.232 s, kernels 1.3 s / 0.148 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 | original fp16 | portable | portable fp32 | 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 | 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.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.7357 | 25.66 / 0.7356 |
Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 45a5c91f, 2026-11-13; portable32: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks dc38c37c, 2026-11-17; kernels: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 45a5c91f, 2026-11-13.
Parity
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).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
realesrgan-x4plus | 0.00112 / 0.00681 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400 |
realesrgan-x2plus | 0.00359 / 0.01713 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400 |
realesrgan-x4plus-anime-6b | 0.001 / 0.0078 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400 |
Example output
No example rendered for this checkpoint yet.