Title: The CLIP Model is Secretly an Image-to-Prompt Converter
Venue: NeurIPS 2023
Accepted: yes
Keywords: Diffusion Model

CLIP model

Image Variation

Customized Generation
Abstract: The Stable Diffusion model is a prominent text-to-image generation model that relies on a text prompt as its input, which is encoded using the Contrastive Language-Image Pre-Training (CLIP). However, text prompts have limitations when it comes to incorporating implicit information from reference images. Existing methods have attempted to address this limitation by employing expensive training procedures involving millions of training samples for image-to-image generation. In contrast, this paper demonstrates that the CLIP model, as utilized in Stable Diffusion, inherently possesses the ability to instantaneously convert images into text prompts. Such an image-to-prompt conversion can be achieved by utilizing a linear projection matrix that is calculated in a closed form. Moreover, the paper showcases that this capability can be further enhanced by either utilizing a small amount of similar-domain training data (approximately 100 images) or incorporating several online training steps (around 30 iterations) on the reference images. By leveraging these approaches, the proposed method offers a simple and flexible solution to bridge the gap between images and text prompts. This methodology can be applied to various tasks such as image variation and image editing, facilitating more effective and seamless interaction between images and textual prompts.

The CLIP Model is Secretly an Image-to-Prompt Converter

Abstract

The Stable Diffusion model is a prominent text-to-image generation model that relies on a text prompt as its input, which is encoded using the Contrastive LanguageImage Pre-Training (CLIP). However, text prompts have limitations when it comes to incorporating implicit information from reference images. Existing methods have attempted to address this limitation by employing expensive training procedures involving millions of training samples for image-to-image generation. In contrast, this paper demonstrates that the CLIP model, as utilized in Stable Diffusion, inherently possesses the ability to instantaneously convert images into text prompts. Such an image-to-prompt conversion can be achieved by utilizing a linear projection matrix that is calculated in a closed form. Moreover, the paper showcases that this capability can be further enhanced by either utilizing a small amount of similar-domain training data (approximately 100 images) or incorporating several online training steps (around 30 iterations) on the reference images. By leveraging these approaches, the proposed method offers a simple and flexible solution to bridge the gap between images and text prompts. This methodology can be applied to various tasks such as image variation and image editing, facilitating more effective and seamless interaction between images and textual prompts.

1 Introduction

In recent years, there has been a surge of interest in vision-and-language research, particularly in the field of text-to-image generation. Prominent models in this domain include autoregression models like DALL-E [1] and Make-A-Scene [2], as well as diffusion models like DALL-E 2 [3] and Stable Diffusion [4]. These models have revolutionized the quality of generated images. They leverage text prompts to synthesize images depicting various objects and scenes that align with the given text. Among these models, Stable Diffusion [4] stands out as a significant open-source model. It serves as a foundation for many recent works, including image generation [5, 6, 7, 8], image editing [9, 10, 11, 12, 13, 14], and more.

∗

This work was done while Yuxuan Ding was visiting The University of Adelaide as a visiting researcher.

<sos>

cat

on

bed

<eos>

<sos>

cat

on

bed

<eos>

However, text prompts have limitations when it comes to incorporating unspeakable information from reference images. It becomes challenging to generate a perfect and detailed prompt when users want to synthesize images related to a picture they have seen. Image variation techniques aim to address this limitation by enabling users to generate multiple variations of an input image, without relying on complex prompts. As illustrated in Fig. 1, the generated variations closely resemble the reference image, often sharing the same scene or objects but with distinct details.

Stable Diffusion Reimagine (SD-R) [4] 3 is a recently proposed image variation algorithm. It achieves this goal by retraining Stable Diffusion [4], where the text encoder is replaced with an image encoder to adapt the model for image input. The model is trained using millions of images and over 200,000 GPU-hours, enabling it to effectively generate image variations based on reference images.

In this paper, we make a significant discovery that allows a more cost-effective image-to-prompt conversion approach. We find the CLIP model [15], as utilized in Stable Diffusion, can be repurposed as an effective image-to-prompt converter. This converter can be directly employed or served as a valuable initialization for a data-efficient fine-tuning process. As a result, the expenses associated with constructing or customizing an image-to-prompt converter can be substantially reduced.

More specifically, our method is built upon a surprising discovery: the control of image generation through text is primarily influenced by the embedding of the end-of-sentence (EOS) token. We found that masking all word tokens, except for the start and end tokens, does not adversely affect the quality of image generation, as illustrated in Figure 2. Simultaneously, during CLIP training, the projection of the end-token embedding is trained to align with the visual embedding. This inherent relationship enables us to derive a closed-form projection matrix that converts visual embedding into an embedding that is capable of controlling the generation of Stable Diffusion [4]. We call this method Stable Diffusion Image-to-Prompt Conversion (SD-IPC).

In addition, we introduce two methods to enhance the quality and flexibility of image-to-prompt conversion. The first approach involves parameter-efficient tuning using a small amount of data, consisting of only 100 images and requiring just 1 GPU-hour. This method encourages the model to better preserve image information and enables practitioners to control the specific content they want to retain when generating new images. The second approach involves customizing the model on reference images using a few iterations, ensuring that the generated images are closer to specific concepts. While this approach has been explored in previous research, we demonstrate that with the advantageous initialization provided by SD-IPC, the online fine-tuning requires significantly fewer iterations to achieve desirable results.

2 Background and Related Works

2.1 Diffusion Model

Firstly, we present a brief overview of the Stable Diffusion [4], which serves as our underlying model. Diffusion models (DMs) [16, 17, 18, 19] belong to a class of latent variable models. In DMs, there exist two Markov chains known as the diffusion process and the reverse process , both having a fixed

length T . The diffusion process progressively introduces Gaussian noise to the original data ( x 0 ) until the signal becomes corrupted ( x T ). During DMs training, the reverse process is learned, which operates in the opposite direction of the diffusion process. The reverse process can be viewed as a denoising procedure, moving from x t to x t -1 at each step. After multiple denoising steps, the model obtains instances that closely resemble the real data.

Stable Diffusion [4] is built on the Latent Diffusion Model (LDM) [4]. LDM [4] proposed to do diffusion process in a latent space rather than the usual pixel space, significantly reducing the training and inference cost of the diffusion model. The authors proposed to utilize a VAE compression to get the latent code z 0 , which is x 0 above. Diffusion process will build on the latents. A U-Net architecture [17] with timestep and text conditions would do the reverse. The text prompt is injected into the model with cross-attention layers. We denote ϵ θ ( z t , c txt ( p txt ) , t ) as the output of the U-Net, which is the predicted denoising result. p txt is the textual prompt and c txt ( p txt ) is the prompt embedding from the text encoder. t is the timestep. The training objective of DMs is as followed:

where ϵ ∼ N ( 0 , I ) is the noise used to corrupt clean latent variables. During the generation, the latent z t , which starts at a random Gaussian noise z T , will recursively go through a denoising operation until z 0 is sampled. Finally, z 0 is reconstructed to an image by the V AE.

2.2 CLIP Model

The CLIP model [15] has garnered significant acclaim as a groundbreaking zero-shot model in recent years. Its training process demands optimizing a contrastive loss function using extensive 400-million pairs of images and corresponding text descriptions. Through the meticulous training, the model has been able to achieve unparalleled capabilities in zero-shot classification and image-text retrieval.

The model comprises an image encoder CLIP i ( · ) , a text encoder CLIP t ( · ) , a visual projection layer W i , and a textual projection layer W t . The image encoder encodes an input image x into a visual embedding f img derived from a special class-token. By applying the visual projection layer, the embedding is projected into the CLIP visual embedding f c img . Similarly, the text encoder processes the input text, yielding a sequence of output embeddings f txt for each text token and a start token and end-of-sentence (EOS) )token. The embedding of the EOS token f t, ⟨ eos ⟩ txt , where t denotes the length of the sentence, is projected into the CLIP textual embedding f c txt through W t . Formally,

The training objective of CLIP is to maximize the cosine similarity between f c txt and f c img for matched sentence-image pair while minimizing this similarity for unmatched pairs. For the simplicity of discussion, we denote the space spanned by f txt as T -space and the space spanned by f c ∗ as C -space.

The CLIP text encoder [15] is directly used in Stable Diffusion to encode text prompts. It encodes a text prompt as a sequence of embeddings:

where f 0 , ⟨ sos ⟩ txt , f i,w txt and f t, ⟨ eos ⟩ txt denote the embeddings corresponding to the start-token, the i -th word token and end-token, respectively. From f t +1 , ⟨ eos ⟩ txt to f 76 , ⟨ eos ⟩ txt are padded tokens.

2.3 Image Variation & Customized Generation

Image Variation. Image variation aims to generate images similar to the reference image but not identical. SD-R [4] is proposed to address this problem, which builds upon the Stable-unCLIP model 4 . The authors fine-tuned the Stable Diffusion model [4] to align with the CLIP visual embedding. In SD-R [4], images can be directly input into the diffusion model through CLIP image encoder. Since the original Stable Diffusion is conditioned on text only, an expensive fine-tuning is required to

accommodate this new input. The process took 200,000 GPU-hours on NVIDIA A100-40GB GPU while our approach only requires 1 GPU-hour on NVIDIA A5000-24GB GPU 5 .

Customized Generation. Recent works such as DreamBooth [11], Textual Inversion [14], and Custom Diffusion [13] focus on learning a special text prompt to feature specific objects or persons from the reference images. For instance, given several photos of a particular cat, these methods use a special-token " ⟨ s ⟩ cat" to represent the concept and incorporate it with the text prompt. DreamBooth [11] and Custom Diffusion [13] also perform simultaneous fine-tuning of diffusion model parameters. However, the fine-tuning process is still somewhat time-consuming, with Custom Diffusion [13] requiring nearly 6 minutes on 2 NVIDIA A100 GPUs. In contrast, our fast update SD-IPC only needs 1 minute on 2 A5000 GPUs.

Image Editing. Stable Diffusion [4] is commonly used for image editing tasks. Prompt-to-Prompt [9] and Plug-and-Play [10] utilize attention map as a bridge to enable concept and style manipulation. Null-Text Inversion [20] and Pix2Pix-Zero [21] relies on inversion-based methods. InstructPix2Pix [22] creates a dataset of paired edited images and fine-tunes Stable Diffusion [4] as an editing model. It's important to highlight that while our primary focus in developing this method was to enhance image variation, it can also be employed to generate images based on prompts that combine both textual instructions and accompanying images. Notably, unlike existing approaches that frequently reproduce the layout of the original image in the generated output, our method operates without being confined to replicating the exact layout of the source image.

3 Methodology

3.1 Image-to-Prompt Conversion via Projecting CLIP embedding

By design, the image generation process in the stable diffusion model should be influenced by embeddings of all tokens in a prompt, like Eq. (4). Interestingly, we have discovered that masking word tokens, by setting their attention weights to 0 except for the start-/end-token, does not have a negative impact on the quality of generated images. This finding is visually illustrated in Figure 2.

On another note, the training objective of CLIP [15] is to match the embeddings f c img and f c txt , with f c txt being essentially a projection of f t, ⟨ eos ⟩ txt . This inherent relationship, coupled with the aforementioned observation, leads us to establish a connection between f c img and f t, ⟨ eos ⟩ txt , effectively converting the visual embedding to a prompt embedding.

Formally, we assume that after training, CLIP model can induce high cosine similarity between the f c img and f txt and we can further make the following approximation:

By using Moore-Penrose pseudo-inverse [23] on W t 6 , we obtain an estimate of f t, ⟨ eos ⟩ txt from f c img :

where we empirically observe ∥ f c txt ∥ can be well approximated by a constant, e.g., ∥ f c txt ∥ = 27 and W t can be obtained from the pretrained CLIP model [15]. We denote the converted embedding as f cnvrt txt and use it to assemble a pseudo-prompt sequence with the following format:

where f 1 ,cnvrt txt = · · · = f 76 ,cnvrt txt = f cnvrt txt . In other words, we replace all word-tokens, pad-tokens and end-token in Eq. (4) with the converted f cnvrt txt , based on the fact that f cnvrt txt is an approximation of f t, ⟨ eos ⟩ txt and masking word-tokens does not influence the generation 7 .

Input Images

SD-R

SD-IPC (Ours)

SD

w/ Text

8

This approximation allows immediate conversion of an image to a text prompt by directly mapping it to an (approximately) equivalent prompt. We refer to this method as Stable Diffusion Image-toPrompt Conversion (SD-IPC). Experimental results in Fig. 3 demonstrate that SD-IPC effectively captures the semantic information present in the reference image and enables image variation.

Furthermore, we have identified a simple yet effective approach to combine both the text prompt and the converted image prompt within our framework. To achieve this, we perform a weighted average of the two embeddings. Formally, the process can be described as follows:

where f i,comb text = f comb text is the combined-token embedding and α is a hyperparameter to control the expression of editing text. Notice that the editing word-token f i,w txt are also in the embedding sequence. Conditioning on ˜ f edit text could generate images that match both the visual and textual conditions. We report some editing results in Appendix D.2.

3.2 Fine-tuning with Image-to-Prompt Conversion

While the aforementioned SD-IPC method demonstrates reasonable performance, it still faces challenges when it comes to real-world applications due to two main reasons. Firstly, the conversion process in SD-IPC relies on approximations, which may not always yield optimal results. Secondly, determining the exact topic or theme of an image introduces ambiguity. As the saying goes, "an image is worth a thousand words", but precisely which words? The same reference image can be interpreted differently based on its objects, scenes, styles, or the identities of people depicted within. Therefore, it becomes crucial to have a method that allows control of the content we wish to preserve and convert into the prompt. To address these concerns and cater to the needs, we propose a partial fine-tuning approach for the CLIP converter derived from Sec. 3.1.

In proposed approach, we focus on fine-tuning two specific types of parameters. Firstly, we address the optimization of the projection matrix within the cross-attention layer of the U-Net in Stable Diffusion [4]. This aspect aligns with the methodology employed in Custom Diffusion [13]. Furthermore, we incorporate deep prompt tuning [25] into the transformer of the CLIP image encoder. Deep prompt tuning [25] introduces learnable tokens within all layers of the transformer while keeping the weights of other components fixed. More details can be found in Appendix A.

Input Images

SD-R

SD-IPC-FT

(Ours)

SD-IPC (Ours)

ImageNet Finetuned

CelebA-HQ Finetuned

Places365 Finetuned

The parameters can be learned by using the following loss:

here the first term is L cnvrt , which is fine-tuning with the image-to-prompt input, and the second term is L text , which is the original text-to-image training loss, we utilize this as a regularization to keep the text-to-image generation. In the proposed approach, c img ( · ) refers to the image-to-prompt conversion derived from SD-IPC. It encompasses the CLIP image transformer augmented with the newly-introduced learnable prompts in deep prompting and the fixed inverse matrix derived from Eq. (6). During tuning, the inverse projection matrix remains unchanged. z t represents the latent representation of the target image x target at time step t . The objective function aims to encourage the image-to-prompt conversion to extract information from x ref that facilitates the recovery of x target . There are two possible choices for x target : (1) x target can be selected to be the same as x ref . (2) x target and x ref can be different images, but with a shared visual concept that we intend to extract as the prompt. This usually poses stronger supervision to encourage the converter to extract information related to the shared theme. The schematic representation of this scheme is illustrated in Appendix C.2.

We use images randomly sampled from ImageNet [26], CelebA-HQ [27], and Places365 [28] dataset to encourage the model extract object, identity, and scene information, respectively. Experiments show that merely 100 images and 1 GPU-hour of training are sufficient for achieving satisfied results thanks to the good initialization provided by SD-IPC. We call this approach SD-IPC-FT , the results are shown in Fig. 4. Some editing examples are listed in Fig. 5, Fig. 6, and Appendix D.4.

3.3 Fast Update for Customized Generation

Existing methods, such as DreamBooth [11] and Custom Diffusion [13], suggest that partially finetuning the model on given concept images before generation can be an effective way to synthesized images with customized visual concepts, e.g. , people with the same identity. Our approach can also benefit from this scheme by performing such an online update with SD-IPC. This can be achieved by simply replacing the training images in SD-IPC-FT with reference images and use L convrt only. We call this method SD-IPC-CT (CT stands for customized concept tuning). Interestingly, we find that our method can generate customized images with much fewer updates. As a comparison, SD-IPC-CT only takes 30-iteration updates with around 1 minute on 2 A5000 GPUs while the Custom Diffusion [13] needs 250 iterations (6 minutes on 2 A100 GPUs). We report customized generation in Fig. 7.

Input Images

'

On the beach

'

'

Under the starry sky

'

SD-R

Without Editing

SD-R

SD-IPC-FT

(Ours)

SD-R

SD-IPC-FT

(Ours)

SD-IPC-FT

(Ours)

Input Images

'

Wearing glasses

'

'

Wearing a hat

'

SD-R

Without Editing

SD-R

SD-IPC-FT

(Ours)

SD-R

SD-IPC-FT

(Ours)

SD-IPC-FT

(Ours)

4 Experiments

4.1 Training Details

Datasets & Evaluations. In previous discussion, we propose three different fine-tuning schemes, using ImageNet [26] for object understanding, CelebA-HQ [27] for portrait understanding, and Places365 [28] for scene understanding. The specific training classes or identities we have selected for each dataset can be found in Appendix B. Each dataset includes 100 images, the test images are non-overlap with the training classes. In order to enable customized generation, we choose two objects and two identities as examples, each accompanied by five images. To assess the quality and semantic consistency of our generated outputs, we measure FID-Score [29] and CLIP-Score [30].

Architecture & Hyperparameter. We utilize Stable Diffusion v1.4 8 and CLIP ViT-L/14 9 models in this paper. We compare our method with the larger Stable-unCLIP-small model 10 using CLIP ViT-H/14 and a 1,024-dimensional attention feature. Our method uses DDIM [19] for sampling, while

SD-IPC-FT

(Ours)

Custom

Diffusion

SD-IPC-FT

(Ours)

Custom

Diffusion

SD-IPC-FT

(Ours)

Custom

Diffusion

Without Editing

Without Editing

'Rainbow color hair'

'Young bog/girl'

'On the bed'

'Pink furry'

Training

Images

SD-IPC-CT

(Ours)

DreamBooth

Custom

Diffusion

Textual

Inversion

A [V] cat in

the snow.

A [V] cat on a

cobblestone

street.

A [V] cat

floating on top

of water.

A [V] cat with

a blue house in

the background.

A purple [V]

cat.

A [V] cat with

a wheat field in

the background.

Stable-unCLIP uses PNDM [31], both with 50 sampling steps. SD-IPC-FT is trained for 100, 50, and 100 epochs on ImageNet [26], CelebA-HQ [27], and Places365 [28], respectively. The learning rates for all datasets are 1 e -5 with cosine decay. Customized generation has a constant learning rate of 5 e -6 for 30-iteration updates. Training is conducted on 2 A5000 GPUs. The editing α is set to 0.9.

4.2 Image Variation Results

SD-IPC. We evaluate image variation on MSCOCO [24] using all 5,000 images in the 2017-split validation set. Fig. 3 compares text-based generation, SD-R [4], and our SD-IPC. Both SD-R [4]

and our method demonstrate image variation, but our approach utilizes an inverse matrix without training. The FID-Score [29] and CLIP-Score [30] are reported in Tab. 2. Our SD-IPC maintains image quality similar to text-based generation (FID-Score: 24.78 vs. 23.65, CLIP-Score: 73.57 vs. 70.15). Note that SD-R [4] achieves better results due to its advanced backbone model.

Finetuning. In Fig. 4, it is observed that SD-IPC may exhibit inconsistency, for example, the input "teddybear" generates a picture of "kid". This inconsistency could be attributed to fact that SD-IPC fails to discern the semantically related concepts "kid" and "teddybear". However, this issue can be rectified through fine-tuning, as demonstrated in Fig. 4, SD-IPC-FT achieves improved generation quality. Moreover, we find that the editing capability of SD-IPC-FT, as illustrated in Fig. 5, Fig. 6, and Appendix D.4, surpasses that of SD-R [4], and fine-tuning does not impact the editing performance. We incorporated a quantitative experiment to validate the superior editing performance of SD-IPC-FT in comparison to SD-R [4]. We utilize images from DreamBooth [11] benchmark and randomly select an editing text for each test image. Editing performance is evaluated using CLIP-T score, the quantitative results are presented in Tab. 4. As seen, our method achieves a higher CLIP-T score than SD-R [4]. Furthermore, we include the training-free SD-IPC for comparison, revealing even SD-IPC slightly outperforms SD-R [4]. The role of different target images used in the fine-tuning stage is outlined in Appendix C.2, which showcases how the choice of target images influences the generation result. Additional generation results are presented in Appendix D.

4.3 Customized Generation Results

In Fig. 7, we compare our SD-IPC-CT with Custom Diffusion [13] in terms of customized generation. We evaluate customization for two identities ("Obama" and "Chastain") and two objects ("cat" and "tortoise"). The training process only requires 5 images and 30 iterations. The results in Fig. 7 reveal that Custom Diffusion [13] struggles to learn the details of the concept with such limited updates, while our SD-IPC-CT demonstrates impressive performance, particularly in the "young boy/girl" editing. However, for rare instances like the "tortoise" example, both methods do not perform well. For quantitative results, we followed DreamBooth [11]. We used DINO and CLIP-I for subject fidelity and CLIP-T for editing performance. Comparing with DreamBooth [11], Textual Inversion [14], and Custom Diffusion [13], the results are in Tab. 3, Fig. 8, and Appendix D.5. DreamBooth [11] excels in DINO/CLIP-I scores but lags in CLIP-T, indicating limited editing performance, evident in visually similar outputs to training images. Textual Inversion [14] and Custom Diffusion [13] have strong CLIP-T but weak DINO/CLIP-I scores, indicating challenges in preserving subject details. Our SD-IPC-CT method strikes a balance between subject identity preservation and editing performance.

4.4 Ablation Study

Effectiveness of Inverse Projection Matrix. To evaluate the effectiveness of the inverse projection matrix in SD-IPC, we introduce a fully-connected layer instead of the inverse matrix in the image-toprompt conversion, referred to as SD-IPC-FC and SD-IPC-FC(I), where (I) means to initialize with

Input

Images

SD-IPC

SD-IPC

-FT (C)

SD-IPC

-FT (U)

SD-IPC-FC

SD-IPC-FT

SD-IPC

-FC (I)

SD-IPC-FC

SD-IPC-FT

(Ours)

Input Images

our inverse projection matrix. We train the FC models with the same training data as SD-IPC-FT. However, the results in Fig. 10 indicate SD-IPC-FC suffers from overfitting. SD-IPC-FC(I) slightly alleviates the overfitting but still gets inferior results, shown in Fig. 9. This highlights that our SD-IPC-FT benefits from the good initialization of SD-IPC and preserves knowledge in CLIP [15].

Prompt Learning & U-Net Fine-tuning. We perform quantitative tests on (text-edited) image variation for the comprehensive ablation studies following the testing in Sec. 4.2. For text-edited variation, we use the editing text as the prompt, such as "A [Class Name] with a mountain in the background.". We present the results of individual fine-tuning for two components: SD-IPC-FT (C) for CLIP and SD-IPC-FT (U) for the U-Net. Qualitative results are available in Fig. 9, while quantitative results are provided in Tab. 5 and Tab. 6. It demonstrates that fine-tuning each component contributes to model adaptation, with the best performance achieved when simultaneously fine-tuning both two parts. Some editing comparisons are in Appendix C.3.

Additionally, we investigate the influence of the editing parameter α in Appendix C.1.

4.5 Limitations & Feature Directions

While SD-IPC offers an alternative to SD-R [4], there are remaining challenges. Firstly, the editing text must be contextually appropriate, as using "on the beach" to edit a portrait may result in a person being on the beach but lacking facial features. Secondly, SD-IPC currently does not support multiple image inputs. Another future study is to extend our method to generate a sequence of images with consistency. Appendix E shows some potential of our method in this direction.

5 Conclusion

This paper reveals that the CLIP model [15] serves as an image-to-prompt converter, enabling image variation in text-to-image Stable Diffusion [4] without extensive training. This finding enhances our understanding of the CLIP embedding space, demonstrating that a simple inverse matrix can convert visual embeddings into textual prompts. Leveraging this image-to-prompt conversion, our SD-IPC methods achieve impressive image variation and editing capabilities, while also enabling fast adaptation for customized generation. Experimental results also show the potential of our method in more multi-modal tasks. We anticipate that this study will inspire future research exploring the image-to-prompt pathway in CLIP-based or LDM-based models.

References

Ramesh, A., M. Pavlov, G. Goh, et al. Zero-shot text-to-image generation. In International Conference on Machine Learning , pages 8821-8831. PMLR, 2021.

Gafni, O., A. Polyak, O. Ashual, et al. Make-a-scene: Scene-based text-to-image generation with human priors. In Computer Vision-ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23-27, 2022, Proceedings, Part XV , pages 89-106. Springer, 2022.

Ramesh, A., P. Dhariwal, A. Nichol, et al. Hierarchical text-conditional image generation with clip latents. arXiv preprint arXiv:2204.06125 , 2022.

Rombach, R., A. Blattmann, D. Lorenz, et al. High-resolution image synthesis with latent diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition , pages 10684-10695. 2022.

Feng, W., X. He, T.-J. Fu, et al. Training-free structured diffusion guidance for compositional text-to-image synthesis. arXiv preprint arXiv:2212.05032 , 2022.

Liu, N., S. Li, Y . Du, et al. Compositional visual generation with composable diffusion models. In Computer Vision-ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23-27, 2022, Proceedings, Part XVII , pages 423-439. Springer, 2022.

Chefer, H., Y. Alaluf, Y. Vinker, et al. Attend-and-excite: Attention-based semantic guidance for text-to-image diffusion models. arXiv preprint arXiv:2301.13826 , 2023.

Zhang, L., M. Agrawala. Adding conditional control to text-to-image diffusion models. arXiv preprint arXiv:2302.05543 , 2023.

Hertz, A., R. Mokady, J. Tenenbaum, et al. Prompt-to-prompt image editing with cross attention control. arXiv preprint arXiv:2208.01626 , 2022.

Tumanyan, N., M. Geyer, S. Bagon, et al. Plug-and-play diffusion features for text-driven image-to-image translation. arXiv preprint arXiv:2211.12572 , 2022.

Ruiz, N., Y. Li, V . Jampani, et al. Dreambooth: Fine tuning text-to-image diffusion models for subject-driven generation. arXiv preprint arXiv:2208.12242 , 2022.

Kawar, B., S. Zada, O. Lang, et al. Imagic: Text-based real image editing with diffusion models. arXiv preprint arXiv:2210.09276 , 2022.

Kumari, N., B. Zhang, R. Zhang, et al. Multi-concept customization of text-to-image diffusion. In CVPR . 2023.

Gal, R., Y. Alaluf, Y. Atzmon, et al. An image is worth one word: Personalizing text-to-image generation using textual inversion. arXiv preprint arXiv:2208.01618 , 2022.

Radford, A., J. W. Kim, C. Hallacy, et al. Learning transferable visual models from natural language supervision. In International conference on machine learning , pages 8748-8763. PMLR, 2021.

Sohl-Dickstein, J., E. Weiss, N. Maheswaranathan, et al. Deep unsupervised learning using nonequilibrium thermodynamics. In International Conference on Machine Learning , pages 2256-2265. PMLR, 2015.

Ho, J., A. Jain, P. Abbeel. Denoising diffusion probabilistic models. Advances in Neural Information Processing Systems , 33:6840-6851, 2020.

Dhariwal, P., A. Nichol. Diffusion models beat gans on image synthesis. Advances in Neural Information Processing Systems , 34:8780-8794, 2021.

Song, J., C. Meng, S. Ermon. Denoising diffusion implicit models. arXiv preprint arXiv:2010.02502 , 2020.

Mokady, R., A. Hertz, K. Aberman, et al. Null-text inversion for editing real images using guided diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition , pages 6038-6047. 2023.

Parmar, G., K. Kumar Singh, R. Zhang, et al. Zero-shot image-to-image translation. In ACM SIGGRAPH 2023 Conference Proceedings , pages 1-11. 2023.

Brooks, T., A. Holynski, A. A. Efros. Instructpix2pix: Learning to follow image editing instructions. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition , pages 18392-18402. 2023.

Penrose, R. A generalized inverse for matrices. In Mathematical proceedings of the Cambridge philosophical society , vol. 51, pages 406-413. Cambridge University Press, 1955.

Lin, T.-Y., M. Maire, S. Belongie, et al. Microsoft coco: Common objects in context. In Computer Vision-ECCV 2014: 13th European Conference, Zurich, Switzerland, September 6-12, 2014, Proceedings, Part V 13 , pages 740-755. Springer, 2014.

Jia, M., L. Tang, B.-C. Chen, et al. Visual prompt tuning. In Computer Vision-ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23-27, 2022, Proceedings, Part XXXIII , pages 709-727. Springer, 2022.

Deng, J., W. Dong, R. Socher, et al. Imagenet: A large-scale hierarchical image database. In 2009 IEEE conference on computer vision and pattern recognition , pages 248-255. Ieee, 2009.

Karras, T., T. Aila, S. Laine, et al. Progressive growing of gans for improved quality, stability, and variation. In International Conference on Learning Representations . 2018.

Zhou, B., A. Lapedriza, A. Khosla, et al. Places: A 10 million image database for scene recognition. IEEE transactions on pattern analysis and machine intelligence , 40(6):1452-1464, 2017.

Heusel, M., H. Ramsauer, T. Unterthiner, et al. Gans trained by a two time-scale update rule converge to a local nash equilibrium. Advances in neural information processing systems , 30, 2017.

Hessel, J., A. Holtzman, M. Forbes, et al. Clipscore: A reference-free evaluation metric for image captioning. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing , pages 7514-7528. 2021.

Liu, L., Y. Ren, Z. Lin, et al. Pseudo numerical methods for diffusion models on manifolds. In International Conference on Learning Representations . 2022.

Peer reviews:
comments: SUMMARY:
This paper demonstrates that the CLIP model in Stable Diffusion inherently possesses the ability to convert images into text prompts, which can be achieved by utilizing a linear projection matrix that is calculated in a closed form.

STRENGTHS:
1. The motivation of image-to-prompt conversion is clear and the proposed closed-form method is concise.
2. The capability of image-to-prompt conversion can be further enhanced by finetuning the model with a small amount of data and time.
3. The paper demonstrates various applications of the method.

WEAKNESSES:
1. The main concern lies in the experiments section:
(1) The quantitative comparison between SD-IPC and SD-IPC-FT can be given. And the quantitative and qualitative results when separately fine-tuning the two specific types of parameters (cross-attention layers or deep prompts) also can be given.
(2) Why not SD-IPC adopts the backbone of  SD-R, i.e.,  Stable Diffusion v2.1 ?
(3) In Sec.4.3, I suggest the paper adopts the dataset and edited prompt used by DreamBooth (https://github.com/google/dreambooth) to make a full comparison. Both qualitative and quantitative results should be presented. And the proposed method can also be compared with more methods (e.g., DreamBooth and Textual Inversion).
(4) It would be better if the quantitative results of the first ablation experiment are presented.
2. The motivation for applying deep prompts tuning in SD-IPC-FT needs to be further explained.
3. The editability of the proposed method may be limited.

QUESTIONS:
Please see the weaknesses. I am willing to improve my score if the concerns are addressed.

LIMITATIONS:
The limitations have been described in the paper.
TITLE: Official Review
SOUNDNESS_CORRECTNESS: 3
DATE: 2023-07-06

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper focuses on the problem of generating images by a reference image w/ or w/o further text guidance. The core of this problem partly lies in how to convert the images to embeddings that can be directly feed into Stable Diffusion model. To this end, the authors propose to leverage CLIP model, the text encoder of which is also part of the stable diffusion model. They compare results with Stable Diffusion Re-imagination, as well as Custom diffusion.\n\nSTRENGTHS:\nThe strengths are as follows:\n\n- This is a timely interesting topic. How to generate new images by a referring image has been an interesting problem, especially given the recent burst of diffusion models. Compared to previous method such as Dreambooth, this method is light-weight. Authors even provided a version without any fine-tuning, though the performance may not be that good. But the authors also provide a easy-to-finetune pipleline which seems to largely improve the performance\n\n- The training cost is much lower. Compared to SD-R which requires 200,000 GPU-hours, this method here reduced the cost to only 100 images with 1 GPU-hour. Compared to Custom Diffusion which requires 250 iterations of fine-tuning, this paper only required ~30 steps.\n\n- This paper provides the generation capability both w/ or w/o text, in addition to the reference image. This is a nice property.\n\n- The results look reasonable.\n\nWEAKNESSES:\nThe first thing to improve might be the writing.\n\n(1) The abstract part can be improved. When I first read the abstract without knowing the main text, I was a bit struggling to understand which exactly problem this paper is particularly trying to solve. Converting image to text? Improving Diffusion? or Image-to-Image generation? This part can be clearer.\n\n(2) There is actually not much contents discussing related work, despite the existence of section 2. I would recommend authors have a separate related section, that discuss prior work sufficiently. For example, the current 2.3 section only discussed SD-R and just mentioned dreambooth, textual inversion, and custom diffusion. But there are more works, such as instructpix2pix, plug-and-play, etc. The similarities and differences can be articulated. Besides, much background contents in section 2 cam actually be cut, e.g., line 81-84.\n\n(3) The formulation in Section 3 can be improved. E.g., where is the 76 comes from? This is not obvious for people unfamiliar with the CLIP details. When you combine text prompt and converted image prompt in equation (8), how do you do that clearly?\n\n(4) you can have a figure illustrating the fine-tuning process in section 3.2\n\nThe next question I have is that, can this method be generally applied to other text-to-image diffusion models. It seems to me that this paper exploits the prior knowledge that stable diffusion used CLIP text encoder, thus you can use text image encoder to convert image to text prompt. This is fine, but would this still work with other approaches such as imagen that relies on T5 model? e.g. dreambooth is agnostic to the text encoder and thus is more generic.\n\nWhile the authors claimed this method is cost effective compared to the the SD-R trained on millions of images and over 200,000 GPU hours, has the author measured the out-of-distribution capability sufficiently? e.g. SD-R may just train once, and generalize to all images, but this method needs to be trained for each domain.\n\nDetailed question:\n\n(1) it seems the way you combine text and image prompts in eq (8) is adhoc, what if the text tokens are longer than 76, then where do you put those $f_{txt}^{comb}$? This seems technically problematic.\n(2) For line 133, you assumed the norm to be 27 as a constant, which seems also problematic to me. This feels not rigorous. One better way to justify this is to visualize the histograms of the norms.\n(3) for imagenet, cele-A, and places fine-tuning using equation (9), how do you get the text, image pair for the $L_{text}$?\n\n\nResults section:\n\n(1) directly compared the SD-IPC-FT w/ text version with SD-R is apple-to-orange. The SD-R just uses image as guidance, you should compare the SD-IPC ( w/ or w/o FT) version that only uses images as well. You can have w/ and w/o text results both there.\n(2) No quantitative comparison between SD-IPC-FT with custom diffusion.\n(3) seems SD-R without text input is still better in Table 2?\n(4) custom diffusion accept multiple concepts, but seems this method is not able to.\n(5) In figure 9, for SD-IPC-FC, what if you initialize the fc layer from the closed form inverse projection, but make it trainable?\n\nQUESTIONS:\nsee above\n\nLIMITATIONS:\nI guess two obvious limitation are:\n(1) may only work for text-to-image models that relies on CLIP encoder\n(2) need to get re-trained every time for a new domain.", "TITLE": "Official Review", "RECOMMENDATION": 5, "REVIEWER_CONFIDENCE": 3, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2023-07-06"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper titled presents a method called Stable Diffusion Image-to-Prompt Conversion (SD-IPC) that leverages the inherent capabilities of the Contrastive Language-Image Pre-Training (CLIP) model to convert images into text prompts for image generation tasks. The authors start from the analysis that the control of image generation through text is primarily influenced by the embedding of the end-of-sentence (EOS) token, and masking other word tokens does not significantly affect the quality of image generation. From this constatation, they derive a closed-form projection matrix that converts visual embeddings into text embeddings and use them to control the Stable Diffusion image generation process.\n\nSTRENGTHS:\n**Technical soundness** The paper is well written and the explanation of the underlying mechanisms of the CLIP model and its relationship with image generation is made intuitive. \n\n**Simple and clever visual-to-prompt embedding conversion** The paper presents a straightforward yet ingenious approach to convert images into text prompts by inverting the textual projection layer. This conversion allows for image variations and editing, effectively bridging the gap between images and textual prompts. The simplicity and cleverness of this method contribute to its practicality and usability.\n\n**Efficient variation model learning through fine-tuning** The authors propose two methods to enhance the quality and flexibility of image-to-prompt conversion. The first method involves parameter-efficient tuning using a small amount of data, requiring minimal computational resources and time. This approach enables efficient learning of the variation model, making it practical for real-world applications.\n\n**Visually sound generations and variations** The paper showcases visually sound image generations and variations achieved through the proposed SD-IPC method. By leveraging the inherent capabilities of the CLIP model, the generated images align well with the desired concepts and demonstrate high-quality results.\n\nWEAKNESSES:\nThe method is only compared with SD-R and the inclusion of additional comparisons with existing methods could have further strengthened the paper in particular for the evaluation of the editing capability of the method.\n\nQUESTIONS:\nAs the authors said, the approximation of the inversion of the textual projection matrix may be a source of suboptimal results. How does this impact the generation process?\n\nLIMITATIONS:\nThe authors show some limitations in their work including the need for coherence between the editing prompt and the target image or the lack of multiple target images.", "TITLE": "Official Review", "RECOMMENDATION": 7, "REVIEWER_CONFIDENCE": 3, "SOUNDNESS_CORRECTNESS": 4, "DATE": "2023-07-06"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper demonstrates that the CLIP model, used in Stable Diffusion, inherently possesses the ability to convert images into text prompts. They achieve this by utilizing a linear projection matrix calculated in a closed form. Furthermore, the paper shows that this capability can be enhanced by incorporating a small amount of similar-domain training data or performing online training steps on reference images. These approaches offer a simple and flexible solution to bridge the gap between images and text prompts, enabling more effective interaction between the two modalities.\n\nSTRENGTHS:\n1. This paper is well organized and the motivation is good. The basic idea of Image-to-Prompt Conversion is simple but interesting. I like the idea of using a closed-form projection matrix to converts the visual embeddings into the semantic prompt which can help control the stable diffusion.\n2. The insights about start-/end-token's attention map for stable diffusion are impressive.\n3. The proposed methods' finetuning time of customized generation is significantly faster than the current methods.\n\nWEAKNESSES:\n1. Although the basic idea of the paper is cool, the visual results of SD-IPC and SD-IPC-FT do not have sufficient preponderance over than previous methods.\n2. This paper only compares proposed methods with Customized Generation and SD-R. I think the authors should also add experiments to compare the SD-IPC-FT with DreamBooth (with and w/o LoRA), textual inversion and Reference-only module for controlnet. \n3. As shown in Table 2, SD-IPC achieves worst FID which means they output the most unrealistic methods. Besides, the CLIP-Score are also not good enough. I think authors should add more explanations of these tables in the SD-IPC part in section 4.2. Aslo, more comparisons should be added in these tables.\n\nQUESTIONS:\n1. Since SD-IPC and textual inversion all aims to convert the visual embeddings into the text prompt, detailed comparison with it should be included in this part. From my point of view, SD-IPC is just a simplified textual inversion method.\n2. For Customized Generation, more comparisons should be provided in this paper.\n\nLIMITATIONS:\nNot applicable.", "TITLE": "Official Review", "RECOMMENDATION": 5, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2023-07-07"}