Models · Image restoration

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

Checkpoint

Paper 2021 Added in 0.2.0 Evaluated with 0.2.0

Kernels, RTX 5060 Ti 16 GB 403 ms 512x512, fp16
vs the faster original 1.6× original fp16: 631 ms
Peak memory 1,220 MiB original: 2,266 MiB
Accuracy vs original fp32 ±0.00 kernels psnr, DIV2K validation (100 images) (26.64 original)

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)

BackenddtypeTime per call (ms)vs original fp16Peak memory
allocated / reserved
Load (s)First call (s)
Original fp32fp32not 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 MiB1.70.73
Portable fp32fp32not measured ––––
Portablefp16 4711.3×1,220 MiB/1,454 MiB0.20.62
Kernelsfp16 4031.6×1,220 MiB/1,434 MiB2.40.43
Portable + torch.compile 3541.8×1,091 MiB/1,394 MiB30 (build)–
TensorRT fp16fp16 2732.3×1,460 MiBenginenot comparable55 (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

DeviceBackenddtypems / callPeak memoryOutput vs referenceInput
Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-14Originalfp322991 4,713 MiB process–512x512
Portablefp162066 2,466 MiB processmatches512x512
Portablefp323022 4,546 MiB processmatches512x512
Kernelsfp16not 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

Our reading of the licences, not legal advice.

Weights

RealESRGAN_x4plus.pth 67.0 MB· hosted on GitHub

fastforks 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)

Rundtypepsnr ↑ssim ↑Δ psnr vs fp32 originalimagesms / image
Original fp32fp3226.640.7580 reference 100 –
Original fp16fp1626.640.7580 ±0.00 100 –
Portable fp32fp3226.640.7580 ±0.00 100 –
Portablefp1626.640.7580 ±0.00 100 –
Kernelsfp1626.640.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).

CheckToleranceMeasured
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.scale x 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.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
realesrgan-x4plussynthetic (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-x2plussynthetic (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-6bsynthetic (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-x4plus 1024x2048 (12.7 GiB peak allocated, 14.9 reserved); realesrgan-x2plus 1988x2880 (11.9 GiB peak allocated, 14.6 reserved); realesrgan-x4plus-anime-6b 1024x2048 (12.7 GiB peak allocated, 14.9 reserved)
  • realesrgan-x4plus 512x512, first call: portable + torch.compile 30 s (cold Inductor cache), TensorRT fp16 55 s (ONNX + engine).
  • realesrgan-x2plus 512x512, first call: portable + torch.compile 33 s (cold Inductor cache), TensorRT fp16 40 s (ONNX + engine).
  • realesrgan-x4plus-anime-6b 512x512, first call: portable + torch.compile 10 s (cold Inductor cache), TensorRT fp16 37 s (ONNX + engine).
  • realesrgan-x4plus original 512x512: the authors' mixed-precision option (float16); upstream RealESRGANer pre_pad 0, no tile, on the float image, half (the default)
  • realesrgan-x2plus original 512x512: the authors' mixed-precision option (float16); upstream RealESRGANer pre_pad 0, no tile, on the float image, half (the default)
  • realesrgan-x4plus-anime-6b original 512x512: the authors' mixed-precision option (float16); upstream RealESRGANer pre_pad 0, no tile, on the float image, half (the default)
  • realesrgan-x4plus load / first call: original 1.62 s / 1.641 s, portable 0.2 s / 0.624 s, kernels 2.43 s / 0.435 s
  • realesrgan-x2plus load / first call: original 1.54 s / 0.417 s, portable 0.25 s / 0.259 s, kernels 1.26 s / 0.106 s
  • realesrgan-x4plus-anime-6b load / 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.

variantdatasetoriginal fp32original fp16portableportable fp32kernelsnote
realesrgan-x4plusDIV2K validation (100 images), bicubic x4 LR -> HR, PSNR / SSIM (Y)26.64 / 0.758026.64 / 0.758026.64 / 0.758026.64 / 0.758026.64 / 0.7580
realesrgan-x2plusDIV2K validation (100 images), bicubic x2 LR -> HR, PSNR / SSIM (Y)30.03 / 0.859230.03 / 0.859230.03 / 0.859230.03 / 0.859230.03 / 0.8591
realesrgan-x4plus-anime-6bDIV2K validation (100 images), bicubic x4 LR -> HR, PSNR / SSIM (Y)25.66 / 0.735725.66 / 0.735725.66 / 0.735725.66 / 0.735725.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).

variantkernels error vs original, mean / p99GPU, torchkernels used
realesrgan-x4plus0.00112 / 0.00681RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400
realesrgan-x2plus0.00359 / 0.01713RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400
realesrgan-x4plus-anime-6b0.001 / 0.0078RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400

Example output

No example rendered for this checkpoint yet.