[論文筆記] Perceptual Losses for Real-Time Style Transfer and Super-Resolution

論文出處 : Perceptual Losses for Real-Time Style Transfer and Super-Resolution

Introduction

以往 Style Transfer 以及 Super Resolutiontask 中,計算 ground-truth imagemodel outputpixel 之間對應的差異是最直觀的 object loss,然而在圖像的感知上,pixel-loss function 考量到的差異太過冗餘,並不能真正反映在影像生成的 task 上,論文中舉了一個例子是,假設一 feature map 的每一個 pixel 如果都加上 11,那在 pixel-loss function 的數值會偏大,但是其實在視覺上的感受是差不多的,肉眼不論對於顏色、邊緣、角落較為敏感的是相對關係。
文中認定 Style 代表的是特定 ColorTexture 亦或是較為抽象的 Semantic(High level feature) 的分布,是一種交互關係,一種相對量而並非絕對量,而本文利用了 CNN 架構中不同 level 中的 feature map 針對該 level filter 的性質作相對應的計算來得到新的 object

本文重點 : Feature Reconstruction LossStyle Reconstruction Loss


Framework

[論文筆記] Perceptual Losses for Real-Time Style Transfer and Super-Resolution
左半部在文中實作上是 Residual Connection,且為避免影像過度壓縮而沒有使用 Max Pooling 而是將 stride 設成 22,最後一層的 activation functionscaling tanh 以確保灰度值介於 00255255
右半部的 Loss NetworkImageNet VGG-16pre-train model,用途在於將影像做特徵的提取而並非優化影像的生成,因此在訓練過程中的參數是固定不變的。
y^\hat yImage Transform Netoutputysy_sycy_c 分別代表著兩種不同的 label :Stylecontent,如下圖所示
[論文筆記] Perceptual Losses for Real-Time Style Transfer and Super-Resolution
而該模型架構不單單可以應用在 Style Transfer 上,Super-Resolution 亦可視為一種 Style Target 與原影像相同的 task


Feature Reconstruction Loss

Definition : lfeatϕ,j(y^,y)=1CjHjWjϕj(y^)ϕj(y)22l_{feat} ^{\phi,j}(\hat y,y)=\dfrac{1}{C_{j}H_{j}W_{j}} ||\phi_j(\hat y) - \phi_j(y)||^2_2
jj 代表特定 CNN layer 的編號,CjC_j 為第 jjlayerfilter channel 數量,HjH_{j} 以及 WjW_{j} 則是 kernel size
ϕj(y^)\phi_j(\hat y)ϕj(y)\phi_j(y) 分別是 Loss Network 中代表 Image Transform Net outputcontent targethigh level feature map
其中,背後物理概念是因為在 CNN 架構中,low levelfilter 抓取的通常是基本的幾何特徵,但在影像上面他並沒有辦法把對於人腦中抽象的意義給區分開來,但是 high level 中的 feature map 則是用以描述抽象的、具備語意的特徵,其 highlight 的部分則具備了一定的 distinguishishability,因此將 high level featurepixel-wise difference 作為 object


Style Reconstruction Loss

Definition :lstyleϕ,j(y^,y)=Gj(y^)Gj(y)F2l_{style} ^{\phi,j}(\hat y,y)=||G_j(\hat y) - G_j(y)||^2_F , Gjϕ(x)c,c=ψψT/CjHjWj , ψ,~G^{\phi}_{j}(x)_{c,c'}= \psi\psi^{T}/C_{j}H_{j}W_{j}~,~\psiϕj(x)\phi_j(x) reshape(Cj,HjWj)(C_{j},H_{j}W_{j}) 的矩陣,Gjϕ(x)c,cG^{\phi}_{j}(x)_{c,c'}Gram-Matrix

Gram Matrix 實際上可看做是 feature 之間的 Covariance Matrix,在 feature map 中,每一個數字都來自於一個特定 filter 在特定位置的 convolution,因此每個數字就代表一個特徵的強度,而 Gram 計算的實際上是特徵之間的相關性,哪兩個特征是同時出現的,哪兩個是此消彼長的等等,同時,Gram 的對角線元素,還體現了每個特征在圖像中出現的量,因此,Gram 有助於把握整個圖像的大體風格。有了表示風格的 Gram Matrix,要度量兩個圖像風格的差異,只需比較他們 Gram Matrix 的差異即可。


Total Variation Regularization

除了上述兩者外,文中實作上亦加入 Total Variation Regularizer : lTV(y^)l_{TV}(\hat y),其目的為將分布標準差限制在特定常數下,以達到抗噪的效果。

最終目標函數為 y^=argminy λclfeatϕ,j(y,yc)+λslstyleϕ,j(y,ys)+λTVlTV(y)\hat y={\arg\min}_{y}~\lambda_c l^{\phi,j}_{feat}(y,y_c) + \lambda_s l^{\phi,j}_{style}(y,y_s) + \lambda_{TV} l_{TV}(y)



Experiment

[論文筆記] Perceptual Losses for Real-Time Style Transfer and Super-Resolution
[論文筆記] Perceptual Losses for Real-Time Style Transfer and Super-Resolution