This is the implementation DR2: Diffusion-based Robust Degradation Remover for Blind face Restoration (CVPR 2023).
DR2E is a two-stage blind face restoration framework consists of the degradation remover DR2 and an enhance module which can be any existing blind face restoration model. In the first stage, DR2 utilizes the input image to control the diffusion sampling process and results in smooth, clean middle result in
Our implementation of DR2 module is heavily based on ILVR_adm, and the pretrained model is trained on FFHQ dataset to generate
Variant blind face restoration models can be plugged in as the enhancement module. To use these model, you can
In our implementation, we choose SPARNetHD and train it from scratch. The training code and loss functions remain unchanged to the original paper, but we construct training set using DR2 augmentation (which is introduced in the paper section 3.4) as follows:
$$
y = DR2(x) \circledast k_\sigma
$$
where
You can directly use pretrained blind face restoration methods like VQFR, CodeFormer, GPEN without further finetuning. Because these methods are trained on complex degradation model and can work fine on DR2 output.
First clone the repo and install dependent packages
# build dependency
pip install -r requirements.txt
Download pretrained weights for DR2 and SPARNetHD and put them in "./weights". And run demo
python demo.py
This will enhance the testing images is file "./test_images/input". Noting that for each subdirectory, we choose different controlling parameters
# in demo.py, line 11-16
dir_para = [
# [data_dir, (N, \tau)]
["./test_images/input/01/", (4, 22)],
["./test_images/input/02/", (8, 35)],
["./test_images/input/03/", (16, 35)],
]
The results of two stages are stored in "./test_images/output". If you installed other blind face restoration methods, you can run them on "./test_images/output/dr2" file.
This the results reported in out paper and you can see our method is robust against heavy degradation and our framework enable VQFR to perform normally again.
Because the stochastic nature of diffusion sampling process, you may get different results on a single images (unless you're using very small
If you have any questions, please contact dedsec_z@sjtu.edu.cn.