Text-to-image personalization
Text-to-Image personalization is a task in deep learning for computer graphics that augments pre-trained text-to-image generative models. In this task, a generative model that was trained on large-scale data (usually a foundation model), is adapted such that it can generate images of novel, user-provided concepts.[1][2] These concepts are typically unseen during training, and may represent specific objects (such as the user's pet) or more abstract categories (new artistic styles[3][4] or object relations[5]).
Text-to-Image personalization methods typically bind the novel (personal) concept to new words in the vocabulary of the model. These words can then be used in future prompts to invoke the concept for subject-driven generation,[6] inpainting, style transfer[7] and even to correct biases in the model. To do so, models either optimize word-embeddings, fine-tune the generative model itself, or employ a mixture of both approaches.
Technology
Text-to-Image personalization was first proposed during August 2022 by two concurrent works, Textual Inversion[8] and DreamBooth.[9]
In both cases, a user provides a few images (typically 3–5) of a concept, like their own dog, together with a coarse descriptor of the concept class (like the word "dog"). The model then learns to represent the subject through a reconstruction based objective, where prompts referring to the subject are expected to reconstruct images from the training set.
In Textual Inversion, the personalized concepts are introduced into the text-to-image model by adding new words to the vocabulary of the model. Typical text-to-image models represent words (and sometimes parts-of-words) as tokens, or indices in a predefined dictionary. During generation, an input prompt is converted into such tokens, each of which is converted into a ‘word-embedding’: a continuous vector representation which is learned for each token as part of the model's training. Textual Inversion proposes to optimize a new word-embedding vector for representing the novel concept. This new embedding vector can then be assigned to a user-chosen string, and invoked whenever the user's prompt contains this string.[8]
In DreamBooth, rather than optimizing a new word vector, the full generative model itself is fine-tuned. The user first selects an existing token, typically one which rarely appears in prompts. The subject itself is then represented by a string containing this token, followed by a coarse descriptor of the subject's class. A prompt describing the subject will then take the form: "A photo of <token> <class>" (e.g. "a photo of sks cat" when learning to represent a specific cat). The text-to-image model is then tuned so that prompts of this form will generate images of the subject.[9]
Textual Inversion
The key idea in textual inversion is to add a new term to the vocabulary of the diffusion model that corresponds to the new (personalized) concept. Textual inversion optimizes the vector embedding of that new term such that using it as an input text prompt will generate images that are similar to given image examples of the concept. The resulting model is extremely light-weight per concept: only 1K long, but succeeds to encode detailed visual properties of the concept.
Extensions
Several approaches were proposed to refine and improve over the original methods. These include the following.
- Low-rank Adaptation (LoRA) - an adapter-based technique for efficient finetuning of models.[10] In the case of text-to-image models, LoRA is typically used to modify the cross-attention layers of a diffusion model.[11]
- Perfusion - a low rank update method that also locks the activations of the key matrix in the diffusion model's cross attention layers to the concept's coarse class.[12]
- Extended Textual Inversion - a technique that learns an individual word embedding for each layer in the diffusion model's denoising network.[13]
- Encoder-based methods that use another neural network to quickly personalize a model[14][15]
Challenges and limitations
Text-to-image personalization methods must contend with several challenges. At their core is the goal of achieving high-fidelity to the personal concept while maintaining high alignment between novel prompts containing the subject, and the generated images (typically referred to as ‘editability’).
Another challenge that personalization methods must contend with is memory requirements. Initial implementations of personalization methods required more than 20 Gigabytes of GPU memory, and more recent approaches have reported requirements of more than 40 Gigabytes.[14] However, optimizations such as Flash Attention[16] have since reduced this requirement considerably.
Approaches that tune the entire generative model may also create checkpoints that are several gigabytes in size, making it difficult to share or store many models. Embedding based approaches require only a few kilobytes, but typically struggle to preserve identity while maintaining editability. More recent approaches have proposed hybrid tuning goals which optimize both an embedding and a subset of network weights. These can reduce storage requirements to as little as 100 Kilobytes while achieving quality comparable to full tuning methods.[12]
Finally, optimization processes can be lengthy, requiring several minutes of tuning for each novel concept. Encoder and quick-tuning methods aim to reduce this to seconds or less[17]
References
- Murphy, Brendan Paul (2022-10-12). "AI image generation is advancing at astronomical speeds. Can we still tell if a picture is fake?". The Conversation. Retrieved 2023-09-14.
- "「好きなキャラに近い絵をAIが量産」――ある概念を"単語"に圧縮し入力テキストに使える技術". ITmedia NEWS (in Japanese). Retrieved 2023-09-14.
- Lanz, Decrypt / Jose Antonio (2023-07-29). "Greg Rutkowski Was Removed From Stable Diffusion, But AI Artists Brought Him Back". Decrypt. Retrieved 2023-09-14.
- Baio, Andy (2022-11-01). "Invasive Diffusion: How one unwilling illustrator found herself turned into an AI model". Waxy.org. Retrieved 2023-09-14.
- Huang, Ziqi; Wu, Tianxing; Jiang, Yuming; Chan, Kelvin C. K.; Liu, Ziwei (2023). "ReVersion: Diffusion-Based Relation Inversion from Images". arXiv:2303.13495 [cs.CV].
- Jr, Edward Ongweso (2022-10-14). "People Are Now Making Fake Selfies With AI". Vice. Retrieved 2023-09-20.
- published, Dave James (2022-12-27). "I thrashed the RTX 4090 for 8 hours straight training Stable Diffusion to paint like my uncle Hermann". PC Gamer. Retrieved 2023-09-20.
- Gal, Rinon; Alaluf, Yuval; Atzmon, Yuval; Patashnik, Or; Bermano, Amit Haim; Chechik, Gal; Cohen-or, Daniel (2022-09-29). "An Image is Worth One Word: Personalizing Text-to-Image Generation using Textual Inversion". arXiv:2208.01618.
{{cite journal}}
: Cite journal requires|journal=
(help) - Ruiz, Nataniel; Li, Yuanzhen; Jampani, Varun; Pritch, Yael; Rubinstein, Michael; Aberman, Kfir (2023). "DreamBooth: Fine Tuning Text-to-Image Diffusion Models for Subject-Driven Generation": 22500–22510. arXiv:2208.12242.
{{cite journal}}
: Cite journal requires|journal=
(help) - Singh, Niharika (2023-02-18). "HuggingFace Publishes LoRA Scripts For Efficient Stable Diffusion Fine-Tuning". MarkTechPost. Retrieved 2023-09-14.
- Hu, Edward J.; Shen, Yelong; Wallis, Phillip; Allen-Zhu, Zeyuan; Li, Yuanzhi; Wang, Shean; Wang, Lu; Chen, Weizhu (2021-10-06). "LoRA: Low-Rank Adaptation of Large Language Models". arXiv:2106.09685.
{{cite journal}}
: Cite journal requires|journal=
(help) - Tewel, Yoad; Gal, Rinon; Chechik, Gal; Atzmon, Yuval (2023-07-23). "Key-Locked Rank One Editing for Text-to-Image Personalization". Special Interest Group on Computer Graphics and Interactive Techniques Conference Conference Proceedings. SIGGRAPH '23. New York, NY, USA: Association for Computing Machinery. pp. 1–11. doi:10.1145/3588432.3591506. ISBN 979-8-4007-0159-7. S2CID 258436985.
- Lorenzi, Daniele (2023-07-22). "Meet P+: A Rich Embeddings Space for Extended Textual Inversion in Text-to-Image Generation". MarkTechPost. Retrieved 2023-08-29.
- Gal, Rinon; Arar, Moab; Atzmon, Yuval; Bermano, Amit H.; Chechik, Gal; Cohen-Or, Daniel (2023-07-26). "Encoder-based Domain Tuning for Fast Personalization of Text-to-Image Models". ACM Transactions on Graphics. 42 (4): 150:1–150:13. arXiv:2302.12228. doi:10.1145/3592133. ISSN 0730-0301. S2CID 257364757.
- Wei, Yuxiang; Zhang, Yabo; Ji, Zhilong; Bai, Jinfeng; Zhang, Lei; Zuo, Wangmeng (2023). "ELITE: Encoding Visual Concepts into Textual Embeddings for Customized Text-to-Image Generation". arXiv:2302.13848 [cs.CV].
- Dao, Tri; Fu, Daniel Y.; Ermon, Stefano; Rudra, Atri; Ré, Christopher (2022). "FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness". arXiv:2205.14135 [cs.LG].
- Shi, Jing; Xiong, Wei; Lin, Zhe; Jung, Hyun Joon (2023). "InstantBooth: Personalized Text-to-Image Generation without Test-Time Finetuning". arXiv:2304.03411 [cs.CV].