Information
Title: Diffusion Models already have a Semantic Latent Space (ICLR 2023)
Reference
Author: Sehwan Park
Last updated on Nov. 18, 2023
Diffusion Models already have a Semantic Latent Space#
Abstract#
Diffusion model์ ๋ง์ domain์์ ์ข์ ์ฑ๋ฅ์ ๋ณด์ด์ง๋ง generative process๋ฅผ controlํ๋ semantic latent space๊ฐ ๋ถ์กฑํ๋ค. ๋ ผ๋ฌธ์์๋ diffusion model์์์ semantic latent space๋ฅผ ๋ฐ๊ฒฌํ๊ธฐ ์ํ asymmetric reverse process(asyrp)๋ฅผ ์ ์ํ๊ณ h-space๋ผ๊ณ ๋ช ์นญํ semantic latent space์ ์ข์ ํน์ฑ(homogeneity, linearity, robustness, consistency across timesteps)๋ค์ ๋ณด์ฌ์ค๋ค. ์ถ๊ฐ์ ์ผ๋ก editing strength์ quality deficiency๋ฅผ ๊ธฐ์ค์ผ๋ก ์ผ๊ณ ๋ ์ข์ image-image translation์ ์ํ Generative Process Design์ ์๊ฐํ๋ค.
1. Introduction#

Fig. 431 Manipulation approaches for diffusion models#
(a) Image guidance๋ unconditionalํ latent variable์ guiding image์ latent variable์ ํฉ์น๋ ๋ฐฉ์์ ์ฌ์ฉํ๋ค. ๊ทธ๋ฌ๋ latent variable์ ๋ ๋ค ์ด์ฉํ๋ฉด์ ๋ช ํํ๊ฒ controlํ๊ธฐ๊ฐ ์ฝ์ง ์๋ค.
(b) Classifier guidance๋ diffusion model์ classifier๋ฅผ ์ถ๊ฐํ์ฌ generative process๋ฅผ ๊ฑฐ์น๋ ๋์ latent variable์ด ์ด๋ค class์ธ์ง ๋ถ๋ฅํ๊ณ target class์ ๊ฐ๊น์์ง๋๋ก score๋ฅผ ๋ถ์ฌํ๋ ๋ฐฉ์์ผ๋ก ์๋ํ๋ค. ๊ทธ๋ฌ๋ latent variable๋ค์ ๋ํด classify๋ฅผ ์คํํด์ผ ํ๊ธฐ์ pretrained model์ ์ฌ์ฉํ๊ธฐ๊ฐ ํ๋ค์ด ์ง์ ํ์ต์ ์์ผ์ผ ํ๊ธฐ์ ์๊ฐ์ ์ผ๋ก, ๋น์ฉ์ ์ผ๋ก ๋ถ๋ด์ด ๋๋ค.
(c) DiffusionCLIP
(d) Diffusion Models already have a Semantic Latent Space๋ original image์ ํน์ฑ์ editํ๊ธฐ ์ํ ์์ฃผ ์ข์ ํน์ฑ์ ๊ฐ์ง๊ณ ์๋ semantic latent space๋ฅผ frozen diffusion model์์ ๋ฐ๊ฒฌํ์๊ณ ์ด๋ฅผ h-space๋ผ๊ณ ์นญํ๋ค. h-space์๋ ๋ค์ํ ์ข์ ํน์ฑ๋ค์ด ์กด์ฌํ๋ค. versatile editing๊ณผ quality boosting์ ์ํด ์๋ก์ด generative process๋ฅผ designํ์ฌ ์ ์ํ๋ค. h-space๋ frozen pretrained diffusion model์์ semantic latent space๋ก์จ์ ์ฒซ ๋ฐ๊ฒฌ์ฌ๋ก์ด๋ค.
2. Background#
2.1 Denoising Diffusion Probability Model(DDPM)#
DDPM์์๋ ์์์ time step t๋ก ๋ถํฐ noise๊ฐ ๊ปด์๋ image
2.2 Denoising Diffusion Implicit Model(DDIM)#
DDIM์์๋ non-Markovian process๋ฅผ ์ด์ฉํด ๋ ๋ค๋ฅธ ๊ด์ ์ reverse process๋ฅผ ์ ์ํ์๊ณ , DDPM๊ณผ DDIM ๋ชจ๋ generalํ๊ฒ ์ ์ฉ๋๋ Diffusion process์ ๋ํ ์์ ๋ณด์ฌ์ฃผ์๋ค.
2.3 Image Manipulation with CLIP#
CLIP์ Image Encoder์ Text Encoder๋ฅผ ์ด์ฉํ์ฌ image์ text๊ฐ์ embedding์ ํ์ตํ๋ค. ํธ์ง๋ ์ด๋ฏธ์ง์ ๋์ ์ค๋ช ๊ฐ์ cosine distance๋ฅผ ์ง์ ์ต์ํํ๋ ๋์ cosine distance๋ฅผ ์ฌ์ฉํ directional loss๋ฅผ ์ฌ์ฉํ์ฌ mode collapse์์ด ๊ท ์ผํ editing์ ๊ฐ๋ฅํ๊ฒ ํ๋ค๊ณ ํ๋ค.
3. Discovering Semantic Latent Space In Diffusion Models#
Editiing์ ํ๋ ๊ณผ์ ์์ naive approach๋ฅผ ํตํด์๋ editing์ด ์ ์ด๋ฃจ์ด์ง์ง ์๋๋ค. ์ด chapter์์๋ ์ ์ ์ด๋ฃจ์ด์ง์ง ์๋์ง์ ๋ํ ์ค๋ช ์ ํ๊ณ ์ด๋ฅผ ํด๊ฒฐํ๋ ์๋ก์ด controllableํ ํ reverse process์ธ Asymmetric Reverse Process(Asyrp)๋ฅผ ์ ์ํ๋ค.
DDIM์์
3.1 Problem#
์ด์ ๋ํ ๋์์ผ๋ก, ๋ชจ๋ sampling step์์ ์ํ๋ ๋ฐฉํฅ์ผ๋ก manipulateํ๋๋ก
Proof of Theroem)
Define
=
=
=
=
=
shifted epsilon์ ์ฌ์ฉํ ๊ฒฐ๊ณผ์ด๋ค. ๋ถ์๋ฅผ ๋ณด๋ฉด
์ฆ

Fig. 432 No Manipulation Effect with shifted epsilon#
3.2 Asymmetric Reverse Process(Asyrp)#
chapter 3.1์์
Loss์ ๋ํ chapter 2.3์์ ์ ์ํ
์ ์ฒด์ ์ธ reverse process๋ ๋ค์๊ณผ ๊ฐ์ด ์ค๊ณ๊ฐ ๋์๋ค. ์ด์ shifted epsilon์ธ
3.3 h-space#

Fig. 433 U-Net structure and h-space#
h-space์ ํฌ๊ธฐ๋
3.4 Implicit Neural Directions#

Fig. 434 Illustration of
h-space์์ epsilon์ controlํด์ asyrp ์ด์ฉํ๋ ์์ ๋ค์๊ณผ ๊ฐ๋ค. ์ดํด๋ฅผ ์ํด
-space์์์ shifted epsilonh-space์์์ shifted epsilon

Fig. 435 Asymmetric Reverse Process#
4. Generative Process Design#

Fig. 436 Intuition for choosing the intervals for editing and quality boosting#
Perception prioritized training of diffusion models(Choi et al)์์๋ Diffusion model์ด early stage์์๋ high-level context๋ฅผ generateํ๊ณ , later stage์์๋ imperceptible fine details๋ฅผ generateํ๋ค๊ณ ์ ์ํ๋ค. ๋ณธ ๋ ผ๋ฌธ์์๋ early stage์์ editing์ ์งํํ๋ editing process์ later stage์์ imperceptible fine details๋ฅผ ์งํํ๋ quality boosting์ ์ํ ๊ตฌ๊ฐ์ ๋๋ ์ ์๋ก์ด Generative Process Design์ ์ ์ํ๋ค.
4.1 Editing Process With Asyrp#
Editing Process์์๋ high-level context๊ฐ generate๋์ด์ผ ํ๋ฏ๋ก ์ ์ฒด timestep[0,T]์์ Editing Process๋ฅผ ์ํ editing interval์ [T,
Editing interval์ด ์์ผ๋ฉด

Fig. 437 Results based on various

Fig. 438 Importance of choosing proper
๋ช๋ช ํน์ฑ๋ค์ ๋ค๋ฅธ ํน์ฑ๋ค์ ๋นํด visual change๋ฅผ ๋ง์ด ํ์๋ก ํ๋ ๊ฒฝ์ฐ๋ ์๋ค. ์๋ฅผ ๋ค์ด source image์ ๋ํด smileํ attribute๋ฅผ ์ถ๊ฐํ๋ ๊ฒฝ์ฐ๋ณด๋ค pixar style์ attribute์ ์ถ๊ฐํ๋ ๊ฒฝ์ฐ๊ฐ ๋ ๋ง์ visual change๋ฅผ ํ์๋ก ํ๋ค. ์ด๋ฌํ ๊ฒฝ์ฐ์๋ Editing interval์ ๋ ๊ธธ๊ฒ ์ค์ ํด์ผ ํ๋ค. ์ด๋ฌํ ๊ฒฝ์ฐ์๋

Fig. 439 Flexible
4.2 Quality Boosting With Stochastic Noise Injection#
DDIM์
Boosting Interval์ ๋ฐ๋ผ image quality๋ฅผ controlํ ์ ์๋๋ฐ, Boosting Interval์ด ๊ธธ๊ฒ๋๋ฉด, Quality๋ ์ฆ๊ฐํ์ง๋ง Interval๋์ ๊ณ์ํด์ stochastic noise๋ฅผ ์ฃผ์
ํด์ผ ํ๊ธฐ์ content๊ฐ ๋ณํ๋ ๋ฌธ์ ๊ฐ ๋ฐ์ํ ์๋ ์๋ค. ๋ฐ๋ผ์ ์ถฉ๋ถํ quality boosting์ ๋ฌ์ฑํ๋ฉด์๋ content์ ์ต์ํ์ ๋ณํ๋ง์ ์ค ์ ์๋๋ก
์ฌ๊ธฐ์๋ editing strength์๋ ๋ค๋ฅด๊ฒ time step์ ๋ฐ๋ผ ์์ธกํ

Fig. 440 Results based on various

Fig. 441 Quality comparison based on the presence of quality boosting#
4.3 Overall Process of Image Editing#
Generalํ Diffusion model์์์ Generative Process๋ฅผ ํํํ๋ฉด ๋ค์๊ณผ ๊ฐ๋ค.

Fig. 442 Quality comparison based on the presence of quality boosting#
์ฒ์๋ถํฐ

Fig. 443 Overview of Generative Process#
5. Experiments#
CelebA-HQ (Karras et al., 2018) ๋ฐ LSUN-bedroom/-church (Yu et al., 2015) ๋ฐ์ดํฐ์ ์์ DDPM++ (Song et al., 2020b) (Meng et al., 2021); AFHQ-dog (Choi et al., 2020) ๋ฐ์ดํฐ์ ์์ iDDPM (Nichol & Dhariwal, 2021); ๊ทธ๋ฆฌ๊ณ METFACES (Karras et al., 2020) ๋ฐ์ดํฐ์ ์์ ADM with P2-weighting (Dhariwal & Nichol, 2021) (Choi et al., 2022)์ ์ฌ์ฉํด ๊ฐ๊ฐ ํ์ต์์ผฐ๋ค๊ณ ํ๋ค. ๋ชจ๋ model๋ค์ pretrained checkpoint๋ฅผ ํ์ฉํ์ผ๋ฉฐ frozen์ํ๋ฅผ ์ ์ง์์ผฐ๋ค๊ณ ํ๋ค.
5.1 Versatility of h-space with Asyrp#

Fig. 444 Editing results of Asyrp on various datasets#
์์ ๊ทธ๋ฆผ์ ๋ณด๋ฉด, ๋ ผ๋ฌธ์์๋ ๋ค์ํ attribute๋ค์ ํน์ฑ์ ์ ๋ฐ์ํด์ image๋ฅผ manipulateํ๋ค๋ ์ ์ ์ ์ ์๋ค. ์ฌ์ง์ด {department, factory, temple} attribute์ training data์ ํฌํจ์ด ๋์ด์์ง ์์์์๋ ์ฑ๋ฅ์ด ์ ๋์จ ์ ์ ํ์ธํ ์ ์๋ค. model์ fine tuningํ์ง ์๊ณ inferenceํ๋ ๊ณผ์ ์์ h-space๋ฅผ ํตํด epsilon์ controlํ๊ณ Asyrp๋ฅผ ์ด์ฉํด ์ฑ๋ฅ์ ๋๋ค๋ ์ ์ด ๊ฐ์ฅ ํฐ ์ฅ์ ์ด๋ค.
5.2 Quantitive Comparison#
Asyrp model์ ๊ฒฐ๊ณผ๋ฅผ ๋ค๋ฅธ model๋ค๊ณผ ๋น๊ตํ๋ ์คํ์ ์งํํ์๋๋ฐ diffusion model ์ ์ฒด๋ฅผ fine-tuningํ์ฌ image์ editingํ๋ DiffsionCLIP model๊ณผ ๋น๊ตํ์๋ค. Asyrp์ ์ฑ๋ฅ์ด ๋ ์ข์์ ํ์ธ ํ ์ ์๋ค.

Fig. 445 Asyrp vs DiffusionCLIP on both CelebA-HQ seen-domain attributes and unseen-domain attributes#
5.3 Analysis on h-space#
Homogeneity
Fig. 446 Homogeneity of h-space#
์์ ๊ทธ๋ฆผ์ (a)๋ Real image์ smiling attribute์ ์ถ๊ฐํ๊ธฐ ์ํด ์ต์ ํ๋
์ ๋ฅผ ๋ํ๋ธ๋ค. ๊ฐ์ ๊ฐ์ ๋ค๋ฅธ Real image์ ์ ์ฉ์์ผฐ์ ๋์ ๊ฒฐ๊ณผ๋ฅผ (b)์ ๋ํ๋ด์๋๋ฐ, ๋ฅผ ์ ์ฉํ๊ฒฝ์ฐ smiling face๋ก ์ ๋ฐ๋๋ ๋ฐ๋ฉด, ์ ์ ์ฉํ ๊ฒฝ์ฐ์๋ image distortion์ด ๋ฐ์ํจ์ ์ ์ ์๋ค.Linearity
Fig. 447 Linearity of h-space - Linear Scaling#
๋ฅผ linearly scaling์ ํ๋ ๊ฒ์ editing์ ํ๋๋ฐ์ ์์ด visual attribute change์ ์์ ๋ฐ์๋๋ค. ์ฆ, ๋ฅผ 1, 2, 3๋ฐฐ ํจ์ ๋ฐ๋ผ result image์์ ๋ฐ์๋๋ attribute๋ํ ์ด์ ๋ง๊ฒ ๋ณํํ๋ค๋ ๊ฒ์ด๋ค. ์์ ๊ทธ๋ฆผ์์ ํํ๋์ด ์๋ฏ์ด negative scaling์ ๋ํด์๋ training์ ํ์ง ์์์์๋ ์ ์ ์ฉ ๋๋ค๋ ์ ์ ์ ์ ์๋ค.Fig. 448 Linearity of h-space - Linear Combination#
์๋ก ๋ค๋ฅธ attributes์ ๋ํ
๋ฅผ ํฉ์ณ์ ๋ถ์ฌ๋ฅผ ํ์ ๊ฒฝ์ฐ์๋ ๊ฐ๊ฐ์ attribute๋ค์ด image์ ์ ๋ฐ์์ด ๋๋ค๋ ์ ์ ์ ์ ์๋ค.Robustness
Fig. 449 Robustness of h-space#
์์ ๊ทธ๋ฆผ์ h-space์
์์ random noise๋ฅผ ์ฃผ์ ํ์ ๋์ ๊ฒฐ๊ณผ๋ฅผ ๋น๊ตํ ๊ฒ์ด๋ค. h-space์ ๊ฒฝ์ฐ์๋ random noise๊ฐ ์ถ๊ฐ๋์์ด๋ image์ ํฐ ๋ณํ๊ฐ ์์ผ๋ฉฐ ๋ง์ noise๊ฐ ์ถ๊ฐ๋์์ ๊ฒฝ์ฐ์๋ image distortion์ ๊ฑฐ์ ์๊ณ semantic change๋ง ๋ฐ์ํ๋ค. ๊ทธ๋ฌ๋ ์ ๊ฒฝ์ฐ์๋ random noise๊ฐ ์ถ๊ฐ๋ ๊ฒฝ์ฐ image distortion์ด ์ฌํ๊ฒ ๋ฐ์ํ๋ค. ์ด๋ฅผ ํตํด h-space๊ฐ ์ผ๋ง๋ robustnessํ์ง ์ ์ ์๋ค.Consistency across time steps
Fig. 450 Consistency across times steps of h-space#
h-space์ homogeneousํ ์ฑ์ง์ ํตํด ๊ฐ์ attribute์ ๋ํ
๋ฅผ ๋ค๋ฅธ image์ ์ ์ฉ์์ผฐ์ ๋์๋ ์ ๋ฐ์์ด ๋์ ํ์ธํ์๋ค. ์ ์๋ค์ ๋ค์ ๋ํ ํ๊ท ์ธ ์ ์ ์ฉ์์ผฐ์ ๊ฒฝ์ฐ์๋ result๊ฐ ๊ฑฐ์ ๋น์ทํจ์ ๋ณด์ธ๋ค. Chapter4์์ ์ ์ํ Generative Process๋ฅผ ๋น์ถ์ด ๋ณด์์ ๋, ๋ Editing Process์์๋ง ์ ์ฉ์ ์ํจ๋ค. ์ด ๊ฒฝ์ฐ, ์ ์ฉํ๋ ๋ฅผ ์ด๋ผ๊ณ ์นญํ๋ฉฐ, ์ ์ฉํ๋ ๊ฐ interval๋์ ๊ฐ์ ํฌ๊ธฐ ๋งํผ ์ ์ฉ๋๋ค๊ณ ๊ฐ์ ํ์ ๊ฒฝ์ฐ, ์ด๋ผ๊ณ ์ธ ์ ์๋ค. ์ด ๊ฒฝ์ฐ์๋ ๊ฒฐ๊ณผ๋ ๋น์ทํจ์ ๋ณด์ฌ์ค๋ค. ๊ฒฐ๊ตญ ์ํ๋ attribute์ ๋ํด ์ฃผ์ ํด์ผ ํ ์๋ง ๊ฐ๋ค๋ฉด, ์ํ๋ editing ํจ๊ณผ๋ฅผ ์ป์ ์ ์๋ค. ๋น๋ก ์ด ๋ ผ๋ฌธ์์๋ best quality manipulation์ ์ํด ๋ฅผ ์ฌ์ฉํ์์ง๋ง, ๊ณผ ์ ๋ํด ๋ ์ฐ๊ตฌ๋ฅผ ํด ๋ณผ ์ฌ์ง๊ฐ ์๋ค๊ณ ํ๋จํ๋ค.
6. Conclusion#
๋ณธ ๋ ผ๋ฌธ์์๋ Pretrained Diffusion models์์ latent semantic space์ธ h-space๋ฅผ ๋ฐ๊ฒฌํ๊ณ h-space์์์ Asyrp(Asymmetric Reverse Process)์ ์๋กญ๊ฒ ์ ์ํ Reverse Process ๋ฐฉ๋ฒ์ ํตํด ์ฑ๊ณต์ ์ธ image editing์ ๊ฐ๋ฅ์ผ ํ์๋ค. Diffusion model์์์ semanticํ latent space์ ๋ํ ์ฒซ ์ ์์ ํ ๋ ผ๋ฌธ์ด๋ค. h-space๋ GAN์ latent space์ ์ ์ฌํ ํน์ฑ์ ๊ฐ์ถ๊ณ ์๋ค. ๋ํ์ ์ธ h-space์ ํน์ฑ์ผ๋ก๋ Homogeneity, Linearity, Robustness, Consistency across timesteps์ด ์๋ค.