Using ESRGAN, Links, And Other Information

From Upscale Wiki
Jump to navigation Jump to search
Make sure that you have followed the installation guide carefully (Windows, Arch Linux, MacOS). We support BlueAmulets fork offically, not the current ESRGAN branch from xinntao, if you use that one, you will get errors.

Now that you have installed ESRGAN you can upscale images. There are a few different ways of using ESRGAN. Below I will document the official one. This should work for everyone, but there are a few different applications designed to make the life of the users easier as well as to prevent common pitfalls of using ESRGAN.

Things you need to know before you use ESRGAN

  • ESRGAN supports only RGB images, that means it will remove alpha / transparency channels if present and it won't work with grayscale images.
  • ESRGAN is limited by the amount of VRAM you have.

But there are ways around both. At the time of writing this there are some popular tools used by a lot of us to solve this:

Tools / Ways to use ESRGAN

GUI Tools

ptrsuder's IEU (Image Enhancement Utility)

IEU is the recommended option out there right now, it has been used by many people and is considered mature, but if you encounter bugs or have feature requests, feel free to report them on Discord, or on GitHub repository by creating an issue. The Download is under the IEU.Winforms Releases tab. Please take a bit of your time to read IEU wiki first.

  • Easy to use
  • Process any amount of images with all models you select via check-boxes
  • Control over the output format and naming scheme
  • Works around VRAM limitations
  • Has a lot of advanced features available without the need to write any scripts
  • Can upscale seamless(tiled) textures (landscape textures for example)
  • Can use a different model for the alpha channel
  • Can upscale each channel separately (Red, Green, Blue and Alpha)
    This is useful for non diffuse textures, so normal maps ( typically), specular maps, ...
  • Can interpolate different models right in the GUI
  • Uses panorama image stitching to merge images. That makes it work with images of any resolution without cropping.
  • No cross platform support
  • GUI only, no CLI support
  • Uses panorama image stitching to merge images. That makes it slower and blends slightly worse. Most people will likely not notice the difference.

CLI Tools

Deorder's scripts

  • Cross-Platform
  • Works on headless systems
  • Script for splitting images
  • Script for merging images (to work around VRAM limitations)
  • Barebones, you can use them for a lot of other Neural Networks not just BasicSR / ESRGAN
  • Barebones, so you can script whatever you want around them
  • Outdated, they use ImageMagick 6
  • Problems when using it for images with dimensions not dividable though the patch size (by default 256x256)
  • Don’t use WSL (Windows Subsystem for Linux) if you run ESRGAN on a NVIDIA GPU since WSL doesn’t support GPU acceleration, which makes it unable to run ESRGAN in CUDA mode. Use git bash or something similar instead.
  • bash (We install that via the windows guide. MacOS and Linux tend to come with it out of the box, no need to do anything for those there)
  • imagemagick

Blue Amulet's Esrgan script (Guide way)

  • Nothing additional needs to be installed
  • Fastest option out there
  • Only works for some image formats (yes, jpg and png work)
  • No splitting of images, so you can run out of VRAM easily as images get bigger
  • You are limited by the amount of channels a model supports. Nearly all models out there require images to have exactly 3 channels (RGB).
How to use it
  1. Put the pictures or textures you want to upscale into the LR folder
  2. If you want to use a model with a scale other than 4, you need to edit the file. Just open it with your text editor and change the scale to the one from your model. The scale of each model is documented on our wiki. If you want to run an artifact removal model, like my jpg model for example change scale=4 to scale=1
  3. Open a terminal window and navigate to the esrgan folder
    • For Windows Shift right click in your esrgan folder and select Open PowerShell window here. For some users it might say Command Line instead, if that is the case for you click on that and procced
    • For Linux / MacOS users the process is similar. File managers like Nautilus for example allow you to open a terminal in a folder. If that isn't an option for you can can also navigate using commands. cd allows you to navigate and pwd shows you the current folder. cd .. goes one directory down (for example from /home/combi/code/git/ctp to /home/combi/code/git). Use cd /path/to/whatever to navigate to absolute (full) paths or cd some-folder-in-the-current-folder to navigate to a folder in the current open folder. (pwd = print working directory; cd = change directory) If you want to find out more about a command you can just type man the command-you-want-to-know-about or use the internet
  4. Enter:
    1. For Nvidia GPUs
      python models/${theModelYouWantToUse}
    2. For other GPUs / integrated Graphic
      python --cpu models/${theModelYouWantToUse}
  5. Don't enter ${theModelYouWantToUse} Instead replace that with the name of a model of course As an example, for the default model it would be: python models/RRDB_ESRGAN_x4.pth
  6. That was it, the results will be in the results folder

Tips when using ESRGAN

  1. When upscaling compressed textures use a 1x decompression model for the format first and or downscale them first by at least 50% with ,code>nearest neighbor or box filtering first, before upscaling them in ESRGAN
  2. ESRGAN runs much faster on Nvidia GPUs, you can compile pytorch yourself for AMD GPUs but at the moment that is quite difficult to do
  3. If you run out of VRAM, use Deorder’s scripts or IEU, which will split the texture in smaller parts first
  4. If you have textures in sub-folders, use Deorder’s scripts or IEU with "Preserve folder structure" mode selected
  5. If your textures contain an alpha channel (transparency), use Deorder’s scripts or IEU
  6. Try out different models. In our Model Database you will find a lot of different models, that we trained ourself
  7. If you are still not happy with the results despite having tried out different models, consider training your own and sharing it with us later

Additional Notices


  • When upscaling large images (depending on your GPU for example 1000x1000px images) on Windows, it's possible for the operating system to kill the ESRGAN process if it takes too long. This can be fixed using the Nvidia Nsight Monitor app that is installed alongside the CUDA toolkit. Here are Instructions for doing so