Nhat-Thanh / SRCNN-Tensorflow

Implement SRCNN model with Tensorflow, Keras

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[TensorFlow] Super-Resolution CNN

Implementation of SRCNN model in Image Super-Resolution using Deep Convolutional Network paper by Tensorflow, Keras. We used Adam with optimize tuned hyperparameters instead of SGD + Momentum.

Contents

Requirements

  • Python 3.8 or 3.9
  • Tensorflow 2.5.0
  • Numpy 1.19.1
  • Matplotlib 3.4.3
  • Pandas 1.3.4
  • OpenCV 4.5.3

Train

You MUST generate data first:

python GenerateData.py --dataset_path="dataset/" --input_size=33 --chanels=3
  • dataset_path: path to dataset directory.
  • input_size: size of input subimages (does not affect to input size of model).
  • chanels: Number of color chanels.

After generating data, you can run this command to begin the training:

python Train.py --epoch=2500 --batch_size=128

NOTE: if you want to train a new model, you can delete all files in checkpoint directory. Your checkpoint will be saved when above command finishs and can be used for next times, so you can train this model on Colab without taking care of GPU limit.

Test

After Training, you can test the model with this command and see the results in test directory:

python Test.py

We trained 60000 epochs and evaluated model with Set5 and Set14 dataset by PSNR:

Methods Set5 x2 Set5 x3 Set5 x4 Set14 x2 Set14 x3 Set14 x4
Bicubic Interpolation 35.7642 33.4815 31.5064 32.7529 30.4050 28.8816
Resize + Smoothing 35.3901 33.0289 31.2894 31.9534 30.0626 28.7333
SRCNN 36.7126 34.5102 32.0289 33.0441 31.0303 29.2228

Demo

You can put your images to demo/images directory first and run this command to see the results in demo/results directory:

python Demo.py --scale=2

We tested with some images from following links and got some results:

Bicubic x3 (left), resize+smoothing x3 (center), SRCNN x3 (right).

Bicubic x3 (left), resize+smoothing x3 (center), SRCNN x3 (right).

Bicubic x3 (left), resize+smoothing x3 (center), SRCNN x3 (right).

References

About

Implement SRCNN model with Tensorflow, Keras


Languages

Language:Python 100.0%