Abstract
Generative adversarial networks (GANs) have recently found applications in image editing. However, most GAN-based image editing methods often require large-scale datasets with semantic segmentation annotations for training, only provide high level control, or merely interpolate between different images. Here, we propose \textit{EditGAN}, a novel method for high-quality, high-precision semantic image editing, allowing users to edit images by modifying their highly detailed part segmentation masks, e.g., drawing a new mask for the headlight of a car. EditGAN builds on a GAN framework that jointly models images and their semantic segmentations~\cite{zhang2021datasetgan,li2021semantic}, requiring only a handful of labeled examples — making it a scalable tool for editing.
生成对抗网络(GANs)最近在图像编辑领域得到了广泛的应用。然而,大多数基于gan的图像编辑方法往往需要使用带有语义分割注释的大规模数据集进行训练,或者只提供高级的控制,或者仅仅在不同的图像之间进行插值。在这里,我们提出了\textit{EditGAN},一种新的高质量、高精度的语义图像编辑方法,允许用户通过修改其高度详细的部分分割蒙版来编辑图像,例如,绘制一个新的汽车前灯蒙版。EditGAN建立在一个GAN框架上,该框架联合建模图像及其语义分割~引用{zhang2021datasetgan,li2021semantic},只需要少量的标记示例——使其成为一个可伸缩的编辑工具。
Specifically, we embed an image into the GAN’s latent space and perform conditional latent code optimization according to the segmentation edit, which effectively also modifies the image. To amortize optimization, we find ``editing vectors’’ in latent space that realize the edits. The framework allows us to learn an arbitrary number of editing vectors, which can then be directly applied on other images at interactive rates. We experimentally show that EditGAN can manipulate images with an unprecedented level of detail and freedom, while preserving full image quality.We can also easily combine multiple edits and perform plausible edits beyond EditGAN’s training data. We demonstrate EditGAN on a wide variety of image types and quantitatively outperform several previous editing methods on standard editing benchmark tasks. Project page: {\footnotesize\url{https://nv-tlabs.github.io/editGAN}}.
具体来说,我们将图像嵌入到GAN的潜空间中,并根据分割编辑进行条件潜码优化,有效地修改了图像。为了平摊优化,我们在潜在空间中找到实现编辑的“编辑向量”。该框架允许我们学习任意数量的编辑矢量,然后可以直接应用于其他图像的交互速率。实验表明,EditGAN能够以前所未有的细节和自由度操纵图像,同时保持完整的图像质量。我们还可以轻松地组合多个编辑,并在EditGAN的训练数据之外执行貌似合理的编辑。我们在各种各样的图像类型上演示了EditGAN,并在标准编辑基准任务上定量地优于以前的几种编辑方法。项目页面:{https://nv-tlabs.github.io/editGAN}} {\ footnotesize \ url。
AI-driven photo and image editing has the potential to streamline the workflow of photographers and content creators and to enable new levels of creativity and digital artistry~\cite{Bailey2020thetools}. AI-based image editing tools have already found their way into consumer software in the form of neural photo editing filters, and the deep learning research community is actively developing further techniques. A particularly promising line of research uses generative adversarial networks (GANs)~\cite{goodfellow2014generative,radford2015unsupervised,karras2017progressive,karras2019style,karras2020analyzing} and either embeds images into the GAN’s latent space or works directly with GAN-generated images.
人工智能驱动的照片和图像编辑有潜力简化摄影师和内容创造者的工作流程,并使创造力和数字艺术达到新的水平~引用{Bailey2020thetools}。基于人工智能的图像编辑工具已经以神经照片编辑滤镜的形式进入消费软件,深度学习研究团体正在积极开发进一步的技术。一个特别有前途的研究领域使用生成对抗网络(GANs)~引用{goodfellow2014生成,radford2015无监督,karras2017进步,karras2019风格,karras2020analyzing},或者将图像嵌入到GAN的潜在空间,或者直接使用生成对抗网络生成的图像。
Careful modifications of the latent embeddings then translate to desired changes in generated output, allowing, for example, to coherently change facial expressions in portraits~\cite{choi2018stargan,lee2020maskgan,wu2020cascade,shen2020interpreting,shen2020interfacegan,alharbi2020disentangled,hou2020guidedstyle,Navigan_CVPR_2021}, change viewpoint or shapes and textures of cars~\cite{zhang2020image}, or to interpolate between different images in a semantically meaningful manner~\cite{collins2020editing,zhu2020sean,lewis2020vogue,kim2021stylemapgan}.
仔细修改的嵌入的然后翻译生成所需的变化输出,允许,例如,连贯地改变面部表情在肖像~ \引用{choi2018stargan、lee2020maskgan wu2020cascade, shen2020interpreting, shen2020interfacegan, alharbi2020disentangled, hou2020guidedstyle, Navigan_CVPR_2021},改变汽车的视角或形状和纹理~引用{zhang2020image},或以语义有意义的方式在不同的图像之间插入~引用{collins2020editing,zhu2020sean,lewis2020vogue,kim2021stylemapgan}。
Most GAN-based image editing methods fall into few categories. Some works rely on GANs conditioning on class labels or pixel-wise semantic segmentation annotations~\cite{zhu2020sean,lee2020maskgan,chen2020deepfacedrawing,wu2020cascade}, where different conditionings lead to modifications in the output, while others use auxiliary attribute classifiers~\cite{he2019attgan,hou2020guidedstyle} %of high-level image attributes
to guide synthesis and edit images. However, training such conditional GANs or external classifiers requires large labeled datasets. % with class labels or pixel-wise semantic segmentation labels.
大多数基于网络的图像编辑方法可以分为几类。有些作品依赖于GANs对类标签或像素语义分割标注的调节~\引用{zhu2020sean,lee2020maskgan,chen2020deepfacedrawing,wu2020cascade},其中不同的条件导致输出的修改,而另一些使用辅助属性分类器~\引用{he2019attgan,hou2020guidedstyle} %的高级图像属性
指导合成和编辑图像。然而,训练这样的条件GANs或外部分类器需要大量的标记数据集。%带有类标签或像素语义分割标签。
Therefore, these methods are currently limited to image types for which large annotated datasets are available, like portraits~\cite{lee2020maskgan}. Furthermore, even if annotations are available, most techniques offer only limited editing control, since these annotations usually consist only of high-level global attributes or relatively coarse pixel-wise segmentations. %, or the method merely interpolates between different images.
Another line of work focuses on mixing and interpolating features from different images~\cite{collins2020editing,zhu2020sean,lewis2020vogue,kim2021stylemapgan}, thereby requiring reference images as editing targets and usually also not offering fine control. Other approaches carefully analyze and dissect GANs’ latent spaces, finding disentangled latent variables suitable for editing~\cite{bau2019gandissect,bau2019semantic,shen2020interpreting,shen2020interfacegan,alharbi2020disentangled,plumerault2020Controlling,harkonen2020ganspace}, or control the GANs’ network parameters~\cite{bau2019semantic,bau2020rewriting,Navigan_CVPR_2021}. Usually, these methods do not enable detailed editing and are often slow.
因此,这些方法目前仅限于可以使用大型注释数据集的图像类型,比如肖像~\引用{lee2020maskgan}。此外,即使可以使用注释,大多数技术也只提供有限的编辑控制,因为这些注释通常只包含高级的全局属性或相对粗糙的像素级分割。%,或者该方法仅仅在不同的图像之间进行插值。
另一条线的工作重点是混合和插值不同图像的特征~\引用{collins2020editing,zhu2020sean,lewis2020vogue,kim2021stylemapgan},因此需要参考图像作为编辑目标,通常也不提供良好的控制。其他方法仔细分析和解剖gan的潜在空间,发现解纠缠的潜在变量适合编辑~引用{bau2019gandissect,bau2019semantic, shen2020interpretation, shen2020interegan, alharbi2020dis, plumerault2020control,harkonen2020ganspace},或控制GANs的网络参数~\引用{bau2019semantic, bau2020rewrite,Navigan_CVPR_2021}。通常,这些方法不支持详细编辑,而且通常很慢。
In this work, we are addressing these limitations and propose \textit{EditGAN}, a novel GAN-based image editing framework that enables high-precision semantic image editing by allowing users to modify detailed object part segmentations. EditGAN builds on a recently proposed GAN that jointly models both images and their semantic segmentations based on the same underlying latent code~\cite{zhang2021datasetgan,li2021semantic}, and requires as few as 16 labeled examples — allowing it to scale to many object classes and choices of part labels.
在这项工作中,我们解决了这些限制,并提出了一个新的基于gan的图像编辑框架,通过允许用户修改详细的对象部分分割来实现高精度的语义图像编辑。EditGAN基于甘最近提议联合模型图像和他们的语义分割基于相同的底层潜在的代码~ \引用{zhang2021datasetgan, li2021semantic},并要求只有16个标签的例子——允许它扩展到许多对象类和选择部分的标签。
We achieve editing by modifying the segmentation mask according to a desired edit and optimizing the latent code to be consistent with the new segmentation, thus effectively changing the RGB image. %Since the latent code of images and segmentations is shared, the RGB image changes during this optimization, obeying the modification in segmentation.
To achieve efficiency, we learn \textit{editing vectors} in latent space that realize the edits, and that can be directly applied on other images, without any or only few additional optimization steps. We can thus pre-train a library of interesting edits that a user can directly utilize in an interactive tool.
%This in itself already allows flexible image editing, but is slow as it relies on optimization.
%To improve efficiency, we utilize the initial and final state of the optimization to define an \textit{editing vector} in latent space that realizes the edit, essentially amortizing the optimization. For many editing operations, this vector can then be directly applied on other images, without any or only few additional optimization steps. Therefore, we have to learn the edit only once in this case, and can then apply the edit on new images at interactive rates. Hence, also the manual segmentation modification needs to be done only once. We can thus pre-design a library of interesting edits that a user could directly utilize in an interactive tool.
我们通过根据需要的编辑修改分割掩码,并优化潜码使其与新的分割一致来实现编辑,从而有效地改变RGB图像。%由于图像和分割的潜代码是共享的,所以在此优化过程中RGB图像会发生变化,服从分割时的修改。
为了达到效率,我们学习\textit{editing vector}在潜在空间中实现编辑,可以直接应用到其他图像上,没有任何或只有几个额外的优化步骤。因此,我们可以预先训练一个有趣的编辑库,用户可以直接在交互工具中使用。
这本身已经允许灵活的图像编辑,但由于它依赖于优化,速度很慢。
%为了提高效率,我们利用优化的初始和最终状态在潜在空间中定义一个\textit{editing vector}来实现编辑,本质上是摊销优化。对于许多编辑操作,这个矢量可以直接应用到其他图像上,而不需要任何或只有一些额外的优化步骤。因此,在这种情况下,我们只需要学习一次编辑,然后就可以在新的图像上以交互速率应用编辑。因此,手动分段修改也只需要做一次。因此,我们可以预先设计一个有趣的编辑库,用户可以直接在交互工具中使用。
We apply EditGAN on a wide range of images, including images of cars, cats, birds, and human faces, demonstrating unprecedented high-precision editing. We perform quantitative comparisons to multiple baselines and outperform them in metrics such as identity preservation, quality preservation, and target attribute accuracy, while requiring orders of magnitude less annotated training data. EditGAN is the first GAN-driven image editing framework, which simultaneously \textbf{(i)} offers very high-precision editing, \textbf{(ii)} requires only very little annotated training data (and does not rely on external classifiers), \textbf{(iii)} can be run interactively in real time, \textbf{(iv)} allows for straightforward compositionality of multiple edits, \textbf{(v)} and works on real embedded, GAN-generated, and even out-of-domain images.
我们将EditGAN应用于广泛的图像,包括汽车、猫、鸟和人脸的图像,展示了前所未有的高精度编辑。我们对多个基线进行定量比较,并在标识保存、质量保存和目标属性准确性等指标上优于它们,同时需要的标注训练数据要少几个数量级。EditGAN是第一个gan驱动的图像编辑框架,它同时提供非常高精度的编辑,textbf{(i)}只需要非常少的标注训练数据(且不依赖于外部分类器),textbf{(ii)}可以实时交互式运行,\textbf{(iv)}允许简单的组合多个编辑,\textbf{(v)}和工作在真实的嵌入式,gan生成,甚至域外的图像。
We can effectively learn an arbitrary number of editing operations and can freely ``design’’ those edits according to our needs. %, in contrast to previous works that merely discover a limited number of possible edits by analyzing the latent space for disentangled latent variables.
In principle, our editing capabilities are only limited by the level of detail of our segmentation annotation. In fact, this is where the second crucial advantage of EditGAN lies: In contrast to conditional GANs, EditGAN can be trained in a semi-supervised manner~\cite{zhang2021datasetgan,li2021semantic}, requiring only very few annotations, as few as 16 in our case. We can therefore quickly annotate a couple of images with a great level of detail for any dataset and even tailor those annotations to the downstream edits we envision. Hence, our framework is easily applicable for virtually any dataset that the GAN can model, without requiring large scale annotated datasets like previous works. Finally, it is worth mentioning that EditGAN can be applied both on images generated by the GAN itself and also on other images by embedding them into the GANs latent space first. % using an encoder and optimization.
We see our method as complementary to previous works that aim at editing images on a coarser, more high-level scale. %, for example via attribute classifier guidance~\cite{hou2020guidedstyle}.
我们可以有效地学习任意数量的编辑操作,并可以根据我们的需要自由地“设计”这些编辑操作。%,相比之下,以前的工作仅仅通过分析解纠缠潜变量的潜空间来发现有限数量的可能编辑。
原则上,我们的编辑功能只受分割注释的详细程度的限制。事实上,这就是EditGAN的第二个关键优势所在:与条件gan相比,EditGAN可以以半监督的方式进行训练~\引用{zhang2021datasetgan,li2021semantic},只需要很少的注释,在我们的例子中只需16个注释。因此,我们可以快速地为任何数据集注释一些图像,甚至可以将这些注释定制到我们预想的下游编辑中。因此,我们的框架很容易适用于GAN可以建模的任何数据集,而不需要像之前的工作那样需要大规模的注释数据集。最后,值得一提的是,EditGAN既可以应用于GAN自身生成的图像,也可以应用于其他图像,首先将它们嵌入到GAN潜伏空间中。%使用编码器和优化。
我们认为我们的方法是对之前的工作的补充,旨在编辑图像在一个粗糙的,更高级的规模。%,例如通过属性分类器引导~\引用{hou2020guidedstyle}。
In summary, we make the following contributions: \textbf{(i)} We introduce EditGAN, a new framework for high-precision semantic image editing, based on a novel segmentation-conditional optimization scheme using a GAN that jointly models images and their semantic segmentation masks. It requires only a handful of annotations during training, which makes our method scalable and applicable to a broad range of datasets. \textbf{(ii)} We propose two modes of operation for EditGAN: On the one hand, manual modification of the segmentation combined with conditional optimization allows to realize even complex and large-scale edits for diverse images with very fine control. On the other hand, we suggest to amortize the iterative optimization and learn editing vectors in latent space that directly transfer to other images without or with only little further iterative optimization, allowing for real-time editing. \textbf{(iii)} Experimentally, we apply EditGAN on a wide range of images, including images of cars, cats, birds, and human faces, demonstrating unprecedented high-precision editing on all of them. \textbf{(iv)} We perform quantitative comparisons to multiple baselines and show that we generally outperform them in metrics such as identity preservation, quality preservation, and target attribute accuracy, while requiring orders of magnitude less annotated training data.
在此基础上,我们提出了一种新的基于分割条件优化的框架——EditGAN,该框架将图像及其语义分割掩模联合起来,实现了图像的高精度语义编辑。在训练过程中,它只需要少量的注释,这使我们的方法具有可伸缩性,并适用于广泛的数据集。我们提出了EditGAN的两种操作模式:一方面,手工修改分割,结合条件优化,可以在非常精细的控制下实现对多种图像的复杂和大规模的编辑;另一方面,我们建议将迭代优化摊销,学习潜在空间中的编辑向量,这些编辑向量可以直接转移到其他图像上,不需要或只需要很少的进一步迭代优化,从而实现实时编辑。实验上,我们将EditGAN应用于广泛的图像,包括汽车、猫、鸟和人脸的图像,在所有这些图像上展示了前所未有的高精度编辑。我们对多个基线进行了定量比较,结果表明,我们通常在标识保持、质量保持和目标属性准确性等指标上优于它们,同时需要的标注训练数据少了几个数量级。
\begin{figure*}[t!]
\vspace{-2.5mm}
\vspace{-4mm}
\begin{center}
\includegraphics[width=0.99\linewidth,clip]{figs/teaser/new_teaser_fixed.pdf}
\end{center}
\vspace{-2mm}
\caption{\footnotesize (\textbf{1}) EditGAN builds on a GAN framework that jointly models images and their semantic segmentations. (\textbf{2 \& 3}) Users can modify segmentation masks, based on which we perform optimization in the GAN’s latent space to realize the edit. (\textbf{4}) Users can perform editing simply by applying previously learnt editing vectors and manipulate images at interactive rates.}
EditGAN建立在一个GAN框架上,该框架联合建模图像及其语义分割。(\textbf{2 \& 3})用户可以修改分割蒙版,在此基础上,我们对GAN的潜空间进行优化来实现编辑。(\textbf{4})用户可以简单地通过应用之前学习的编辑矢量来执行编辑,并以交互速率操作图像。}
\vspace{-5mm}
\end{figure*}
\section{Related Work}
\vspace{-2mm}
\textbf{Image Editing and Manipulation.} Image Editing has a long history in computer vision and graphics, as well as machine learning~\cite{wolberg1994digital,efros2001image,hertzmann2001image,reinhard2001color,perez2003poisson,schaefer2006image,barnes2009patchmatch,tao2010error,gatys2016imagestyel,zhu2017unpaired,portenier2018faceshop,ling2020variational,collins2020editing,wu2020cascade,bau2020rewriting,park2020swapping,kim2021grivegan,Navigan_CVPR_2021}. Recently, deep generative models~\cite{goodfellow2014generative,kingma2014vae,rezende2014stochastic}, in particular modern GANs~\cite{karras2017progressive,brock2018large,karras2019style,park2019semantic,karras2020analyzing}, received much attention as a promising tool for efficient image editing, as it was found that latent space manipulations often lead to interpretable and predictable changes in output~\cite{goetschalckx2019ganalyze,bau2019gandissect,jahanian2020Osteerability,voynov2020unsupervised,plumerault2020Controlling,harkonen2020ganspace,wang2021geometric}.
\textbf{图像编辑和操作。图像编辑在计算机视觉和图形学领域有着悠久的历史,和机器一样学习~ \引用{wolberg1994digital、efros2001image hertzmann2001image, reinhard2001color, perez2003poisson, schaefer2006image, barnes2009patchmatch, tao2010error, gatys2016imagestyel, zhu2017unpaired, portenier2018faceshop, ling2020variational, collins2020editing, wu2020cascade, bau2020rewriting, park2020swapping, kim2021grivegan, Navigan_CVPR_2021}。最近,深度生成模型~引用{goodfellow2014生成,kingma2014vae,rezende2014随机},特别是现代GANs~引用{karras2017progressive,brock2018large,karras2019style,park2019semantic,karras2020analyzing},作为一种有前途的高效图像编辑工具,受到了广泛的关注。因为它发现潜在的空间操纵经常导致输出中可解释和可预测的变化~\引用{goetschalckx2019ganalyze,bau2019gandissect,jahanian2020Osteerability,voynov2020unsupervised, plumerault2020controlor,harkonen2020ganspace,wang2021几何}。
GAN-based image editing methods can be broadly sorted into a number of categories. \
基于网络的图像编辑方法可以大致分为几个类别。
textbf{(i)} One line of work relies on the careful dissection of the GAN’s latent space, aiming to find interpretable and disentangled latent variables, which can be leveraged for image editing, in a fully unsupervised manner~\cite{goetschalckx2019ganalyze,bau2019gandissect,bau2019semantic,shen2020interpreting,shen2020interfacegan,alharbi2020disentangled,jahanian2020Osteerability,voynov2020unsupervised,plumerault2020Controlling,harkonen2020ganspace,wang2021geometric,shen2021closedform}. Although powerful, these approaches usually do not result in any high-precision editing capabilities. The editing vectors we are learning in EditGAN would be too hard to find independently without segmentation-based guidance.
一条工作线依赖于对GAN的潜在空间的仔细解剖,目的是找到可解释和解纠缠的潜在变量,这可以用于图像编辑,以完全无监督的方式~\引用{goetschalckx2019ganalyze,bau2019gandissect,bau2019semantic,shen2020interpreting, shen2020interegan, alharbi2020distangle,jahanian2020Osteerability,voynov2020unsupervised, plumerault2020controleability,harkonen2020ganspace,wang2021geometric, shen2021closeform}。尽管功能强大,但这些方法通常不能产生任何高精度的编辑功能。如果没有基于分段的指导,我们在EditGAN中学习的编辑矢量将很难独立找到。
\textbf{(ii)} Other works utilize GANs that condition on class or pixel-wise semantic segmentation labels to control synthesis and achieve editing~\cite{choi2018stargan,wang2018high,park2019semantic,zhu2020sean,lee2020maskgan,chen2020deepfacedrawing,wu2020cascade}. Hence, these works usually rely on large annotated datasets, which are often not available, and even if available, the possible editing operations are tied to whatever labels are available. This stands in stark contrast to EditGAN, which can be trained in a semi-supervised fashion with very little labeled data and where an arbitrary number of high-precision edits can be learnt.
\textbf{(ii)}其他作品利用基于类或像素的语义分割标签的GANs来控制合成并实现编辑~\引用{choi2018stargan,wang2018high,park2019semantic,zhu2020sean,lee2020maskgan, chen2020deepface绘图,wu2020cascade}。因此,这些工作通常依赖于大型带注释的数据集,而这些数据集通常是不可用的,即使可用,可能的编辑操作也被绑定到任何可用的标签上。这与EditGAN形成了鲜明的对比,EditGAN可以以一种半监督的方式训练,使用很少的标记数据,并且可以学习任意数量的高精度编辑。
\textbf{(iii)} Furthermore, auxiliary attribute classifiers have been used for image manipulation~\cite{he2019attgan,hou2020guidedstyle}, thereby still relying on annotated data and usually only providing high-level control.
此外,辅助属性分类器已被用于图像处理~引用{he2019attgan,hou2020guidedstyle},因此仍然依赖带注释的数据,通常只提供高层控制。
\textbf{(iv)} Image editing is often explored in the context of ``interpolating’’ between a target and different reference image in sophisticated ways, for example by replacing certain features in a given image with features from a reference images~\cite{collins2020editing,zhu2020sean,lewis2020vogue,kim2021stylemapgan}. From the general image editing perspective, the requirement of reference images limits the broad applicability of these techniques and prevents the user from performing specific, detailed edits for which potentially no reference images are available.
\ textbf {(iv)}图像编辑的上下文中往往是探索“插值”之间的一个目标和不同参考图像在复杂的方面,例如通过替换某些特性在一个给定的图像与参考图像特征~ \引用{collins2020editing、zhu2020sean lewis2020vogue, kim2021stylemapgan}。从一般的图像编辑角度来看,对参考图像的要求限制了这些技术的广泛适用性,并阻止用户执行可能没有参考图像的具体、详细的编辑。
\textbf{(v)} Recently, different works proposed to directly operate in the parameter space of the GAN instead of the latent space to realize different edits~\cite{bau2019semantic,bau2020rewriting,Navigan_CVPR_2021}. For example,~\cite{bau2019semantic,bau2020rewriting} essentially specialize the generator network for certain images at test time to aid image embedding or ``rewrite’’ the network to achieve desired semantic changes in output. The drawback is that such specializations prevent the model from being used in real-time on different images and with different edits. %Concurrently with us,
~\cite{Navigan_CVPR_2021} proposed an approach that more directly analyses the parameter space of a GAN and treats it as a latent space in which to apply edits.
最近,不同的作品提出直接在GAN的参数空间而不是潜空间中操作,以实现不同的编辑~引用{bau2019semantic, bau2020rewrite,Navigan_CVPR_2021}。例如,~\cite{bau2019semantic, bau2020rewrite}本质上是在测试时专门针对特定图像的生成器网络,以帮助图像嵌入或“重写”网络,以在输出中实现所需的语义变化。其缺点是,这种专门化无法在不同的图像和不同的编辑上实时使用模型。与我们同时%,
{Navigan_CVPR_2021}提出了一种方法,更直接地分析GAN的参数空间,并将其视为应用编辑的潜在空间。
However, the method still merely discovers edits in the network’s parameter space, rather than actively defining them like we do. It remains unclear whether their method can combine multiple such edits, as we can, considering that they change the GAN parameters themselves. \textbf{(vi)} Finally, another line of research targets primarily very high-level image and photo stylization and global appearance modifications~\cite{gatys2016imagestyel,luan2017deepphoto,liu2017unsupervised,li2018eccv,wang2018high,kazemi2019style,park2019semantic,yoo2019photorealistic,park2020swapping}.
然而,该方法仍然只是在网络的参数空间中发现编辑,而不是像我们那样积极地定义它们。考虑到他们自己改变GAN参数,他们的方法是否能像我们一样结合多次这样的编辑还不清楚。\textbf{(vi)}最后,另一行研究目标主要是非常高级的图像和照片风格化和全局外观修改~\引用{gatys2016imagestyel, luan2017deephoto,liu2017unsupervised,li2018eccv,wang2018high,kazemi2019style,park2019semantic,yoo2019photorealistic, park2020交换}。
Generally, most works only do relatively high-level and not the detailed, high-precision editing, which EditGAN targets.
一般情况下,大多数作品只做相对高层次的编辑工作,而不是EditGAN所追求的详细、高精度的编辑工作。
Hence, we consider EditGAN as complementary to this body of work.
因此,我们认为EditGAN是这一工作的补充。
\textbf{GANs and Latent Space Image Embedding.} EditGAN builds on top of DatasetGAN~\cite{zhang2021datasetgan} and SemanticGAN~\cite{li2021semantic}, which proposed to jointly model images and their semantic segmentations using shared latent codes. However, these works leveraged this model design only for semi-supervised learning, not for editing. EditGAN also relies on an encoder, together with optimization, to embed new images to be edited into the GAN’s latent space. This task in itself has been studied extensively in different contexts before, and we are building on these works. Previous papers studied encoder-based methods~\cite{perarnau2016invertible,donahue2016adversarial,Brock2017neural,dumoulin2017adversarially,richardson2020encoding}, used primarily optimization-based techniques~\cite{zhu2016generative,Yeh2017,lipton2017precise,abdal2019image2stylegan,huh2020transforming,creswell2019inverting,Raj2019gan,plumerault2020Controlling}, and developed hybrid approaches~\cite{zhu2016generative,bau2019gandissect,bau2019semantic,bau2019seeing,zhu2020domain}.
GANs和潜在空间图像嵌入。EditGAN在DatasetGAN~\cite{zhang2021datasetgan}和SemanticGAN~\cite{li2021semantic}的基础上,提出了使用共享的潜在代码联合建模图像及其语义分割。然而,这些作品只将这种模型设计用于半监督学习,而不是编辑。EditGAN还依赖于编码器和优化,将新编辑的图像嵌入到GAN的潜在空间中。这项任务本身已经在不同的背景下进行了广泛的研究,我们正在这些工作的基础上进行建设。之前的论文研究了基于编码器的方法~\引用{perarnau2016invertible,donahue2016adversarial,Brock2017neural,dumoulin2017adversarial,richardson2020encoding},主要使用文中针对技术~ \引用{zhu2016generative、Yeh2017 lipton2017precise, abdal2019image2stylegan, huh2020transforming, creswell2019inverting, Raj2019gan, plumerault2020Controlling},和开发的混合方法~ \引用{zhu2016generative、bau2019gandissect bau2019semantic, bau2019seeing, zhu2020domain}。
Finally, a concurrent paper~\cite{xu2021linear} shares similarities with DatasetGAN~\cite{zhang2021datasetgan}, on which our method builds, and explores an editing approach related to our EditGAN as one of its applications. However, our editing approach is methodologically different and leverages editing vectors, and also demonstrates significantly more diverse and stronger experimental results. Furthermore, \cite{bau2021paint} shares some high-level ideas with EditGAN; however, it leverages the CLIP~\cite{radford2021learning} model and targets text-driven editing.
最后,在一篇同时发表的论文~\cite{xu2021linear}与DatasetGAN~\cite{zhang2021datasetgan}有相似之处的基础上,构建了我们的方法,并探索了一种与我们的EditGAN相关的编辑方法作为其应用之一。然而,我们的编辑方法在方法上是不同的,并利用了编辑向量,也显著地展示了更多样化和更强的实验结果。此外,\cite{bau2021paint}与EditGAN分享了一些高层次的想法;然而,它利用了CLIP引用{radford2021学习}模型,并以文本驱动编辑为目标。
\subsection{Background} \label{sec:background}
EditGAN’s image generation component is StyleGAN2~\cite{karras2019style, karras2020analyzing}, currently the state-of-the-art GAN for image synthesis. The StyleGAN2 generator maps latent codes $\rvz \in \mathcal{Z}$,
drawn from a multivariate Normal distribution, into realistic images. A latent code $\rvz$ is first transformed into an intermediate code $\rvw \in \mathcal{W}$ by a non-linear mapping function and then further transformed into $K+1$ vectors, $\rvw^0,…,\rvw^K$, through learned affine transformations. These transformed latent codes are fed into synthesis blocks, whose outputs are deep feature maps.
EditGAN的图像生成组件是StyleGAN2~\cite{karras2019style, karras2020analysis},目前最先进的图像合成GAN。StyleGAN2生成器将潜在代码$ rvz \映射到\mathcal{Z}$,
从一个多元的正态分布中提取出来,变成真实的图像。一个潜码$ rvz$首先通过一个非线性映射函数转化为mathcal{W}$中的中间码$ rvw \,然后进一步转化为$K+1$向量,$ rvw^0,…,通过学过的仿射变换。这些转换后的潜在代码被输入合成块,合成块的输出是深层特征图。
Deep generative models such as StyleGAN2, which are trained to synthesize highly realistic images, acquire a semantic understanding of the modeled images in their high-dimensional feature space. Recently, DatasetGAN~\cite{zhang2021datasetgan} and SemanticGAN~\cite{li2021semantic} built on this insight to learn a joint distribution $p(\rvx, \rvy)$ over images $\rvx$ and pixel-wise semantic segmentation labels $\rvy$, while requiring only a handful of labeled examples. EditGAN utilizes this joint distribution $p(\rvx, \rvy)$ to perform high-precision semantic image editing of real and synthesized images.
深层生成模型,如StyleGAN2,被训练来合成高度逼真的图像,在其高维特征空间中获得建模图像的语义理解。最近,DatasetGAN~\cite{zhang2021datasetgan}和SemanticGAN~\cite{li2021semantic}建立在这一洞察力的基础上,学习图像$ rvx$和像素级语义分割标签$ rvy$的联合分布$p(\rvx, \rvy)$,而只需要少量的标记示例。EditGAN利用这种联合分布$p(\rvx, \rvy)$对真实图像和合成图像进行高精度的语义图像编辑。
Both methods~\cite{zhang2021datasetgan,li2021semantic} model $p(\rvx, \rvy)$ by adding an additional segmentation branch to the image generator, which is a pre-trained StyleGAN~\cite{zhang2021datasetgan}. We follow DatasetGAN~\cite{zhang2021datasetgan}, which applies a simple three-layer multi-layer perceptron classifier on the layer-wise concatenated and appropriately upsampled feature maps.
This classifier operates on the concatenated feature maps in a per-pixel fashion and predicts the segmentation label of each pixel.
这两种方法~\引用{zhang2021datasetgan,li2021semantic}模型$p(\rvx, \rvy)$通过在图像生成器中添加一个额外的分割分支,这是一个预先训练的StyleGAN~\引用{zhang2021datasetgan}。我们遵循DatasetGAN~\cite{zhang2021datasetgan},它将一个简单的三层多层感知器分类器应用于分层级联和适当上采样的特征映射。
这个分类器以逐像素的方式对连接的特征映射进行操作,并预测每个像素的分割标签。
\subsection{Segmentation Training and Inference by Embedding Images into GAN’s Latent Space} \label{sec:embedding}
\vspace{-2mm}
To both train the segmentation branch and perform segmentation on a new image, we embed an image into the GAN’s latent space using an encoder and optimization.
To this end, we build on previous works~\cite{abdal2019image2stylegan,richardson2020encoding,li2021semantic} and train an encoder that embeds images into $\mathcal{W}^+$ space, which is defined as $\mathcal{W}$ but where the $\rvw$’s are modeled independently~\cite{abdal2019image2stylegan,richardson2020encoding}. Our objectives to train this encoder consist of standard pixel-wise L2 and perceptual LPIPS reconstruction losses using both the real training data as well as samples from the GAN itself. For the GAN samples, we also explicitly regularize the encoder with the known underlying latent codes. %(in $\mathcal{W}$).
In practice, we use the encoder to initialize images’ latent space embeddings and then iteratively refine the latent code $\rvw^+$ via optimization, again using standard reconstruction objectives.
为了训练分割分支和对新图像进行分割,我们使用编码器和优化将图像嵌入到GAN的潜在空间中。
为此,我们建立在先前的作品~ \引用{abdal2019image2stylegan、richardson2020encoding li2021semantic}和训练一个编码器,嵌入图像到美元\ mathcal {W} ^ + $空间,它被定义为美元\ mathcal {W}但是\ rvw美元美元的独立建模~ \引用{abdal2019image2stylegan, richardson2020encoding}。我们的目标是训练这个编码器由标准像素级L2和感知LPIPS重建损失组成,使用真实的训练数据和GAN本身的样本。对于GAN样本,我们也用已知的潜在码显式正则化编码器。% ($ \ mathcal {W} $)。
在实际应用中,我们使用编码器初始化图像的潜空间嵌入,然后通过优化迭代细化潜代码$\rvw^+$,再次使用标准重构目标。
In that way, we embed the annotated images $\rvx$ from a dataset labeled with semantic segmentations into latent space, and train the segmentation branch of the generator using standard supervised learning objectives, i.e., the cross entropy loss. We keep the image generator’s weights frozen and only backpropagate the loss to the segmentation branch~\cite{zhang2021datasetgan}. After training the segmentation branch, we can formally define a generator $\tilde{G} : \mathcal{W}^+ \rightarrow \mathcal{X}, \mathcal{Y} $ that models the joint distribution $p(\rvx, \rvy)$ of images $\rvx$ and semantic segmentations $\rvy$. Details about encoder and segmentation branch training as well as optimization for image embedding can be found in the Appendix.
通过这种方法,我们将带有语义分割标记的数据集上标注的图像$ rvx$嵌入到潜在空间中,并使用标准监督学习目标(即交叉熵损失)训练生成器的分割分支。我们保持图像生成器的权值不变,只将损失反向传播到分割分支~\cite{zhang2021datasetgan}。训练了分割分支后,我们可以形式化地定义一个生成器$\tilde{G}: \mathcal{W}^+ \ rightrow \mathcal{X}, \mathcal{Y} $,它对图像$ rvx$和语义分割$ rvy$的联合分布$p(\rvx, \rvy)$进行建模。关于编码器和分割分支训练以及图像嵌入优化的详细信息可以在附录中找到。
