Basic Usage
Real-ESRGAN provides a simple command-line interface for upscaling images. This guide will walk you through your first image enhancement.Download a Pre-trained Model
Before running inference, you need to download a pre-trained model. Let’s start with the general-purposeRealESRGAN_x4plus model:
The model will be automatically downloaded to the
weights directory if it’s not found when running inference.Upscale Your First Image
Run Inference
Use the This command will:
inference_realesrgan.py script to upscale your image:- Use the
RealESRGAN_x4plusmodel - Process all images in the
inputsfolder - Save results to the
resultsfolder (default output directory)
Command-Line Options
The inference script provides many options for customization:Available Arguments
Input image or folder path
Output folder path
Model name. Options:
RealESRGAN_x4plus- General images (default)RealESRGAN_x4plus_anime_6B- Anime imagesRealESRNet_x4plus- Alternative general modelRealESRGAN_x2plus- 2x upscalingrealesr-animevideov3- Anime videosrealesr-general-x4v3- General scenes (small model)
The final upsampling scale. Allows arbitrary output sizes (e.g., 3.5x)
Suffix for the restored image filename
Tile size for processing large images. Use this to reduce GPU memory usage. Set to 0 for no tiling. Recommended values: 200-400 for limited VRAM
Enable GFPGAN face enhancement
Use FP32 precision instead of FP16. Slower but may improve quality on some images
Output image extension. Options:
auto, jpg, pngGPU device ID to use (e.g., 0, 1, 2 for multi-GPU systems)
Common Examples
Upscale General Images
Upscale Anime Images
For anime illustrations, use the specialized anime model:The anime model (
RealESRGAN_x4plus_anime_6B) is optimized specifically for anime-style artwork and has a smaller model size compared to the general model.Face Enhancement
Enhance faces in your images using integrated GFPGAN:Handle Large Images
If you encounter CUDA out of memory errors, use the tile option:Understanding Tiling
Understanding Tiling
The
--tile option splits large images into smaller tiles for processing, then stitches them back together. This reduces GPU memory usage but may introduce slight inconsistencies at tile boundaries.Recommended tile sizes:- 4GB VRAM:
--tile 200 - 6GB VRAM:
--tile 300 - 8GB+ VRAM:
--tile 400or no tiling
Python API Usage
You can also use Real-ESRGAN programmatically in your Python scripts:API with Face Enhancement
Supported Image Formats
Real-ESRGAN supports various image formats and types:RGB Images
Standard color images (JPG, PNG, WebP)
RGBA Images
Images with alpha channel transparency
Grayscale
Single-channel grayscale images
16-bit Images
High bit-depth images for professional workflows
Performance Tips
Use FP16 (Half Precision)
Use FP16 (Half Precision)
By default, Real-ESRGAN uses FP16 for faster inference. Only use
--fp32 if you experience quality issues.Optimize Tile Size
Optimize Tile Size
For large images, experiment with different tile sizes to find the best balance between speed and memory usage.
Batch Processing
Batch Processing
Place multiple images in the input folder to process them in a single run.
Use GPU
Use GPU
Always use a CUDA-enabled GPU for practical performance. CPU inference is extremely slow.
Troubleshooting
CUDA out of memory
CUDA out of memory
Solution: Use the
--tile option with a smaller tile size:RuntimeError during inference
RuntimeError during inference
Solution: Check that your input image is valid and not corrupted. Also ensure you have enough disk space for the output.
Model not found
Model not found
Solution: The model will be automatically downloaded. Ensure you have internet connectivity and write permissions in the
weights folder.Next Steps
Model Zoo
Explore all available models and their use cases
Training Guide
Learn how to train Real-ESRGAN on your own dataset