Real-ESRGAN icon

Real-ESRGAN

A practical video restoration AI model for real-world scenarios, capable of enhancing and repairing video quality.

Real-ESRGAN: AI-Powered Super-Resolution for Real-World Images and Videos

Introduction

Real-ESRGAN (Real-World Enhanced Super-Resolution Generative Adversarial Network) is an open-source AI-powered tool designed for general image and video restoration, with a particular focus on upscaling content affected by complex real-world degradations. Developed by Xintao Wang and collaborators (often associated with Tencent ARC Lab), Real-ESRGAN builds upon the powerful ESRGAN architecture to deliver practical and high-quality super-resolution. Unlike many earlier methods trained on synthetic degradations (like simple bicubic downsampling), Real-ESRGAN is specifically trained with a more complex degradation modeling process to better handle the blur, noise, compression artifacts, and other issues commonly found in real-world low-resolution images and videos.

The project, available on GitHub, provides pre-trained models and code, making advanced AI super-resolution accessible to developers, researchers, content creators, and anyone looking to enhance the quality and resolution of their visual media.

Key Features

Real-ESRGAN offers a robust set of features for image and video upscaling:

  • AI Image Super-Resolution: Upscales low-resolution images to higher resolutions (commonly 2x, 4x, with some models potentially offering other scales or being chainable for higher factors like 8x).
  • Focus on Real-World Degradations: Specifically engineered to handle a wide range of complex, real-world image and video degradations, including blur, noise, JPEG compression artifacts, and low light conditions, leading to more practical and visually appealing results.
  • ESRGAN-Based Architecture with Enhancements:
    • Extends the powerful ESRGAN (Enhanced Super-Resolution Generative Adversarial Network) architecture.
    • Often incorporates a high-order degradation modeling process for training data synthesis.
    • May use an improved U-Net discriminator with spectral normalization to enhance discriminator capability and stabilize training dynamics, especially when dealing with complex real-world artifacts.
  • Pre-trained Models for Various Needs:
    • General Models (e.g., RealESRGAN_x4plus): For upscaling general photographic images.
    • Anime-Specific Models (e.g., RealESRGAN_x4plus_anime_6B, realesr-animevideov3): Optimized for upscaling anime, cartoons, and manga-style illustrations, preserving sharp lines and vibrant colors. These are often smaller and faster.
    • Video Models: Specific models or techniques for upscaling video frames while aiming for temporal consistency.
  • Video Super-Resolution (Real-ESRGAN-Video):
    • Provides methods for upscaling video content, typically by processing video frames individually and then reassembling them.
    • Often involves tools like ffmpeg for extracting frames from a video and merging upscaled frames back into a video, optionally copying the original audio.
  • Open Source Code & Models: The core algorithms, training methodologies (for some aspects), and pre-trained model weights are publicly available, encouraging community use, research, and development.
  • Command-Line Interface (CLI):
    • Provides pre-compiled executables for Windows, Linux, and macOS, allowing users to perform upscaling via simple command-line instructions without needing to set up a full Python development environment.
    • Options to specify input/output paths, select models, define the upscaling scale factor (-s), and potentially control output format or face enhancement.
  • Python Scripting: For users who prefer programmatic access or integration into custom workflows, Real-ESRGAN can be used via Python scripts, typically requiring PyTorch and other dependencies.
  • NCNN Implementation (RealESRGAN-ncnn-vulkan):
    • An NCNN (Neural Network Computing Library for Mobile Platforms) implementation using Vulkan for GPU acceleration.
    • This version is highly optimized for speed and cross-platform compatibility, running efficiently on Windows, Linux, macOS, and even mobile devices with Vulkan-capable GPUs (Intel, AMD, NVIDIA).
  • Face Enhancement (Optional): Some versions or associated tools might include an option to specifically enhance facial details during the upscaling process, often using auxiliary models like GFPGAN.
  • Tile/Outscale Option: For very large images or limited VRAM, an "outscale" or tiling option might be available to process the image in smaller tiles and then stitch them back together.

Specific Use Cases

Real-ESRGAN is widely used for a variety of image and video enhancement tasks:

  • Enhancing Old and Degraded Photos: Restoring clarity, detail, and color to old family photographs, historical images, or scanned pictures that suffer from blur, noise, or low resolution.
  • Upscaling Low-Resolution Images: Increasing the size and quality of images for print, web display, or further editing when only a small source image is available.
  • Improving Anime and Cartoon Quality: Specifically upscaling anime screenshots, illustrations, manga pages, and animated video content while preserving the characteristic art style, sharp lines, and vibrant colors.
  • Video Restoration and Upscaling: Enhancing the resolution and visual quality of old video footage, low-resolution digital videos, or digitized film.
  • Game Texture Enhancement: Upscaling textures for older video games to give them a more modern look on higher-resolution displays.
  • Improving Product Images: Enhancing the quality of product photos for e-commerce websites and marketing materials.
  • Preparing Images for Print: Enlarging images to meet print resolution requirements without significant quality loss.
  • Digital Art Enhancement: Upscaling AI-generated art or other digital creations to larger sizes while improving detail.

Usage Guide

There are several ways to use Real-ESRGAN, catering to different user needs:

  1. Using Pre-compiled Executables (Easiest for Non-Developers):

    • Download: Go to the "Releases" section of the Real-ESRGAN GitHub repository (https://github.com/xinntao/Real-ESRGAN/releases). Download the appropriate pre-compiled executable for your operating system (Windows, Linux, macOS). The NCNN Vulkan versions (e.g., realesrgan-ncnn-vulkan.exe) are generally recommended for broad GPU compatibility and speed.
    • Extract: Extract the downloaded ZIP file to a folder on your computer.
    • Run via Command Line:
      • Open a terminal or command prompt (PowerShell on Windows).
      • Navigate (cd) to the folder where you extracted Real-ESRGAN.
      • Use the following command structure:
        # For Windows (example)
        ./realesrgan-ncnn-vulkan.exe -i path/to/your/input_image.jpg -o path/to/your/output_image.png -n model_name -s scale_factor
        # For Linux/macOS (example)
        ./realesrgan-ncnn-vulkan -i path/to/your/input_image.jpg -o path/to/your/output_image.png -n model_name -s scale_factor
        
        • -i <input_path>: Path to your low-resolution image or folder of images.
        • -o <output_path>: Path to save the upscaled image or folder for upscaled images.
        • -n <model_name>: Specify the pre-trained model to use (e.g., realesrgan-x4plus, realesrgan-x4plus-anime, realesr-animevideov3). Model .param and .bin files for NCNN are usually included with the executables.
        • -s <scale_factor>: The upscaling factor (e.g., 2 for 2x, 4 for 4x). The chosen model usually implies a default scale (e.g., x4 models).
        • -f <format>: Output image format (e.g., png, jpg, webp).
        • Optional flags:
          • --face_enhance: To enable face enhancement (may require additional models or be built into certain executables).
          • --tile <tile_size>: To process the image in tiles (e.g., --tile 256) to save VRAM.
          • --outscale <float>: If you want to achieve a final scale different from the model's native scale by combining model upscaling with traditional resizing (e.g., using a 4x model but outputting at 2x overall with --outscale 0.5).
  2. Using Python Scripts (For Developers & Customization):

    • Clone the Repository:
      git clone [https://github.com/xinntao/Real-ESRGAN.git](https://github.com/xinntao/Real-ESRGAN.git)
      cd Real-ESRGAN
      
    • Set up Python Environment: Ensure you have Python (usually 3.7+) and pip. Install PyTorch matching your CUDA version (if using NVIDIA GPU) or for CPU. Install other dependencies:
      pip install basicsr facexlib gfpgan
      pip install -r requirements.txt
      python setup.py develop
      
    • Download Pre-trained PyTorch Models (.pth): Download the .pth model files from the links provided in the GitHub README or model zoo (e.g., for RealESRGAN_x4plus.pth, RealESRGAN_x4plus_anime_6B.pth). Place them in a weights or experiments/pretrained_models directory.
    • Run Inference Script: Use the inference_realesrgan.py script.
      python inference_realesrgan.py -n RealESRGAN_x4plus -i path/to/input_image.jpg -o results --outscale 4 --face_enhance
      
      • -n <model_name>: Name of the model (e.g., RealESRGAN_x4plus).
      • -i <input_path>: Input image/folder.
      • -o <output_folder>: Output folder.
      • --outscale <float>: The final upsampling scale.
      • --face_enhance: Enable face enhancement using GFPGAN.
      • --tile <int>: Tile size for out-of-memory (OOM) issues.
      • --half: Use FP16/half-precision for faster inference on compatible GPUs.
  3. Video Upscaling:

    • Typically involves extracting frames from the video using ffmpeg.
    • Upscaling each frame using Real-ESRGAN (either CLI executable or Python script).
    • Merging the upscaled frames back into a video using ffmpeg, often copying the audio from the original video.
    • The Real-ESRGAN GitHub repository provides scripts and examples for this process (e.g., in docs/anime_video_model.md).

Model Variants

Real-ESRGAN provides several pre-trained models tailored for different needs:

  • RealESRGAN_x4plus: A general-purpose model for 4x upscaling of real-world photos.
  • RealESRGAN_x2plus: A general-purpose model for 2x upscaling.
  • RealESRGAN_x4plus_anime_6B: A smaller and faster 4x model specifically optimized for anime and cartoon images.
  • realesr-animevideov3: A model designed for upscaling anime video frames, often used with the NCNN implementation.
  • Other specialized or older versions might also be available.
  • Compact/UltraCompact Models (via OpenModelDB): Some very small "lite" versions for specific restoration tasks or chaining, often 1x or 2x.

Hardware Requirements

  • GPU (Highly Recommended):
    • For the Python (PyTorch) version, an NVIDIA GPU with CUDA support is typically required for good performance. VRAM requirements depend on the image size, model, and scale factor. 4GB VRAM might work for smaller images/scales with tiling, but 6GB-8GB+ is better.
    • For the RealESRGAN-ncnn-Vulkan executables, a Vulkan-compatible GPU is needed. This includes many modern NVIDIA, AMD, and Intel GPUs. This version is generally more efficient and can run on a wider range of GPUs.
  • CPU: While CPU-only inference is possible with the Python scripts (if PyTorch is set to CPU), it will be significantly slower than GPU inference. The NCNN executables are also primarily designed for GPU acceleration but may fall back to CPU.
  • RAM: 8GB of system RAM is a minimum, with 16GB or more recommended, especially if not using a powerful GPU with ample VRAM.

License

The Real-ESRGAN project is typically released under a permissive open-source license. The primary codebase on xinntao/Real-ESRGAN often uses the BSD 3-Clause "New" or "Revised" License. Some components or specific model weights might have slightly different permissive licenses (e.g., models from other authors hosted on OpenModelDB). The NCNN version also generally follows permissive licensing.

This means the software can generally be used for commercial purposes, with conditions like retaining copyright notices. However, users should always check the specific LICENSE file in the version they download.

Frequently Asked Questions (FAQ)

Q1: What is Real-ESRGAN? A1: Real-ESRGAN is an AI-powered super-resolution tool designed to upscale and enhance images and videos, particularly those affected by real-world degradations like blur, noise, and compression artifacts. It's an improvement over the original ESRGAN.

Q2: How is Real-ESRGAN different from ESRGAN or other upscalers? A2: Real-ESRGAN is specifically trained using a more complex degradation process to better simulate real-world image issues, making it more effective for general photo and video restoration compared to ESRGAN, which was often trained on simpler bicubic downscaling. It aims for more practical and visually pleasing results on a wider variety of inputs.

Q3: Is Real-ESRGAN free to use? A3: Yes, Real-ESRGAN is an open-source project. The code, pre-trained models, and pre-compiled executables provided by the authors are free to download and use under the terms of their license (typically BSD 3-Clause).

Q4: Do I need a powerful GPU to use Real-ESRGAN? A4: While CPU-only mode is possible for the Python version (but very slow), a GPU is highly recommended for practical use. The RealESRGAN-ncnn-vulkan executables leverage Vulkan for GPU acceleration and can run on a wide range of modern GPUs (NVIDIA, AMD, Intel). VRAM requirements depend on the image size and scale factor.

Q5: What types of images work best with Real-ESRGAN? A5: Real-ESRGAN has general models (RealESRGAN_x4plus) that work well on a variety of real-world photos. It also offers specialized models like RealESRGAN_x4plus_anime_6B which are highly effective for upscaling anime, cartoons, and similar illustrative styles.

Q6: Can Real-ESRGAN upscale videos? A6: Yes, Real-ESRGAN can be used to upscale videos. This typically involves extracting all frames from the video, upscaling each frame individually using a suitable Real-ESRGAN model (e.g., realesr-animevideov3 for anime videos), and then merging the upscaled frames back into a video, usually with the original audio track. Scripts and guides for this process are available.

Q7: What are the realesrgan-ncnn-vulkan executables? A7: These are pre-compiled versions of Real-ESRGAN that use the NCNN deep learning inference framework and Vulkan for cross-platform GPU acceleration. They are often the easiest way for non-programmers to use Real-ESRGAN quickly on Windows, Linux, or macOS with a compatible GPU, without needing to set up a Python environment.

Q8: Can I use Real-ESRGAN for commercial projects? A8: The BSD 3-Clause license, under which Real-ESRGAN is commonly distributed, is a permissive license that allows for commercial use, modification, and distribution, provided the license conditions (like retaining copyright notices) are met.

Here are examples of helpful resources for learning and using Real-ESRGAN:

Community & Support

  • GitHub Issues: The "Issues" tab on the Real-ESRGAN GitHub repository is the primary place for reporting bugs, asking technical questions, and discussing development.
  • AI Upscaling Communities: Broader communities focused on AI image and video upscaling (e.g., on Reddit like r/StableDiffusion, r/deeplearning, or specific upscaling forums/Discords) will often have discussions and user experiences related to Real-ESRGAN.

Ethical Considerations & Limitations

  • User Responsibility: Users are responsible for the content they upscale and ensuring it complies with copyright and ethical guidelines.
  • Artifacts: While Real-ESRGAN is designed for real-world degradations, like any super-resolution algorithm, it can sometimes introduce artifacts or unnatural textures, especially with very low-quality inputs or if pushed beyond its intended scale.
  • "Hallucinating" Details: Super-resolution models reconstruct details based on their training. Sometimes these details might not perfectly match the original (if it were high-resolution) but are plausible generations.
  • Computational Cost: Upscaling, especially for video or very high-resolution images, can be computationally intensive and time-consuming without a decent GPU.
  • Generalization: While robust, performance can vary depending on the type of image/video and the nature of its degradation. Using specialized models (e.g., anime models for anime content) often yields better results.

Last updated: May 26, 2025

Found an error in our documentation?Email us for assistance