Sitemap

Deep Photo Enhancer

6 min readDec 24, 2018

--

Introduction

透過相機得到的照片往往因為硬體限制、顏色不夠鮮明、解析度低等問題,造成使用者不滿意。因此使用者需要自行透過修圖軟體,手動調整各種參數才能達到滿意的結果,這樣不但耗費人力也耗時。因此,本篇論文提出GAN的技術,來對照片自動做增強。

使用者只需要提供機器一組好的照片,這些照片都有使用者喜歡的特徵,例如:對比度高、解析度高等特性,機器就能學習如何將不好的照片轉成好的照片,就是image-to-image translation problem。

為了得到photo enhancer,能夠將input image x 轉成output image,作為x的enhanced version。需要使用者自行提供一組好的照片當作範本,這些照片都有共同的特徵,機器會將x轉為擁有這些特徵的照片。

論文提出了兩種方法,第一種是supervised learning,第二種是unsupervised learning,可再分為one-way GAN 與two-way GAN。

Press enter or click to view image in full size

The dataset

使用MIT-Adobe 5K dataset來training 與 testing,包含5000張照片,並挑選photographer C的修圖做為labels。把此dataset分為三部分,第一部分是2250張照片及對應的修圖版本,作文supervised learning的訓練資料。第二部分是2250張照片及另外2250張照片對應的修圖版本,前者為source domain,後者為target domain,用於訓練GAN,剩餘的500張照片用於testing。

Supervised Learning

Press enter or click to view image in full size

採用paired learning,Generator使用U-Net架構,並加入global feature,可以考量光線條件與場景設定。每個convolution layer包含5*5 filters,再接著SELU activation與batch normalization,直到維度是1*1*128,再copy32倍與原本的feature map做concatenated,這樣就融合了global feature 與local feature。另外還加入resudual learning,來加速學習效果。

loss function是為了maximize PSNR。

實驗結果:

Press enter or click to view image in full size

One-way GAN

採用unpaired training,GAN架構使用了GAN、LSGAN、DRAGAN、WGAN-GP,identity loss

確保output與input相似, α為identity loss的權重。D/G為discriminator與generator的訓練比例。從實驗結果來看,可以發現WGAN-GP的效果比其他的好,但很容易受到lambda的設定影響結果。

Press enter or click to view image in full size

WGAN使用Lipschitz contraint,確保梯度小於等於1。

yˆ is point sampled along straight lines between point in the target distribution and the generator distribution.

Get ivlab’s stories in your inbox

Join Medium for free to get updates from this writer.

λ為其權重,當λ太小,就無法遵守Lipschitz constraint,當λ太大,則收斂速度太慢。

因此對於λ的設定,採用adaptive weighting scheme來調整λ,使梯度介於[1.001,1.05],若梯度大於1.05則將 λ調高兩倍-->2 λ;若梯度小於1.001則將 λ除以--> λ/2。

由上面的實驗結果可以發現,若採用adaptive weighting scheme,則無論 λ初始為何,最終target distribution與 generator distribution都會重疊。

Two-way GAN

Gx 與 G‘x使用相同的參數,Gy 與 G‘y也是,但使用了individual BN,也就是Gx 與 G‘x的batch normalization layer參數各自設定,使他們各自學習自己的輸入分布,前者輸入為x,後者輸入為x'。Gy 與 G‘y也是同樣方式。

Loss function

identity loss: 確保transformed image y 與 input image x相似。

cycle consistency loss:為了讓轉換回source domain的照片與原本在source domain相似。

adversarial losses for discriminator AD 與 generator AG:

訓練discriminator,使用的gradient penalty P:

綜合上述,訓練discriminator:

訓練generator:

最終的AG就是我們的photo enhancer。

Result

(a)為原始照片(b)是使用Flickr images tagged with HDR 做為training data,共選了627張(c)為使用HDR訓練2-way GAN,沒有用individual BN(d)使用supervised learning(e)使用unsupervised learning

--

--