How to Use ESRGAN: A Free AI Tool to Upscale Images
Abstract: python inference_realesrgan.py -n RealESRGAN_x4plus -i upload --outscale 3.5 --face_enhance Conclusion In this tutorial we learned how to use ESRGAN v
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.
In this article we’ll cover how you can upscale any image using ESRGAN in Google Colab.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.
Table of Contents- Getting ESRGAN onto Google Colab
- Setting up The Notebook for Faster Processing
- Running the Program Cells
- Run All
- Upload Your Image
- Visualize Before / After Results
- Download Results
- Upscale Multiple Images
- Troubleshooting
- Error 「slow_conv2d_cpu」 not implemented for ‘Half’
- Conclusion
- Resources
To access the ESRGAN Google Colab notebook, click the following link: https://colab.research.google.com/drive/1k2Zod6kSHEvraybHl50Lys0LerhyTMCo?usp=sharing
You can also find additional information on ESRGAN here: https://github.com/xinntao/Real-ESRGANThe following is what you’ll see when you access the ESRGAN Google Colab notebook.
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 AllNow 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.
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.
You can view the input and upscaled image side by side.
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.
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:
You can upload and upscale multiple images at once like shown below.
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