This repository contains a simple PyTorch implementation of 4x SRGAN combined with EDSR, RCAN, MSRN.
Now CPU/OneGPU/DDP versions have been implemented, you can use it freely with bash
- Linux version 3.10.0-693.el7.x86_64
- Python 3.8.15
- Pytorch 1.12.0
- CUDA Toolkit 11.6
- cuDNN 8302
Pretrained weight for CNN and GAN also offer Google Drive
- prepare the dataset DIV2K in whatever directory you want, and assign to args in train.py/pretrain.sh
- assign the model out path as above too
- input: bash pretrain.sh
- if you want to monitor the training, input: bash tensorboard.sh after you assign the model out paht in bash
- use test.ipynb in MyNet.code, the example has been offered
- The function torchvision.transforms.Resize used for downsample is not bicubic by default, but has been change to Bicubic now
- Training and Validating Dateset is DIV2K
- Data augmentation: random crop -> random rotation in 90 * k degree/flipping, you can change it in MyNet.code.dataset.py
- You can assgin your own lr_scheduler in net.solver.init
- Train on RGB, but validate on Y. However, validate on RGB is also offer in MyNet.code.net.solver.test
- D_train require d_real_loss and d_fake_loss more than 0.4 to aviod D too strong, you can change the value in train.py's D_threshold !!!
- Hyper parameter K in GAN is not supported(default==1) because it is useless in practice, you have to recode net.solver.run/run_resume if you want
- pretrain G with 1e-4 lr for 2000 times, and then 1e-5 lr for 18000 times
- run G and D with 1e-5 lr for 10000 times
- the more iteration you train in pretrain and run, the better G is, if you want know more, read about SRGAN or ESRGAN
- PSNR and SSIM calculations are only on the y channel
- Use float32 for PSNR calculation and uint8 for SSIM calculation
Model | Set5 | Set14 | BSD100 |
---|---|---|---|
Bicubic | 28.42/0.8223 | 25.95/0.7246 | 25.97/0.6862 |
SRCNN | 30.07/0.8627 | 27.18/0.7861 | 26.68/0.7291 |
SRGAN | 29.40/0.8472 | 26.02/0.7397 | 25.16/0.6688 |
ESRGAN | 30.39/0.8641 | 26.20/0.7211 | 25.35/0.6732 |
MSCARN(Ours) | 32.00/0.9019 | 28.36/0.8003 | 27.59/0.7550 |
MSCAR-GAN(Ours) | 31.00/0.8762 | 27.64/0.7636 | 26.78/0.7106 |
Please feel free to contribute to the project, I am pleasured to answer any questions
This code is built on SRGAN (PyTorch). Thank a lot to the authors for sharing codes!