ESRGAN (Enhanced Super-Resolution Generative Adversarial Network) is a free AI tool that provides a perception-driven approach for single image super-resolution that is able to produce photorealistic images.
It upscales images, which means it increases the resolution of an image. It is a fantastic tool that’ll bring life to your old photos.
Those nostalgic memories that were captured on old cameras, whose images, as compared to current standard quality, are blurry and seem to lack information, can now be upscaled and relived with the help of ESRGAN.
ESRGAN is also often used as a component in AI image generators to save time and resources when generating images. For example, generating a 512x512px image and upscaling it to 1024×1024 can be a lot less computationally intensive than generating a 1024x1024px image.
Google Colab is a free service hosted by Google that provides an environment within which you can create and share documents that contain live code, equations, visualizations and text. It’s like Google Docs, but for Python code. You don’t need to download anything and you can use Google Colab from any computer or phone with an internet connection.
This is a beginner-friendly guide, and you won’t need any programming knowledge at all. If you’d like a quick and beginner-friendly intro on using Google Colab and it’s benefits check out our related tutorial.
Table of Contents
Sidenote: AI art tools are developing so fast it’s hard to keep up.
We set up a newsletter called tl;dr AI News.
In this newsletter we distill the information that’s most valuable to you into a quick read to save you time. We cover the latest news and tutorials in the AI art world on a daily basis, so that you can stay up-to-date with the latest developments.
Check tl;dr AI NewsGetting ESRGAN onto Google Colab
To access the ESRGAN Google Colab notebook, click the following link: https://colab.research.google.com/drive/1k2Zod6kSHEvraybHl50Lys0LerhyTMCo?usp=sharing
[powerkit_alert type=”info” dismissible=”false” multiline=”false”]
You can also find additional information on ESRGAN here: https://github.com/xinntao/Real-ESRGAN
[/powerkit_alert]
The following is what you’ll see when you access the ESRGAN Google Colab notebook.
Setting up The Notebook for Faster Processing
We need to make sure that Colab is using GPU.
Usually Google allocates GPU by for your Colab notebook by default, but still, it’s better to check in advance.
To do this, in the Colab menu, click Runtime > Change runtime type
.
A small popup will appear. Under Hardware accelerator
there’s a dropdown. Male sure GPU is selected and click Save
.
Now we are all ready to upscale our images.
Running the Program Cells
Run All
Now we’ll just have to run all of the code cells. To do this easily go into the menu again Runtime > Run all
. This will make every code cell to run, one after the other.
Google will give you a warning. Click Run anyway
. This notebook is safe. It’s good to be careful when running other Google Colab notebooks, however.
The numbered cells will start running.
Upload Your Image
After the second cell runs for 10-20 seconds, it will give you an option to choose/upload an image.
After you choose the image, all of the below cells will start to run.
Visualize Before / After Results
You can view the input and upscaled image side by side.
Download Results
Now the upscaled image zip
file will be downloaded when the 5th cell runs.
You can open the zip
file and find the jpg
upscaled image.
Downloading via The Google Colab File Browser
Still if you want to view the result and the 5th cell could not execute properly, you can access the upscaled image in Google Colab’s file browser, on the left:
Upscale Multiple Images
You can upload and upscale multiple images at once like shown below.
Troubleshooting
Error “slow_conv2d_cpu” not implemented for ‘Half’
If you’re getting the following error Error "slow_conv2d_cpu" not implemented for 'Half'
, try the following:
- In the
3. Inference
cell you’ll see the line:!python inference_realesrgan.py -n RealESRGAN_x4plus -i upload --outscale 3.5 --face_enhance
- Just add
--fp32
after the upload statement and then run all the cells again (step-1). This will turn it into:!python inference_realesrgan.py -n RealESRGAN_x4plus -i upload --outscale 3.5 --face_enhance
Conclusion
In this tutorial we learned how to use ESRGAN via Google Colab to easily upscale one or more images for free. If you encounter any issues feel free to leave a comment and we’ll get back to you as soon as possible.
Resources
- https://github.com/xinntao/Real-ESRGAN – The Github repository for ESRGAN