Skip to main content

Overview

The inference_realesrgan.py script is the main tool for performing image super-resolution with Real-ESRGAN. It supports various models, configurations, and advanced features like face enhancement and tile processing.

Quick Start

1

Basic Usage

Run Real-ESRGAN with default settings:
This will process all images in the inputs folder using the RealESRGAN_x4plus model and save results to the results folder.
2

Custom Output

Specify input and output paths:
3

View Results

Enhanced images will be saved with the _out suffix by default (e.g., image_out.png).

Command-Line Arguments

Required Arguments

string
default:"inputs"
Input image file or folder containing images to process
string
default:"RealESRGAN_x4plus"
Model to use for super-resolution. Available models:
  • RealESRGAN_x4plus - General purpose 4x upscaling
  • RealESRNet_x4plus - ESRGAN model without GAN
  • RealESRGAN_x4plus_anime_6B - Optimized for anime images
  • RealESRGAN_x2plus - 2x upscaling model
  • realesr-animevideov3 - Anime video model (XS size)
  • realesr-general-x4v3 - General purpose with denoise control

Output Options

string
default:"results"
Output folder for enhanced images
float
default:"4"
Final upsampling scale of the image. Can be any value (e.g., 3.5).The model performs its native upscaling, then resizes to the target scale using LANCZOS4 interpolation.
string
default:"out"
Suffix added to restored images (e.g., image_out.png). Set to empty string for no suffix.
string
default:"auto"
Output image format: auto, jpg, or png
  • auto: Uses the same extension as input
  • RGBA images are always saved as PNG

Performance Options

integer
default:"0"
Tile size for processing large images. Set to 0 to disable tiling.
Use tiling if you encounter CUDA out of memory errors. Recommended values: 256, 400, or 512.
integer
default:"10"
Padding size for each tile to reduce edge artifacts
integer
default:"0"
Pre-padding size at each border of the image
flag
Use FP32 (full precision) instead of FP16 (half precision) during inferenceIncreases memory usage but may improve quality slightly. Default is FP16.
integer
default:"None"
GPU device to use (e.g., 0, 1, 2 for multi-GPU systems)

Advanced Options

flag
Enable GFPGAN face enhancement integrationAutomatically enhances faces in the image using GFPGAN v1.3
float
default:"0.5"
Denoise strength for the realesr-general-x4v3 model only
  • 0: Weak denoise (keep noise)
  • 1: Strong denoise ability
  • Values between 0 and 1 interpolate between the two extremes
string
default:"None"
Custom model path. Usually not needed as models are auto-downloaded to the weights folder.
string
default:"realesrgan"
Upsampler for alpha channels in RGBA images: realesrgan or bicubic

Common Usage Examples

Example 1: Basic Upscaling

Example 2: Custom Scale with Face Enhancement

Example 3: Batch Processing with Tiling

Example 4: Denoise Control

Model Downloads

Models are automatically downloaded on first use. Manual download URLs:

Error Handling

CUDA Out of Memory ErrorIf you encounter this error:
Try the following solutions:
  1. Use the --tile option with a smaller value (e.g., 256 or 400)
  2. Enable --fp32 if using half precision
  3. Use a smaller --outscale value
  4. Process images one at a time instead of batch processing

Supported Image Formats

The inference script supports:
  • Color spaces: RGB, RGBA (with alpha channel), Grayscale
  • Bit depths: 8-bit, 16-bit images
  • Formats: JPG, PNG, WebP, and other common formats

Next Steps

General Images

Learn model selection for real-world photos

Anime Images

Optimize for anime and illustration content

Face Enhancement

Integrate GFPGAN for better face restoration

Video Processing

Process video files frame by frame