StarGAN v2: Diverse Image Synthesis for Multiple Domains

1. Introduction

定义domain和style

Here, domain implies a set of images that can be grouped as a visually distinctive category, and each image has a unique appearance, which
we call style.
For example, we can set image domains based on the gender of a person, in which case the style include makeup, beard, and hairstyle.

2. StarGAN v2

2.1. Proposed framework

输入图像 x ∈ X \mathbf{x}\in\mathcal{X} xX,arbitrary domain y ∈ Y y\in\mathcal{Y} yY y y y相当于domain的id
在这里插入图片描述
Generator(Figure 2a)
生成器 G G G将一幅输入图像 x \mathbf{x} x按照指定的style code s \mathbf{s} s,生成图像 G ( x , s ) G(\mathbf{x}, \mathbf{s}) G(x,s)

按照之前的做法,应该将target domain y y y送入 G G G中,此处将style code s \mathbf{s} s送入 G G G中,要求 s \mathbf{s} s是target domain y y y的一种style

Mapping network(Figure 2b)
给定latent code z \mathbf{z} z(下文提到了 z \mathbf{z} z是随机采样Gaussian Distribution得到的),Mapping Network F F F z \mathbf{z} z转换为指定domain y y y中的一个style code s \mathbf{s} s,即 s = F y ( z ) \mathbf{s}=F_y(\mathbf{z}) s=Fy(z),下标 y y y表示 F F F中的一个branch,因为 F F F是多个branch的,所以说 F F F是multi-task architecture
注:multi-branch architecture F y F_y Fy其实可以用condition architecture F ( z , y ) F(\mathbf{z}, y) F(z,y)来代替,这样处理更加灵活

Style encoder(Figure 2c)
给定输入图像 x \mathbf{x} x以及对应的domain y y y,encoder网络 E E E负责解析出图像所包含的style code s = E y ( x ) \mathbf{s}=E_y(\mathbf{x}) s=Ey(x)
Question:因为 E E E也是multi-branch architecture,那么假设 x \mathbf{x} x对应了domain 1,那么 F y = 1 ( x ) F_{y=1}(\mathbf{x}) Fy=1(x)是对 x \mathbf{x} x提取得到的style code,但是其它branch F y ≠ 1 ( x ) F_{y\neq1}(\mathbf{x}) Fy=1(x)的输出,其实是没有意义的

Discriminator(Figure 2d)
判别器 D D D包含多个分支,每个分支 D y D_y Dy负责判别在domain y y y中图像的真假
Q:原版StarGAN的判别器只接收一个输入,如果额外接收一个label作为输入会怎样?
A:判别器只接收图像作为输入,输出real/fake和domain_id,等价于判别器接收图像和label作为输入,输出real/fake

2.2. Training objectives

Adversarial objective
在训练过程中,随机采样latent code z ∈ Z \mathbf{z}\in\mathcal{Z} zZ以及target domain y ~ ∈ Y \tilde{y}\in\mathcal{Y} y~Y,然后生成target style code s ~ = F y ~ ( z ) \tilde{\mathbf{s}}=F_{\tilde{y}}(\mathbf{z}) s~=Fy~(z),接着使用 G G G生成图像 G ( x , s ~ ) G(\mathbf{x}, \tilde{\mathbf{s}}) G(x,s~),于是adversarial loss定义如下
L a d v = E x , y [ log ⁡ D y ( x ) ] + E x , y ~ , z [ log ⁡ ( 1 − D y ~ ( G ( x , s ~ ) ) ) ] ( 1 ) \begin{aligned} \mathcal{L}_{adv}=&\mathbb{E}_{\mathbf{x},y}\left [ \log D_y(\mathbf{x}) \right ]+\\ &\mathbb{E}_{\mathbf{x},\tilde{y},\mathbf{z}}\left [ \log\left ( 1-D_{\tilde{y}}\left ( G\left ( \mathbf{x},\tilde{\mathbf{s}} \right ) \right ) \right ) \right ] \qquad(1) \end{aligned} Ladv=Ex,y[logDy(x)]+Ex,y~,z[log(1Dy~(G(x,s~)))](1)

Style reconstruction
为了保证 G G G生成的图像包含了style code s ~ \tilde{\mathbf{s}} s~,定义style reconstruction loss如下
L s t y = E x , y ~ , z ∥ s ~ − E y ~ ( G ( x , s ~ ) ) ∥ 1 ( 2 ) \mathcal{L}_{sty}=\mathbb{E}_{\mathbf{x},\tilde{y},\mathbf{z}}\left \| \tilde{\mathbf{s}}-E_{\tilde{y}}(G(\mathbf{x},\tilde{\mathbf{s}})) \right \|_1 \qquad(2) Lsty=Ex,y~,zs~Ey~(G(x,s~))1(2)
意思是将 E E E用来计算loss,如果生成的图像 G ( x , s ~ ) G(\mathbf{x},\tilde{\mathbf{s}}) G(x,s~) E E E解码出来的style code与 s ~ \tilde{\mathbf{s}} s~差异很大的话,说明 G G G没有按照 s ~ \tilde{\mathbf{s}} s~去生成图像
style reconstruction loss可以看作是一种约束“相貌”的损失函数

Style diversification
为了保证 G G G生成图像的多样性,定义diversity sensitive loss如下
L d s = E x , y ~ , z 1 , z 2 ∥ G ( x , s ~ 1 ) − G ( x , s ~ 2 ) ∥ 1 ( 3 ) \mathcal{L}_{ds}=\mathbb{E}_{\mathbf{x},\tilde{y},\mathbf{z}_1,\mathbf{z}_2}\left \| G(\mathbf{x},\tilde{\mathbf{s}}_1)-G(\mathbf{x},\tilde{\mathbf{s}}_2) \right \|_1 \qquad(3) Lds=Ex,y~,z1,z2G(x,s~1)G(x,s~2)1(3)
对于 G G G来说,需要最大化公式(3),如果对于同一幅图像 x \mathbf{x} x使用两个完全不同的style code z 1 , z 2 \mathbf{z}_1, \mathbf{z}_2 z1,z2生成出来的图像很相像的话,那么说明 G G G的多样性不足

Since the objective does not have an optimal point, we linearly decay the weight of the loss to zero during training.

Preserving source characteristics
我们要求 G G G只改变图像与domain有关的部分,对于domain-invariant characteristics(比如pose,表情等)要求不变,通过cycle consistency loss来保证
L c y c = E x , y , y ~ , z ∥ x − G ( G ( x , s ~ ) , s ^ ) ∥ 1 ( 4 ) \mathcal{L}_{cyc}=\mathbb{E}_{\mathbf{x},y,\tilde{y},\mathbf{z}}\left \| \mathbf{x}-G\left ( G\left ( \mathbf{x},\tilde{\mathbf{s}} \right ),\hat{\mathbf{s}} \right ) \right \|_1 \qquad(4) Lcyc=Ex,y,y~,zxG(G(x,s~),s^)1(4)
其中 s ^ = E y ( x ) \hat{\mathbf{s}}=E_y(\mathbf{x}) s^=Ey(x)是图像 x \mathbf{x} x的estimated style code

Full objective
L D = − L a d v ( 5 ) \mathcal{L}_D=-\mathcal{L}_{adv} \qquad(5) LD=Ladv(5)
L F , G , E = L a d v + λ s t y L s t y − λ d s L d s + λ c y c L c y c ( 6 ) \begin{aligned} \mathcal{L}_{F,G,E}&=\mathcal{L}_{adv}+\lambda_{sty}\mathcal{L}_{sty}\\ &-\lambda_{ds}\mathcal{L}_{ds}+\lambda_{cyc}\mathcal{L}_{cyc} \qquad(6) \end{aligned} LF,G,E=Ladv+λstyLstyλdsLds+λcycLcyc(6)

3. Experiments

Evaluation metrics.

衡量生成图像的评价指标有Frechét inception distance (FID)和learned perceptual image patch similarity (LPIPS)

3.1. Analysis of individual components

Baseline StarGAN的config包括:WGAN-GP、ACGAN discriminator、depth-wise concatenation

【总结】
StarGAN v2的优点是,训练数据只需要domain级别的标注,而不需要style级别的标注
缺点是对于只能处理一对domain

For multi-domain comparisons, we train these models multiple times for every pair of image domains.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值