A TensorFlow 2 implementation of the paper Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network
To run the models an different images, follow the code in: run_model.ipynb.
Add images to the input directory.
Select between SRResNet or SRGAN
model_name = "srresnet"
model_name = "srgan"
Output images will appear in either output/srresnet_bicubic_x4 or output/srgan_bicubic_x4, depending on the selected model.
Follow the code in: train_SRRestNet_and_SRGAN.ipynb.
If training on colab, be sure to use a GPU (runtime > Change runtime type > GPU)
The models train using the div2k dataset using the parameters specified in the paper Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network. I have added a slight adaptation to handle noise from jpeg images when upscaling.
To train without jpeg noise adaptation, change from
train_mappings = [
lambda lr, hr: random_crop(lr, hr, hr_crop_size=hr_crop_size, scale=dataset_parameters.scale),
random_flip,
random_rotate,
random_lr_jpeg_noise]
to
train_mappings = [
lambda lr, hr: random_crop(lr, hr, hr_crop_size=hr_crop_size, scale=dataset_parameters.scale),
random_flip,
random_rotate]
You can select from the different div2k datasets by changing the key:
dataset_key = "bicubic_x4" # by default
Available keys: bicubic_x2, unknown_x2, bicubic_x3, unknown_x3, bicubic_x4, unknown_x4, realistic_mild_x4, realistic_difficult_x4, realistic_wild_x4, bicubic_x8
Data will automatically be downloaded and the super resolution scale will be set based on the key.
Example images 000002x4.png, 000003x4.png, 000004x4.png come from Flickr2K_LR_bicubic X4
Example image 187_0019.jpg comes from Caltech 256
Much of the code in this repository has been refactored from https://github.com/krasserm/super-resolution