Real-ESRGAN-x4v3 β 4Γ Image Super-Resolution (ONNX)
ONNX export of Real-ESRGAN's general-purpose 4Γ upscaler (realesr-general-x4v3 variant). At only ~5 MB it punches well above its weight on real photographs.
Re-hosted under Heliosoph for distribution stability β xinntao's GitHub releases are the authoritative source.
Credit: Wang Xintao et al. (Tencent ARC Lab).
What this repo contains
realesr-general-x4v3.onnx # ~5 MB
A single ONNX file. The model upscales any input image to 4Γ its width and height with learned restoration of fine detail.
Input/output
| Spec | |
|---|---|
| Input name | input |
| Input shape | dynamic β [1, 3, H, W] |
| Input dtype | float32, range [0, 1] |
| Input color order | RGB |
| Preprocessing | Divide by 255 (no mean/std subtraction). Tile large images to avoid OOM. |
| Output | [1, 3, H*4, W*4] in [0, 1] |
How to use
import onnxruntime as ort
import numpy as np
from PIL import Image
sess = ort.InferenceSession("realesr-general-x4v3.onnx")
img = Image.open("low_res.jpg").convert("RGB")
arr = np.asarray(img, dtype=np.float32) / 255.0
arr = arr.transpose(2, 0, 1)[None, ...] # 1x3xHxW
upscaled = sess.run(None, {"input": arr})[0][0] # 3 x (H*4) x (W*4)
upscaled = (upscaled.transpose(1, 2, 0) * 255).clip(0, 255).astype(np.uint8)
Image.fromarray(upscaled).save("upscaled_4x.png")
For images larger than ~512Γ512, tile the input into overlapping patches and stitch the outputs β otherwise inference memory grows quadratically. Real-ESRGAN's reference implementation includes a tiler.
When to use which Real-ESRGAN variant
This repo ships realesr-general-x4v3 only. Other Real-ESRGAN variants exist upstream:
| Variant | Best for |
|---|---|
realesr-general-x4v3 (this repo) |
General-purpose photos, illustrations, screenshots |
RealESRGAN_x4plus_anime_6B |
Anime / cartoon-style images |
RealESRGAN_x4plus |
Photographs, more aggressive enhancement |
The general-x4v3 is the safest default β it doesn't over-sharpen real photos or hallucinate on noisy input.
License
BSD-3-Clause β same as upstream. LICENSE file included.