Increasing the resolution of an image using an SRGAN
I have my first experience of image processing, and of using a pre-trained network.
Introduction
I wanted to print out an image for a friend, and I wanted to first crop the image to only include a relatively small part of the photo (namely, the individuals in the photo. The original photo was 90% scenary). However, after the cropping, the image became too small and would have been pixelated when printed. I thought that a neural network ought to be able to solve this problem, because it could be trained on a manually created dataset (just take a bunch of images and use these as the outputs, then reduce the quality of these images to create the inputs). I decided to Google around to see what already had been done, and I found out about SRGANs. At my current level of knowledge, I cannot understand the details of the architecture, so for now, my aim was just to see if I could use a pre-trained network to achieve my goal. After a bit more searching, I found this Github repo.
Steps taken
- Create a new directory and environment.
- Download the github repo.
- Install the requirements.
- Create a directory
inputs
for input images, and folderoutputs
for where the output images will go. - Add images to the inputs directory.
- Run the command `python infer.py –image_dir ‘inputs’ –output_dir ‘outputs’
Results
Below are samples of the images, comparing before and after applying the neural network.
Example 1
Example 2
Example 3
This is amazing! This feels like magic to me.
Limits
I tried applying this to blurry images, expecting it to make the images less blurry. This did not happen:
This reveals how limited my understanding is! After thinking and googling a bit, I think the issue is that resolution and blurriness/sharpness are two separate issues. Previously, I just lumped them together as ‘reasons an image can look bad’. After a bit more searching, it seems I might learn about anti-blurring / sharpening in the FastAI course that I am doing, so that is something to look forward to.
Finally, I hope I will soon be at at stage where I can understand these intricate architectures, and be able to train my own cutting edge neural networks.