最近看了这篇论文 Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization 。由于没有详细的博客参考,还是花了一些时间来阅读论文。于是提出自己对论文的理解,以供大家参考。下面直接进入主题:

1 Adaptive Instance Normalization

作者在 CIN 的基础上提出了 Adain :
【风格迁移系列三】(Adain)Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization 论文解读
其中,x 和 y 分别是内容图片和风格图片 encode 后的特征图, σ\sigmaμ\mu 分别是均值和标准差。论文中说该公式将内容图片的均值和标准差与风格图片的均值和标准差对齐,我们可以这样理解:首先 内容图片 经过标准化后均值为0,标准差为1;然后乘以风格的标准差再加上风格的均值,Adain 的结果不就使得原来的内容特征图的标准差和均值与风格特征图的相同了吗?那么就可以说成它们的标准差和均值对齐了。

2 Model Architecture

【风格迁移系列三】(Adain)Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization 论文解读
论文的模型如上图:

  1. 首先将内容图片 c 和风格图片 s 输入 VGG 网络 ff;
  2. f(c)f(c)f(s)f(s) 进行上述的 Adain 操作,得到 t;
    【风格迁移系列三】(Adain)Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization 论文解读
  3. 最后通过 Decoder gg 输出风格迁移结果 T(c,s)T(c,s)
    【风格迁移系列三】(Adain)Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization 论文解读

3 Training

首先总损失的定义和其他的论文类似:
【风格迁移系列三】(Adain)Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization 论文解读
内容损失定义如下:
【风格迁移系列三】(Adain)Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization 论文解读
可以看上图的模型最右边进行理解,f(g(t))f(g(t)) 就是将得到的结果再输入到 vgg 中的结果,然后与 t 计算均方差损失。

风格损失定义如下:
【风格迁移系列三】(Adain)Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization 论文解读
这里是计算decode生成的结果的均值和方差和风格特征图的均值和方差的均方差损失。也就是让 g(t)g(t)tt 的方差和均值对齐。

4 Code

官方实现(Torch): https://github.com/xunhuang1995/AdaIN-style
非官方实现(Pyorch): https://github.com/irasin/Pytorch_Adain_from_scratch

相关文章: