论文 Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks ( CycleGAN ) 学习笔记
1. 模型简介
在之前 pix2pix 论文中,作者已经很好地解决了训练集中有匹配对的图像风格转换问题,本文讨论的是对于训练集中不存在图像匹配对(寻找到匹配的图像数据集成本非常高)的情况下,如何能够较好地实现图像的风格转换。
若使用简单的单一映射 G:X→YG:X \to YG:X→Y,输入图像经过生成器转换为输出图像 y^=G(x),x∈X\hat y=G(x), x \in Xy^=G(x),x∈X,并使输出图像与真实图像难以区分,这种约束太弱,会造成以下问题:
- 存在太多种 GGG 能能够满足该映射条件;
- 难以对目标函数进行优化,容易造成“mode collapse”问题(不同输入对应同一种输出)。
为了解决上述问题,作者给损失函数增加了更多的结构:
- 在希望 G:X→YG:X \to YG:X→Y 的同时,还希望 F:Y→XF:Y \to XF:Y→X,即学习2个能相互转换的生成函数 GGG、FFF,当然也就存在2个不同的判别函数 DYD_YDY、DXD_XDX;
- 希望图像在连续经过 GGG 和 FFF 后能够还原为原来的图像,即 F(G(x))≈xF(G(x)) \approx xF(G(x))≈x,G(F(y))≈yG(F(y)) \approx yG(F(y))≈y。
2. 公式
2.1. 对抗损失(Adversarial Loss)
G:X→YG:X \to YG:X→Y 的对抗损失函数:
LGAN(G,DY,X,Y)=Ey∼pdata(y)[logDY(y)]+Ex∼pdata(x)[1−logDY(G(x))]
\mathcal{L}_{GAN}(G,D_Y,X,Y)=\mathbb{E}_{y\sim p_{data}(y)}[logD_Y(y)]+\mathbb{E}_{x\sim p_{data}(x)}[1-logD_Y(G(x))]
LGAN(G,DY,X,Y)=Ey∼pdata(y)[logDY(y)]+Ex∼pdata(x)[1−logDY(G(x))] 目标是 minGmaxDYLGAN(G,DY,X,Y)\min\limits_G \max\limits_{D_{Y}}\mathcal{L}_{GAN}(G,D_Y,X,Y)GminDYmaxLGAN(G,DY,X,Y)
F:Y→XF:Y \to XF:Y→X 的对抗损失函数:
LGAN(F,DX,Y,X)=Ex∼pdata(x)[logDX(x)]+Ey∼pdata(y)[1−logDX(G(y))]
\mathcal{L}_{GAN}(F,D_X,Y,X)=\mathbb{E}_{x\sim p_{data}(x)}[logD_X(x)]+\mathbb{E}_{y\sim p_{data}(y)}[1-logD_X(G(y))]
LGAN(F,DX,Y,X)=Ex∼pdata(x)[logDX(x)]+Ey∼pdata(y)[1−logDX(G(y))] 目标是 minFmaxDXLGAN(F,DX,Y,X)\min\limits_F \max\limits_{D_{X}}\mathcal{L}_{GAN}(F,D_X,Y,X)FminDXmaxLGAN(F,DX,Y,X)
2.2. 循环一致性损失(Cycle Consistency Loss)
Lcyc(G,F)=Ex∼pdata(x)[∥F(G(x))−x∥1]+Ey∼pdata(y)[∥G(F(y))−y∥1] \mathcal{L}_{cyc}(G,F)=\mathbb{E}_{x\sim p_{data}(x)}[\lVert F(G(x))-x\rVert _1]+\mathbb{E}_{y\sim p_{data}(y)}[\lVert G(F(y))-y\rVert _1] Lcyc(G,F)=Ex∼pdata(x)[∥F(G(x))−x∥1]+Ey∼pdata(y)[∥G(F(y))−y∥1] 作者这里使用的是 L1 损失,在实验中作者还尝试过将其替代为 F(G(x))F(G(x))F(G(x)) 与 xxx 以及 G(F(y))G(F(y))G(F(y)) 与 yyy 的对抗损失(Adversarial Loss),但并未观察到效果的提高。
2.3. Full Objective
将上述两种损失函数组合,得到最终损失函数:
L(G,F,DX,DY)=LGAN(G,DY,X,Y)+LGAN(F,DX,Y,X)+λLcyc(G,F)
\mathcal{L}(G,F,D_X,D_Y)=\mathcal{L}_{GAN}(G,D_Y,X,Y)+\mathcal{L}_{GAN}(F,D_X,Y,X)+\lambda\mathcal{L}_{cyc}(G,F)
L(G,F,DX,DY)=LGAN(G,DY,X,Y)+LGAN(F,DX,Y,X)+λLcyc(G,F) 最终的目标是求:
G∗,F∗=arg minG,FmaxDX,DYL(G,F,DX,DY)
G^*,F^*=arg\ \min\limits_{G,F}\max\limits_{D_X,D_Y}\mathcal{L}(G,F,D_X,D_Y)
G∗,F∗=arg G,FminDX,DYmaxL(G,F,DX,DY)
3. 具体实现
3.1. 网络结构
生成器的网络结构见文献 Perceptual Losses for Real-Time Style Transfer and Super-Resolution 中所写。
判别器的网络结构为 PatchGANs,在 pix2pix 中有所介绍。
3.2. 训练细节
在编程实现中,为了进一步提高效果,作者列出了几点 trick:
- 对于 LGAN\mathcal{L}_{GAN}LGAN 作者采用的是均方误差而不是 log 来进行每一次的更新。
更新 GGG 时,最小化 Ex∼pdata(x)[(DY(G(x))−1)2]\mathbb{E}_{x\sim p_{data}(x)}[(D_Y(G(x))-1)^2]Ex∼pdata(x)[(DY(G(x))−1)2] ;
更新 DDD 时,最小化 Ey∼pdata(y)[(DY(y)−1)2]+Ex∼pdata(x)[DY(G(x))2]\mathbb{E}_{y\sim p_{data}(y)}[(D_Y(y)-1)^2]+\mathbb{E}_{x\sim p_{data}(x)}[D_Y(G(x))^2]Ey∼pdata(y)[(DY(y)−1)2]+Ex∼pdata(x)[DY(G(x))2] - 为减小模型的振荡,在更新判别器时,会使用当前以及一系列过去的生成器生成的图片来进行训练。
- 使用 Adam 算法来进行生成器和判别器的每一步更新,学习率先保持不变,在 epoch 到达100次后,开始线性下降直至为0。
4. 模型评估
模型的评估方式与 pix2pix 相同,采用 Amazon Mechanical Turk(AMT)与 FCN score 的方式。
5. 效果展示
将自然风景图转化为不同画家风格的图:
相近类别的图像进行风格转换:
手机照片到专业相机(远处背景模糊)的图像转换:
- 点赞
- 收藏
- 分享
- 文章举报
- ICCV2017论文“Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks” 阅读笔记
- 论文Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks
- CycleGAN:Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks
- CycleGAN:Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Network阅读笔记
- Image-to-Image Translation with Conditional Adversarial Networks论文学习
- 『论文阅读』Image-to-Image Translation with Conditional Adversarial Networks
- StackGAN: Text to Photo-realistic Image Synthesis with Stacked Generative Adversarial Networks 论文笔记
- Image-to-Image Translation with Conditional Adversarial Networks 论文翻译
- 每日论文image-to-Image Translation with Conditional Adversarial Networks
- 论文笔记之:Deep Generative Image Models using a Laplacian Pyramid of Adversarial Networks
- 《image Style Transfer Using Convolutional Neural Networks》论文笔记
- 【论文笔记】Unpaired Photo-to-Caricature Translation on Faces in the Wild
- DA-GAN: Instance-level Image Translation by Deep Attention Generative Adversarial Networks阅读笔记
- 神经机器翻译RNNsearch(论文Neural Machine Translation by Jointly Learning to Align and Translate) 学习笔记
- [semantic segmentation] using Adversarial Networks 论文学习
- Image-to-Image Translation with Conditional Adversarial Networks
- [深度学习论文笔记][Visualizing] Deep Inside Convolutional Networks Visualising Image Classification
- AlexNet论文(ImageNet Classification with Deep Convolutional Neural Networks)学习笔记
- [深度学习论文笔记][Image to Sentence Generation] Deep Visual-Semantic Alignments for Generating Image Descri
- Unsupervised Image-to-Image Translation Networks---VAE+GAN+Cycle