# MHD decomposition explains diffuse $\gamma$-ray emission in Cygnus X

Ottavio Fornieri<EMAIL_ADDRESS>ORCID: 0000-0002-6095-9876
Deutsches Elektronen-Synchrotron DESY, Platanenallee 6, 15738 Zeuthen, Germany
Gran Sasso Science Institute, Viale Francesco Crispi 7, 67100 L’Aquila, Italy
INFN-Laboratori Nazionali del Gran Sasso (LNGS), Via G. Acitelli 22, 67100
Assergi (AQ), Italy  Heshou Zhang<EMAIL_ADDRESS>ORCID:
0000-0003-2840-6152 Deutsches Elektronen-Synchrotron DESY, Platanenallee 6,
15738 Zeuthen, Germany  Institut für Physik und Astronomie, Universität
Potsdam, Haus 28, Karl-Liebknecht-Str. 24/25, 14476 Potsdam, Germany.
Istituto Nazionale di Astrofisica (INAF) - Osservatorio Astronomico di Brera,
Via E. Bianchi 46, 23807 Merate(LC), Italy.

###### Abstract

Cosmic-ray (CR) diffusion is the result of the interaction of such charged
particles against magnetic fluctuations. These fluctuations originate from
large-scale turbulence cascading towards smaller spatial scales, decomposed
into three different modes, as described by magneto-hydro-dynamics (MHD)
theory. As a consequence, the description of particle diffusion strongly
depends on the model describing the injected turbulence. Moreover, the amount
of energy assigned to each of the three modes is in general not equally
divided, which implies that diffusion properties might be different from one
region to another. Here, motivated by the detection of different MHD modes
inside the Cygnus-X star-forming region, we study the 3D transport of CRs
injected by two prominent sources within a two-zone model that represents the
distribution of the modes. Then, by convolving the propagated CR-distribution
with the neutral gas, we are able to explain the $\gamma$-ray diffuse emission
in the region, observed by the Fermi-LAT and HAWC Collaborations. Such a
result represents an important step in the long-standing problem of connecting
the CR observables with the micro-physics of particle transport.

MHD — Magnetosonic modes — Cosmic-ray diffusion

##  I Introduction

More than one hundred years after the discovery of cosmic rays (CRs), the
debate about their origin is still largely ongoing. According to the standard
paradigm, CRs are accelerated at the shock fronts of Supernova Remnants (SNRs)
via diffusive shock acceleration (DSA) [1] and then transported across our
Galaxy, undergoing all the physical processes that are effectively described
by the transport equation [2]. The fact that the bulk of CRs is originated at
SNRs was first proposed in Baade and Zwicky [3] and since then motivated by
energy considerations. In particular, comparing the power injected by the
sources of CRs in the Galaxy with that of a typical SNR, we obtain a
reasonable $\sim 10\%$ efficiency for the conversion of their energy budget
into CRs [4].

A limitation in such a paradigm is represented by the maximum energy
$E_{\mathrm{max}}$ that CRs from SNRs can reach. This $E_{\mathrm{max}}$ is
regulated by the number of accelerating cycles that particles undergo bouncing
back and forth at the shock front before escaping, and is therefore eventually
limited by the efficiency of confinement in the region upstream of the shock.
The excitation of resonant instabilities [5] can help in this sense, but
hardly allows to achieve energies of the order
$\sim\mathcal{O}(100\,\mathrm{TeV})$ [6, 7]. This value, however, needs to
face the experimental evidence of an all-particle spectrum that extends up to
a few $\mathrm{PeV}$’s. For this reason, massive stellar clusters (MSCs) have
been invoked as alternative accelerating sites for galactic CRs.

On the theory side, MSCs have been studied for this purpose since long time
ago [8]. The engine causing the acceleration process could come from the
collection of $\sim\mathcal{O}(100)$ stellar winds confined in the compact
cluster $(R_{\mathrm{cluster}}\sim 1-5\,\mathrm{pc})$, injecting kinetic
energy at a rate $L_{w}\sim 10^{34}-10^{38}\,\mathrm{erg\cdot s^{-1}}$ [9,
10], forcing charged particles to undergo multiple shocks before being
released into the Interstellar Medium (ISM). Whether this mechanism results in
a continuous injection of particles [11] or a burst, once the shell excavated
by the winds is dissipated [12], is still matter of debate, and depends on the
adopted acceleration mechanism (see Bykov  _et al._ [13] for a recent review
on the topic). Regardless, considering all the stars contributing to the wind
luminosity across the Galaxy, a (possibly) sizeable but not dominant
contribution to the CR flux at Earth could come from MSCs [10].

From the experimental point of view, the observations of Very High Energy
(VHE) $(100\,\mathrm{GeV}\leq E_{\gamma}\leq 100\,\mathrm{TeV})$ $\gamma$-ray
emission in compact star clusters — such as Westerlund 1 [14], Westerlund 2
[15] and the Cygnus-X star-forming region [9, 16] — have been interpreted as
signatures of local PeV accelerators. Since they are compatible with the decay
of neutral pions originated by the scattering of CR-hadrons off the molecular
clouds — this process generates photons with energy $\langle
E_{\gamma}\rangle\simeq 0.1E_{\mathrm{CR}}$ — these findings have opened the
way in the search for PeV accelerators, the so-called PeVatrons. Among the
above-mentioned observations, the cocoon at the center of the Cygnus-X region
has recently received much attention in a broader multi-messenger sense. In
fact, the LHAASO [17] Collaboration reported the $7\sigma$-detection of $\sim
530$ photons with $E_{\gamma}\geq 100\,\mathrm{TeV}$ from twelve regions with
overlapping known sources, including the Cygnus cocoon, where the highest-
energy event $(E_{\gamma}^{\mathrm{max}}\simeq 1.4\,\mathrm{PeV})$ was
originated. Similarly, Tibet-AS$\gamma$ [18] reports 10 $\gamma$-ray events
from the Galactic plane with $E_{\gamma}\geq 398\,\mathrm{TeV}$ of clear
hadronic origin, 4 of which — including the one at the highest energy, again
$(E_{\gamma}^{\mathrm{max}}\simeq 957\,\mathrm{TeV})$ — are coming from the
Cygnus region. These observations represent the first direct evidence that
stellar clusters may be acceleration sites for PeV CRs.

The last important piece of information comes from the identification, within
Cygnus X, of regions where different magneto-hydro-dynamic (MHD) modes
dominate the turbulent spectrum [19]. Indeed, as it is well known [20], after
turbulence is injected, energy is transferred to smaller spatial scales, and
it is decomposed into Alvén (incompressible), fast\- and slow-magnetosonic
(compressible) modes. The amount of energy transferred to each of these modes
depends on the driving force that turbulence experiences [21], with also the
possibility of mode mixing, in specific environments [22]. Based on the
calculation in Makwana and Yan [21] and on the analysis of the polarized
synchrotron light, in Zhang  _et al._ [19] it is found that the turbulent
energy is differently partitioned among the modes in different locations of
the Cygnus-X region. Since Alfvén modes cascade anisotropically in wave number
[23, 24] and, consequently, are not able to confine particles below
$E_{\mathrm{CR}}\sim 10\,\mathrm{TeV}$ [25], this evidence has significant
implications on CR transport, that is therefore inhomogeneous.

In this paper, we consider the Cygnus-X region and study the detailed
propagation of particles injected by the OB2 cluster and a nearby SNR
($\gamma$-Cygni) in a two-zone diffusion model, where the values of the
diffusion coefficients are regulated by the different MHD modes dominating the
transport. The resulting CR distribution will serve to reproduce the
$\gamma$-ray morphology observed in the region. The paper is organized as
follows. First, we describe the details of the model that we use in the
simulations and show the resulting CR distributions. Then, we convolve such
distributions with the neutral gas in the molecular clouds, the targets
generating the observed $\gamma$-rays. Finally, we discuss the results and
derive our conclusions.

##  II Simulation setup

Figure 1: The diffusion coefficients in the region are shown. In (a) we report
their scaling, according to the parametrization described in the text. In (b)
we report their configuration: in particular the $x$ and $z$ axes are,
respectively, longitude and latitude of a
$(200\,\mathrm{pc})\times(200\,\mathrm{pc})$ region with Galactic coordinates
$l^{\mathrm{Sim}}_{\mathrm{Cyg}}\simeq[75.4^{\circ},\,83.6^{\circ}]$ and
$b^{\mathrm{Sim}}_{\mathrm{Cyg}}\simeq[-2.6^{\circ},\,5.6^{\circ}]$.

###  II.1 Sources of CRs in the region

As mentioned in the introduction, much attention has been given to the
Cygnus-X region, especially motivated by the possible presence of an
accelerator of $\mathrm{PeV}$ CRs. The invoked acceleration mechanism involves
the dynamics of stellar winds [8, 12] driven by the presence of the OB2
cluster, a young $(t^{\mathrm{OB2}}_{\mathrm{age}}\sim 1-4\,\mathrm{Myr})$
globular cluster of $\sim\mathcal{O}(100)$ type-O stars dominating the
emission in the region — $\sim 90\%$ of the emission is estimated to come from
this association, at $\mathrm{TeV}$ energy as well as in the lower Fermi
domain. This region is identified to be HAWC J2030+409 by the HAWC
Collaboration [16] and is considered to be the counterpart of the
$\mathrm{GeV}$ cocoon observed by Fermi [9]. Another source contributes in the
region to the $\gamma$-ray analysis, $\gamma$-Cygni — 2HWC J2020+403 [16]
likely associated with the VERITAS source VER J2019+407 [26] —, a young SNR
whose age is estimated from its internal pulsar to be
$t^{\mathrm{SNR}}_{\mathrm{age}}\simeq 77\,\mathrm{kyr}$. The SNR accelerates
CRs at the forward shock and releases them into the ISM at the beginning of
the Sedov-Taylor phase $(t_{\mathrm{Sed}}\leq 10^{3}\,\mathrm{yr})$ as a delta
function in time [27]. For what concerns the star cluster, on the other hand,
the responsible acceleration mechanism considers a reverse shock that traps
particles in the inner region for as long as $\sim 1\,\mathrm{Myr}$, until the
shock is dissipated and CRs of all energies are released in the ISM [12]. In
what follows, we consider the physical situation where the OB2 cluster — with
Galactic coordinates
$(l_{\mathrm{OB2}},\,b_{\mathrm{OB2}})=(80^{\circ},\,1^{\circ})$ — has an age
$t_{\mathrm{age}}^{\mathrm{OB2}}=2\,\mathrm{Myr}$ and it injected particles
$t^{\mathrm{OB2}}_{\mathrm{rel}}=1.2\,\mathrm{Myr}$ ago. Additionally, the SNR
— with coordinates
$(l_{\mathrm{SNR}},\,b_{\mathrm{SNR}})=(78^{\circ},\,2.3^{\circ})$ — injects
particles as well after a long time, $t^{\mathrm{SNR}}_{\mathrm{age}}\simeq
t^{\mathrm{SNR}}_{\mathrm{rel}}=77\,\mathrm{kyr}$ ago, normalized such that
$n_{\mathrm{OB2}}\big{/}n_{\mathrm{SNR}}=100$.

###  II.2 Transport properties

In order to reproduce the $\gamma$-ray diffuse emission observed by Fermi-LAT
[9] — in the range $1\,\mathrm{GeV}\leq E_{\gamma}\leq 100\,\mathrm{GeV}$ —
and HAWC [16] — above $E_{\gamma}=1\,\mathrm{TeV}$ —, we propagate parent CRs
with energies $10\,\mathrm{GeV}\leq E_{\mathrm{CR}}\leq 10\,\mathrm{TeV}$,
since we expect the main photon production to be of hadronic origin (see
details below), due to neutral pion decay, for which $\langle
E_{\gamma}\rangle\simeq 0.1E_{\mathrm{CR}}$. Due to the declining source
spectra of the type $dN_{\mathrm{CR}}/dE\propto E^{-\Gamma_{\mathrm{inj}}}$,
with $\Gamma_{\mathrm{inj}}>2$, the contribution to the final maps coming from
more energetic CRs can be considered negligible. For what concerns the nature
of the particles responsible for the photon emission, there are clues pointing
towards a hadronic origin. Above the $\mathrm{TeV}$ scale this is well-
established, as discussed for instance in Aharonian  _et al._ [11], Amenomori
_et al._ [18]. In the $\mathrm{GeV}$ domain the situation is different: the
Radio and X-ray emission constrains the higher-energy $\gamma$-ray data to be
not of leptonic origin, as clearly shown in Abeysekara  _et al._ [16]. It is
worth noticing however that, although this implies that a single lepton
population cannot be responsible for the whole spectrum from Radio to
$\gamma$-rays, still it cannot rule out the possibility of an additional
leptonic component contributing below $E_{\gamma}\sim 100\,\mathrm{GeV}$ and
then becoming subdominant due to the large magnetic field in the region (see
details below) and the consequent rapid loss rates. In what follows, we
investigate the hadronic scenario and its implications, leaving the study of a
possible lepton contamination to a future work.

In order to propagate CR-protons in the region, we use the findings discussed
in Zhang  _et al._ [19], in particular regarding (i) the emerging magnetic
field directions and (ii) the different modes dominating different regions in
the Cygnus-X area. (i) Regarding the former, there is evidence for a randomly
distributed direction of the total field
$\bm{B}_{\mathrm{tot}}=\bm{B}_{0}+\delta\bm{B}$, being $\bm{B}_{0}$ and
$\delta\bm{B}$ the regular and the turbulent fields, respectively. This
implies a 3D particle transport isotropic with respect to
$\bm{B}_{\mathrm{tot}}$, so that for the spatial diffusion coefficient it
holds $D_{\parallel}\approx D_{\perp}\equiv D$. (ii) Regarding the latter, as
mentioned in the introduction, it was found in Zhang  _et al._ [19] that
magnetosonic modes dominate the area surrounding the Cygnus cocoon
$(l\simeq[79^{\circ},81^{\circ}],b\simeq[0^{\circ},2^{\circ}])$, whereas, on
the bottom right
$(l\simeq[77^{\circ},80^{\circ}],b\simeq[-3^{\circ},0^{\circ}])$ and on the
top right $(l\simeq[79^{\circ},81^{\circ}],b\simeq[1^{\circ},4^{\circ}])$ of
the region, Alfvén modes become the main component of turbulence. As a
consequence, CR diffusion in the region is isotropic but inhomogeneous. In
particular, here we adopt a two-zone diffusion model, where fast modes
dominate the region around the cocoon (hereafter region 1) and Alfvén modes
dominate the other areas (hereafter region 2, as they have the same
energetics). This partition affects the resulting diffusion coefficients
$D_{1}$ and $D_{2}$ as described below.

Figure 2: The PoS CR-distribution in the region, caused by the two sources
(OB2 and $\gamma$-Cygni) is shown, for different energies (in the rows) and
different time-steps of the simulation (in the columns). The particle density
is normalized to 1.

It has been shown that, in a developed turbulent cascade, fast modes play a
dominant role in confining CRs with respect to Alfvén and slow modes [24, 28,
29, 25]. In particular, their pitch-angle coefficients is
$D^{\mathrm{fast}}_{\mu\mu}\gg D^{\mathrm{A}}_{\mu\mu}$, so that the spatial
diffusion coefficient reads

$\displaystyle D(E)$
$\displaystyle=\frac{1}{4}\,\int_{0}^{1}d\mu\,\frac{c^{2}\,(1-\mu^{2})^{2}}{D^{\mathrm{fast}}_{\mu\mu}+D^{\mathrm{slow}}_{\mu\mu}+D^{\mathrm{A}}_{\mu\mu}}$
(1)
$\displaystyle\approx\frac{1}{4}\,\int_{0}^{1}d\mu\,\frac{c^{2}\,(1-\mu^{2})^{2}}{D^{\mathrm{fast}}_{\mu\mu}},$

for CRs with pitch-angle cosine $\cos\theta\equiv\mu$, moving at the speed of
light $c$. In this context, we remark that the strongly hierarchical relation
between $D_{\mu\mu}^{\mathrm{fast}}$ and the other $D_{\mu\mu}$’s leads us to
believe that, in our environment, the mixing of the modes does not play a
significant role in shaping our diffusion coefficients. The normalized energy
density of the turbulent magnetic field, at the injection scale $L$, is
$\left(\delta B_{L}^{2}\big{/}B_{0}^{2}\right)\big{|}_{\mathrm{tot}}\approx
M^{2}_{A}$. This quantity can be expressed as the sum of the energy densities
in the three modes: $\left(\delta
B_{L}^{2}\big{/}B_{0}^{2}\right)\big{|}_{\mathrm{tot}}=\left(\delta
B_{L}^{2}\big{/}B_{0}^{2}\right)\big{|}_{\mathrm{fast}}+\left(\delta
B_{L}^{2}\big{/}B_{0}^{2}\right)\big{|}_{\mathrm{slow}}+\left(\delta
B_{L}^{2}\big{/}B_{0}^{2}\right)\big{|}_{\mathrm{Alf}}$. We assume the
turbulence in the two regions be trans-Alfvénic — $\left(\delta
B_{L}^{2}\big{/}B_{0}^{2}\right)\big{|}_{\mathrm{tot}}\sim 1$ — with a
different energy partition among the plasma modes. Within this partition, we
are interested in the amount of fast modes only, due to the approximation in
Equation (1). In particular, in region 1 we assume the fast modes to be the
only component, so that $\left(\delta
B_{L}^{2}\big{/}B_{0}^{2}\right)\big{|}_{\mathrm{fast}}\sim(M_{A}^{\mathrm{fast,1}})^{2}\sim
1$, while in region 2, according to Makwana and Yan [21], the energy assigned
to the fast modes is reduced to an amount $\lesssim 25\%$, due to the acting
driving force. Therefore, the fast-modes magnetic energy in region 2 is
$\left(\delta B_{L}^{2}\big{/}B_{0}^{2}\right)\big{|}_{\mathrm{fast}}\sim
25\%$, which results in $\left(\delta
B_{L}\big{/}B_{0}\right)\big{|}_{\mathrm{fast}}\simeq
M_{A}^{\mathrm{fast,2}}=0.5$. A lower amount would even improve the goodness
of our results.

The diffusion coefficients $D_{1}$ $(M_{A}^{\mathrm{fast}}=1)$ and $D_{2}$
$(M_{A}^{\mathrm{fast}}=0.5)$ are computed according to Equation (1), with the
code already used for the propagation studies in Fornieri  _et al._ [25], that
can be found at Fornieri [30]. For the calculation, we use that the local ISM
has density $n_{\mathrm{Cyg}}\simeq 10^{-1}\,\mathrm{cm^{-3}}$ and temperature
$T_{\mathrm{Cyg}}\simeq 5000\,\mathrm{K}$ [31, 32], and that the injection
scale of the turbulence is reduced with respect to the typical values
$\sim\mathcal{O}(100\,\mathrm{pc})$ invoked for the ISM, due to the compact
nature of our sources. Finally, a magnetic-field intensity
$B_{0}=20\,\mu\mathrm{G}$ is considered in Ackermann  _et al._ [9], Abeysekara
_et al._ [16], while a lower one, in the range $B_{0}\sim
5-10\,\mu\mathrm{G}$, is estimated based on the ISM environment in star-
forming regions [33, 11]. For the sake of definiteness, we consider
$B_{0}=10\,\mu\mathrm{G}$. With our environmental parameters
$(n_{\mathrm{Cyg}},\,T_{\mathrm{Cyg}})$, both collisional (viscous) and
collisionless damping mechanisms for the turbulent waves are taken into
account, as discussed in Yan and Lazarian [29], Fornieri  _et al._ [25].
Motivated by these considerations, for our runs we fix $\beta\approx
3.3\left(3\,\mu\mathrm{G}\big{/}B_{\mathrm{Cyg}}\right)^{2}\left(n_{\mathrm{Cyg}}\big{/}\mathrm{cm^{-3}}\right)\left(T_{\mathrm{Cyg}}\big{/}10^{4}\,\mathrm{K}\right)\sim
0.01$, and $L_{\mathrm{inj}}=10\,\mathrm{pc}$. The resulting coefficients for
the two regions, as a function of the CR energy, are shown in Figure 1a. The
ratio between them is $D_{2}/D_{1}\sim 7.5$ at $E_{\mathrm{CR}}\simeq
100\,\mathrm{GeV}$, and $D_{2}/D_{1}\sim 4.7$ at $E_{\mathrm{CR}}\simeq
10\,\mathrm{TeV}$.

In the energy range under study, hadronic transport is dominated by diffusion,
as we can neglect energy losses, contributing at $E_{\mathrm{CR}}\geq
100\,\mathrm{TeV}$, and spallation reactions, contributing at
$E_{\mathrm{CR}}\leq 1\,\mathrm{GeV}$. Therefore, we compute the CR transport
by solving the following 3D diffusion equation for each energy, from
$E_{\mathrm{CR}}=10\,\mathrm{GeV}$ to $E_{\mathrm{CR}}=10\,\mathrm{TeV}$:

$\displaystyle\frac{\partial n(\bm{r})}{\partial
t}=\sum_{i=1,2,3}\frac{\partial}{\partial
x_{i}}\left(D(\bm{r})\,\frac{\partial n(\bm{r})}{\partial
x_{i}}\right)+\mathcal{S}(\bm{r},t)$ (2)

where $\bm{r}=(x_{1},x_{2},x_{3})\equiv(x,y,z)$, with boundary conditions
$n=0$ for all times $t$ at the edge of the simulation box and initial
condition $n(x,y,z,t=0)=0$.

In the above equation, $n(x,y,z,t)$ represents the CR density in arbitrary
units, and $D(x,y,z)$ the isotropic, inhomogeneous diffusion coefficient, that
can take values $D_{1}$ or $D_{2}$. The source term $\mathcal{S}(x,y,z,t)$
parametrizes the two sources described above: for their spatial profile, we
consider two Gaussians with full-width-half-maximum (FWHM)
$\sigma_{\mathrm{FWHM}}=16\,\mathrm{pc}$, while the energy part is a single
power law scaling as $dN_{\mathrm{CR}}\big{/}dE\propto E^{-2.1}$, without any
sign of cutoff up to the highest energy propagated, injecting nearly all
$(\sim 90\%)$ CRs in a time burst. To solve Equation (2), we use a Forward-
Euler explicit numerical scheme, as described in Langtangen and Linge [34].

The region of interest has Galactic coordinates
$l_{\mathrm{Cyg}}=[77^{\circ},\,82^{\circ}]$ and
$b_{\mathrm{Cyg}}=[-1^{\circ},\,4^{\circ}]$. We convert this information to
build a 3D cube in Cartesian coordinates, as well as the coordinates of the
two sources, via the usual transformation equations that consider the Galactic
Center to be at
$(x_{\mathrm{GC}},\,y_{\mathrm{GC}},\,z_{\mathrm{GC}})=(0,\,0,\,0)$ and the
Solar System at
$(x_{\odot},\,y_{\odot},\,z_{\odot})=(-8,\,0,\,0)\,\mathrm{kpc}$:

$\displaystyle x=d_{\mathrm{Cyg}}\cdot\cos b\cos l-R_{\odot}$ (3)
$\displaystyle y=d_{\mathrm{Cyg}}\cdot\cos b\sin l$ $\displaystyle
z=d_{\mathrm{Cyg}}\cdot\sin b,$

where $R_{\odot}=8\,\mathrm{kpc}$ and the average distance of the Cygnus-X
region $d_{\mathrm{Cyg}}=1.4\,\mathrm{kpc}$ [16].

Figure 3: The $\gamma$-ray map at $E_{\gamma}\geq 1\,\mathrm{TeV}$. The
original HAWC observation is shown in (a), where a triangle-shaped enhancement
is highlighted as a white circle. The CR interactions with neutral molecules
are shown in (b) - (c), with and without the smoothing procedure described in
the text. The color bar for (b) and (c) represents the ratio
$N_{\gamma}\big{/}N_{\mathrm{max}}$.

With the transformation equations (3), we map the Plane-of-Sky (PoS) locations
of the objects under study into a 3D cuboid, such that $(\Delta
x_{\mathrm{Cyg}},\,\Delta y_{\mathrm{Cyg}},\,\Delta
z_{\mathrm{Cyg}})\simeq(120,\,25,\,122)\,\mathrm{pc}$,
$(x_{\mathrm{OB2}},\,y_{\mathrm{OB2}},\,z_{\mathrm{OB2}})\simeq(-7.76,\,1.38,\,0.02)\,\mathrm{kpc}$
and
$(x_{\mathrm{SNR}},\,y_{\mathrm{SNR}},\,z_{\mathrm{SNR}})\simeq(-7.71,\,1.37,\,0.06)\,\mathrm{kpc}$.
We can easily notice that, since the $\hat{y}$ coordinates of the region — and
thus of the two sources within it — is much more distant from the Earth than
the $\hat{x}$ and $\hat{z}$ coordinates, the PoS corresponds to the
$\widehat{xz}$ plane of the cuboid, with an uncertainty proportional to
$\sin\left[(-7.75+8)\big{/}(1.38-0)\right]\sim 0.01$, namely at the level of
percent. For practical reasons, we want to construct the simulation on an
equilateral cuboid. In fact, besides being more convenient to control the
resolution of the CR distribution in the region, also the $\hat{y}$
coordinates of the two sources are too close to the edge of the cube, which
can have an impact on the final solution of the PDE equation. Therefore, we
enlarge the simulation box to $(\Delta
x^{\mathrm{Sim}}_{\mathrm{Cyg}},\,\Delta
y^{\mathrm{Sim}}_{\mathrm{Cyg}},\,\Delta
z^{\mathrm{Sim}}_{\mathrm{Cyg}})\simeq(200,\,200,\,200)\,\mathrm{pc}$,
corresponding to the Galactic coordinates
$l^{\mathrm{Sim}}_{\mathrm{Cyg}}\simeq[75.4^{\circ},\,83.6^{\circ}]$,
$b^{\mathrm{Sim}}_{\mathrm{Cyg}}\simeq[-2.6^{\circ},\,5.6^{\circ}]$. For our
3D grid, we consider a spatial resolution of $\Delta\phi_{\mathrm{res}}\simeq
0.17^{\circ}$. Based on what just detailed, the PoS configuration of the
region is shown in Figure 1b.

With the setup described above, the CR distributions as observed in the PoS
are plotted in Figure 2, where $E_{\mathrm{CR}}\simeq 100\,\mathrm{GeV}$ and
$E_{\mathrm{CR}}\simeq 10\,\mathrm{TeV}$ are shown in the first and second
row, respectively, for different time steps of the simulation. In particular,
in the first column we report the initial step, corresponding to
$t^{\mathrm{OB2}}_{\mathrm{rel}}=1.2\,\mathrm{Myr}$ ago — at this stage only
the OB2 cluster has released CRs —; in the second column we show the moment
when the SNR starts to release particles as well, namely
$t^{\mathrm{SNR}}_{\mathrm{rel}}=t^{\mathrm{SNR}}_{\mathrm{age}}-t^{\mathrm{SNR}}_{\mathrm{Sed}}\approx
77\,\mathrm{kyr}$ ago; finally in the third column we show the current age. It
is interesting to notice that the last time step corresponds to a steady-state
condition for the high-energy particles $(E_{\mathrm{CR}}>1\,\mathrm{TeV})$
propagating in region 1, where fast modes dominate diffusion, while lower-
energy CR-distributions are still evolving with time. On the other hand, for
what concerns region 2, CRs that propagate there but are injected by the OB2
are in steady state, while those injected by the SNR are still evolving, due
to their very recent release. Such considerations are easily interpreted in
terms of the diffusion coefficient $D_{1}\big{|}_{10\,\mathrm{GeV}}\simeq
4.99\cdot 10^{26}\,\mathrm{cm^{2}\cdot s^{-1}}$ that particles experience,
according to which steady state is achieved by $10\,\mathrm{GeV}$ particles
after $t_{\mathrm{ss}}\sim 3.5\cdot 10^{6}\,\mathrm{yr}$.

Figure 4: The $\gamma$-ray map at $10\,\mathrm{GeV}\leq E_{\gamma}\leq
100\,\mathrm{GeV}$. The original Fermi-LAT observation is shown in (a), where
4 zones are highlighted. The CR interactions with neutral molecules are shown
in (b) - (c), with and without the smoothing procedure described in the text.
The color bar for (b) and (c) represents the ratio
$N_{\gamma}\big{/}N_{\mathrm{max}}$.

Clearly, particles diffuse in the box according to the properties of the two
different regions. In particular, around the cocoon, they remain confined for
a long time, while they quickly evaporate as they reach the Alfvén-dominated
region 2: this is visible in panels (b)-(c)-(f), where an evident separation
is present. In panels (b)-(e) — the instant when $\gamma$-Cygni releases the
particles in the box — the OB2 particles are visible only at low energy (panel
(b)), while at high energy (panel (e)) their distribution appears to be very
faint compared to the freshly injected SNR-CRs, due to the higher diffusion
coefficient the latter experience — $D_{1}(E=10\,\mathrm{TeV})\simeq 7.1\cdot
D_{1}(E=100\,\mathrm{GeV})$, as it is shown in Figure 1a. Finally, the last
column shows the current configuration of CRs. Since some time has passed from
the SNR release, this configuration exclusively reflects the role of
particles’ diffusivities in the two zones: at $E_{\mathrm{CR}}\simeq
100\,\mathrm{GeV}$ (panel (c)) CRs propagate slowly, while at
$E_{\mathrm{CR}}\simeq 10\,\mathrm{TeV}$ (panel (f)) they are faster, and the
highest-density distribution is concentrated just around the emission area. We
verified that an equal injection from the two sources does not notably change
the final CR distribution, which therefore is mainly the result of the two-
zone diffusion configuration. Due to this last statement, we also note that,
even though our CR distribution has been obtained in a purely-Gaussian
diffusion regime, contamination due to superdiffusion [35, 36] are not
expected to play a significant role in our result, though the rigidity
scalings of the respective diffusion coefficients might be different by a
small amount — especially at low energy $(E_{\mathrm{CR}}\lesssim
1\,\mathrm{TeV})$.

##  III Results

###  III.1 HAWC high-energy $\gamma$-rays

As discussed in the introduction, enhanced emission has been observed by HAWC
$(E_{\gamma}\geq 1\,\mathrm{TeV})$ and Fermi-LAT $(E_{\gamma}\simeq
10-100\,\mathrm{GeV})$ and claimed to be of diffusive origin, namely
subtracting the contributions from the known sources. In this Section, we
investigate such photon production as a result of the hadronic interaction
between our simulated cosmic rays and the target gas. We use the CO molecule
as a tracer to represent the baryon distribution, which is given as a 2D map
[37]. For each pixel in the map, a 2D-Gaussian distribution is considered,
with a $68\%$ containment radius of
$\sigma^{\mathrm{CO}}_{2\mathrm{D}}=0.125^{\circ}$. Since we have a 2D map for
the gas and a 3D CR distribution, we first integrate the latter along the
line-of-sight (l.o.s.) and then multiply the result by the baryon density,
pixel by pixel. This convolution procedure corresponds to the following
calculation:

$N_{\gamma}=n_{\mathrm{CR}}\ast
n_{\mathrm{CO}}=\left(\int_{\mathrm{l.o.s.}}dl\,n_{\mathrm{CR}}(\bm{r})\right)\cdot
n_{\mathrm{CO}}$ (4)

where $N_{\gamma}$ is the number density of the photons and $n_{\mathrm{CO}}$
the column density of the gas.

The resulting raw $\gamma$-ray map is given as a pixel-by-pixel distribution.
Then, we spread the flux contained in each pixel as to have a 2D Gaussian
distribution where the $68\%$ containment radius is
$\sigma^{\gamma}_{2\mathrm{D}}=0.17^{\circ}$ (consistent with the HAWC and
Fermi measurement), which therefore may overlap with the neighboring pixels.
The evolution of the $\gamma$-ray maps for energy $E_{\gamma}\geq
1\,\mathrm{TeV}$ is shown in Figure 3. In particular, the HAWC measured
emission is shown in panel (a), the raw convolution computed with Equation (4)
in panel (b), and the final smoothed calculation in panel (c). As is
highlighted by the circled region in the figures, we observe a triangle-shaped
enhancement at
$l_{\mathrm{HAWC}}=[78^{\circ},\,80^{\circ}],\;b_{\mathrm{HAWC}}=[-0.5^{\circ},\,1.5^{\circ}]$.
Remarkably, even though the gas distribution has an evident enhancement at
$(l_{\mathrm{CO}},b_{\mathrm{CO}})=(79^{\circ},0^{\circ})$ [37], this region
is Alfvén-dominated, which makes CRs escape quickly. On the other hand, the
highest intensity in our simulated emission is reached at
$(l,b)\simeq(79.5^{\circ},1^{\circ})$ — here fast modes confine particles —,
that very-well resembles the observed structure.

###  III.2 Fermi-LAT low-energy $\gamma$-rays

The morphology of the enhanced $\gamma$-ray emission observed by Fermi [9] is
more extended than that seen by HAWC. In order to guide the comparison, we
focus on the 4 areas with the highest significance (pink regions in Figure
4a): A. the enhancement on the left side
$(l_{\mathrm{Fermi,A}}=[80.5^{\circ},\,82^{\circ}],\;b_{\mathrm{Fermi,A}}=[0.3^{\circ},\,1.5^{\circ}])$;
B. the low-energy counterpart of the HAWC structure, the so-called cocoon; C.
the extended enhancement in the upper-right near $\gamma$-Cygni
$(l_{\mathrm{Fermi,C}}=[77.5^{\circ},\,79.5^{\circ}],\;b_{\mathrm{Fermi,C}}=[1.5^{\circ},\,3^{\circ}])$;
D. the extended zone on the top
$(l_{\mathrm{Fermi,D}}=[79.4^{\circ},\,80.2^{\circ}],\;b_{\mathrm{Fermi,D}}=[2.2^{\circ},\,3^{\circ}])$.
This configuration is shown in Figure 4, where in panel (a) the Fermi
observation is reported, while in panel (b)-(c) we show the raw and smoothed
convoluted maps, respectively, as resulting from the procedure described
above. As we can see in the figure, the main difference between this
morphology and the HAWC map is that, besides the cocoon in B, a significant
excess is detected in the areas identified as A and D. Considering the more
extended area that $E_{\mathrm{CR}}\simeq 100\,\mathrm{GeV}$ CRs cover with
respect to $E_{\mathrm{CR}}\simeq 10\,\mathrm{TeV}$ ones, such a difference
can be explained and these enhancements are reproduced with reasonably good
agreement, as seen in Figure 4c. On the other hand, for B it similarly holds
what we described for the high-intensity gas structure at
$(l_{\mathrm{CO}},b_{\mathrm{CO}})=(79^{\circ},0^{\circ})$. The yellow
structure at $(l_{\mathrm{CO,2}},b_{\mathrm{CO,2}})=(78^{\circ},-1^{\circ})$ —
inside the Alfvén-dominated area — has, in the CO map, the same significance
as the one at $(l_{\mathrm{CO}},b_{\mathrm{CO}})$ discussed above. This is not
matched in the final photon emissivity, hence reflecting the distribution of
the plasma modes instead of the gas. The enhanced emission in zone C is not
reproduced in the current calculation due to the low CO-intensity here, so
that CRs have no target to scatter off. Nonetheless, spots of intense emission
in C are present (panel (a)). With this regards, the Fermi map shows an empty
circle at the center of zone C, which corresponds to the $\gamma$ rays
directly injected by the SNR $\gamma$-Cygni, removed to estimate the diffuse
component. As the enhancement around this circle is shaped as a “ring”, what
is considered as diffuse emission in zone C may have likely received some
contamination from single-source $\gamma$-rays that were not extracted with
the Gaussian cut [9].

In conclusion, the diffuse $\gamma$-ray emission observed by both HAWC and
Fermi-LAT is nicely interpreted in terms of hadronic interaction with the gas.
Structures are reproduced, which are not correlated with the configuration of
the gas, but rather with the distribution of the plasma modes (see Figure 4e
in Zhang  _et al._ [19]).

##  IV Discussion and Summary

In this work, we have taken into account the distribution of the plasma modes
identified in the Cygnus-X region to build a two-zone diffusion model where we
propagated CR-hadrons. We studied the $\gamma$-ray photons produced by the
interactions between our simulated CR distribution and the baryon population
in the region, which is represented by the CO molecular gas. Our calculations
nicely match the $\gamma$-ray observations from HAWC $(\sim 1\,\mathrm{TeV})$
especially, whereas key structures have been identified in the Fermi-LAT
domain $(10-100\,\mathrm{GeV})$. With this respect, we argued that a more
refined subtraction procedure for the SNR may be responsible for spurious
enhancements in the low-energy band and that a slight contamination from CR
leptons cannot be ruled out by current observations. Overall, we find that the
hadronic origin of the emission can be considered satisfactory.

Our findings are based on a distribution of plasma modes that locally shape
the diffusion coefficient, that is therefore an inhomogeneous property of the
medium.

##  V Acknowledgments

The authors are grateful to Pasquale Blasi, Pedro De La Torre Luque, Carmelo
Evoli, Stefano Gabici, Daniele Gaggero, Tim Linden, Andrew Taylor, Walter
Winter, Huirong Yan and the DESY Theory Group for their helpful comments and
the deep discussions that led to the realization of this manuscript. H.Z.
acknowledges the ERC-granted ”Hot Milk” research team.

## References

  * Blandford and Eichler [1987] R. Blandford and D. Eichler, Phys. Rep. 154, 1 (1987).
  * Berezinskii  _et al._ [1990] V. S. Berezinskii, S. V. Bulanov, V. A. Dogiel, and V. S. Ptuskin,  _Astrophysics of cosmic rays_ (1990).
  * Baade and Zwicky [1934] W. Baade and F. Zwicky, Proceedings of the National Academy of Science 20, 259 (1934).
  * Gabici  _et al._ [2019] S. Gabici, C. Evoli, D. Gaggero, P. Lipari, P. Mertsch, E. Orlando, A. Strong, and A. Vittino, Int. J. Mod. Phys. D 28, 1930022 (2019), arXiv:1903.11584 [astro-ph.HE] .
  * Kulsrud and Pearce [1969] R. Kulsrud and W. P. Pearce, ApJ 156, 445 (1969).
  * Lagage and Cesarsky [1983a] P. O. Lagage and C. J. Cesarsky, A&A 118, 223 (1983a).
  * Lagage and Cesarsky [1983b] P. O. Lagage and C. J. Cesarsky, A&A 125, 249 (1983b).
  * Cesarsky and Montmerle [1983] C. J. Cesarsky and T. Montmerle, Space Science Reviews 36, 173 (1983).
  * Ackermann  _et al._ [2011] M. Ackermann _et al._ , Science 334, 1103 (2011).
  * Seo  _et al._ [2018] J. Seo, H. Kang, and D. Ryu, J. Korean Astron. Soc. 51, 37 (2018), arXiv:1804.07486 [astro-ph.HE] .
  * Aharonian  _et al._ [2019] F. Aharonian, R. Yang, and E. de Oña Wilhelmi, Nature Astron. 3, 561 (2019), arXiv:1804.02331 [astro-ph.HE] .
  * Morlino  _et al._ [2021] G. Morlino, P. Blasi, E. Peretti, and P. Cristofari,  (2021), 10.1093/mnras/stab690, arXiv:2102.09217 [astro-ph.HE] .
  * Bykov  _et al._ [2020] A. M. Bykov, A. Marcowith, E. Amato, M. E. Kalyashova, J. M. D. Kruijssen, and E. Waxman, Space Sci. Rev. 216, 42 (2020), arXiv:2003.11534 [astro-ph.HE] .
  * Abramowski  _et al._ [2012] A. Abramowski _et al._ (H.E.S.S.), Astron. Astrophys. 537, A114 (2012), arXiv:1111.2043 [astro-ph.HE] .
  * Yang  _et al._ [2018] R.-z. Yang, E. de Oña Wilhelmi, and F. Aharonian, A&A 611, A77 (2018), arXiv:1710.02803 [astro-ph.HE] .
  * Abeysekara  _et al._ [2021] A. U. Abeysekara _et al._ , Nature Astron. 5, 465 (2021), arXiv:2103.06820 [astro-ph.HE] .
  * Cao  _et al._ [2021] Z. Cao _et al._ , Nature 594, 33 (2021).
  * Amenomori  _et al._ [2021] M. Amenomori _et al._ (Tibet ASgamma), Phys. Rev. Lett. 126, 141101 (2021), arXiv:2104.05181 [astro-ph.HE] .
  * Zhang  _et al._ [2020] H. Zhang, A. Chepurnov, H. Yan, K. Makwana, R. Santos-Lima, and S. Appleby, Nature Astronomy 4, 1001 (2020), arXiv:1808.01913 [physics.plasm-ph] .
  * Kulsrud [2004] R. M. Kulsrud,  _Plasma Physics for Astrophysics_ (2004).
  * Makwana and Yan [2020] K. D. Makwana and H. Yan, Phys. Rev. X 10, 031021 (2020).
  * Lehmann  _et al._ [2016] A. Lehmann, C. Federrath, and M. Wardle, MNRAS 463, 1026 (2016), arXiv:1608.02050 [astro-ph.GA] .
  * Goldreich and Sridhar [1995] P. Goldreich and S. Sridhar, ApJ 438, 763 (1995).
  * Yan and Lazarian [2002] H. Yan and A. Lazarian, Phys. Rev. Lett. 89, 281102 (2002).
  * Fornieri  _et al._ [2021] O. Fornieri, D. Gaggero, S. S. Cerri, P. De La Torre Luque, and S. Gabici, Monthly Notices of the Royal Astronomical Society 502, 5821 (2021).
  * Aliu  _et al._ [2013] E. Aliu _et al._ , ApJ 770, 93 (2013), arXiv:1305.6508 [astro-ph.HE] .
  * Blasi and Amato [2012] P. Blasi and E. Amato, JCAP 2012, 011 (2012), arXiv:1105.4529 [astro-ph.HE] .
  * Yan and Lazarian [2004] H. Yan and A. Lazarian, Astrophys. J. 614, 757 (2004), arXiv:astro-ph/0408172 .
  * Yan and Lazarian [2008] H. Yan and A. Lazarian, Astrophys. J. 673, 942 (2008), arXiv:0710.2617 [astro-ph] .
  * Fornieri [2020] O. Fornieri, “ottaviofornieri/Diffusion_MHD_modes: Diffusion coefficient from MHD modes,”  (2020).
  * Draine [1978] B. T. Draine, ApJS 36, 595 (1978).
  * Wesson  _et al._ [2005] R. Wesson, X. W. Liu, and M. J. Barlow, MNRAS 362, 424 (2005).
  * Heiles and Crutcher [2005] C. Heiles and R. Crutcher, “Magnetic Fields in Diffuse HI and Molecular Clouds,” in  _Cosmic Magnetic Fields_, Vol. 664, edited by R. Wielebinski and R. Beck (2005) p. 137.
  * Langtangen and Linge [2017] H. P. Langtangen and S. Linge,  _Finite difference computing with PDEs: a modern software approach_ (Springer Nature, 2017).
  * Sampson  _et al._ [2022] M. L. Sampson, J. R. Beattie, M. R. Krumholz, R. M. Crocker, C. Federrath, and A. Seta, (2022), arXiv:2205.08174 [astro-ph.GA] .
  * Beattie  _et al._ [2022] J. R. Beattie, M. R. Krumholz, C. Federrath, M. L. Sampson, and R. M. Crocker, Frontiers in Astronomy and Space Sciences 9 (2022), 10.3389/fspas.2022.900900.
  * Dame  _et al._ [2001] T. M. Dame, D. Hartmann, and P. Thaddeus, ApJ 547, 792 (2001), arXiv:astro-ph/0009217 [astro-ph] .


# Optimizing Latent Space Directions For GAN-based Local Image Editing

###### Abstract

Generative Adversarial Network (GAN) based localized image editing can suffer
ambiguity between semantic attributes. We thus present a novel objective
function to evaluate the locality of an image edit. By introducing the
supervision from a pre-trained segmentation network and optimizing the
objective function, our framework, called Locally Effective Latent Space
Direction (LELSD), is applicable to any dataset and GAN architecture. Our
method is also computationally fast and exhibits a high extent of
disentanglement, which allows users to interactively perform a sequence of
edits on an image. Our experiments on both GAN-generated and real images
qualitatively demonstrate the high quality and advantages of our method.

Fig. 1: Examples of localized edits performed by our method on GAN-generated
images. The images to the left and right of the middle one are results of
moving the latent code in directions discovered by our method to edit each
semantic part.

Index Terms—  GANs, Latent Space Directions, Local Image Editing, Semantic
Attribute Editing, StyleGAN

##  1 Introduction

Generative Adversarial Networks, like StyleGAN [1, 2] and BigGAN [3], are
capable of generating diverse high-resolution images, sometimes
indistinguishable from real photos. In addition, substantial semantic meaning
has been found in the latent space of trained GANs, which makes high-level
semantic image editing possible. Semantic image editing using GANs [4] has
found a broad range of applications in Digital Art [5], Fashion [6], Interior
Design [7], and Face Editing [8].

Several recent works control the semantics of the GAN-generated image by
tweaking the latent code to perform global [9, 10, 11, 12, 13, 14] or
localized [7, 15, 16, 17] editing. Although a lot of progress has been made in
global image editing, it remains challenging to disentangle the semantic
attributes and thus control the local semantics of the image. Therefore, in
this paper, we specifically focus on localized semantic image editing, where
the goal is to control one semantic attribute of the image without changing
other image parts.

State-of-the-art methods of finding semantically localized latent space
directions build on the first-order Taylor expansion of the generator network
[16, 17], and assume a linear relation between the latent code and the
generated image. Since this assumption is only valid in close proximity to the
original latent code, [16, 17] are limited in the range of local editing they
can achieve. Meanwhile, [16] proposes a method to achieve disentanglement by
exhaustively searching the latent space of StyleGAN [1, 2], and consequently
cannot be applied to other GAN architectures. However, we are specifically
interested in designing a framework which is not only agnostic to the GAN
architecture, but also is able to effectively disentangle the semantic
attributes. To this end, we propose Locally Effective Latent Space Directions
(LELSD), a framework to find the latent space directions that affect local
regions of the output image. We introduce a novel objective function to
evaluate the extent of the local change and disentanglement by incorporating
supervision from a pre-trained semantic segmentation model. Note that, the
supervision could also come from unsupervised [15] or weakly-supervised [18]
models that use the intermediate featuremaps of the generator network to
achieve semantic segmentation. As a result, our method is not limited to any
specific dataset. Figure 1 shows some of the semantic edits that our method
can perform. Since we apply optimization instead of exhaustive search, our
training time is three orders of magnitude faster than [16]. Meanwhile, unlike
[17] we do not perform test-time optimization and thus allow interactive image
editing.

##  2 Related Works

| GAN-based Image
---
Editing Algorithms
| Supervision
---
| A
---
| B
---
| C
---
| D
---
| E
---
| F
---
| G
---
[10, 11, 12] | Unsupervised | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✗ |  Latent Space Traversal
Zhu et al. [17] | Unsupervised | ✓ | ✗ | ✓ | ✓ | ✗ | ✓ | ✗
[19, 14] | Self-Supervised | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✗
InterFaceGAN [9] | Supervised | ✗ | ✓ | ✓ | ✓ | ✓ | ✗ | ✗
GANALYZE [13] | Supervised | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✗
StyleSpace [16] | Supervised | ✓ | ✓ | ✗ | ✓ | ✗ | ✓ | ✓
LELSD (Ours) | Supervised | ✓ | ✓ | ✓ | ✓ | ✗ | ✓ | ✓ |  Image Composition
Bau et al. [20] | Unsupervised | ✓ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓
Chai et al. [21] | Unsupervised | ✓ | ✓ | ✓ | ✗ | ✗ | ✓ | ✓
Editing in Style [15] | Unsupervised | ✓ | ✓ | ✗ | ✗ | ✗ | ✓ | ✗
Zhang et al. [7] | Supervised | ✗ | ✓ | ✗ | ✗ | ✗ | ✓ | ✓
Barbershop [22] | Supervised | ✓ | ✓ | ✗ | ✗ | ✗ | ✓ | ✗

Table 1: Comparison of GAN-based image editing algorithms by their
characteristics. A Works on any Dataset, B No test-time optimization, C Works
on any GAN architecture, D Can perform the edit using a single image, E Allows
global semantic editing, F Allows localized semantic editing, G Allows editing
any object in the image.

Table 1 summarizes the strengths and weaknesses of of different GAN-based
image editing methods. Some works use an unsupervised approach to discover
meaningful latent space directions, and then manually attribute a semantic to
each of the found directions [10, 11, 12, 19]. However, the discovered
directions are entangled and usually change more than one semantic attributes
simultaneously, e.g., both age and gender. Hence , they are rarely applied to
localized image editing.

To solve this problem, [9, 13, 14] use an external supervision and find latent
space directions that yield the desired change in the generated images. This
is done by finding the latent space direction that maximizes a designed
objective function.

There are two distinct approaches to GAN-based localized semantic image
editing: 1) Latent Space Traversal, and 2) Image Composition. In the former,
the goal is to discover latent space directions that yield localized changes
in the output image. The later aims to combine different parts from two images
to achieve localized editing, e.g., transferring the nose from one face image
to another. Our method falls in the first category. The disadvantage of the
Image Composition methods is that they require a second image to transfer the
parts from (See Table 1, Column D). In this paper we thus focus on Latent
Space Traversal methods as they can perform single-image editing, which is
more user-friendly.

InterFaceGAN [9] finds latent space directions that maximally change the score
of a pre-trained SVM classifier for face attributes, and therefore is only
applicable to face images. On the other hand, [16, 17] use the gradient of the
output image w.r.t the latent code to find subspaces of the latent code that
highly correlate with local regions in the generated image. Wu et al. [16] use
a pretrained semantic segmentation network to find channels in StyleGAN’s
style code that have a high overlap with a semantic category, e.g., eyes. Zhu
et al [17] perform test-time optimization to find latent space directions that
mostly affect the regions of the image given by user’s query. The upper part
of Table 1 compares the existing Latent Space Traversal methods in the
literature.

Similar to [7, 16, 22], we use the supervision from a pretrained semantic
segmentation network, and propose a novel scoring function that encourages
latent space directions that mainly affect the desired semantic part of
interest, e.g., eyes in a face image. Meanwhile, we allow layer-wise (both
coarse and fine-grained) semantic editing similar to [10] for both style-based
GANs and BigGAN. GAN Inversion is complementary to our method and advancement
in GAN Inversion research [23, 24] also enhances the quality of real-image
semantic editing when combined with our method.

##  3 Method

Fig. 2: Scheme of our method. The green boxes indicate the pretrained
generator network and the yellow box shows the pretrained semantic
segmentation model. We draw random samples from the latent space $\Omega$ and
optimize the latent space direction to maximize the localization score.

Figure 2 provides an overview of our method. The generator network $G(.)$ in a
GAN, generates an image starting from a latent code
$\mathbf{\omega}\in\Omega$, i.e.
$\mathbf{x}=G(\boldsymbol{\omega})=f(h(\boldsymbol{\omega}))$ where
$\mathbf{r}=h(\boldsymbol{\omega})$ is a tensor representing the activation of
a certain layer in the network. The latent space $\Omega$ can be any of
$\mathcal{Z},\mathcal{W},\mathcal{W}+,\mathcal{S}$ for StyleGAN generator as
in [16], and $\mathcal{Z},\mathcal{Z}+$ for BigGAN generator as in [10].
Semantic editing of an image is done by moving its latent code along a
specific direction

$\mathbf{x}^{edit}(\mathbf{u})=f(\mathbf{r}^{edit}(\mathbf{u}))=G(\boldsymbol{\omega}+\alpha\mathbf{u})$
(1)

in which $\alpha$ controls the intensity of the change, and the latent
direction $\mathbf{u}$ determines the semantic of the edit.

The goal is to find an editing direction $\mathbf{u}_{c}$ that mainly changes
parts of the generated image corresponding to a mask given by a pretrained
semantic segmentation model $\mathbf{s}_{c}(\mathbf{x})$ where $c$ determines
the desired object to edit in the image. Based on this, we can write the
localization score as

$LS(\mathbf{u})=\frac{\sum_{i,j}\overset{\downarrow}{\tilde{\mathbf{s}_{c}}}(\mathbf{x},\mathbf{x}^{edit})\odot|\mathbf{r}-\mathbf{r}^{edit}(\mathbf{u})|^{2}}{\sum_{i,j}|\mathbf{r}-\mathbf{r}^{edit}(\mathbf{u})|^{2}}$
(2)

where $i,j$ iterate over spatial dimensions and
$\overset{\downarrow}{\tilde{\mathbf{s}_{c}}}(\mathbf{x},\mathbf{x}^{edit})$
is the average of the two semantic segmentation masks down-sampled to the
resolution of the corresponding layer. This objective function measures the
proportion of feature map change inside the semantic segmentation mask. Our
final objective function is calculated by simply summing up the localization
scores for all layers in the generator network. Unlike [17] that only aims to
achieve localized change in the generated image, we also encourage the
intermediate featuremaps to only change locally. This allows us to achieve a
larger variety of edits than [17]. For example, we can change both hairstyle
and hair color, while [17] cannot manipulate hairstyle.

##  4 Experiments

For the pretrained semantic segmentation model, we use Face-BiSeNet [25] for
face/portrait images and DeepLabV3 [26] for other images. We use the Adam
optimizer to find a latent space direction that maximizes the localization
score defined in Equation (2)111Our code can be found at
https://github.com/IVRL/LELSD. We train on 800 randomly sampled latent codes
with a batch size of 4, starting from a learning rate of 0.001 and halving it
every 50 steps. Optimizing a latent space direction for each semantic part
takes approximately two minutes on a single Tesla V100 GPU. We observe that
our method is robust to the choice of the mask aggregation method in Equation
(2) and works as well with the union or the intersection of the masks.

###  4.1 Finding multiple directions

In order to find two or more distinct directions for editing the same semantic
part such as hair, we add
$R(\mathbf{u}_{1},\;...,\mathbf{u}_{k})=\frac{-1}{2}||\textup{Corr}(\mathbf{u}_{1},\;...,\mathbf{u}_{K})-\textup{I}_{K}||_{\textup{F}}$
as a regularization term to our objective function, where $\textup{Corr}(.)$
is the correlation matrix of a set of vectors, $||.||_{\textup{F}}$ is the
Frobenius Norm, and $\textup{I}_{K}$ is the $K\times K$ Identity matrix. Our
final objective can thus be written as

$J(\mathbf{u}_{1},\;...,\mathbf{u}_{k})=\sum_{k}LS(\mathbf{u}_{k})+cR(\mathbf{u}_{1},\;...,\mathbf{u}_{k})$
(3)

where $c$ is the regularization coefficient. The added regularization term
encourages the editing directions to be mutually perpendicular, and carry
distinct semantics as can be seen in Figure 3. We linearly increase the number
of training samples by $K$ and alternate between each $\mathbf{u}_{k}$ during
the optimization.

Fig. 3: Visualization of two latent space directions found by our method.
Linearly combining different directions gives users limitless possibilities in
image editing.

###  4.2 Comparison with First-Order methods

Both [16, 17] rely on the first-order Taylor expansion of the generator
network and assume a linear relationship between the generated image and the
latent code. This causes them to perform poorly when increasing the editing
strength, $\alpha$, in Equation (1). Since $\alpha$ has a different scale in
each GAN-based image editing method, we use the LPIPS distance [27] for
comparison. For each method we find the value of $\alpha$ such that
$LPIPS(\mathbf{x},\mathbf{x}^{edit})=d$, and show that for higher values of
$d$ the linearity assumption is not valid and our method outperforms [16]
222The authors of [17] have not released the code at the time of submission.
Note that there are two values of $\alpha$, one positive and one negative that
yield the same LPIPS distance. Figure 4 compares the edits performed by our
method and StyleSpace [16], for different editing strengths. As $d$ and
subsequently $\alpha$ increase, our method performs coherently while
StyleSpace distorts the semantics of the image.

Fig. 4: Comparison of our method with a gradient-based method. The first-order
approximation of the generator network is only valid in close proximity to the
original latent code. This is the reason why gradient-based methods like
StyleSpace [16] perform poorly as the editing strength increases. The $d$ in
the figure shows the LPIPS distance between the edited and original images.

###  4.3 Editing Real Images

Combined with a GAN Inversion model, our method allows editing real images. We
use e4e [24] trained on StyleGAN2 FFHQ to project real images into the latent
space of the StyleGAN. More importantly, we can perform sequential editing by
simply adding the discovered latent space directions. Figure 5 shows a series
of edits applied to the inversion of real images. As can be seen, the
semantics of the edits are consistent across different images. The quality of
the inversion is beyond the scope of this paper.

Fig. 5: Sequential editing applied to real images. The edits are semantically
consistent between different images and each edit only changes the desired
part without affecting previous changes.

###  4.4 Performance Comparison

Interactiveness and performance are two very important factors in the image
editing experience. The method in [17] requires test-time optimization and
hence is not interactive. Although the approach of [16] allows interactive
editing, it requires a lot of training time as it needs to separately
backpropagate through all 6080 channels in the style code of the StyleGAN. As
we use the same number of training samples as [16], we estimate that our
method is three orders of magnitude faster than [16].

##  5 Conclusion

In this work, we have presented LELSD, our computationally friendly framework
that uses the supervision from a pre-trained semantic segmentation network to
maximize a novel objective function that encourages local editing and can be
applied to any GAN architecture and dataset. Our experiments in different
setting qualitatively show the advantage of our method, especially the extent
of disentanglement between local attributes.

## References

  * [1] Tero Karras, Samuli Laine, and Timo Aila,  “A style-based generator architecture for generative adversarial networks,”  in CVPR, 2019, pp. 4401–4410.
  * [2] Tero Karras, Samuli Laine, Miika Aittala, Janne Hellsten, Jaakko Lehtinen, and Timo Aila,  “Analyzing and improving the image quality of stylegan,”  in CVPR, 2020, pp. 8110–8119.
  * [3] Andrew Brock, Jeff Donahue, and Karen Simonyan,  “Large scale gan training for high fidelity natural image synthesis,”  arXiv preprint arXiv:1809.11096, 2018.
  * [4] Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio,  “Generative adversarial nets,”  NeurIPS, vol. 27, 2014.
  * [5] Aaron Hertzmann,  “Aesthetics of neural network art,”  arXiv preprint arXiv:1903.05696, 2019.
  * [6] Amir Hossein Raffiee and Michael Sollami,  “Garmentgan: Photo-realistic adversarial fashion transfer,”  in 2020 25th International Conference on Pattern Recognition (ICPR). IEEE, 2021, pp. 3923–3930.
  * [7] Chen Zhang, Yinghao Xu, and Yujun Shen,  “Decorating your own bedroom: Locally controlling image generation with generative adversarial networks,”  arXiv preprint arXiv:2105.08222, 2021.
  * [8] FaceApp,  “https://www.faceapp.com/,” 2021.
  * [9] Yujun Shen, Ceyuan Yang, Xiaoou Tang, and Bolei Zhou,  “Interfacegan: Interpreting the disentangled face representation learned by gans,”  IEEE transactions on pattern analysis and machine intelligence, 2020\.
  * [10] Erik Härkönen, Aaron Hertzmann, Jaakko Lehtinen, and Sylvain Paris,  “Ganspace: Discovering interpretable gan controls,”  arXiv preprint arXiv:2004.02546, 2020.
  * [11] Andrey Voynov and Artem Babenko,  “Unsupervised discovery of interpretable directions in the gan latent space,”  in ICML. PMLR, 2020, pp. 9786–9796.
  * [12] Yujun Shen and Bolei Zhou,  “Closed-form factorization of latent semantics in gans,”  in CVPR, 2021, pp. 1532–1540.
  * [13] Lore Goetschalckx, Alex Andonian, Aude Oliva, and Phillip Isola,  “Ganalyze: Toward visual definitions of cognitive image properties,”  in CVPR, 2019, pp. 5744–5753.
  * [14] Ali Jahanian, Lucy Chai, and Phillip Isola,  “On the” steerability” of generative adversarial networks,”  arXiv preprint arXiv:1907.07171, 2019.
  * [15] Edo Collins, Raja Bala, Bob Price, and Sabine Susstrunk,  “Editing in style: Uncovering the local semantics of gans,”  in CVPR, 2020, pp. 5771–5780.
  * [16] Zongze Wu, Dani Lischinski, and Eli Shechtman,  “Stylespace analysis: Disentangled controls for stylegan image generation,”  in CVPR, 2021, pp. 12863–12872.
  * [17] Jiapeng Zhu, Ruili Feng, Yujun Shen, Deli Zhao, Zhengjun Zha, Jingren Zhou, and Qifeng Chen,  “Low-rank subspaces in gans,”  arXiv preprint arXiv:2106.04488, 2021.
  * [18] Jianjin Xu and Changxi Zheng,  “Linear semantics in generative adversarial networks,”  in CVPR, 2021, pp. 9351–9360.
  * [19] Antoine Plumerault, Hervé Le Borgne, and Céline Hudelot,  “Controlling generative models with continuous factors of variations,”  arXiv preprint arXiv:2001.10238, 2020.
  * [20] David Bau, Steven Liu, Tongzhou Wang, Jun-Yan Zhu, and Antonio Torralba,  “Rewriting a deep generative model,”  in ECCV. Springer, 2020, pp. 351–369.
  * [21] Lucy Chai, Jonas Wulff, and Phillip Isola,  “Using latent space regression to analyze and leverage compositionality in gans,”  arXiv preprint arXiv:2103.10426, 2021.
  * [22] Peihao Zhu, Rameen Abdal, John Femiani, and Peter Wonka,  “Barbershop: Gan-based image compositing using segmentation masks,”  arXiv preprint arXiv:2106.01505, 2021.
  * [23] Rameen Abdal, Yipeng Qin, and Peter Wonka,  “Image2stylegan++: How to edit the embedded images?,”  in CVPR, 2020, pp. 8296–8305.
  * [24] Elad Richardson, Yuval Alaluf, Or Patashnik, Yotam Nitzan, Yaniv Azar, Stav Shapiro, and Daniel Cohen-Or,  “Encoding in style: a stylegan encoder for image-to-image translation,”  in CVPR, 2021, pp. 2287–2296.
  * [25] Changqian Yu, Jingbo Wang, Chao Peng, Changxin Gao, Gang Yu, and Nong Sang,  “Bisenet: Bilateral segmentation network for real-time semantic segmentation,”  in ECCV, 2018, pp. 325–341.
  * [26] Liang-Chieh Chen, George Papandreou, Florian Schroff, and Hartwig Adam,  “Rethinking atrous convolution for semantic image segmentation,”  arXiv preprint arXiv:1706.05587, 2017.
  * [27] Richard Zhang, Phillip Isola, Alexei A Efros, Eli Shechtman, and Oliver Wang,  “The unreasonable effectiveness of deep features as a perceptual metric,”  in CVPR, 2018, pp. 586–595.