This repository implements a Super-Resolution Generative Adversarial Network (SRGAN) designed to upscale low-resolution (LR) images (96x96) to high-resolution (HR) outputs (384x384), achieving a 16x increase in total pixel area. The architecture and training methodology are based on the paper: Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network.
Traditional super-resolution methods like bicubic interpolation often result in blurry images. This SRGAN implementation utilizes Perceptual Loss (VGG-19 based) and an Adversarial Loss to recover photo-realistic textures and high-frequency details that pixel-wise loss functions (like MSE) typically fail to capture.
- 16x Enlargement: Upscales images from 96x96 to 384x384.
- Residual Architecture: Generator features 8 residual blocks for deep feature extraction.
- Pixel Shuffle Upsampling: Efficient spatial resolution enhancement.
- Perceptual Loss: Leverages VGG-19
block5_conv4activations to ensure structural fidelity. - LSGAN Loss: Uses Mean Squared Error for adversarial stability.
- Input: (96, 96, 3) image.
- Blocks: 9x9 initial convolution, 8 residual blocks with Batch Normalization and PReLU.
- Upsampling: Two upsampling stages using a pixel-shuffle style approach to reach 384x384.
- Output: Tanh-activated convolution for normalized pixel values.
- A deep CNN utilizing strided convolutions (strides=2) to progressively downsample the 384x384 HR image.
- Uses LeakyReLU activation and Global Average Pooling to output a single scalar realism score.
The Generator is optimized using a weighted combination of two losses:
- Content Loss (Weight: 1.0): MSE between VGG-19 feature maps of HR and SR images.
- Adversarial Loss (Weight: 1e-3): Pushes the generator to produce images that reside on the manifold of real natural images.
The model was evaluated using Peak Signal-to-Noise Ratio (PSNR) and Structural Similarity Index (SSIM).
| Metric | Value |
|---|---|
| Mean PSNR | 27.70 dB |
| Mean SSIM | 0.8916 |
| Best PSNR | 31.61 dB |
Results based on evaluation of a test subset within the provided notebook.
- Python 3.x
- TensorFlow 2.x
- NumPy, Pandas, Matplotlib
- Pillow (PIL)
- tqdm
The notebook supports both fresh training and resuming from checkpoints stored in Google Drive:
# To start training
train_gan_full(lr_images, hr_images, epochs=100, batch_size=4)
# To resume from a checkpoint
resume_training(lr_images, hr_images, epochs=100, batch_size=4)To upscale a single image:
from tensorflow.keras.models import load_model
gen = load_model('srgan_generator.keras', compile=False)
sr_output = gen.predict(lr_input_tensor)SRGAN__Image_Enlargement.ipynb: Complete implementation including data preprocessing, model building, training loops, and evaluation.checkpoints/: Directory for saving.kerasmodel weights during training.
Note: This implementation was developed and tested on a T4 GPU environment.