ControlNet Aligner: 基於ControlNet的結合參考對象之文本至圖像生成模型
ControlNet Aligner: A ControlNet-Based Subject-Driven Text-to-Image Generation Model
摘要
我們提出了一個架構,能夠讓使用者輸入一段文字加上一張圖片作為參考,生出符合文字敘述的圖片,不需要額外的訓練時間且能保證參考圖與生成圖片之關聯性。使用文字作為條件生成圖片是擴散模型其中一項重要的功能。在文字生成圖片的任務中,我們希望能夠以一張圖片作為參考,產生符合文字敘述之圖片,同時能夠保有參考圖片的特徵。我們使用StanfordCars資料集中的車輛之圖片作為我們的參考圖片,並使用FastComposer 提到之方法,訓練模型將車輛圖片與該圖片代表的文字(在本實驗中為英文單字”car”) 之嵌入向量進行融合,讓預訓練StableDiffusion模型能夠生出該車輛的圖片並符合輸入之文字條件。然而經過實驗我們發現,該方法生成之車輛圖片雖然形狀大致正確,顏色卻經常是錯誤的,即此方法存在「色盲」問題。我們也嘗試訓練Controlnet 並將參考之車輛圖片作為Controlnet的輸入,該模型可以做到將車輛剪下並貼到生成的圖片中。此方法生成之車輛形狀及顏色皆與參考圖片相同,然而相較於FastComposer 可以生出各個角度的車輛,這種完全的複製貼上使其使用情境較為狹隘,我們仍然希望生成之圖片可以有更多角度上的變化,因此我們建構了Controlnet Aligner,它是一個能夠在潛空間(latent space) 中修正顏色之模型,並提出了一個架構: 首先將文字與圖片的嵌入向量進行融合以維持參考物件的形狀,ControlnetAligner在潛空間中根據參考物件修正顏色,再利用Controlnet將修正後的圖片作為輸入來產生最終的輸出。這個架構解決了FastComposer的色盲問題,且三個部分皆為單獨訓練,可以隨意替換。
We propose a framework that allows users to input a text description along with a reference image to generate an image that conforms to the textual description. This framework requires no additional training time and ensures the relevance between the reference image and the generated image.
Using text as a condition for generating images is a significant feature of diffusion models. In the task of text-to-image generation, we aim to generate images that conform to the textual description while retaining the features of a reference image. We utilized vehicle images from the Stanford Cars dataset as our reference images and employed the method mentioned in FastComposer. This method trains a model to fuse the embeddings of vehicle images and the corresponding textual representation (the word "car" in our experiment) so that the pre-trained Stable Diffusion model can generate images of the vehicle that match the input text condition. However, our experiments revealed that while the shape of the generated vehicle images was generally correct, the colors were often inaccurate, indicating a "color-blindness" issue in this method. We also attempted to train ControlNet, using the reference vehicle images as input to ControlNet. This model could effectively cut out the vehicle and paste it into the generated image. Although this method produced vehicles with shapes and colors identical to the reference images, it lacked the ability to generate images from various angles. To address this, we constructed ControlNet Aligner, which is capable of correcting colors in the latent space and proposed an integrated framework. First, the embeddings of the text and images are fused to maintain the shape of the reference object. ControlNet Aligner then corrects the color in the latent space based on the reference object, and finally, ControlNet uses the color-corrected image as input to produce the final output. This framework resolves the color blindness issue of FastComposer, and since each component is trained independently, they can be easily replaced as needed.
Using text as a condition for generating images is a significant feature of diffusion models. In the task of text-to-image generation, we aim to generate images that conform to the textual description while retaining the features of a reference image. We utilized vehicle images from the Stanford Cars dataset as our reference images and employed the method mentioned in FastComposer. This method trains a model to fuse the embeddings of vehicle images and the corresponding textual representation (the word "car" in our experiment) so that the pre-trained Stable Diffusion model can generate images of the vehicle that match the input text condition. However, our experiments revealed that while the shape of the generated vehicle images was generally correct, the colors were often inaccurate, indicating a "color-blindness" issue in this method. We also attempted to train ControlNet, using the reference vehicle images as input to ControlNet. This model could effectively cut out the vehicle and paste it into the generated image. Although this method produced vehicles with shapes and colors identical to the reference images, it lacked the ability to generate images from various angles. To address this, we constructed ControlNet Aligner, which is capable of correcting colors in the latent space and proposed an integrated framework. First, the embeddings of the text and images are fused to maintain the shape of the reference object. ControlNet Aligner then corrects the color in the latent space based on the reference object, and finally, ControlNet uses the color-corrected image as input to produce the final output. This framework resolves the color blindness issue of FastComposer, and since each component is trained independently, they can be easily replaced as needed.