Real-ESRGAN is an open-source set of practical image/video restoration algorithms, proposed by Xintao Wang et al., with the paper titled "Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data", from Tencent ARC Lab and the Shenzhen Institute of Advanced Technology, Chinese Academy of Sciences. The project's core goal is to extend ESRGAN into a practically applicable restoration tool and to train it using purely synthetic data, in order to address the blind super-resolution problem of unknown degradation types in the real world.
Main capabilities and models Real-ESRGAN provides multiple pretrained models covering different uses:
- realesrgan-x4plus (default): general-scene image super-resolution.
- realesrnet-x4plus: another version of the general model.
- realesrgan-x4plus-anime: optimized for anime images, with a smaller model size (corresponding to RealESRGAN_x4plus_anime_6B.pth).
- realesr-animevideov3: a model for anime videos, and there is also the AnimeVideo-v3 small anime video model.
- realesr-general-x4v3: a small model for general scenes, and it supports the -dn option to adjust denoising strength to avoid over-smoothing of the results. In addition, the project also provides RealESRGAN_x2plus.pth and supports arbitrary output scale through the --outscale parameter (it will actually further adjust the size with LANCZOS4). The inference code supports tile chunking options, images with alpha channels, grayscale images, and 16-bit images. The project has integrated GFPGAN to support face enhancement.
Usage According to the official description, there are usually three inference methods:
- Online inference: you can use the online Colab Demo, including the Real-ESRGAN general version and the anime video version; there is also a Replicate online Demo, as well as the ARC Demo website (currently only supporting RealESRGAN_x4plus_anime_6B). It has also been integrated into Huggingface Spaces with Gradio, providing a Gradio Web Demo.
- Portable executable file (NCNN): provides Windows / Linux / MacOS executable files, suitable for Intel/AMD/Nvidia GPUs, and comes with the required binaries and models, without needing a CUDA or PyTorch environment. The ncnn implementation is located in Real-ESRGAN-ncnn-vulkan. An example command under Windows is ./realesrgan-ncnn-vulkan.exe -i input.jpg -o output.png -n realesrnet-x4plus. Note that the executable file does not support all the functionality of the Python script inference_realesrgan.py (such as outscale), and because the input image is first split into several tiles for separate processing and then stitched together, it may introduce block-like inconsistency, so the results differ slightly from the PyTorch implementation.
- Python script inference: dependencies must be installed first. The environment requires Python >= 3.7, and Anaconda or Miniconda is recommended. The installation steps are: first clone the repository git clone https://github.com/xinntao/Real-ESRGAN.git and enter the directory cd Real-ESRGAN; then install the dependency packages, including pip install basicsr, pip install facexlib, pip install gfpgan, pip install -r requirements.txt, python setup.py develop.
Training and Fine-tuning The project has released training code, with a detailed guide in Training.md. It supports fine-tuning on your own data or paired data (i.e., fine-tuning ESRGAN).
Applicable Scenarios Real-ESRGAN is suitable for upscaling and restoring low-quality images/videos, such as clearing up old photos, anime illustrations, and anime videos, as well as blind super-resolution restoration of general-scene images. It can be used for personal local processing, quickly experienced through the online Demo, and also serves as a foundation for research or secondary development.
Limitations and Notes Different models are optimized for different content types, and general models and anime-specific models have different performance emphases; the NCNN portable version does not support all features and may produce blocky inconsistencies; when using the online Demo, functionality may be limited (for example, the ARC Demo only supports specific models). In addition, the project encourages users to provide feedback, which is compiled in feedback.md. If you need to learn more or ask questions, you can contact xintao.wang@outlook.com or xintaowang@tencent.com.