CLR-Face: Conditional Latent Refinement for Blind Face Restoration Using Score-Based Diffusion Models
Proceedings of the Thirty-Third International Joint Conference on Artificial Intelligence. Main Track. Pages 1290-1298.
https://doi.org/10.24963/ijcai.2024/143
Keywords
- Machine Learning: ML: Generative models
- Computer Vision: CV: Image and video synthesis and generation
- Computer Vision: CV: Biometrics, face, gesture and pose recognition
Abstract
Recent generative methods have shown promising blind face restoration performance. They usually project the degraded images to the latent space and then decode high-quality faces either by single-stage latent optimization or directly from the encoding. Generating fine-grained facial details faithful to inputs remains challenging. Most existing methods produce either overly smooth outputs or alter the identity. This could be attributed to the typical trade-off between quality and resolution in the latent space. If the latent is highly compressed, the decoded output is more robust to degradations but shows worse fidelity. On the other hand, a more flexible latent space can capture intricate details better, but is extremely difficult to optimize for highly degraded faces. We introduce a diffusion-based-prior inside a VQGAN architecture that focuses on learning the distribution over uncorrupted latent embeddings. We iteratively recover the clean embedding conditioning on the degraded counterpart. Furthermore, to ensure the reverse diffusion trajectory does not deviate from the underlying identity, we train a separate Identity Recovery Network and use its output to constrain the reverse diffusion. Specifically, using a learnable latent mask, we add gradients from a face-recognition network to a subset of latent features that correlates with the finer identity-related details in the pixel space, leaving the other features untouched. Disentanglement between perception and fidelity in the latent space allows us to achieve the best of both worlds. We perform extensive evaluations on multiple real and synthetic datasets to validate our approach.
- [Baker and Kanade, 2000] Simon Baker and Takeo Kanade. Hallucinating faces. In Proceedings Fourth IEEE interna- tional conference on automatic face and gesture recogni- tion (Cat. No. PR00580), pages 83-88. IEEE, 2000.
- [Bourlai et al., 2011] Thirimachos Bourlai, Arun Ross, and Anil K. Jain. Restoring degraded face images: A case study in matching faxed, printed, and scanned photos. IEEE Transactions on Information Forensics and Security, 6(2):371-384, 2011.
- [Chen et al., 2018] Yu Chen, Ying Tai, Xiaoming Liu, Chun- hua Shen, and Jian Yang. Fsrnet: End-to-end learning face super-resolution with facial priors. In Proceedings of the IEEE conference on computer vision and pattern recogni- tion, pages 2492-2501, 2018.
- [Chen et al., 2021] Chaofeng Chen, Xiaoming Li, Lingbo Yang, Xianhui Lin, Lei Zhang, and Kwan-Yee K Wong. Progressive semantic-aware style transformation for blind face restoration. In Proceedings of the IEEE/CVF confer- ence on computer vision and pattern recognition, pages 11896-11905, 2021.
- [Choi et al., 2021] Jooyoung Choi, Sungwon Kim, Yonghyun Jeong, Youngjune Gwon, and Sungroh Yoon. Ilvr: Conditioning method for denoising diffusion probabilistic models. arXiv preprint arXiv:2108.02938, 2021.
- [Chung et al., 2022] Hyungjin Chung, Byeongsu Sim, and Jong Chul Ye. Come-closer-diffuse-faster: Accelerating conditional diffusion models for inverse problems through stochastic contraction. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 12413-12422, 2022.
- [Cornett et al., 2023] David Cornett, Joel Brogan, Nell Bar- ber, Deniz Aykac, Seth Baird, Nicholas Burchfield, Carl Dukes, Andrew Duncan, Regina Ferrell, Jim Goddard, et al. Expanding accurate person recognition to new al- titudes and ranges: The briar dataset. In Proceedings of the IEEE/CVF Winter Conference on Applications of Com- puter Vision, pages 593-602, 2023.
- [Deng et al., 2019] Jiankang Deng, Jia Guo, Niannan Xue, and Stefanos Zafeiriou. Arcface: Additive angular mar- gin loss for deep face recognition. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 4690-4699, 2019.
- [Dhariwal and Nichol, 2021] Prafulla Dhariwal and Alexan- der Nichol. Diffusion models beat gans on image synthe- sis. Advances in Neural Information Processing Systems, 34:8780-8794, 2021.
- [Dogan et al., 2019] Berk Dogan, Shuhang Gu, and Radu Timofte. Exemplar guided face image super-resolution without facial landmarks. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition workshops, pages 0-0, 2019.
- [Esser et al., 2021] Patrick Esser, Robin Rombach, and Bjorn Ommer. Taming transformers for high-resolution image synthesis. In Proceedings of the IEEE/CVF con- ference on computer vision and pattern recognition, pages 12873-12883, 2021.
- [Gu et al., 2020] Jinjin Gu, Yujun Shen, and Bolei Zhou. Im- age processing using multi-code gan prior. In Proceedings of the IEEE/CVF conference on computer vision and pat- tern recognition, pages 3012-3021, 2020.
- [Gu et al., 2022] Yuchao Gu, Xintao Wang, Liangbin Xie, Chao Dong, Gen Li, Ying Shan, and Ming-Ming Cheng. Vqfr: Blind face restoration with vector-quantized dic- tionary and parallel decoder. In Computer Vision-ECCV 2022: 17th European Conference, Tel Aviv, Israel, Octo- ber 23-27, 2022, Proceedings, Part XVIII, pages 126-143. Springer, 2022.
- [Heusel et al., 2017] Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochre- iter. Gans trained by a two time-scale update rule converge to a local nash equilibrium. Advances in neural information processing systems, 30, 2017.
- [Ho et al., 2020] Jonathan Ho, Ajay Jain, and Pieter Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems, 33:6840-6851, 2020.
- [Isola et al., 2017] Phillip Isola, Jun-Yan Zhu, Tinghui Zhou, and Alexei A Efros. Image-to-image translation with con- ditional adversarial networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1125-1134, 2017.
- [Johnson et al., 2016] Justin Johnson, Alexandre Alahi, and Li Fei-Fei. Perceptual losses for real-time style transfer and super-resolution. In Computer Vision-ECCV 2016: 14th European Conference, Amsterdam, The Netherlands, October 11-14, 2016, Proceedings, Part II 14, pages 694- 711. Springer, 2016.
- [Kadkhodaie and Simoncelli, 2020] Zahra Kadkhodaie and Eero P Simoncelli. Solving linear inverse problems us- ing the prior implicit in a denoiser. arXiv preprint arXiv:2007.13640, 2020.
- [Karras et al., 2017] Tero Karras, Timo Aila, Samuli Laine, and Jaakko Lehtinen. Progressive growing of gans for improved quality, stability, and variation. arXiv preprint arXiv:1710.10196, 2017.
- [Karras et al., 2019] Tero Karras, Samuli Laine, and Timo Aila. A style-based generator architecture for generative adversarial networks. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 4401-4410, 2019.
- [Karras et al., 2022] Tero Karras, Miika Aittala, Timo Aila, and Samuli Laine. Elucidating the design space of diffusion-based generative models. arXiv preprint arXiv:2206.00364, 2022.
- [Kim et al., 2019] Deokyun Kim, Minseon Kim, Gihyun Kwon, and Dae-Shik Kim. Progressive face super- resolution via attention to facial landmark. arXiv preprint arXiv:1908.08239, 2019.
- [Li et al., 2020] Xiaoming Li, Chaofeng Chen, Shangchen Zhou, Xianhui Lin, Wangmeng Zuo, and Lei Zhang. Blind face restoration via deep multi-scale component dictionar- ies. In Computer Vision-ECCV 2020: 16th European Con- ference, Glasgow, UK, August 23-28, 2020, Proceedings, Part IX 16, pages 399-415. Springer, 2020.
- [Liang et al., 2021] Jingyun Liang, Jiezhang Cao, Guolei Sun, Kai Zhang, Luc Van Gool, and Radu Timofte. Swinir: Image restoration using swin transformer. In Proceedings of the IEEE/CVF international conference on computer vi- sion, pages 1833-1844, 2021.
- [Menon et al., 2020] Sachit Menon, Alexandru Damian, Shijia Hu, Nikhil Ravi, and Cynthia Rudin. Pulse: Self- supervised photo upsampling via latent space exploration of generative models. In Proceedings of the ieee/cvf con- ference on computer vision and pattern recognition, pages 2437-2445, 2020.
- [Miller et al., 2019] Kevin J Miller, Bradley Preece, Todd W Du Bosq, and Kevin R Leonard. A data-constrained algo- rithm for the emulation of long-range turbulence-degraded video. In Infrared Imaging Systems: Design, Analysis, Modeling, and Testing XXX, volume 11001, pages 204- 214. SPIE, 2019.
- [Richardson et al., 2021] Elad Richardson, Yuval Alaluf, Or Patashnik, Yotam Nitzan, Yaniv Azar, Stav Shapiro, and Daniel Cohen-Or. Encoding in style: a stylegan en- coder for image-to-image translation. In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 2287-2296, 2021.
- [Rogers and Williams, 2000] L Chris G Rogers and David Williams. Diffusions, Markov processes and martingales: Volume 2, Itô calculus, volume 2. Cambridge university press, 2000.
- [Saharia et al., 2022] Chitwan Saharia, Jonathan Ho, William Chan, Tim Salimans, David J Fleet, and Mo- hammad Norouzi. Image super-resolution via iterative refinement. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2022.
- [Shen et al., 2018] Ziyi Shen, Wei-Sheng Lai, Tingfa Xu, Jan Kautz, and Ming-Hsuan Yang. Deep semantic face de- blurring. In Proceedings of the IEEE conference on com- puter vision and pattern recognition, pages 8260-8269, 2018.
- [Simonyan and Zisserman, 2014] Karen Simonyan and An- drew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556, 2014.
- [Song and Ermon, 2019] Yang Song and Stefano Ermon. Generative modeling by estimating gradients of the data distribution. Advances in neural information processing systems, 32, 2019.
- [Song et al., 2020] Yang Song, Jascha Sohl-Dickstein, Diederik P Kingma, Abhishek Kumar, Stefano Ermon, and Ben Poole. Score-based generative modeling through stochastic differential equations. arXiv preprint arXiv:2011.13456, 2020.
- [Song et al., 2023] Yang Song, Prafulla Dhariwal, Mark Chen, and Ilya Sutskever. Consistency models. arXiv preprint arXiv:2303.01469, 2023.
- [Tashiro et al., 2021] Yusuke Tashiro, Jiaming Song, Yang Song, and Stefano Ermon. Csdi: Conditional score- based diffusion models for probabilistic time series impu- tation. Advances in Neural Information Processing Sys- tems, 34:24804-24816, 2021.
- [Vincent, 2011] Pascal Vincent. A connection between score matching and denoising autoencoders. Neural computa- tion, 23(7):1661-1674, 2011.
- [Wang et al., 2021] Xintao Wang, Yu Li, Honglun Zhang, and Ying Shan. Towards real-world blind face restora- tion with generative facial prior. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 9168-9178, 2021.
- [Wang et al., 2022] Zhouxia Wang, Jiawei Zhang, Runjian Chen, Wenping Wang, and Ping Luo. Restoreformer: High-quality blind face restoration from undegraded key- value pairs. In Proceedings of the IEEE/CVF Confer- ence on Computer Vision and Pattern Recognition, pages 17512-17521, 2022.
- [Whang et al., 2022] Jay Whang, Mauricio Delbracio, Hos- sein Talebi, Chitwan Saharia, Alexandros G Dimakis, and Peyman Milanfar. Deblurring via stochastic refine- ment. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 16293- 16303, 2022.
- [Yang et al., 2016] Shuo Yang, Ping Luo, Chen-Change Loy, and Xiaoou Tang. Wider face: A face detection bench- mark. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 5525-5533, 2016.
- [Yang et al., 2021] Tao Yang, Peiran Ren, Xuansong Xie, and Lei Zhang. Gan prior embedded network for blind face restoration in the wild. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 672-681, 2021.
- [Yue and Loy, 2022] Zongsheng Yue and Chen Change Loy. Difface: Blind face restoration with diffused error contrac- tion. arXiv preprint arXiv:2212.06512, 2022.
- [Zhang et al., 2018] Richard Zhang, Phillip Isola, Alexei A Efros, Eli Shechtman, and Oliver Wang. The unreasonable effectiveness of deep features as a perceptual metric. In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 586-595, 2018.
- [Zhou et al., 2022] Shangchen Zhou, Kelvin CK Chan, Chongyi Li, and Chen Change Loy. Towards robust blind face restoration with codebook lookup transformer. arXiv preprint arXiv:2206.11253, 2022.
- [Zhu et al., 2016] Shizhan Zhu, Sifei Liu, Chen Change Loy, and Xiaoou Tang. Deep cascaded bi-network for face hal- lucination. In Computer Vision-ECCV 2016: 14th Eu- ropean Conference, Amsterdam, The Netherlands, Octo- ber 11-14, 2016, Proceedings, Part V 14, pages 614-630. Springer, 2016.
References were extracted automatically from the PDF and may contain errors.
Full text extracted automatically from the PDF; figures, tables and equations may differ. The PDF is the version of record.
1 Introduction
Blind face restoration (BFR) is a challenging problem that aims to recover a high-quality facial image from a low-quality input. With the increasing availability of degraded images captured in various real-world scenarios, the demand for effective BFR techniques has increased significantly in recent years. The primary goal of BFR is to recover undegraded facial features while preserving the person's identity. A
complex combination of many factors, such as low resolution, blur, noise, compressions, etc., corrupts a facial image. Typically, traditional approaches [Baker and Kanade, 2000; Bourlai et al., 2011] rely on a degradation model and manually designed priors, which often lead to sub-optimal results and restricted ability to handle a variety of real-life images. Recently, generative priors [Wang et al., 2021; Yang et al., 2021] have shown remarkable improvement in restoration performance. Generative priors encapsulated in a welltrained high-quality face generator (e.g., StyleGAN [Karras et al., 2019]) are typically exploited in such approaches. The degraded image is first projected to the latent space to get a 'cleaner' latent vector either directly or after certain refinement operations. The decoder projects the latent vector back to the pixel space, producing a restored image. Instead of dealing with a continuous latent space, [Gu et al., 2022; Zhou et al., 2022] utilizes pretrained vector-quantized codebooks. The mechanism of vector quantization in a compressed latent space reduces the uncertainty of the task, making these methods robust to various degradations. Intuitively, these approaches exploit information from two sources when restoring an image. The degraded input image contains crucial information about the person's identity. On the other hand, the pretrained decoder is utilized for a high-quality generation. Thus, ultimately, the task boils down to predicting the corresponding clean latent given a degraded image/latent. Using a highly compressed latent space usually reduces the complexity of the prediction task and prioritizes high-quality generation but fails to maintain intricate facial details essential for identity preservation. It may also lead to repeated and less diverse texture patterns in the output. On the other hand, using a less compressed latent space can be potentially more expressive and flexible but is often extremely difficult to optimize when directly projecting the degraded image to the latent space or trying to predict the correct latent code as a classification problem. A lower compression often diminishes the advantages of latent-space-based generative models, leading to suboptimal degradation removal from the input. Similar behavior was recently discussed in [Gu et al., 2022], where the trade-off between fidelity and quality depending on the compression factor was analyzed. We argue that the performance of such face restoration approaches mainly depends on the nature and size of the latent space. It is non-trivial to balance the demands of face generation and restoration using existing latent refinement techniques. [Gu et al., 2022; Zhou et al., 2022] deploy a highly spatially-compressed latent space (downsampled by 32) and instead use skip-connections to improve the fidelity, which is often counter-productive for the output quality, as the information from the encoder is usually corrupted.
In this work, we design an alternative approach, where we first select a highly expressive latent space with lower compression and to handle its additional complexity, we introduce diffusion-based-prior to model it. We learn the clean latent space distribution by directly modeling the gradient of the log density of the data, known as the score function [Song and Ermon, 2019], using a neural network. Such gradient information can be utilized in reverse by stochastic sampling to generate diverse samples from the underlying distribution. Unlike unconditional generation as in [Song et al., 2020], for the current task, we model it as a conditional generation task, where given degraded latent, we perform multi-step refinement to produce the cleaner counterpart.
Our approach has several key advantages. 1. Similar to prior state-of-the-art (SOTA) blind face restoration works [Zhou et al., 2022], we also utilize a pre-trained VQVAE framework to produce high-quality face images given correct latent codes. 2. The significantly lower compression ration allows us to maintain higher fidelity, suitable for BFR task. 3. Compared to the single-step refinement strategy of prior arts, multi-step conditional refinement of the corrupted latent using score-based diffusion prior is far more effective in producing the clean embedding, enabling us to use relatively mild compression rates, achieving more faithful and sharper reconstructions. 4. Compared to pixel-space-based diffusion models used in [Saharia et al., 2022] (DDPM), our score-based latent-diffusion model has much better time complexity and requires significantly fewer refinement steps (≈ 20×).
The diffusion prior is extremely powerful for producing a clean latent. However, during multiple refinements, deviating from the trajectory of correct identity is plausible. To further constraint the refinement process, we deploy a separate Identity Recovery Network (IRN), which prioritizes recovering identity-specific intricacies given the input image using a face recognition loss. We utilize the output of the IRN to initialize the iterative refinement process. Next, at each step, we utilize a gradient-based score-update strategy using a pre-trained face recognition network to steer the refinement process along the identity recovered by the IRN. While this approach considerably diminishes the risk of identity distortion, the guidance signal from a face-recognition network may not align well with the other objective of producing visually pleasing results. Such a dilemma is observed in existing works as well [Wang et al., 2021], where usually a small amount of identity loss is introduced while prioritizing standard perceptual losses, which ultimately fails to recover the identity information adequately. Instead of blindly enforcing the identity constraint across the entire latent space, we introduce a learnable latent mask, where the gradient from the recognition network is harnessed to selectively update specific latent locations that contribute most significantly to identity information. This enables us to balance the restored identity and the perceptual quality derived from the diffusion prior.
To summarize, our main contributions are
- We propose a diffusion-prior-based conditional latent refinement strategy for recovering the clean latent inside a pretrained VQVAE framework.
- The strong modeling capability of such iterative refinement allows us to design a latent space with a lower spatialcompression ratio (f=4), improving the overall fidelity and sharpness of the output.
- We further deploy an IRN to recover identity-specific features from the degraded input. The output of IRN, along with adaptive guidance using a learnable latent mask, steers the refinement process for better identity recovery without compromising the perceptual quality.
- Extensive evaluation on multiple real and synthetic datasets demonstrates our proposed framework's superior perceptual and identity-preserving properties.
2 RelatedWorks
Various priors have been proposed, including geometric priors such as facial landmarks [Kim et al., 2019; Chen et al., 2018; Zhu et al., 2016] and parsing maps [Chen et al., 2021; Shen et al., 2018], as well as reference-based approaches [Li et al., 2020; Dogan et al., 2019]. However, these priors often struggle to estimate necessary information from corrupted images. Recent generative priors optimize the latent vector for GAN inversion techniques [Menon et al., 2020; Gu et al., 2020] or direct projection of the input image to the latent space [Richardson et al., 2021]. [Yang et al., 2021], and [Wang et al., 2021] exploited the generative prior inside an encoder-decoder, with structural details from the degraded input through skip connections. For severe degradations, such links lead to unwanted artifacts.
Diffusion and score-based models have shown improvements recently [Saharia et al., 2022; Whang et al., 2022; Choi et al., 2021; Yue and Loy, 2022; Chung et al., 2022]. Iterative refinement strategies has been adopted by [Saharia et al., 2022], [Whang et al., 2022] for super-resolution and motion deblurring tasks. [Choi et al., 2021] guided the reverse process with low-frequency information from a conditional image. However, such a conditioning strategy does not translate well for the BFR problem with significant degradation and may alter the identity. [Yue and Loy, 2022] uses an unconditional diffusion model and starts from an intermediate stage of the reverse diffusion process. But, as the underlying diffusion model is unconditional, the identity of the restored face changes considerably. If it is used for a smaller timespan, the visual quality and sharpness of the output suffer considerably. [Chung et al., 2022] addressed only non-blind super-resolution tasks, and its identity-preserving capability is yet to be tested for more difficult BFR scenarios. Our work mainly aims to balance identity preservation and perceptual quality for heavily degraded faces.
3 Method
Our framework has two main parts, a Vector-Quantized (VQ) autoencoder is our backbone that maps a degraded image to the latent space with a downsampling factor f = 4 and reverses this operation after refining the latent. A conditional

(a) Inference
Figure 1: An overview of our inference (left) and training framework (right).
diffusion model (denoising UNet) is used for the latent refinement task. We pre-train the quantized autoencoder through self-reconstruction to obtain a discrete codebook and the corresponding decoder for projecting the restored latent back to pixel space. In addition, we also deploy IRN to produce an initial estimate of the restored face, focusing on recovering identity-specific features, which are used to steer the iterative latent refinement process. An overview of our framework is shown in Fig. 1. In the following sections, we describe the details of different parts of our framework.
3.1 Learning Latent Space of Images via Vector-Quantized Codebook
We use x and z to represent image in pixel space and the corresponding latent representation, respectively. Our perceptual compression model utilizes a variant of the VectorQuantize codebook called VQGAN [Esser et al., 2021]. It learns a perceptual codebook through a combination of perceptual loss [Johnson et al., 2016] and adversarial training [Isola et al., 2017], preventing blurriness that can occur when relying solely on pixel-space L2 or L1 losses. The model consists of an encoder E, a decoder G, and a codebook Z = zkKk=1 ∈ RK×d containing a finite set of embedding vectors. Here, K represents the codebook size, and d denotes the dimension of the codes. Given an input image x ∈ R3×H×W , we project it to the latent space as z = E(x) ∈ Rd× Hf × Wf . Next, a spatial collection of image tokens zq is obtained using a spatial-wise quantizer Q(·), which maps each spatial feature zij into its closest codebook entry zk
The decoder reconstructs the image from the latent, giving ˜x = G(zq). The encoder E, the decoder G and the codebook Z are trained end-to-end via the following loss function
where sg(·) stands for the stop-gradient operator, ϕ(·) represents the VGG-based [Simonyan and Zisserman, 2014] feature extractor. The first three terms help reconstruct the input image, whereas the last two terms reduce the distance between codebook Z and input feature embeddings z. As we build upon the foundation of continuous space diffusion models, we absorb the quantization layer in the decoder. Given z, we use the conditional diffusion model to recover the correct latent embedding through iterative refinement. Next, quantization and the pre-trained high-quality codebook can handle any inaccuracies in the latent prediction for producing a clean, restored face. Compared to existing BFR works that use VQVAE [Gu et al., 2022; Zhou et al., 2022], our work has two critical differences: we use a milder compression (downsample f = 4 instead 32) and a larger codebook size (K = 8192 instead of 1024). Such an expressive yet highly complex latent space can be optimally modeled by iterative diffusionprior-based refinement. As a result, the restored image is of higher fidelity and realness than prior art.
3.2 Latent Refinement Using Diffusion Prior
Given the high dimensional latent with a lower compression ratio, existing methods encounter challenges in generating a cleaner latent through a single pass in the encoder or a classification-based refinement module, as elaborated in [Gu et al., 2022]. Instead, we aim to learn the probability distribution of the clean latent space (through gradients of log probability density functions) and map the degraded latent to the clean space in multiple refinement steps. Our approach is built upon the framework of [Song and Ermon, 2019], where stochastic differential equations drive the underlying diffusion process. We can represent this process using continuous time variables zt t=1 t=0 , where z0 represents the initial variable (i.e., clean latent representation) and zt represents its noisy version at time t. The diffusion process is defined by an Itˆo SDE [Rogers and Williams, 2000]
where f(·, ·) and g(·) are the drift and diffusion coefficients, respectively, and wt denotes the standard Brownian motion.
We denote the distribution of zt as p(zt). The SDE in Eq. 3 can be converted to a generative model by first sampling from z1 ∼ N(z1, 0, I) and then running the reverse-time SDE as
where ¯wt is a reverse-time standard Wiener process and dt is an infinitesimal negative time step. As shown in [Song et al., 2020], there exists a deterministic ordinary differential equation (ODE), whose trajectories share the same marginal probability densities as the SDE (Eqs. 3, 4)
In practice, blackbox ODE solvers can be used on Eq. 5 for faster and high quality sampling, assuming we know the score function. The score function (∇zt log p(zt)) is typically approximated using a neural network sθ(zt, t) [Vincent, 2011; Song and Ermon, 2019; Ho et al., 2020], trained to minimize the weighted Fisher's divergence with a positive weighting function λ as
Conditional Diffusion for BFR
Instead of unconditionally sampling from the underlying clean latent distribution using Eq. 5, for the task of BFR, our goal is to predict the clean counterpart, given a degraded latent zd of the input image xd . We are interested in p(z0|zd ), where z0 is the target clean latent distribution corresponding to the image xd and zd is the condition signal. Similar to Eq. 5, we can obtain a conditional reverse-time ODE as
We need to learn the conditional score function ∇zt log p(zt|zd ) in order to be able to sample from Eq. 7 using reverse-time diffusion. In [Song et al., 2020], ∇zt log p(zt|zd ) was estimated using
where ∇zt log p(zt) is learned using an unconditional model and ∇zt log p(zd |zt) is learned using a separate auxiliary network. But, modeling such a forward process is nontrivial for BFR, as there could be many possible zd given a zt. Instead, following the intuition of [Saharia et al., 2022; Tashiro et al., 2021], we can extend the formulation of Eq. 6 to a conditional case as
where we pass the condition zd directly to the denoising UNet, making it learn the conditional score. We empirically verify that it works well for BFR task. In [Song et al., 2020; Kadkhodaie and Simoncelli, 2020], the noise was added to both the target and the conditional observations, which we found to be harmful. We follow the simplified configuration of [Karras et al., 2022], where we set f(zt, t) = 0 and g(t) = √2t. Then, p(zt) can be expressed as p(z0) ∗ N(0, t2 I), where ∗ represents convolution operation and p(z0) is the underlying distribution of the clean or non-degraded images' latent space, which we aim to model. Once we know the score function (using a neural network), Eq. 7 can be re-written as
During the reverse process, we can proceed backward in time with a black box ODE solver, such as Heun solvers [Karras et al., 2022], to obtain the solution trajectory. The resulting ˆz0 can be considered an approximate embedding of the clean image corresponding to xd . ˆz0 is passed through the pre-trained decoder to produce the restored image. The decoder has the quantization layer, which handles minor errors in the continuous space prediction.
3.3 Identity Recovery Network (IRN)
Existing works typically introduce an identity-preserving loss to the same restoration network in addition to standard perceptual losses. But, often, minimizing both losses together hampers the perceptual quality and may introduce unwanted artifacts, especially if the coefficient for identity loss is high. Instead, to ease the learning process, we aim to disentangle these two objectives and use a separate IRN (fϕ) to focus on recovering the identity. We train fϕ, emphasizing the identity-preserving loss, with a small amount of L1 loss for better stability. The loss function for training fϕ is as follows:
where Dcos denotes the cosine distance between two feature vectors and farc denotes a pre-trained ArcFace model. We denote the second term in Eq. 11 as Larc. The IRN aims to generate a stable approximation xid that primarily recovers the identity information rather than focusing on visually pleasing sharp results. Such crucial identity features are also transferred to the latent embedding zid . To ensure that during reverse diffusion process, the output does not deviate from the already recovered identity in xid , we add a gradient term ∇ˆz0,t Larc to the estimated score at each step, where the Larc is calculated between the image obtained after projecting ˆz0,t to pixel-space using the pretrained decoder and xid , ˆz0,t is the denoised output at step t. It follows the intuition of classifier guidance in [Dhariwal and Nichol, 2021]. But, we have observed that simply adding the gradient for the whole latent again deteriorates the perceptual quality. We hypothesize that the latent embedding should have specific features that correlate to identity-specific details in the pixel space. We should ideally regularize the score function of only those features while keeping the rest untouched.
To verify this, we introduce a learnable latent mask Ml ∈ Rd× Hf × Wf , denoting the identity-specific latent features. We use a stack of a few convolutional layers followed by a sigmoid layer as fM, that takes the ˆzct as input and produces Ml. To train fM , we first update the score to obtain the corresponding ˆz0,t and project it back to pixel space. We use LPIPS, cosine-distance-based ID loss on the output image, and a sparsity constraint on Ml to ensure Ml selects only the subset of identity-specific features without harming the LPIPS score. As discussed in our ablation study, the observed improvement after introducing the latent mask validates our design choice. For all the cases, straight-through gradient estimator [Esser et al., 2021] is utilized to copy the gradients from the decoder to the continuous latent embedding to handle the non-differentiable quantization operation.

| Methods | FID ↓ | LPIPS ↓ | IDS ↑ | LDM ↓ | PSNR ↑ | SSIM ↑ |
|---|---|---|---|---|---|---|
| GPEN | 101.12 | 0.3362 | 0.4022 | 10.76 | 22.43 | 0.6009 |
| GFPGAN | 99.03 | 0.2812 | 0.4633 | 10.49 | 22.50 | 0.6060 |
| PSFRGAN | 64.81 | 0.2513 | 0.3983 | 6.51 | 21.75 | 0.5450 |
| CodeFormer | 54.41 | 0.2288 | 0.5009 | 5.85 | 22.35 | 0.5736 |
| DifFace | 52.18 | 0.2061 | 0.4833 | 5.40 | 22.74 | 0.6116 |
| RestoreFormer | 59.51 | 0.2899 | 0.4041 | 7.65 | 21.73 | 0.5256 |
| VQFR | 60.75 | 0.3147 | 0.37 | 8.32 | 21.02 | 0.4931 |
| Ours | 46.15 | 0.1868 | 0.5667 | 5.00 | 21.66 | 0.5652 |
4 Experimental Results
4.1 Training Dataset
The FFHQ dataset [Karras et al., 2019] contains 70,000 highquality face images at 1024 × 1024 resolution. We resized the images to 512 × 512 for training. We synthesized degraded images on the FFHQ dataset using the degradation model proposed in [Yang et al., 2021; Wang et al., 2021; Wang et al., 2022; Chen et al., 2021]: xd = ((x ⊗ k) ↓s +nσ)q. Here, x, xd , k, nσ, s, and q are the clean face image, the corresponding degraded image, the blur kernel, the Gaussian noise with standard deviation σ, downscaling factor, and the JPEG-compression quality factor, respectively. We randomly and uniformly sampled σ, s, and q from [0,20], [1,32], and [30,90], respectively. We evaluated our approach on 3,000 synthetic images from CelebA-Test dataset [Karras et al., 2017]. The degraded images in this dataset were synthesized using the same degradation range as our training. Additionally, we tested our method on real-world datasets: WebPhoto-Test [Wang et al., 2021] (407 images), WIDER Face [Yang et al., 2016] (970 images), Celeb-Child [Wang et al., 2021] (180 images) and TURB. For the TURB dataset, we randomly sampled 139 images from the BRIAR [Cornett et al., 2023] and LRFID [Miller et al., 2019] datasets, which provided a more challenging scenario as our models were not trained on severe turbulence-affected images.
| Methods | LPIPS ↓ | FID ↓ | IDS ↑ | LDM ↓ | PSNR ↑ | SSIM ↑ |
|---|---|---|---|---|---|---|
| GPEN | 0.4350 | 148.39 | 0.1843 | 21.80 | 19.91 | 0.5346 |
| GFPGAN | 0.4028 | 160.29 | 0.2243 | 23.10 | 19.95 | 0.5366 |
| CodeFormer | 0.3565 | 73.45 | 0.2546 | 11.24 | 19.14 | 0.4639 |
| DifFace | 0.3001 | 53.93 | 0.2892 | 8.85 | 20.12 | 0.5314 |
| RestoreFormer | 0.4193 | 103.13 | 0.1438 | 14.10 | 19.26 | 0.4581 |
| VQFR | 0.4090 | 109.97 | 0.1583 | 15.30 | 18.88 | 0.4220 |
| Ours | 0.2574 | 39.71 | 0.3512 | 7.67 | 18.77 | 0.4751 |
4.2 EvaluationMetrics
To assess the quality of the restored images quantitatively, we primarily rely on the Frechet Inception Distances (FID) [Heusel et al., 2017] and Learned Perceptual Image Patch Similarity (LPIPS) [Zhang et al., 2018] metrics. We also compute PSNR and SSIM for completeness, although they often fail to capture visual quality. To evaluate the face recognition performance of the restored images, we calculate the cosine similarity between the features of the restored image and the paired GT image (IDS). Higher cosine similarity val- Input GFPGAN





Input



| Methods | WIDER Face | WebPhoto | CelebA-Child |
|---|---|---|---|
| PSFRGAN | 49.85 | 88.45 | 107.40 |
| GPEN | 46.99 | 81.77 | 109.55 |
| GFPGAN | 39.76 | 87.35 | 111.78 |
| CodeFormer | 39.21 | 78.87 | 116.18 |
| VQFR | 44.54 | 75.46 | 105.68 |
| DifFace | 37.49 | 85.52 | 110.81 |
| Ours | 34.25 | 75.05 | 104.40 |
Table 3: Quantitative comparisons of FID (↓) on real-world datasets in terms of FID. Bold and underline indicate the best and the second best performance, respectively.
ues indicate better recovery of the identity information. We use the same evaluation metrics and pre-trained models for LPIPS, FID, and ArcFace as used in the prior art [Wang et al., 2022; Wang et al., 2021]. We also adopt landmark distance (LMD) as the fidelity metric, following [Gu et al., 2022].
4.3 Comparisons with State-of-the-Art Methods
We compare with the following state-of-the-art (SOTA) methods: PSFRGAN [Chen et al., 2021], GPEN [Yang et al., 2021], GFPGAN [Wang et al., 2021], CodeFormer [Zhou et al., 2022], RestoreFormer [Wang et al., 2022], DifFace [Yue and Loy, 2022] and VQFR [Gu et al., 2022]. We use the official results and checkpoints provided by the authors.
Synthetic BFR: We reported restoration accuracy on the synthetic CelebA-Test dataset for BFR task in Table 1. Our approach achieves a much better balance between fidelity (IDS, LDM) and perceptual metrics (LPIPS, FID).
Extreme Upscaling: We tested the algorithms under extreme BFR conditions, where we applied a fixed downscaling factor of ×32 to 512×512 images, resulting in degraded images of size 16 × 16. To make the task more challenging, we added noise and blur to the images. The quantitative results can be found in Table 2. Despite the limited information in the input, our approach outperforms other algorithms in terms of perceptual quality and recognition accuracy.
| Methods | LPIPS ↓ | FID ↓ | IDS ↑ | PSNR ↑ |
|---|---|---|---|---|
| VQVAE-Rec (f=32) | 0.0559 | 22.76 | 00.9012 | 29.46 |
| VQVAE-Rec (f=4) | 0.0068 | 9.02 | 0.9903 | 35.72 |
| VQVAE-Rest (f=4) | 0.2127 | 81.69 | 0.5258 | 19.09 |
| IRN | 0.3344 | 127.53 | 0.5155 | 24.26 |
| IRNID | 0.3109 | 118.50 | 0.5849 | 24.16 |
| Diff. Prior | 0.1901 | 47.91 | 0.5107 | 21.06 |
| IRNID + Diff. Prior | 0.2004 | 53.22 | 0.5712 | 22.34 |
| IRNID + Diff. Prior +Ml | 0.1868 | 46.15 | 0.5667 | 21.66 |
Real-World Cases: Our approach outperforms existing GAN-based methods like GPEN and GFPGAN in terms of producing more realistic and faithful reconstructions on realworld degraded datasets. CodeForm, VQFR's outputs show visible artifacts or repetitive skin/hair texture due to highly compressed latent space. DifFace outputs are less sharp and may alter facial details as the underlying model is unconditional. In contrast, our approach achieves superior results with fewer artifacts, even for low to medium degradation levels. Real-world colorization examples are shown in Fig. 5, for which we finetune our network for colorization. We also report the accuracy for the downstream face-recognition task on the TURB dataset in Table 5. Our approach comfortably outperforms prior arts for recognition, as well.
5 Ablation Analysis
In Table 4, we analyze the effect of individual components of our approach on the perceptual quality and identitypreserving aspect. We use CelebA-Test with 512 × 512 images for our ablation. We empirically found that the IRN is IP






VQVAE-Rest GD (t=1000)
IRN
Ours GT
Figure 6: (Left): Reconstruction performance of VQVAE. (Right): Restoration performance of VQVAE, GD, IRN and our final model using latent space refinement.
model agnostic, and any SOTA restoration network results in a comparable accuracy boost. We provided detailed comparisons of possible options for IRN in the supplementary. We finally select SwinIR [Liang et al., 2021] that keeps a good balance between performance and accuracy. We design our VQ backbone with the following settings: f=4, codebook = 8192, latent = 3×128×128, feat = 128 (×1, ×2, ×3). For the diffusion model, we have used 40 time steps with heun sampler [Karras et al., 2022] and a UNet-based denoiser based on GD 1 . More implementation and network details, additional results are provided in the supplementary material.
Compression Factor: First, we compared VQVAE models with different latent sizes: f = 32 and f = 4. The f = 32 models, commonly used in previous works [Gu et al., 2022], resulted in poor reconstruction quality due to significant spatial compression to 16 × 16. In contrast, the f = 4 models achieved superior reconstruction quality, as shown in Fig. 6 (Left). We have verified that it is satisfactorily accurate in reconstructing degraded images as well (PSNR=37.9). Higher spatial compression led to the loss of fine facial details and overly smooth outputs. For example, in the first row, the eye color was changed, and in the second row, both the eye and hair patterns were altered in the f = 32 models.
Latent Refinement: We attempted to fine-tune the VQVAE model (with f = 4) directly for restoration, but it often failed to remove degradation effectively, as reported in [Gu et al., 2022]. To address this issue, we developed a modified version called VQVAE-Rest. This variant takes both the degraded image and the coarse estimate from the IRN as inputs, enabling it to focus on recovering residual details. However, even with this modification, the output of VQVAE-Rest still exhibited lower quality and noticeable artifacts (Figure 6 (Right), Column 2). These results show the need for appropriate latent-space refinement to achieve satisfactory restoration outcomes. We also compare with Guided-Diffusion (GD) for pixel-space-based diffusion (DDPM), which is run for 1000 timesteps in Figure 6 (Right). As can be observed, it is not only computationally intensive due to large no. of time steps, but also fails to reconstruct the image properly starting from pure noise. The outputs of the IRN shown in Figure 6 (Right), Column 4, may lack sharp details. However, it recovers crucial facial locations like eye, nose, etc.
ID Loss: Table 4 demonstrates the significance of the ArcFace [Deng et al., 2019] based identity-preserving loss for the IRN (IRNID vs. IRN), which prioritizes the recovery of identity-specific features, which are valuable for regularizing the diffusion process.
Adaptive Mask: While the diffusion model alone can achieve good perceptual quality, it may inadvertently alter certain identity-specific facial features. Adding IRNID -based gradient improves the IDS, but is detrimental for perceptual metrics. The final output could be slightly different from the output of IRN as we regularize only a subset of the latent in the diffusion stage. Our final model, combining the strengths of the Diff. Prior, IRNID and the learnable latent mask Ml achieves superior accuracy both in terms of perceptual metrics and fidelity. Inference time(s) for GFPGAN, CodeFormer, DifFace, Guided-Diffusion and ours are: 0.5, 0.15, 6,30, 0.61. Our design is still much faster than existing diffusion-based BFR methods, and can potentially be further accelerated by reducing the number of steps using knowledge-distillation techniques [Song et al., 2023]. We also have comparable or less parameters (16M) compared to VQFR (76.3M), DifFace (17.5), RestoreFormer (12M).
1 GD: https://github.com/openai/guided-diffusion
| Methods | Top-1 (↑) | Top-3 (↑) | Top-5 (↑) |
|---|---|---|---|
| GPEN | 32/50.6 | 50/72 | 62/81 |
| GFPGAN | 26/57 | 58/79 | 60/85 |
| CodeFormer | 28/61 | 52/77 | 58/82 |
| RestoreFormer | 20/62 | 50/81 | 62/88 |
| VQFR | 34/60 | 60/79 | 64/87 |
| Ours | 34/68 | 68/81 | 72/90 |
6 Conclusions
We propose a iterative latent-space refinement technique using diffusion prior for restoring severely degraded face images, achieving a better balance between restoration quality and identity recovery compared to existing methods. However, the performance of our approach is limited by the IRN's ability to preserve identity information. To improve efficiency, we plan to explore the development of a recognitionmodel-free reverse algorithm in future research.
Acknowledgements
This research is based upon work supported in part by the Office of the Director of National Intelligence (ODNI), Intelligence Advanced Research Projects Activity (IARPA), via [2022-21102100005]. The views and conclusions contained herein are those of the authors and should not be interpreted as necessarily representing the official policies, either expressed or implied, of ODNI, IARPA, or the U. S. Government. The US. Government is authorized to reproduce and distribute reprints for governmental purposes notwithstanding any copyright annotation therein.
@inproceedings{ijcai2024p143,
title = {CLR-Face: Conditional Latent Refinement for Blind Face Restoration Using Score-Based Diffusion Models},
author = {Suin, Maitreya and Chellappa, Rama},
booktitle = {Proceedings of the Thirty-Third International Joint Conference on
Artificial Intelligence, {IJCAI-24}},
publisher = {International Joint Conferences on Artificial Intelligence Organization},
editor = {Kate Larson},
pages = {1290--1298},
year = {2024},
month = {8},
note = {Main Track},
doi = {10.24963/ijcai.2024/143},
url = {https://doi.org/10.24963/ijcai.2024/143},
}
TY - CPAPER TI - CLR-Face: Conditional Latent Refinement for Blind Face Restoration Using Score-Based Diffusion Models AU - Suin, Maitreya AU - Chellappa, Rama T2 - Proceedings of the Thirty-Third International Joint Conference on Artificial Intelligence, IJCAI-24 PB - International Joint Conferences on Artificial Intelligence Organization PY - 2024 SP - 1290 EP - 1298 DO - 10.24963/ijcai.2024/143 UR - https://doi.org/10.24963/ijcai.2024/143 ER -Copied
Machine-readable versions of this paper, for tools and AI agents: