info | |
---|---|
paper | https://arxiv.org/pdf/2308.06721.pdf |
code | https://github.com/tencent-ailab/IP-Adapter |
org. | Tencent AI Lab |
個(gè)人博客地址 | http://myhz0606.com/article/ip_adapter |
1 Motivation
為了對文生圖diffusion model
進(jìn)行特定概念的定制,常用LoRA
[1]、textual inversion
[2]等inference before fine-tune的方法。此類方法有一個(gè)弊端:每一個(gè)新的概念都需要重新訓(xùn)練一個(gè)權(quán)重,比較麻煩。那么,能不能有一個(gè)方法inference前無須微調(diào),只需給一張reference image,就能將該圖片的概念融入到生成過程中?這就是IP-adapter
想要解決的問題。
2 Method
IP-adapter
和LoRA
等工作類似,也是一個(gè)PEFT
(parameter efficient fine-tuning)的方法。區(qū)別在于,一般LoRA
等方法只須定制特定概念,訓(xùn)練數(shù)據(jù)只需少量(一般只需數(shù)十張)、高質(zhì)量特定概念的圖片。而IP-adapter希望diffusion model能夠理解開放式的圖片特征,并依此生成圖片,故為了保證泛化性,需要在大量數(shù)據(jù)上進(jìn)行訓(xùn)練。
2.1 模型架構(gòu)
為了降低訓(xùn)練成本,作者引入了預(yù)訓(xùn)練的CLIP
[3] image encoder來初步提取reference image的圖片特征,隨后接了一個(gè)Linear+layer norm層來調(diào)整特征的維度。隨后設(shè)計(jì)了一個(gè)decoupled cross-attention
模塊,將image feature融入到diffusion model
的生成過程中。通過訓(xùn)練讓diffusion model
能夠理解image prompt。(pipeline中只有 ??的module更新權(quán)重,其它module freeze。)
2.2 decoupled cross-attention
decoupled cross-attention
相比文生圖的cross attention多了兩個(gè)訓(xùn)練參數(shù)
W
i
k
′
,
W
i
v
′
W_{i}^{k'},W_{i}^{v'}
Wik′?,Wiv′?,起始階段用text分支的
W
i
k
,
W
i
v
W_{i}^{k},W_{i}^{v}
Wik?,Wiv?進(jìn)行初始化。(下標(biāo)
i
i
i代表第
i
i
i層cross-attention
)。
可以通過調(diào)整image embedding的權(quán)重 λ \lambda λ來決定image condition的影響程度。
2.3 模型訓(xùn)練
模型的訓(xùn)練數(shù)據(jù)采用LAION-2B
和COYO-700M
的子集,總計(jì)10M左右。訓(xùn)練目標(biāo)和經(jīng)典的diffusion model[4]一致。
L s i m p l e = E x 0 , ? , c t , c t , t ∣ ∣ ? ? ? θ ( x t , c t , c i , t ) ∣ ∣ 2 . { \mathcal L } _ { \mathrm { s i m p l e } } = { \mathbb E } _ { { \boldsymbol { x } } _ { 0 } , \epsilon , c _ { t } , c _ { t } , t } \vert \vert \epsilon - \epsilon _ { \theta } ( { \boldsymbol { x } } _ { t } , c _ { t } , c _ { i } , t ) \vert \vert ^ { 2 } . Lsimple?=Ex0?,?,ct?,ct?,t?∣∣???θ?(xt?,ct?,ci?,t)∣∣2.
同樣為了classifier-free guidance訓(xùn)練時(shí)隨機(jī)drop condition。
3 Result
IP-Adapter
的一大優(yōu)勢是他能結(jié)合其它c(diǎn)ondition tool。
下圖展示了IP-Adapter
和其它方法的對比結(jié)果
IP-adapter
還能做instruction editing
(更多結(jié)果請見原論文)
4 summary
IP-Adapter
能接受image作為prompt,實(shí)現(xiàn)inference without fine-tune的定制生成。雖然在單一概念比不上精心微調(diào)的LoRA
等定制方法,但在一些精細(xì)化要求沒那么高的場景,IP-Adapter
是一個(gè)非常有用的工具。
Reference
[1] LoRA: Low-Rank Adaptation of Large Language Models
[2] An Image is Worth One Word: Personalizing Text-to-Image Generation using Textual Inversion
[3] Learning Transferable Visual Models From Natural Language Supervision文章來源:http://www.zghlxwxcb.cn/news/detail-845454.html
[4] Denoising Diffusion Probabilistic Models文章來源地址http://www.zghlxwxcb.cn/news/detail-845454.html
到了這里,關(guān)于diffusion model(十五) : IP-Adapter技術(shù)小結(jié)的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!