arXiv(opens in a new tab)Computer ScienceApr 2022Cited by 88 papers on PaperVantageClassic Paper

Manuscript Offprint

arXiv:2204.06125

Hierarchical Text-Conditional Image Generation with CLIP Latents

Ramesh, Aditya, Prafulla Dhariwal, Alex Nichol, Casey Chu, Mark I-Cheng Chen

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Contrastive models like CLIP have been shown to learn robust representations of images that capture both semantics and style. To leverage these representations for image generation, we propose a two-stage model: a prior that generates a CLIP image embedding given a text caption, and a decoder that generates an image conditioned on the image embedding. We show that explicitly generating image representations improves image diversity with minimal loss in photorealism and caption similarity. Our decoders conditioned on image representations can also produce variations of an image that preserve both its semantics and style, while varying the non-essential details absent from the image representation. Moreover, the joint embedding space of CLIP enables language-guided image manipulations in a zero-shot fashion. We use diffusion models for the decoder and experiment with both autoregressive and diffusion models for the prior, finding that the latter are computationally more efficient and produce higher-quality samples.

1 Introduction

Recent progress in computer vision has been driven by scaling models on large datasets of captioned images collected from the internet Desai and Johnson (2020); Sariyildiz et al. (2020); Zhang et al. (2020); Radford et al. (2021); Mu et al. (2021); Fürst et al. (2022). Within this framework, CLIP Radford et al. (2021) has emerged as a successful representation learner for images. CLIP embeddings have a number of desirable properties: they are robust to image distribution shift, have impressive zero-shot capabilities, and have been fine-tuned to achieve state-of-the-art results on a wide variety of vision and language tasks Shen et al. (2021). Concurrently, diffusion models Sohl-Dickstein et al. (2015); Song and Ermon (2020); Ho et al. (2020) have emerged as a promising generative modeling framework, pushing the state-of-the-art on image and video generation tasks Dhariwal and Nichol (2021); Ho et al. (2021); Ho and Salimans (2021). To achieve best results, diffusion models leverage a guidance technique Dhariwal and Nichol (2021); Ho and Salimans (2021) which improves sample fidelity (for images, photorealism) at the cost of sample diversity.

In this work, we combine these two approaches for the problem of text-conditional image generation. We first train a diffusion decoder to invert the CLIP image encoder. Our inverter is non-deterministic, and can produce multiple images corresponding to a given image embedding. The presence of an encoder and its approximate inverse (the decoder) allows for capabilities beyond text-to-image translation. As in GAN inversion Zhu et al. (2016); Xia et al. (2021), encoding and decoding an input image produces semantically similar output images (Figure 3). We can also interpolate between input images by inverting interpolations of their image embeddings (Figure 4). However, one notable advantage of using the CLIP latent space is the ability to semantically modify images by moving in the direction of any encoded text vector (Figure 5), whereas discovering these directions in GAN latent space involves

FigureFigureFigure
vibrant portrait painting of Salvador Dalí with a robotic half facea shiba inu wearing a beret and black turtlenecka close up of a handpalm with leaves growing from it
FigureFigureFigure
an espresso machine that makes coffee from human souls, artstationpanda mad scientist mixing sparkling chemicals, artstationa corgi’s head depicted as an explosion of a nebula
FigureFigureFigure
a dolphin in an astronaut suit on saturn, artstationa propaganda poster depicting a cat dressed as french emperor napoleon holding a piece of cheesea teddy bear on a skateboard in times square

Figure 1: Selected 1024×10241024\times 1024 samples from a production version of our model.

luck and diligent manual examination. Furthermore, encoding and decoding images also provides us with a tool for observing which features of the image are recognized or disregarded by CLIP.

To obtain a full generative model of images, we combine the CLIP image embedding decoder with a prior model, which generates possible CLIP image embeddings from a given text caption. We compare our text-to-image system with other systems such as DALL-E Ramesh et al. (2021) and GLIDE Nichol et al. (2021), finding that our samples are comparable in quality to GLIDE, but with greater diversity in our generations. We also develop methods for training diffusion priors in latent space, and show that they achieve comparable performance to autoregressive priors, while being more compute-efficient. We refer to our full text-conditional image generation stack as unCLIP, since it generates images by inverting the CLIP image encoder.

Figure

Figure 2: A high-level overview of unCLIP. Above the dotted line, we depict the CLIP training process, through which we learn a joint representation space for text and images. Below the dotted line, we depict our text-to-image generation process: a CLIP text embedding is first fed to an autoregressive or diffusion prior to produce an image embedding, and then this embedding is used to condition a diffusion decoder which produces a final image. Note that the CLIP model is frozen during training of the prior and decoder.

References (58)

Cited by (88)