Real-ESRGAN: Practical AI Image and Video Restoration for Developers

Jul 11, 2025

Introduction

Dealing with low-resolution, blurry, or compressed images is a constant struggle for developers and digital content creators. Whether it is an old photo, a low-quality screenshot, or a compressed video frame, the lack of detail often renders a project unprofessional. Real-ESRGAN is an open-source image restoration tool that solves this by using advanced AI to upscale and clean images with remarkable clarity, boasting thousands of GitHub stars and a wide adoption in the AI community.

What Is Real-ESRGAN?

Real-ESRGAN is a practical image restoration tool that performs blind super-resolution for general images and anime videos. Developed by the Tencent ARC Lab and the Shenzhen Institutes of Advanced Technology, it is designed to tackle real-world image degradation—such as blur, noise, and JPEG compression artifacts—without needing to know the specific cause of the degradation.

Built on the powerful ESRGAN architecture, it is written primarily in Python and released under the BSD 3-Clause License. It leverages synthetic data to train the model, allowing it to simulate complex real-world damage and learn how to invert that process to restore high-resolution versions of degraded images.

Why Real-ESRGAN Matters

Before Real-ESRGAN, most super-resolution models were trained on simple bicubic downsampling, which meant they worked well in laboratory settings but failed on actual “real-world” images that had noise or compression. Real-ESRGAN fills this gap by using a high-order degradation model that mimics the messy reality of digital images.

Its significance lies in its versatility. It doesn’t just upscale; it restores. By integrating with tools like GFPGAN, it can specifically target and enhance facial details, making it a go-to for photo restoration. Its ability to handle anime and video frames with specialized models makes it an essential tool for the modern digital archivist and developer.

With a robust community and multiple deployment options—from portable executables for non-developers to full Python environments for engineers—it has become one of the most accessible high-quality upscalers available today.

Key Features

  • Blind Super-Resolution: The tool can upscale images without knowing the specific degradation process, making it ideal for images from unknown sources.
  • High-Order Degradation Modeling: It uses a complex pipeline to simulate blur, noise, and JPEG artifacts during training, ensuring the model handles real-world noise effectively.
  • Specialized Model Variants: It offers multiple pre-trained models, including RealESRGAN_x4plus for general photos and RealESRGAN_x4plus_anime_6B for anime and drawings.
  • Face Enhancement Integration: Through integration with GFPGAN, the tool can detect and restore facial details, preventing the “uncanny valley” effect often seen in standard upscaling.
  • Arbitrary Scale Support: Using the --outscale flag, users can resize outputs to any desired resolution using LANCZOS4 interpolation.
  • Broad Input Support: The inference engine supports images with alpha channels (transparency), grayscale images, and 16-bit images.
  • Portable Executables: For users who don’t want to manage Python environments, NCNN-based portable binaries are available for Windows, Linux, and macOS.
  • Training Capabilities: The repository provides full training codes, allowing developers to fine-tune the model on their own paired or unpaired datasets.

How Real-ESRGAN Compares

When choosing an upscaler, the trade-off is usually between speed, fidelity, and the type of content. Real-ESRGAN is often compared to SwinIR and the original ESRGAN.

Feature Real-ESRGAN SwinIR ESRGAN
Primary Focus Real-world restoration High-fidelity restoration Perceptual texture
Inference Speed Fast (3-5x faster than SwinIR) Slow Medium
Artifact Handling Excellent (handles noise/JPEG) Very High Moderate (can over-sharpen)
Ease of Setup Very Easy (Portable Binaries) Moderate Moderate

Real-ESRGAN is the most practical choice for the majority of users. While SwinIR may produce slightly sharper results in some benchmark tests, it is significantly slower and requires more VRAM. Real-ESRGAN’s primary differentiator is its ability to handle “dirty” images—those with heavy compression or noise—without creating the ringing artifacts that often plague the original ESRGAN.

For developers building production pipelines, Real-ESRGAN’s speed and the availability of NCNN binaries make it far more deployable than research-heavy models like SwinIR. If you are working with anime or digital art, the specialized 6B model provides a level of cleanliness that general-purpose models cannot match.

Getting Started: Installation

Real-ESRGAN provides several ways to get started, depending on your technical comfort level.

Python Installation (Developer Mode)

This method is recommended for those who want to use the full API or fine-tune the model. Prerequisites include Python >= 3.7 and PyTorch >= 1.7.

git clone https://github.com/xinntao/Real-ESRGAN.git
cd Real-ESRGAN
pip install basicsr
pip install facexlib
pip install gfpgan
pip install -r requirements.txt
python setup.py develop

Portable Executable (NCNN)

For users on Windows, Linux, or macOS who do not want to install Python, you can download the pre-compiled realesrgan-ncnn-vulkan binaries from the GitHub Releases page. These binaries use the Vulkan API to leverage your GPU without needing CUDA.

Pip Installation

For a quick integration into an existing Python project, you can install the package directly via pip:

pip install realesrgan

How to Use Real-ESRGAN

The most common way to use Real-ESRGAN is through the command-line interface (CLI). Once installed, you can run the inference script to upscale an image.

To upscale a single image by 4x using the general-purpose model, use the following command:

python inference_realesrgan.py -n RealESRGAN_x4plus -i input.jpg -o output.png

This command tells the script to use the RealESRGAN_x4plus model, takes input.jpg as the input and saves the result as output.png. The tool will automatically download the pre-trained weights if they are not already present in the experiments/pretrained_models folder.

If you are working with anime images, simply replace the model name with RealESRGAN_x4plus_anime_6B. For video restoration, the tool can process folders of frames, allowing you to upscale an entire sequence of images before re-assembling them into a video.

Code Examples

For developers integrating Real-ESRGAN into a Python application, the RealESRGANer class provides a straightforward way to enhance images.

The following example demonstrates how to load a model and upscale an image using the Python API:

from realesrgan import RealESRGANer
from basicsr.archs.rrdbnet_arch import RRDBNet
import cv2
import numpy as np

# Initialize the RRDBNet architecture
model = RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=4)

# Create the upsampler
upsampler = RealESRGANer(
    scale=4,
    model_path='https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth',
    model=model,
    tile=0, 
    tile_pad=10,
    pre_pad=0,
    half=True
)

# Load image
img = cv2.imread('input.jpg')

# Enhance image
output, _ = upsampler.enhance(img, outscale=4)

# Save result
cv2.imwrite('output.png', output)

In this snippet, we define the network architecture (RRDBNet) and the upsampler. The half=True parameter enables FP16 half-precision, which significantly reduces VRAM usage and increases speed on compatible GPUs.

Real-World Use Cases

Real-ESRGAN is highly effective in scenarios where the source material is of poor quality and the output needs to be professional.

  • Legacy Photo Restoration: Photographers and archivists can use the tool to upscale old, grainy scanned photos, using the GFPGAN integration to restore facial details that were lost to time.
  • E-commerce Product Enhancement: Online sellers can improve the visual appeal of low-resolution product images provided by suppliers, ensuring they look sharp on high-resolution displays.
  • Anime and Digital Art Upscaling: Artists and fans can upscale low-resolution anime frames or digital drawings, removing JPEG artifacts and creating clean, high-resolution versions for printing or wallpaper.
  • Surveillance Footage Enhancement: While not “CSI-style” magic, it can be used to improve the clarity of low-resolution security camera frames for better human analysis.
  • Medical Imaging: Researchers can use the model to enhance the resolution of certain types of medical scans to assist in visual inspection, provided the model is fine-tuned for the specific domain.

Contributing to Real-ESRGAN

The project is open-source and encourages contributions from the community. While there is no formal CONTRIBUTING.md file, the standard GitHub flow is used. Developers can contribute by reporting bugs via the Issues tab or submitting Pull Requests for new features or optimizations.

Contributions are particularly welcome for new pre-trained models, optimization of the NCNN implementation, or improving the documentation for easier onboarding of non-technical users.

Community and Support

Real-ESRGAN is supported primarily through its GitHub repository. Users can find help through GitHub Discussions and the Issues tab for troubleshooting. The project also has a wide presence in the AI community, as it is integrated into many third-party GUI wrappers and open-source upscaling tools.

For those who want to try the tool without installation, the project provides official Gradio web demos on Hugging Face Spaces, allowing users to upload an image and see the results in real-time.

Conclusion

Real-ESRGAN is a powerful, versatile tool that bridges the gap between laboratory super-resolution and practical, real-world image restoration. By focusing on blind super-resolution and high-order degradation modeling, it provides a level of detail and clarity that standard upscalers cannot match.

Whether you are a developer building an automated restoration pipeline or a hobbyist restoring old family photos, Real-ESRGAN is the right choice when you need a fast, reliable, and open-source solution. It is the ideal tool for images that are not just low-resolution, but are actually degraded.

Star the repo, try the quickstart, and join the community to start enhancing your images today.

What is Real-ESRGAN and what problem does it solve?

Real-ESRGAN is an open-source AI tool for blind super-resolution that restores and upscales low-resolution images. It solves the problem of real-world image degradation, such as blur and JPEG artifacts, which standard upscalers often fail to handle.

How do I install Real-ESRGAN?

You can install it via pip using pip install realesrgan, or by cloning the repository and installing dependencies like BasicSR and GFPGAN for full developer access. Portable NCNN binaries are also available for Windows, Linux, and macOS.

How does Real-ESRGAN compare to SwinIR?

Real-ESRGAN is generally 3-5 times faster than SwinIR and is better suited for general real-world restoration tasks. SwinIR typically produces sharper results on high-fidelity benchmarks but is significantly slower and more VRAM-intensive.

Can I use Real-ESRGAN for anime and digital art?

Yes, Real-ESRGAN provides a specialized model called RealESRGAN_x4plus_anime_6B specifically optimized for anime images and drawings, which removes artifacts and produces cleaner lines.

Does Real-ESRGAN support face restoration?

Real-ESRGAN integrates with GFPGAN to provide optional face enhancement. When enabled, the tool detects faces in the image and uses a generative facial prior to restore missing details in eyes, skin, and features.

What license does Real-ESRGAN use?

Real-ESRGAN is licensed under the BSD 3-Clause License, which allows for redistribution and redistribution with modification, making it suitable for both open-source and commercial applications.

Can I use Real-ESRGAN for video upscaling?

Yes, it can be used for video upscaling by processing individual frames as images. The project provides specialized models for anime videos, such as Real-ESRGAN-anime-video-v3, to maintain temporal consistency.