Unsupervised Attention-guided Image-to-Image Translation

目前的無監督Image-to-Image Translation很難在不改變背景或場景中多個對象的情況下將注意力集中在單個對象上。作者提出了一種方法來解決這個問題。

Introduction

目前的包括CycleGAN在內的許多無監督Image-to-Image Translation方法都無法只關注特定的場景對象,如下圖所示:

為了解決這個問題,作者提出了一種只修改圖像中相關區域的方法,並且將attention機制加入了CycleGAN中的生成器中。下面進行詳細的解釋。

Method

Image-to-Image Translation的任務就是尋找出一個映射 F_{S 	o T} 使得源圖像域 S 轉換到目標域 T ,下面的方法基於CycleGAN。 需要解決兩個重要的問題:

  • 定點陣圖像中需要轉換的區域
  • 對定位區域進行正確的轉換

Attention map intuition

為了解決這兩個問題,作者加入了兩個attention networks A_S,A_T ,這兩個網路通過最大化discriminator出錯的概率來選擇要轉化的區域, A_S:S 	o S_a, A_T:T 	o T_a ,其中, S_a,T_a 是attention map,就相當於一個mask,其值介於0,1之間,這個mask其實就是用來摳圖的,具體可以看下面這張圖:

上圖只展示了CycleGAN中 S	o T 的這部分,我們先看左邊部分, F_{S	o T} 還是對整張圖像進行轉化, A_S 網路學習到了一個attention map,將這個attention map與 F_{S	o T} 的輸出進行element-wise乘積,就提取出了需要轉化的特定對象,然後再加上原圖的背景,生成最終圖像 S ,整個過程可以用下式表示: s=underbrace{s_a odot F_{S	o T}(s)}_{	ext{Foreground}} + underbrace{(1-s_a) odot s}_{	ext{Background}} s_a 全是1,則得到作者的方法的特例CycleGAN;若 s_a 為全0,則輸入圖像和輸出圖像一樣,discriminator可以很輕易的判別;理想的情況是 s_a 只關注圖像中特定的對象,既能夠騙過discriminator,又使得輸出圖像看起來更加真實。

因此,使得 F_{S	o T},A_S,D_T 達到平衡的方法就是使得 A_S 將注意力集中在相應discriminator認為在其領域內最具描述性的對象或區域(例如,馬)。GAN的機制也使得attention networks能夠找到圖像中最具領域描述性的對象。 需要注意的是,attention map的值是在[0,1]之間的連續值,而不像分割的二值化的mask一樣,作者對此的解釋是:

  1. it makes estimating the attention maps differentiable, and so able to train at all;
  2. it allows the network to be uncertain about attention during the training process, which allows convergence;
  3. it allows the network to learn how to compose edges, which otherwise might make the foreground object look 『stuck on』 or produce fringing artifacts.

Loss function

首先是adversarial loss:

然後是cycle-consistency loss:

其中, ss 通過 F_{T	o S}A_T 得到的。 最終得loss為:

其中, lambda_{cyc}=10 ,優化目標是求解minimax問題:

Attention-guided discriminator

前面介紹說,attention network能夠讓網路只關注圖像中特定的對象,然而,這會產生一個問題:生成圖像的背景可能和轉化後的特定對象不搭,舉例來說,Figure 1中原來的馬轉化為了斑馬,但是整幅圖像還是假的,因為馬生活在草原上,而斑馬生活在熱帶稀樹草原。

為了解決這個問題,作者在訓練discriminator的時候只考慮有注意力的區域。簡單的使用 s_aodot s 會有問題,因為剛開始的時候attention network還未訓練,所以作者在前30個epochs使用全圖進行訓練,然後切換到masked image進行訓練。

還有另一個問題,由於attention map是連續的,discriminator可能會得到小數的像素值,這些數值在訓練初期可能會非常接近於0,雖然生成器能夠得益於在對象邊界上混合像素,但是將真實圖像於這些小數值相乘導致discriminator學習到了中灰色是「真實的」(也就是我們將答案推到歸一化[- 1,1]像素空間的中點0),因此作者給學習到的attention map進行閾值處理:

其中, t_{new},s_{new} 分別是目標域樣本 t 和轉換後的源域樣本 s 的masked version, 	au 設置為0.1 由此,原來的adversarial loss(公式2)變為:

下面是源域到目標域 S	o T 的訓練過程演算法:

需要注意的是,為了避免mode collapse問題,作者在30個epoch後停止訓練 A_S,A_T

Experiments

Dataset

  • Apple to Orange( Aleftrightarrow O )
  • Horse to Zebra( H leftrightarrow Z )
  • Lion to Tiger( Lleftrightarrow T )

部分結果展示:

Limitation

  • 對不同domains的shape的變化不魯棒;
  • 只能在attended regions裡面進行轉變;

推薦閱讀:

相关文章