摘要
无监督的图像到图像转换是计算机视觉中的重要且具有挑战性的问题。给定源域中的图像,目标是学习目标域中的对应图像的条件分布,而不会看到对应图像对的任何示例。虽然这种条件分布本质上是多模态的,但现有方法做出了过于简化的假设, 将其建模为确定性的一对一映射。结果,它们无法从给定的源域图像生成不同的输出。为了解决这个限制,我们提出了一种多模态无监督图像到图像转换(MUNIT)框架。我们假设图像表示可以分解为域不变的内容代码,以及捕获特定于域的属性的样式代码。要将图像转换为另一个域,我们会将其内容代码重新组合为随机 从目标域的样式空间中采样的样式代码。我们分析了提出的框架并建立了几个理论结果。通过与现有技术方法的比较进行的广泛实验进一步证明了所提出的框架的优势。此外,我们的框架允许用户通过提供示例样式图像来控制翻译输出的样式。代码和预训练模型可从https://github.com/nvlabs/MUNIT获得。
符号
- 两个域: X 1 , X 2 \mathcal{X}_1 , \mathcal{X}_2 X1,X2 .
- 样本: x 1 ( ∈ X 1 ) , x 2 ( ∈ X 2 ) x_1 (\in \mathcal{X}_1 ) , x_2 (\in \mathcal{X}_2 ) x1(∈X1),x2(∈X2)
- 边缘分布: p ( x 1 ) , p ( x 2 ) p(x_1) , p(x_2) p(x1),p(x2)
- 编码器: E i , i = 1 , 2 E_i ,i=1,2 Ei,i=1,2
- 解码器: G i , i = 1 , 2 G_i , i=1,2 Gi,i=1,2
- content code : c ( ∈ C ) c (\in \mathcal{C}) c(∈C)
- style code: s i ( ∈ S i , i = 1 , 2 ) , ( c i , s i ) = ( E i C ( x i ) , ( E i S ( x i ) ) = E i ( x i ) s_i (\in \mathcal{S}_i , i=1,2) , (c_i,s_i)=(E^\mathcal{C}_i(x_i) , (E^\mathcal{S}_i(x_i))=E_i(x_i) si(∈Si,i=1,2),(ci,si)=(EiC(xi),(EiS(xi))=Ei(xi)
- 将图片 x 1 ∈ X 1 x_1\in \mathcal{X}_1 x1∈X1迁移到 X 2 \mathcal{X}_2 X2: x 1 → 2 x_{1\to 2} x1→2
模型
例子:将图片 x 1 ∈ X 1 x_1\in \mathcal{X}_1 x1∈X1迁移到 X 2 \mathcal{X}_2 X2
- 如图(a)所示: E i ( x i ) = ( c i , s i ) = ( E i C ( x i ) , ( E i S ( x i ) ) , i = 1 , 2 E_i(x_i)=(c_i,s_i)=(E^\mathcal{C}_i(x_i) , (E^\mathcal{S}_i(x_i)) , i=1,2 Ei(xi)=(ci,si)=(EiC(xi),(EiS(xi)),i=1,2.
- 从先验分布 q ( s 2 ) ∼ N ( 0 , I ) q(s_2)\sim \mathcal{N}(0,I) q(s2)∼N(0,I)随机取style latent code : s 2 s_2 s2.
- 用 G 2 G_2 G2产生最后的输出: x 1 → 2 = G 2 ( c 1 , s 2 ) x_{1\to 2}=G_2(c_1,s_2) x1→2=G2(c1,s2).
Loss
- 双向重构Loss(Bidirectional reconstruction loss)
- 图像重构 (image
→
\to
→ latent
→
\to
→ image)
L r e c o n x 1 = E x 1 ∼ p ( x 1 ) [ ∥ G 1 ( E 1 c ( x 1 ) , E 1 S ( x 1 ) ) − x 1 ∥ 1 ] \mathcal{L}_{recon}^{x_1}=\mathbb{E}_{x_1\sim p(x_1)}[\Vert G_1 (E^c_1(x_1),E_1^S(x_1))-x_1\Vert _1] Lreconx1=Ex1∼p(x1)[∥G1(E1c(x1),E1S(x1))−x1∥1] - 隐层重构 (latent
→
\to
→ image
→
\to
→ latent)
L r e c o n c 1 = E c 1 ∼ p ( c 1 ) , s 2 ∼ q ( s 2 ) [ ∥ E 2 c ( G 2 ( c 1 , s 2 ) ) − c 1 ∥ 1 ] \mathcal{L}_{recon}^{c_1}=\mathbb{E}_{c_1\sim p(c_1),s_2\sim q(s_2)}[\Vert E_2^c(G_2(c_1,s_2))-c_1 \Vert _1] Lreconc1=Ec1∼p(c1),s2∼q(s2)[∥E2c(G2(c1,s2))−c1∥1] L r e c o n s 1 = E c 1 ∼ p ( c 1 ) , s 2 ∼ q ( s 2 ) [ ∥ E 2 s ( G 2 ( c 1 , s 2 ) ) − s 2 ∥ 1 ] \mathcal{L}_{recon}^{s_1}=\mathbb{E}_{c_1\sim p(c_1),s_2\sim q(s_2)}[\Vert E_2^s(G_2(c_1,s_2))-s_2 \Vert _1] Lrecons1=Ec1∼p(c1),s2∼q(s2)[∥E2s(G2(c1,s2))−s2∥1]
其中 p ( c 1 ) p(c_1) p(c1)由 c 1 = E 1 c ( x 1 ) c_1=E_1^c(x_1) c1=E1c(x1)得到; x 1 ∼ p ( x 1 ) x_1 \sim p(x_1) x1∼p(x1).
- 图像重构 (image
→
\to
→ latent
→
\to
→ image)
- Adversarial loss(对抗loss)
L G A N x 2 = E c 1 ∼ p ( c 1 ) , s 2 ∼ q ( s 2 ) [ log ( 1 − D 2 ( G 2 ( c 1 , s 2 ) ) ) ] + E x 2 ∼ p ( x 2 ) [ log D 2 ( x 2 ) ] \mathcal{L}_{GAN}^{x_2}=\mathbb{E}_{c_1\sim p(c_1),s_2\sim q(s_2)}[\log(1-D_2(G_2(c_1,s_2)))]+\mathbb{E}_{x_2\sim p(x_2)}[\log D_2(x_2)] LGANx2=Ec1∼p(c1),s2∼q(s2)[log(1−D2(G2(c1,s2)))]+Ex2∼p(x2)[logD2(x2)].其中 D 2 D_2 D2是用来判别数据是属于 X 2 \mathcal{X}_2 X2还是迁移的. - Total Loss
min E 1 , E 2 , G 1 , G 2    max D 1 , D 2 L ( E 1 , E 2 , G 1 , G 2 , D 1 , D 2 ) = \min_{E_1,E_2,G_1,G_2} \; \max_{D_1,D_2}\mathcal{L}(E_1,E_2,G_1,G_2,D_1,D_2)= E1,E2,G1,G2minD1,D2maxL(E1,E2,G1,G2,D1,D2)= L G A N x 1 + L G A N x 2 + λ x ( L r e c o n x 1 + L r e c o n x 2 ) + λ c ( L r e c o n c 1 + L r e c o n c 2 ) + λ s ( L r e c o n s 1 + L r e c o n s 2 ) \mathcal{L}_{GAN}^{x_1}+\mathcal{L}_{GAN}^{x_2}+\lambda_x(\mathcal{L}^{x_1}_{recon}+\mathcal{L}^{x_2}_{recon})+\lambda_c(\mathcal{L}_{recon}^{c_1}+\mathcal{L}_{recon}^{c_2})+\lambda_s(\mathcal{L}_{recon}^{s_1}+\mathcal{L}_{recon}^{s_2}) LGANx1+LGANx2+λx(Lreconx1+Lreconx2)+λc(Lreconc1+Lreconc2)+λs(Lrecons1+Lrecons2)
理论分析
实现
- content encoder:包含几个strided convolutional layers对输入进行下采样。还包含几个residual blocks进一步。所有的卷积层都跟着 normalization.
- style encoder:几个strided convolutional layers,global average pooling层和全连接层。
- decoder: