Deblurring-by-Realistic-Blurring
Deblurring-by-Realistic-Blurring copied to clipboard
A PyTorch implementation of the "Deblurring by Realistic Blurring", unofficially
Deblurring by Realistic Blurring
two GANs are used, one for blurring the image(BGAN) and one for deblurring the image (DBGAN), with the former serving as a priori for the latter.
processes:
- sharp --> bgan --> real blur
- real blur --> dbgan --> sharp(fake)
losses:relativistic blur loss
the general loss is mainly to ensure that the GANs has the following effects:
- the probability that the discriminator considers img to be the real category tends to be infinitely close to 1
- the probability that the discriminator considers img to be the fake category tends to be infinitely close to 1
relativistic blur loss is to make p(fake_d) == p(real_d)
Data
please see this part in official implementation
but they do not have training script, that's why I write these code.
Model
BGAN:sharp --> blur
GBGAN:blur --> sharp, like DeblurGAN
BGAN
- gaussian noise concat
- Conv2d --> 9ResBlock --> 2Conv2d (maybe we could use less resblock)
- ResBlock: 5Conv2d --> 4LeakyReLU (maybe we could use less Conv2d)
- long res
GAN_D: vgg19, pretrained (without BN)
Because the data set is not aligned, the cyclegan idea is used
DBGAN
Basically the same as BGAN
- without BN (why not IN)
- 16个ResBlock (also, i don't think need so many resblocks)
Result
原图 | 模糊后 | 去模糊后 |
---|---|---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Usage
use tfrecord in pytorch
you can also see .h5 made in Chinese README
in ./dataset_make
, run
python dataset_make.py --mode train_blur
python dataset_make.py --mode train_deblur
then sh train_small.sh
TODOs
- [x] format code
- [x] amp
in branch: amp
- [ ] visdom
Citation
@inproceedings{zhang2020deblurring,
title={Deblurring by realistic blurring},
author={Zhang, Kaihao and Luo, Wenhan and Zhong, Yiran and Ma, Lin and Stenger, Bjorn and Liu, Wei and Li, Hongdong},
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
pages={2737--2746},
year={2020}
}