谈谈图像的style transfer(二)

总说
主要从几个方面来进行说明吧 
- 加快transfer的速度 
- 让transfer的效果看起来更加visual-pleasing 
- 其他的一些方面 
- 用GAN来做

加快style stransfer
谈谈图像的Style Transfer(一) 
这里写了 Neural style以及fast neural style。 
在超越fast style transfer—-任意风格图和内容图0.1秒出结果已经可以将转换做到实时。这篇的一个主要的问题是耗费的大部分时间是在提取隐藏层的patch上。 
下面介绍的论文都秉承任意风格图一次前向直接出结果

A Learned representation for artistic style
这个在ICLR 2017发表的文章,核心思想:many styles probably share some degree of computation.就是说,虽然我们可以用fast neural style根据很多不同的style训练不同的模型,但是这些模型的所有卷积层的权值都是一样的! 
看原文比较容易: 
we found a very surprising fact about the role of normalization in style transfer networks: 
to model a style, it is sufficient to specialize scaling and shifting parameters after normalization to each specific style.
In other words, all convolutional weights of a style transfer network can be shared across many styles, 
and it is sufficient to tune parameters for an affine transformation after normalization for each style.。 
他们把这个方法称为condition instance normalization。 
[Math Processing Error]
z=γs(x−μσ)+βs
 
我们只要根据不同的style选择不同的参数[Math Processing Error]γs和[Math Processing Error]βs就行。这样的话,一次前向,就能生成N幅不同style的图像。这种方法只能生成指定数量的预先训练的style,还不能说是任意的。
Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization
论文 
这篇的话主要的思想是:加入了 adaptive instance normalization(AdaIN)层,主要是让生成图像特征与画的特征在 均值和方差上进行尽量相似。其实就是换了一种约束。原版的neural style是用二阶统计信息(协方差,用Gram矩阵)来进行匹配风格,但是也有用其他的,比如MRF loss(ombining markov random fields and convolutional neural networks for image synthesis.), Adversarial loss(C. Li and M. Wand. Precomputed real-time texture synthesis with markovian generative adversarial networks. In ECCV,2016), 梯度直方图(P. Wilmot, E. Risser, and C. Barnes. Stable and controllable neural texture synthesis and style transfer using histogram losses. arXiv preprint arXiv:1701.08893 , 2017), MMD损失(P. Wilmot, E. Risser, and C. Barnes. Stable and controllable neural texture synthesis and style transfer using histogram losses. arXiv preprint arXiv:1701.08893, 2017)等等吧。然后貌似均值和方差没有人用啊,所以他们就用了。 
先说一下,Instance Normalization不同于不同的BN,它是每个例子的每个通道进行normalization的。 
[Math Processing Error]
μnc(x)=1HW∑h=1H∑w=1Wxnchw
 
上篇说的CIN(condition Instance Normalization) 
[Math Processing Error]
CIN(x;s)=γs(x−μ(x)σ(x))+βs
 
他们学的是每种style图的这两个参数。但是这种仿射参数其实可以由style图的本身的统计信息来替代。 
所以如果我们把这两个仿射系数去掉,用style图像的方差和均值替代,那么就可以将CIN转换成任意风格的图像。 
[Math Processing Error]
AdaIN(x,y)=σ(y)(x−μ(x)σ(x))+μ(y)
 

然而我个人觉得这种效果很差啊,生成的风格图呈现出很严重的“块状”效果。
代码:https://github.com/xunhuang1995/AdaIN-style

让style transfer更加的visual-pleasing
Controlling Perceptual Factors in Neural Style Transfer
这篇主要是从三个方面着手

颜色控制
在以前的风格转换中,生成图的颜色都会最终变成style图的颜色,但是很多时候我们并不希望这样。其中一种方法是,将RGB转换成YIQ,只在Y上进行风格转换,因为I和Q通道主要是保存了颜色信息。 
 


空间控制
主要是加入R个引导通道。 
唯一的区别是 
[Math Processing Error]
Flr(x)[:,i]=Tlr∘Fl(x)[:,i]
 
原版的是这样的,可以看到下面的生成图片,天空有一部分变成墙壁了。这是因为协方差来衡量一个分布存在不稳定性。(在 Risser E, Wilmot P, Barnes C. Stable and Controllable Neural Texture Synthesis and Style Transfer Using Histogram Losses[J]. 2017. 有提到这一点。) 
 
如果加入了空间控制,那么 
 
如果再加上style II,那么得到如下,可以看到被style II所stransfer只有天空部分。 
 
复现代码:https://github.com/leongatys/NeuralImageSynthesis
Deep Photo Style Transfer(个人很喜欢)
从最初的CNN做style transfer一年多,style transfer出来的都是“画”,并不是照片。直到17年3月份,Cornell和Adobe的这篇论文。 
可以看到,这种风格转换可以使得生成图几乎看不出任何“画”的细节,如同照片一样。所谓“画”就是包含局部的扭曲,这篇论文成功抑制了这种扭曲,将style transfer变成颜色域的仿射变换。 

可以看到,比如第四行,最右侧被子颜色成功变成第二幅的,而前两种方法都没法很好的进行颜色转换,并且前两种方法扭曲明显,比如墙壁的垂直边缘扭曲很明显,而这篇论文的方法就几乎没有这种现象。 
他们还比较了其他一些”spatially-variant color transfer”的方法。效果明显更好。 


他们主要在传统损失函数中加入了一个”Photorealism regularization”项。由于是local color stransfer,所以他们采用 Matting Laplacian of Levin的方法,这种方法将灰度模板用RGB通道的局部仿射组合来表示。所以 
[Math Processing Error]
Lm=∑c=13Vc[O]TMIVv[O]
 
其中,[Math Processing Error]Vc[O]表示第c个通道的输出的向量化(Nx1)。关键点在于这个[Math Processing Error]MI,这个值只和输出有关,[Math Processing Error]Mi是NxN的。
此外,由于Gram矩阵自身是计算整幅图的协方差,并不是局部的,所以就先根据输入图像生成多个masks,然后将该图像标上一系列标签(天空、楼房、水等等),然后把这些模板作为额外通道直接concatenate上去就行。 
[Math Processing Error]
Ls+l=∑c=1C12Nl,c2∑ij(Gl,c[O]−Gl,c[S])ij2
 
[Math Processing Error]
Fl,c[O]=Fl[O]Ml,c[I]
 
[Math Processing Error]
Fl,c[S]=Fl[S]Ml,c[S]
 
可以看到我们需要分别给C图和S图进行分割,还是挺麻烦的。 
最终公式: 
[Math Processing Error]
Ltotal=∑l=1LαlLcl+Γ∑l=1LβlLs+l+λLm
代码:https://github.com/luanfujun/deep-photo-styletransfer 
顺带说一句,3月份公开的论文,现在才过了2个月不到,竟然已经差不多8800多颗star了。。大家挺喜欢这个工作的。。

其他方面
Stable and Controllable Neural Texture Synthesis and Style Transfer Using Histogram Losses
他们发现Gram矩阵用于style transfer的不稳定性,即两种完全不同的分布其Gram矩阵可能是一样的。 
从而提出加入直方图信息来强化约束。用于纹理生成时可以生成更加符合参考图的纹理。 


SON OF ZORN’S LEMMA TARGETED STYLE TRANSFER USING INSTANCE-AWARE SEMENTIC SEGMENTATION
 
以前都是整幅图stransfer的,然后他们想只对一幅图的单个物体进行stransfer,比如下面这幅图是电视剧Son of Zorn的剧照,设定是一个卡通人物生活在真实世界。他们还说这种技术可能在增强现实起作用,比如Pokemon go. 


通过GAN的风格转换
Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks(个人很喜欢)

这个就是一个对偶学习的思想。现在这种论文N多啊。比如discoGAN之类的。这个没什么好说的。

代码:Torch版本(论文原版):https://github.com/junyanz/CycleGAN 
Pytorch版本(仍旧是作者实现的):https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix

待做列表
高优先级

加入ZM-NET
CycleGAN补充
Unsupervised cross-domain image generation
Characterizing and Improving Stability in Neural Style Transfer
Demystifying Neural Style Transfer
低优先级

Multimodal Transfer: A Hierarchical Deep Convolutional Neural Network for Fast Artistic Style Transfer
Visual Attribute Transfer through Deep Image Analogy
StyleBank: An Explicit Representation for Neural Image Style Transfer
对”其他方面”加入加入更多的补充。
--------------------- 
作者:Hungryof 
来源:CSDN 
原文:https://blog.csdn.net/hungryof/article/details/71512406 
版权声明:本文为博主原创文章,转载请附上博文链接!

猜你喜欢

转载自blog.csdn.net/c2a2o2/article/details/83410468