TensorFlow Keras scikit-learn NumPy Matplotlib OpenCV

AIP391 Project: Enhance image resolution using a Generative Adversarial Network

🧱 SRGAN architecture

Original paper: Photo-Realistic Single Image Super- Resolution Using a Generative Adversarial Network.

Figure 1: SRGAN architecture

📚 Data preparation

1. Training set

  • We use DIV2K dataset for training the model, you can download here.
  • Then doing random crop the image with size 96x96 for HR image and resize to 24x24 for LR image.
  • After cropping, we scale HR and LR images to range [-1, 1].

2. Test set

  • You can download Set5, Set14, and Urban100 datasets here.

🏗️ Run model

Change the choice variable in train_test_model.py to run the model

1: Train model
2: Validate model
3: Test model 
4: Test on video

1. Training

  • 📁 Set the train data path hr_train_path = Dataset/DIV2K and the LR image size lr_size = (24, 24), then the HR image size equals LR image size times 4 hr_size = (96, 96).
  • You can use other dataset with different LR image size for training by set up:
hr_train_path = 'Dataset/your_images_folder'
lr_size = your_size
  • 📁 Set your weight path to save weights in every epoch with HR and LR image size. Your directory will be weight/(LR_size)_(HR_size)
save_path = 'weight'

📊 2. Validation

You should set the HR and LR valid image paths for comparing the SR image with HR and LR images

hr_valid_path = 'Dataset/your_HR_image'
lr_valid_path = 'Dataset/your_LR_image'
weight_path = 'weight/e_77.h5' # You can change the path

📈 3. Test

Set the LR test image paths for comparing the SR image with HR and LR images

lr_test_path = 'Your_image'
weight_path = 'weight/e_77.h5' # You can change the path

NOTE: Make sure the height and width are under 500 pixels because of running out of memory on GPU

🌞 Result

Figure 2: Set14 and Set5 dataset

Figure 3: Urban dataset