58同城枣庄网站建设,dw制作网页步骤,系统官网网站模板下载地址,网站地址查询域名非配对的图像转换应用 Unpaired Image-to-Image Translation
Unpaired image-to-image translation 主要用于学习两组图像之间的对应关系#xff0c;检查和寻找两堆数据中的共同内容#xff08;content#xff09;以及每堆独有的特点#xff08;style#xff09;。而这个…非配对的图像转换应用 Unpaired Image-to-Image Translation
Unpaired image-to-image translation 主要用于学习两组图像之间的对应关系检查和寻找两堆数据中的共同内容content以及每堆独有的特点style。而这个模型是非监督的也就意味着不需要进行数据的标注便可以进行训练。 CycleGAN 循环GANs模型
循环一致性 Cycle Consistency
循环一致性指的是当图片经过生成模型后再次经过生成模型的反向模型而得到的循环后的模型其图片与原图片的一致性问题。
当然如果循环后图片与原图片一模一样当然是最好的这证明了了模型的稳定性。而在循环模型中我们通过这种方式来告诉两个模型哪些是特征哪些不是特征。这样我们不用通过对数据进行标注而是原图像与循环后的图像互为配对以此来互相纠正模型的错误并使其能够达到我们想要的效果。 模型结构 - Two GANs
Cycle会存在两个GANs分别代表两个方向。比如说我们要把正常马的身上涂上白色斑纹变为斑马。那么在Cycle GANs中模型会由两个生成器正常马生成斑马斑马生成正常马和两个分辨器分辨生成的斑马与实际斑马的分辨器以及分辨生成的马与实际马的分辨器所组成。 因此Cycle GAN使用两个GAN来进行图片到图片的转化 CycleGAN uses two GANs for unpaired image-to-image translation。并且其分辨器是经典的PatchGANs也就是分辨结果是一个分类矩阵而不是一个简单的值。其生成器十分类似于U-Net和DCGAN但是在其中加入了SKIP CONNECTIONs, 也就是增加了层之间的信息交互。 、
其中和U-Net最大的区别就是中间的Residual Block (残留区块)这种区块可以相当于一种skip function它不是作为新的通道被串联起来而是直接添加到卷积的输出。在下面的可视化中你可以想象条纹是由卷积产生的然后添加到马的原始图像中将其转化为斑马。这些跳过连接也允许网络更加深入因为它们有助于解决梯度消失的问题当神经网络变得太深梯度在反向传播中倍增变得非常小的时候就会出现梯度消失的问题相反这些跳过连接能够实现更多的梯度流动。一个更深的网络通常能够学习更复杂的特征。Residual Block的解释还有待进一步研究*。 正向的从斑马到正常的马 反向的从正常的马到斑马 总之由于是无监督的学习数据并没有配对因此并没有明确的目标输出。而且不同的分辨器分辨的是不同类型的数据。
损失函数
循环一致性损失 Cycle Consistency Loss
正向的从斑马到马再到斑马的循环一致性 经过连个生成器保持一致是非常重要的性质其可以让模型去分析两组图片中的唯一特性有条纹和没有条纹和共同特性马的形状并将其他模型所误判断的特性进行逐渐的纠正。
反向的从马到斑马再到马的循环一致性 另一种理解便是循环一致性Cycle consistency可以将不一致的特征进行传递而保持一致的内容。而且这种损失可以缓慢地矫正生成器生成结果的趋势且两个方向的一致性都需要保证。
具体的实例代码如下。
def get_identity_loss(real_X, gen_YX, identity_criterion):Return the identity loss of the generator given inputs(and the generated images for testing purposes).Parameters:real_X: the real images from pile Xgen_YX: the generator for class Y to X; takes images and returns the images transformed to class Xidentity_criterion: the identity loss function; takes the real images from X andthose images put through a Y-X generator and returns the identity loss (which you aim to minimize)identity_X gen_YX(real_X)identity_loss identity_criterion(identity_X, real_X)return identity_loss, identity_X 最小均方误差 Least Squares Loss
最小均方误差的损失函数在某些情况下可以解决vanishing gradients 和 mode collapse的问题其定义如下所示。 其定义的原理主要是预测值与真实值的差距类似于BCEloss 但是其的平方特性使得其比BCELoss更加的稳定。 不变性损失 Identity Loss
加入该损失可以非常有效地避免生成器改变图片颜色的问题其主要利用像素距离来告诉生成器进行一定的纠正。
具体的操作便是将图片经过反向的生成器将生成的结果与原结果比较像素距离。如果相同则说明其能够分辨出这个结果不需要进行任何变化而不相同则说明生成器还有待进步。 而加入不变性损失会非常高效的保留原相片的颜色Color preservation如下图所示。 具体的示例代码如下。
def get_identity_loss(real_X, gen_YX, identity_criterion):Return the identity loss of the generator given inputs(and the generated images for testing purposes).Parameters:real_X: the real images from pile Xgen_YX: the generator for class Y to X; takes images and returns the images transformed to class Xidentity_criterion: the identity loss function; takes the real images from X andthose images put through a Y-X generator and returns the identity loss (which you aim to minimize)identity_X gen_YX(real_X)identity_loss identity_criterion(identity_X, real_X)return identity_loss, identity_X
模型总结
正向结构的模样 反向结构的模样 损失函数的结构 参考文献 Reference
(Optional) The CycleGAN Paper
Compelled to learn more about CycleGAN? Take a look at the original paper!
Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks (Zhu, Park, Isola, and Efros, 2020): https://arxiv.org/abs/1703.10593
(Optional) CycleGAN for Medical Imaging
Intrigued by the application of CycleGANs in the medical field? See how they can be used to help augment data for medical imaging!
Data augmentation using generative adversarial networks (CycleGAN) to improve generalizability in CT segmentation tasks (Sandfort, Yan, Pickhardt, and Summers, 2019):
(Optional Notebook) MUNIT
https://colab.research.google.com/github/https-deeplearning-ai/GANs-Public/blob/master/C3W3_MUNIT_(Optional).ipynb
Please note that this is an optional notebook, meant to introduce more advanced concepts if youre up for a challenge, so dont worry if you dont completely follow!
In this notebook, you will learn about and implement MUNIT, a method for unsupervised image-to-image translation, as proposed in Multimodal Unsupervised Image-to-Image Translation (Huang et al. 2018).