Deep Learning

Machine Learning in Linux: Real-ESRGAN – image and video restoration software

Last Updated on March 6, 2023

In Operation

We evaluated the software mostly with the Python script as the portable executable file can add block inconsistencies.

Here are the available flags.

usage: inference_realesrgan.py [-h] [-i INPUT] [-n MODEL_NAME] [-o OUTPUT] [-dn DENOISE_STRENGTH] [-s OUTSCALE]
                               [--model_path MODEL_PATH] [--suffix SUFFIX] [-t TILE] [--tile_pad TILE_PAD] [--pre_pad PRE_PAD]
                               [--face_enhance] [--fp32] [--alpha_upsampler ALPHA_UPSAMPLER] [--ext EXT] [-g GPU_ID]

options:
  -h, --help            show this help message and exit
  -i INPUT, --input INPUT
                        Input image or folder
  -n MODEL_NAME, --model_name MODEL_NAME
                        Model names: RealESRGAN_x4plus | RealESRNet_x4plus | RealESRGAN_x4plus_anime_6B | RealESRGAN_x2plus |
                        realesr-animevideov3 | realesr-general-x4v3
  -o OUTPUT, --output OUTPUT
                        Output folder
  -dn DENOISE_STRENGTH, --denoise_strength DENOISE_STRENGTH
                        Denoise strength. 0 for weak denoise (keep noise), 1 for strong denoise ability. Only used for the realesr-
                        general-x4v3 model
  -s OUTSCALE, --outscale OUTSCALE
                        The final upsampling scale of the image
  --model_path MODEL_PATH
                        [Option] Model path. Usually, you do not need to specify it
  --suffix SUFFIX       Suffix of the restored image
  -t TILE, --tile TILE  Tile size, 0 for no tile during testing
  --tile_pad TILE_PAD   Tile padding
  --pre_pad PRE_PAD     Pre padding size at each border
  --face_enhance        Use GFPGAN to enhance face
  --fp32                Use fp32 precision during inference. Default: fp16 (half precision).
  --alpha_upsampler ALPHA_UPSAMPLER
                        The upsampler for the alpha channels. Options: realesrgan | bicubic
  --ext EXT             Image extension. Options: auto | jpg | png, auto means using the same extension as inputs
  -g GPU_ID, --gpu-id GPU_ID
                        gpu device to use (default=None) can be 0,1,2 for multi-gpu

As you can see there are 6 pre-trained models included. And we can use GFPGAN to enhance images for face restoration. There is also GPU support, upsampling, and denoise support.

  • RealESRGAN_x4plus – For anime images (real-life video upscaling);
  • RealESRNet_x4plus – a model trained on the DIV2K dataset;
  • RealESRGAN_x4plus_anime_6B – optimized for anime images with much smaller model size
  • RealESRGAN_x2plus
  • realesr-animevideov3 – Anime video model with XS size. It’s probably the best model for anime.
  • realesr-general-x4v3 – e very tiny models for general scenes
Example output
Click image for full size

Summary

Real-ESRGAN offers good performance with admirable texture and background restoration. It’s software that requires experience to make best use, as you’ll want to use your own trained models.

It’s a popular project amassing an impressive 18k GitHub stars.

The pre-trained model for general scenes is quite limited although it still produces good results. For the current models, the software is focused on anime images and video.

Website: github.com/xinntao/Real-ESRGAN
Support:
Developer: Xintao Wang
License: BSD 3-Clause License

Real-ESRGAN is written in Python. Learn Python with our recommended free books and free tutorials.

Artificial intelligence icon For other useful open source apps that use machine learning/deep learning, we’ve compiled this roundup.

Pages in this article:
Page 1 – Introduction and Installation
Page 2 – In Operation and Summary

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments