arXiv:2310.01407Computer ScienceOct 2023

Manuscript Offprint

arXiv:2310.01407

CoDi: Conditional Diffusion Distillation for Higher-Fidelity and Faster Image Generation

Kangfu Mei, M. Delbracio, Hossein Talebi, Zhengzhong Tu, Vishal M. Patel, P. Milanfar

Abstract

Large generative diffusion models have revolutionized text-to-image generation and offer immense potential for conditional generation tasks such as image enhancement, restoration, editing, and compositing. However, their widespread adoption is hindered by the high computational cost, which limits their real-time application. To address this challenge, we introduce a novel method dubbed CoDi, that adapts a pre-trained latent diffusion model to accept additional image conditioning inputs while significantly reducing the sampling steps required to achieve high-quality results. Our method can leverage architectures such as ControlNet to incorporate conditioning inputs without compromising the model’s prior knowledge gained during large scale pre-training. Additionally, a conditional consistency loss enforces consistent predictions across diffusion steps, effectively compelling the model to generate high-quality images with conditions in a few steps. Our conditional-task learning and distillation approach outperforms previous distillation methods, achieving a new state-of-the-art in producing high-quality images with very few steps (e.g., 1-4) across multiple tasks, including super-resolution, text-guided image editing, and depth-to-image generation.

Figure

Figure 1: Our proposed CoDi efficiently distills a conditional diffusion model from an unconditional one, enabling rapid generation of high-quality images under various conditional settings. We demonstrate CoDi’s capabilities through generated results across various tasks.

1 Introduction

Text-to-image diffusion models [34, 29, 27] trained on large-scale data [15, 38] have significantly dominated generative tasks by delivering impressive high-quality and diverse results. A newly emerging trend is to use the prior of pre-trained text-to-image models such latent diffusion models (LDMs) [29] to guide the generated results with external image conditions for image-to-image transformation tasks such as image manipulation, enhancement, or super-resolution [22, 53]. Among these transformation processes, the diffusion prior introduced by pre-trained models is shown to be capable of greatly promoting the visual quality of the conditional image generation results [31, 3, 16, 26].

However, diffusion models heavily rely on an iterative refinement process [43, 35, 33, 49, 4] that often demands a substantial number of iterations, which can be challenging to accomplish efficiently. Their reliance on the number of iterations further increases for high-resolution image synthesis. For instance, in state-of-the-art text-to-image latent diffusion models [29], achieving optimal visual quality typically requires 20−20020\mathrm{-}200 sampling steps (function evaluations), even with advanced sampling methods [17, 10]. The slow sampling time significantly impedes practical applications of the aforementioned conditional diffusion models.

Recent efforts to accelerate diffusion sampling predominantly employ distillation methods [21, 36, 44]. These methods achieve significantly faster sampling, completing the process in just 4−84\mathrm{-}8 steps, with only a marginal decrease in generative performance. Very recent works [23, 14] show that these strategies are even applicable for distilling pre-trained large-scale text-to-image diffusion models.

A very common application scenario is to incorporate new conditions into these distilled diffusion models, such as using low-resolution images for super-resoltion [35], or instruction-tuning for image editing [3], where the most straightforward way is to directly finetune the distilled text-to-image pre-trained model with new conditional data. An alternative common approach [23] is to first finetune the diffusion model with the new conditional data, then conducting distillation on the already-finetuned conditional model. While these two methods have been demonstrated to accelerate sampling, each has distinct disadvantages in terms of result quality and cross-task flexibility, as discussed below.

In this paper, we introduce a new algorithm for Conditional Distillation which we call CoDi for efficiently adding new controls into distilled models. Unlike previous distillation methods that rely on finetuning, our method directly distills a diffusion model from a text-to-image pretraining (e.g., StableDiffusion) and ends with a fully distilled conditional diffusion model. As depicted in Figure 1, our distilled model is capable of predicting high-quality results in just 1−41-4 sampling steps.

By design, our method eliminates the need for the original text-to-image data [38, 37], a requirement in previous distillation methods (i.e., those that first distill the unconditional text-to-image model), thereby making our method more practical. Additionally, our formulation avoids sacrificing the diffusion prior in the pre-trained model during finetuning, a common drawback in the first stage of the finetuning-first procedure. Our extensive experiments show that our CoDi outperforms previous distillation methods in both visual quality and quantitative metrics, particularly when operating under the same sampling time.

Parameter-efficient distillation methods are a relatively understudied area. We demonstrate that our method also enables a new Parameter-Efficient distillation paradigm (PE-CoDi). It can transform an unconditional diffusion model to conditional tasks by incorporating a small number of additional learnable parameters. Specifically, our formulation allows for integration with various existing parameter-efficient tuning algorithms, e.g., ControlNet [53]. We show that our distillation process that integrates the ControlNet adapter can efficiently preserve the generative prior in pretraining while adapting the model to new conditioned data. This new paradigm significantly improves the practicality of different conditional tasks.

Our contributions are summarized as follows:

  • We propose a new method for image and image-text conditioned generation. It can derive a conditional diffusion model from pretrained text-to-image LDMs for generating high-quality results in only a few sampling steps.
  • The proposed method’s efficiency and effectiveness arise from a non-trivial consistency between the model’s predictions at different time steps. Enforcing this consistency through learning enables the simultaneous reduction of required sampling steps and the integration of new conditions into the model.
  • We introduce the first parameter-efficient distillation mechanism that can produce compelling results in just a few steps, while requiring only a small number of additional parameters compared with the pretrained LDMs.

References (54)