image thumbnail

SRGAN-VGG54 Single Image Super Resolution Matlab port.

version 1.0.0 (5.04 MB) by manoreken
SRGAN-VGG54 Single Image Super Resolution Matlab port. Inputs pristine image and performs 2x upsampling using a deep learning.


Updated 03 Jul 2021

View License

SRGAN-VGG54 Single Image Super Resolution Matlab port.
■ Prerequisites ■
  • Matlab 2021a
  • Image Processing toolbox
  • Statistics and Machine Learning toolbox
  • Deep Learning Toolbox
  • Parallel Computing Toolbox
■ How to Test ■
Run SRGAN_Test.m which calls SRGAN_2xSuperResolution.m
Trained net is loaded on the line 5 of SRGAN_2xSuperResolution.m
■ How to Perform SRGAN Super-Resolution to your image file ■
Input image MyPicture.jpg should be pristine (not blurred) image. SRGAN neural net will upscale the image by 2x.
img = imread("MyPicture.jpg"); % 1024x768 input image
imgSR = SRGAN_2xSuperResolution(img);
imwrite(imgSR, "MyPicture_2x_SRGAN_MSE.png"); % 2048x1536 image is outputted
■ How to Train the network using Flickr2K dataset ■
Download Flickr2K dataset and place it on
Flickr2K/Flickr2K_HR for train data of 2650 images.
Run CreateTrainingSetAll_Flickr2K.m to create Flickr2K_RGB_MatlabF folder that contains converted mat files.
Run SRGAN_Train.m to train and create trained file.
Use your trained file on SRGAN_2xSuperResolution.m
Other dataset such as DIV2K should be fine to train.
■ Difference from original SRGAN ■
  • Training input image size is 112x112 (not 48x48)
  • Only 2x super resolution is implemented.
  • VGG19_54 loss, MSE loss, and GAN loss weighting ratio for Generator training is different.
■ Training image displayed becomes complete white. How to fix it ■
  • Reduce the learning rate.
  • Set breakpoint at SRGAN_Train.m:353 and run it, read values of lossGenMSE, lossGenFromDisc, lossGenContent value balance on Workspace. If one value is significantly larger than other two, decrease it.
  • First 1000 iteration or so after the training start to use GAN tends to unstable (but it should not become complete white) but the result should be stabilized eventually.
■ How to get more crisp image ■
Decrease lossGenMSE contribution of SRGAN_Train.m:353 to get more crisp image. But artifact increases.
■ Changelog ■
Version 20210703 1.0.0
  • Initial release.
■ References ■
Train Generative Adversarial Network (GAN) using Matlab
Monitor GAN Training Progress and Identify Common Failure Modes
VGG-19 convolutional neural network (Matlab)
Ledig, C., Theis, L., Husz ́ar, F., Caballero, J., Cunningham, A., Acosta, A., Aitken,A., Tejani, A., Totz, J., Wang, Z., et al.: Photo-realistic single image super-resolution using a generative adversarial network. In: CVPR (2017)
Single Image Super-Resolution Using Deep Learning
(VDSR is implemented using Matlab Deep Learning Toolbox)
Matlab PReLU layer

Cite As

manoreken (2022). SRGAN-VGG54 Single Image Super Resolution Matlab port. (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2021a
Compatible with R2021a
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!