Overview
Theinference_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
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.Command-Line Arguments
Required Arguments
Input image file or folder containing images to process
Model to use for super-resolution. Available models:
RealESRGAN_x4plus- General purpose 4x upscalingRealESRNet_x4plus- ESRGAN model without GANRealESRGAN_x4plus_anime_6B- Optimized for anime imagesRealESRGAN_x2plus- 2x upscaling modelrealesr-animevideov3- Anime video model (XS size)realesr-general-x4v3- General purpose with denoise control
Output Options
Output folder for enhanced images
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.
Suffix added to restored images (e.g.,
image_out.png). Set to empty string for no suffix.Output image format:
auto, jpg, or pngauto: Uses the same extension as input- RGBA images are always saved as PNG
Performance Options
Tile size for processing large images. Set to 0 to disable tiling.
Padding size for each tile to reduce edge artifacts
Pre-padding size at each border of the image
Use FP32 (full precision) instead of FP16 (half precision) during inferenceIncreases memory usage but may improve quality slightly. Default is FP16.
GPU device to use (e.g., 0, 1, 2 for multi-GPU systems)
Advanced Options
Enable GFPGAN face enhancement integrationAutomatically enhances faces in the image using GFPGAN v1.3
Denoise strength for the
realesr-general-x4v3 model only0: Weak denoise (keep noise)1: Strong denoise ability- Values between 0 and 1 interpolate between the two extremes
Custom model path. Usually not needed as models are auto-downloaded to the
weights folder.Upsampler for alpha channels in RGBA images:
realesrgan or bicubicCommon 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:- RealESRGAN_x4plus
- RealESRNet_x4plus
- RealESRGAN_x2plus
- realesr-general-x4v3
Error Handling
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