In this guide, we will go through the process of setting up the Real-ESRGAN package for image super-resolution. Real-ESRGAN allows you to enhance the quality of images using deep learning techniques. Follow these steps to clone the repository, install the necessary dependencies, and perform inference on your images.
Updated for 2026. Just want to upscale a picture without installing anything? Try the free SeeB4 AI Upscaler. It runs 2x super-resolution on your own GPU in the browser, so your image is never uploaded. If you want the full Real-ESRGAN models with 4x output, face enhancement and batch processing, follow the setup below.
Prerequisites
- Ensure you have Python 3.10 installed on your system.
- Make sure you have Git installed to clone the repository.
Step 1: Clone the Repository
Open your terminal or command prompt and run the following commands to clone the Real-ESRGAN repository:
git clone https://github.com/xinntao/Real-ESRGAN.git
cd Real-ESRGAN
Step 2: Install Dependent Packages
Real-ESRGAN relies on several packages for training and inference. Install the required dependencies by running:
# Install specific versions of NumPy
pip install numpy<2
# Install PyTorch and torchvision for CUDA 11.6
pip install torch==1.13.1+cu116 torchvision==0.14.1+cu116 -f https://download.pytorch.org/whl/torch_stable.html
# Install BasicSR
pip install basicsr
# Install facexlib and gfpgan for face enhancement
pip install facexlib
pip install gfpgan
# Install other requirements
pip install -r requirements.txt
# Set up the package
python setup.py develop
Step 3: Check CUDA Version (Optional)
You can check your NVIDIA GPU status and installed CUDA version using the following command:
nvidia-smi
Note: Checking the CUDA version is optional. You only need to do this if you encounter any errors while running the following command to install PyTorch:
pip install torch==1.13.1+cu116 torchvision==0.14.1+cu116 -f https://download.pytorch.org/whl/torch_stable.html
If you face issues during installation, verifying your CUDA version can help troubleshoot the problem.
Step 4: Download Pre-trained Models
Download the pre-trained model for Real-ESRGAN using the following command or by visiting the Real-ESRGAN releases page:
wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth
Ensure that the downloaded model file is placed in the appropriate directory as specified in the inference script.
Step 5: Running Inference
You can use the inference_realesrgan.py script to enhance images. The usage format for the script is as follows:
python inference_realesrgan.py -n RealESRGAN_x4plus -i infile -o outfile [options]...
Common Command Example
To perform image enhancement using the X4 model with face enhancement, use the following command:
python inference_realesrgan.py -n RealESRGAN_x4plus -i inputs --outscale 3.5 --face_enhance
Command Options
-h: Show help information.-i --input: Specify the input image or folder. Default isinputs.-o --output: Specify the output folder. Default isresults.-n --model_name: Choose the model name. Default isRealESRGAN_x4plus.-s, --outscale: Set the final upsampling scale of the image. Default is4.--suffix: Define the suffix for the restored image. Default isout.-t, --tile: Set tile size for testing. Use0for no tiling. Default is0.--face_enhance: Use GFPGAN to enhance faces. Default isFalse.--fp32: Use full precision during inference. Default isfp16.--ext: Specify the image extension. Options areauto,jpg, orpng. Default isauto.
Example Command to Enhance Faces
To enhance faces in images located in the inputs folder, run:
python inference_realesrgan.py -n RealESRGAN_x4plus -i inputs --face_enhanceCheck Your Processed Images After executing the inference command, navigate to the results folder. Here, you will find the final output images enhanced by Real-ESRGAN. This folder will contain the processed images, allowing you to compare them with the original inputs.
2026 update: install Real-ESRGAN with a newer PyTorch
The commands above pin PyTorch 1.13 with CUDA 11.6, which was the safe choice when this guide was written. On newer graphics cards (RTX 40 and 50 series) those old wheels often won’t install or won’t see your GPU. Instead, install the current PyTorch build for your system from pytorch.org, then install the rest:
# 1. Install current PyTorch (copy the exact command for your CUDA version from pytorch.org)
pip install torch torchvision
# 2. Install Real-ESRGAN dependencies
pip install basicsr facexlib gfpgan
pip install -r requirements.txt
python setup.py developFix: ModuleNotFoundError: No module named ‘torchvision.transforms.functional_tensor’
This is the most common error people hit today. Newer torchvision versions removed the functional_tensor module that BasicSR still imports. The fix is a one-line change. Open basicsr/data/degradations.py inside your Python site-packages folder and change this line:
# Before
from torchvision.transforms.functional_tensor import rgb_to_grayscale
# After
from torchvision.transforms.functional import rgb_to_grayscaleSave the file and run the inference command again. Not sure where the file is? Run pip show basicsr and look at the Location line.
Which Real-ESRGAN model should you use?
Real-ESRGAN ships several pre-trained models. Pass the name with -n and download the matching .pth file from the official releases page.
| Model name | Scale | Best for |
|---|---|---|
| RealESRGAN_x4plus | 4x | General photos (the default) |
| RealESRGAN_x2plus | 2x | Photos where 4x is too much. Add -s 2 |
| RealESRNet_x4plus | 4x | Softer, less sharpened results |
| RealESRGAN_x4plus_anime_6B | 4x | Anime and illustrations (smaller, faster model) |
| realesr-animevideov3 | x2 / x3 / x4 | Anime video frames |
| realesr-general-x4v3 | 4x | Lightweight general model with adjustable denoise |
For example, a clean 2x upscale of a whole folder looks like this:
python inference_realesrgan.py -n RealESRGAN_x2plus -i inputs -o results -s 2No Python? Use the portable ncnn-vulkan version
If you’re on Windows with an AMD or Intel GPU, or you just don’t want to set up Python and CUDA, use the portable realesrgan-ncnn-vulkan build from the Real-ESRGAN GitHub releases. It runs on any GPU that supports Vulkan. Unzip it, open a terminal in that folder and run:
realesrgan-ncnn-vulkan.exe -i input.jpg -o output.png -n realesrgan-x4plusOn macOS and Linux, use the binary without the .exe extension.
Real-ESRGAN FAQ
What is the official Real-ESRGAN website?
The official project is the xinntao/Real-ESRGAN repository on GitHub. Models and the portable builds are on its Releases page. Be careful with sites that ask you to pay for “Real-ESRGAN online”.
Can I use Real-ESRGAN online for free?
The original project is a download, not a website. For a quick no-install option, use a browser tool like the SeeB4 AI Upscaler, which runs locally in your browser.
How do I upscale 2x instead of 4x?
Use the RealESRGAN_x2plus model, or keep the 4x model and add -s 2 to set the final output scale.
Do I need an NVIDIA GPU?
The Python version is fastest with an NVIDIA GPU and CUDA. It can also run on CPU, but slowly. For AMD and Intel GPUs, use the ncnn-vulkan build.
My output is out of memory or crashes on big images. What do I do?
Add a tile size, for example -t 400. Real-ESRGAN then processes the image in pieces, which uses far less GPU memory.
Conclusion
You have successfully set up Real-ESRGAN and performed image super-resolution. By following these steps, you can enhance the quality of your images, bringing out fine details and textures. This process can be especially useful in various fields such as photography, digital art, and more.
Additional Resources
With Real-ESRGAN, you can transform low-resolution images into stunning high-resolution masterpieces! Enjoy enhancing your images!
Related tutorials
- How to Make a Game Bot in Python (OpenCV Template Matching)
- Template Matching Made Easy with Scikit-image: Python Image Processing Guide
- How to Extract Text from Images with Python (OpenCV, Pytesseract)
- How to Set Up YOLO11 for Object Detection AI Model
- How to Create an AI Image Background Remover Using MODNet






