天天看點

Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)

paper: Li, Yijun, et al. “Diversified texture synthesis with feed-forward networks.” IEEE CVPR 2017.

目前的判别和生成模型在紋理合成方面有較好的效果。但是,現存的基于前饋神經網絡的方法往往犧牲generality(普遍性)來換取效率,這往往會引發以下問題: 1) 訓練出的網絡缺少generality(普遍性) : 也就是說對于每種紋理都要訓練一個網絡

2) 缺少diversity(多樣性): 也就是說不同的輸入容易得到視覺上幾乎相同的輸出。

3) suboptimality: 生成的效果不理想

文章訓練了一種網絡能夠用一個網絡生成多種texture,并能在測試階段通過插值的方法生成新的紋理。

Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)

用one-hot selction unit來表示紋理。之後将将這個one-hot selection unit 映射到一個低維、連續的embedding vector。

noise vector負責産生噪聲,用noise vector和embedding vector進行外積,得到一個矩陣,然後用 1 × 1 1\times 1 1×1的卷積去得到多個channel的tensor。最終再通過一系列的upsample和卷積去得到 256 × 256 × 3 256\times 256 \times 3 256×256×3的圖像輸出。這一流程稱為Generator Stream, 除此之外下方還有一個Selector Stream, embedding vector通過不斷的upsample得到一系列不同尺度的feature map。

這些feature map和Generator Stream中的特征進行融合 用來指導的圖像生成。

(PS: 外積的概念,來自Wikipedia )

Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)

最終生成的圖像被送到一個預訓練好的固定VGG網絡,通過VGG網絡不同層提取到的特征計算統計量,并去和目标紋理的統計量進行比對。

(Parametric methods [17, 27] for texture synthesis aim

to represent textures through proper statistical models, with

the assumption that two images can be visually similar

when certain image statistics match well [20].)

Loss Function

使用texture loss和diversity loss。

Texture Loss
Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)

其中G代表Gram 矩陣。

We use the activations at the conv1_1, conv2_1, conv3_1, conv4_1 and conv5_1 layer of the VGG model.

However,文章發現直接使用Gram矩陣生成的圖像效果并不好: 生成的紋理存在明顯的artifacts和顔色混合問題。 他們将這種問題歸結于不同材質Gram矩陣大小上的差異。

并提出了如下修改後的loss:

也就是對特征減去均值(進行中心化)後再來求偏心協方差矩陣。

這個均值是指某個layer中所有激活值的均值,即包含所有channel的Tensor的均值。

(Gram矩陣反應的是不同channel之間關聯程度)

Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)

觀察發現用減去均值之後的feature來求Gram矩陣的生成效果明顯更好。

不減去均值生成圖檔中會有artifacts出現。

沒有中心化時,使用不同風格圖檔指導風格化時loss和梯度會發生劇烈變化。文章認為這樣網絡會去學習深度特征的規模,而不是去區分不同紋理圖像的差異。

Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)
Diversity loss.

目前的前饋方法很容易得到一個退化的解法: 不同的輸入得到一個近似相同的輸出(有時候會表現為一個較差的模式并在輸出圖像中重複出現)。

文章認為這種結果的出現是因為訓練時隻用texture loss去讓輸出圖像的style和目标圖像保持一緻,但并沒有提出輸出具有多樣性的要求。換句話說,每個輸出的結果和網絡輸入部分的噪聲并沒有關聯起來。

為了解決這個問題,文章提出了diversity loss,要求對于同一種輸入不同噪聲的情況下,輸出圖像盡可能不同:

Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)

具體參數說明:

Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)

其中 Φ \Phi Φ用代表VGG網絡conv4_2層提取到的特征,Q相當于對排列P進行了一次shuffle。這個loss每個batch求一次。

由于要求下面這個式子盡可能大,是以在訓練時 L d i v e r s i t y L_diversity Ld​iversity前面會有一個負系數。

Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)
Final loss function
Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)

其中 α = 1 , β = − 1 \alpha=1,\beta=-1 α=1,β=−1。

Incremental training

增量式學習

對于每次訓練時,選中的訓練樣本在selection unit中對應的bit為1,其它bits為0。

(Once a target texture is selected, we set the corresponding bit in the

selection unit as 1 and the corresponding texture is used to

compute the texture loss.)

文章通過實驗論證了增量式的訓練方式較随機抽取樣本的方式進行訓練有更好的效果。

随機抽取樣本進行訓練出現的問題:

雖然,對于在某個iteration中随機抽取到的樣本的學習效果有所提升,這種提升在之後的iterations中容易被限制住,之後的iterations往往會去優化其它樣本的學習效果。 總之,學習效果不佳,并且最後學習到一個局部最優點。

增量學習方法:1) 學好一個任務之後(收斂後),再去學習新的任務。

2) 并且在學習新任務的時候時常複習之前學習的任務,以保證網絡不遺忘/記住如何去生成舊的目标圖像。

具體來說,前K個iteration,将selection unit的第1個bit設定為1(去學習第一個紋理)。

在接下來的K個iteration中,交替學習第1個和第2個紋理。依次列推…

在所有紋理都被學習之後,訓練的樣本使用随機采樣的方法直到收斂。

實驗結果證明了增量式學習比随機抽取樣本學習效果好。

Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)
Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)

有趣的是,文章發現當網絡學習到的紋理足夠多時,再去學習一種新的紋理時速度會變快(收斂所需的iteration次數降低)

Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)

Experimental Results

Multi-texture synthesis
Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)
Diversity
Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)

與其它方法相比,文章提出方法的diversity更強,這是因為顯示地提出了diversity loss。雖然[32] 通過注入不同尺度的噪聲來增強diversity。但沒有顯示地限制條件去要求具有多樣性,這樣注入噪聲後較大的變化/差異,可能會被減少或是被網絡吸收,這樣仍然會使輸出的多樣性有限。

Interpolation

插值的目的主要是創造新的紋理,即通過生成大量樣本,再通過對這些樣本插值來創造新的紋理。

Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)

上圖中第一行為紋理20到紋理19的插值圖像。這通過逐漸減少selection unit中第20bit的權值,并且逐漸增加selection unit中第19bit的權值,同時保持其它bit為0來實作。

其它方法 [14]通過對Gram矩陣進行插值來實作。

Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)
Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)
Extension to multi-style transfer (拓展到風格遷移)

風格遷移:

全局内容保持不變,風格和局部結構發生變化。

Given a style image and a content image, image stylization aims at synthesizing an image that preserves the global content while transferring the colors and local structures from the style image。

結構:

Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)

當選擇一種風格時,noise map對應bit上的值随機初始化,其它bit上的值為0。

注意此時應該仍然有selction unit,感覺上圖有所省略。(selection unit中這種風格對應的bit應該為1,其它bit應該為0。)

Fig. 12中上方用一個Encoder對圖像進行提取特征。

之後生成的圖像用VGG提取特征并施加三種loss:style和diversity loss和之前介紹的texture loss和diverstiy loss相同。

content loss 計算用VGG conv4_2層分别對生成圖像和輸出圖像提取出特征的差異。

The content loss is computed as the feature differences between the

transferred result and the content at the conv4_2 layer of the

VGG model as in [14].

Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)
Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)

風格插值:

Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)
Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)

多樣性:

Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)

不同于紋理生成:由于保留内容資訊 (content) 的限制,圖像的全局結構會保持不變。

是以,diversity被表現在局部視覺結構。注意上圖中不同結果之間輕微但有意義的差異/變化。

Discussion

Selector network

The selector injects guidance to the generator at every upsampling scale and

helps the model distinguish different textures better during the synthesis.

選擇器的作用:

Diversified texture synthesis with feed-forward networks (紋理生成、風格遷移,CVPR2017)
Embedding

将selection unit映射到一個低維的embedding中,實驗證明這樣仍然可以區分不同的紋理用于生成,這證明了one-hot 表示是備援的。

Conclusion

In order to train a deep network for multi-texture synthesis, we introduce the

diversity loss and propose an incremental leaning scheme.

繼續閱讀