# Which Style Makes Me Attractive? Interpretable Control Discovery and
Counterfactual Explanation on StyleGAN††thanks: Disclaimer: By attractiveness
we mean the prediction of attractiveness by a classifier. Please be aware that
the classifier might be biased. This paper does not reflect the judgement of
the authors on the standard of attractiveness.

Bo Li1,2 Qiulin Wang1 Jiquan Pei1 Yu Yang2 Xiangyang Ji2
1JD Technology
2Tsinghua University
<EMAIL_ADDRESS>
###### Abstract

The semantically disentangled latent subspace in GAN provides rich
interpretable controls in image generation. This paper includes two
contributions on semantic latent subspace analysis in the scenario of face
generation using StyleGAN2. First, we propose a novel approach to disentangle
latent subspace semantics by exploiting existing face analysis models, e.g.,
face parsers and face landmark detectors. These models provide the flexibility
to construct various criterions with very concrete and interpretable semantic
meanings (e.g., change face shape or change skin color) to restrict latent
subspace disentanglement. Rich latent space controls unknown previously can be
discovered using the constructed criterions. Second, we propose a new
perspective to explain the behavior of a CNN classifier by generating
counterfactuals in the interpretable latent subspaces we discovered. This
explanation helps reveal whether the classifier learns semantics as intended.
Experiments on various disentanglement criterions demonstrate the
effectiveness of our approach. We believe this approach contributes to both
areas of image manipulation and counterfactual explainability of CNNs. The
code is available at https://github.com/prclibo/ice.

Backward propagation

StyleGANCriterionCriterion$u$$\\{J_{i}^{\top}J_{i}\\}_{i}$Latent subspace

Backward propagation

ClassifierAttractive: 0.68StyleGAN$u$GradientsProjection$\Delta u$
Interpretable counterfact Attractive: 0.99

Eye boundary

Attractive: 0.96

Mouth shape

Attractive: 0.86

Lip color

Eye shapeMouth shapeLip color Figure 1: The left part illustrates the procedure of latent subspace discovery. Latent code samples $u$ are fed into StyleGAN and then interpretable criterions sequentially. We execute backward pass to obtain the Jacobian of the cascaded model to solve latent subspaces. The middle part illustrates the procedure of counterfactual generation. We feed a latent code sample $u$ into StyleGAN and then a classifier sequentially. The classification score is then backward passed through the cascaded model. The resulted gradients are projected into the previously solved interpretable subspaces. Thus we obtained interpretable controls on the latent code to produce counterfactuals and increase the classification score, as shown in the right part. See Sections 3 and 4 for details. |  |  |
---|---|---|---
(a) Original image and mask |  (b) $\mathsf{span}(V_{\text{mp}}^{\text{mou}})$ |  (c) $\cdots\cap\mathsf{span}(W_{\text{mp}}^{\overline{\text{mou}}})$ | (d) Interpolated correspondences
|  |  |
(e) $\mathsf{span}(V_{\text{fl}}^{\text{mou}})$ |  (f) $\cdots\cap\mathsf{span}(W_{\text{fl}}^{\overline{\text{mou}}})$ |  (g) $\cdots\cap\mathsf{span}(W_{\text{ap}})$ |  (h) $\cdots\cap\mathsf{span}(W_{\text{id}})$
Figure 2: Illustration of latent controls generated by different criterions as
described in Section 3.3. We use $\cdots$ to denote the subspace denoted in
the previous sub-figure. In b-c and e-h, extra subspaces are consecutively
intersected with the previous resulted subspaces.

##  1 Introduction

Modern Generative Adversarial Networks (GANs) [14] have shown impressive
ability to synthesize highly realistic images. StyleGAN [14] and its variants
[16] are one of the most successful representatives. StyleGAN converts a
random latent code to an intermediate style code and injects styles into each
layers of the generator network. Recent studies have shown that the latent
space of StyleGAN provides well-disentangled representations for visual
semantics. This property has derived an active research area on exploring
interpretable latent subspaces (also referred as latent controls) to modify
visual attributes in synthesized images [28, 40, 23, 1, 11, 27, 5, 44]. Recent
study has revealed the ability of StyleGAN subspaces to control even very
elaborate structures such as eye gaze or earings [40]. In this paper, we
further show that by exploiting the knowledge from conventional face analysis
models, e.g., face parsers and facial landmark detectors, more various
interpretable latent subspaces can be discovered for face image generation.

The development of interpretable latent subspaces in image generation reminds
a question whether this technique can be exploited to study deep learning
interpretability. In this paper, we answer this question by proposing a new
type of counterfactuals which are generated from our discovered interpretable
latent subspaces.

The idea originates from the earlier studies on explaining classifiers of
table data [37, 3] and are recently recognized as an important perspective in
the ML interpretability study. An ideal counterfactual alters the variables of
a sample as little as possible to flip the classifier prediction. These
altered variables help explain the factors related to a particular prediction.
For example, a counterfactual usually comes in a form of “If my salary is 10k
higher, I will not be rejected for the loan”. Unlike table data, generating
valid image counterfactuals is non-trivial. On one hand, it is difficult to
sample valid counterfactuals from high-dimensional image manifold by simply
altering pixels. To address this difficulty, some recent studies consider to
exploit image generation techniques to produce counterfactuals [30, 7, 19]. On
the other hand, even though image counterfactuals can be sampled using
generators, it is sometimes still difficult to explain what attributes or
concepts are altered. Some works [30, 7] make use of heatmaps to highlight the
difference between the original sample and its counterfactuals. However, when
the difference is non-local and noisy, such explanation is still not
satisfactory.

In order to produce counterfactuals which can be explained concretely, we
realize that interpretable latent subspaces serve as an possible solution. If
counterfactuals are produced by altering with an interpretable latent
subspace, their difference with the original sample can be better interpreted.
Based on this assumption, we propose the following two contributions in this
paper:

  * •

We propose a novel approach to discover interpretable latent subspaces. By
exploiting face analysis models (e.g., face parsers and facial landmark
detectors) as supervision, we are able to discover various new latent
subspaces with good interpretability and concrete semantics. The flexibility
of our approach could significantly enriches the latent subspaces for face
generation.

  * •

By restricting the latent code within the discovered latent subspace, we can
produce counterfactuals with concrete semantics to explain the behavior of a
face attribution classifier. We believe this approach provides a new
perspective to the interpretability study for CNNs.

##  2 Related Works

###  2.1 Interpretable Subspaces in StyleGAN

The study of interpretable latent subspace disentanglement has become an
active area recently [43]. Current approaches can be roughly categorized into
two categories based on the requirement of supervision.

Supervised methods [28, 41, 2, 40, 23, 1, 22] utilize annotated data or pre-
trained networks to obtain domain specific knowledge. InterFaceGAN [28] uses
pre-trained face attribute classifiers trained on attribute annotations to
find hyper-planes in the latent space that can linearly separate positive and
negative samples. Yang et al. [41] and Bau et al. [2] explore and visualize
the semantic hierarchy embedded in the intermediate layers of GANs through the
correspondences with annotated parts or objects in the images. Wu et al. [40]
explore the more disentangled StyleSpace and discover the locally-active or
attribute-specific style channels through the pre-trained segmentation and
classification networks. StyleCLIP [23] adopts the Contrastive Language-Image
Pre-training (CLIP) model [25] as supervision to perform the text-guided
manipulation by optimization in the latent space. StyleFlow [1] utilizes a
pre-trained normalizing flow, which defines an attribute-conditioned mapping
between the latent space and the style space.

Unsupervised methods discover meaningful latent codes or directions by
analyzing the space distribution under certain constraints [11, 27, 5, 44, 12,
32]. Jahanian et al. [12] and Spingarn et al. [31] explore the ”steerability”
of pre-trained GANs and find ”steering” directions correspond to image
transformations by optimization or a closed form solution from the generator’s
weights. StyleRig [32] proposes to train a new rigging network in a self-
supervised pattern, which controls the StyleGAN via a 3D morphable face model
(3DMM). GANSpace [11] applies Principal Component Analysis (PCA) either in the
latent space or feature space to identify useful control directions.
Plumerault et al. [24] find interpretable latent directions that correspond to
continuous factors of variations (e.g. the position or scale of an object).
SeFa [27] delves into the very first fully-connected layer of the generator.
It proposes an unsupervised and closed-form semantic factorization algorithm
that discovers interpretable directions. Collins et al. [5] demonstrate that
the StyleGAN’s latent space can be spatially disentangled and decomposed into
semantic objects and parts, which enables simple and effective local image
editing. Voynov and Babenko [36] propose an unsupervised and model-agnostic
approach to discover interpretable directions in the GAN latent space by
optimizing a joint classification and regression objective. Wang and Ponce
[38] compute the Hessian matrix of the squared distance function and perform
eigen-decomposition to discover interpretable axes in the latent space.
LowRankGAN [44] proposes a low-rank factorization algorithm on the Jacobian
matrix that corresponds to a specific local region to perform precise local
control via null space projection.

In this paper, our subspace discovery approach combines both supervised and
unsupervised strategies. We formulate various novel supervisions by exploiting
face analysis models to narrow the range of discovery, and then use the
unsupervised strategy similar to [44] to discover rich latent subspaces which
is unknown previously.

###  2.2 Generative Counterfactual Images

Counterfactuals have been regarded as an important means to explain the
behavior of black-box ML models. Comprehensive general reviews of this topic
could be found in recent literature such as [3]. Besides ML models on table
data, a number of works have studied to generate counterfactuals of image
data. Due to the difficulty to synthesize realistic images, earlier literature
[6, 35] mostly works with simple datasets like MNIST. Recently, the
development of generative models (e.g., GANs [9], VAEs [18], Normalizing Flows
[17], etc) provides the possibility to generate very realistic counterfactual
images since they are able to learn mappings from the latent space to the
image manifold. Singla et al. [29] adopt a conditional GAN to produce
realistic perturbations on a given image that gradually change the predictions
of a classifier. GANalyze [8] takes advantages of the GAN-based model to
visualize what a CNN model learns about high-level cognitive properties.
StylEx [19] proposes to incorporate the classifier into the training process
of StyleGAN and learn a classifier-specific StyleSpace. Sauer and Geiger [26]
propose to disentangle object shape, object texture and background in the
image generation process and generate structured conterfacturals which help
improve the robustness and interpretability of classifiers. Goyal et al. [10]
adopt a VAE as the generative model to discover the Causal Concept Effects
(CaCE) that explain a specific classifier. Sixt et al. [30] combine an
invertible network with a linear classifier to generate faithful
counterfactual examples and find the isosurface of the classifier through PCA.
Dombrowski et al. [7] perform gradient ascent in the latent space of a well-
trained normalizing flow to maximize the probability of the target class, then
invert it back to the image space to generate counterfactuals.

As mentioned in Section 1, after the counterfactuals are produced by
generators, it is still unclear what semantic features are altered. We propose
in this paper to alleviate this problem by restricting the alternation in a
subspace with concrete semantics.

###  2.3 Interpretable Face Analysis

To explain the motivation of this paper in a wider perspective, we further
briefly review the study of interpretability on deep learning face recognition
task. Interpretability has been an active topic in ML and also an important
component to establish trustworthy AI [20]. In the area of computer vision,
recent works on interpretable mostly focus on image classification tasks on
dataset like MNIST or ImageNet [3]. In terms of face recognition or
attribution tasks which distinguish fine-grained structures, these approaches
are usually not applicable. We notice there have been some recent literature
working on explaining either face recognition or face attribution [13, 39, 42,
30, 7]. We believe the proposed approach also makes contribution to this
underdeveloped area.

##  3 Supervised Subspace Discovery

###  3.1 Notations

StyleGAN is known to have three different internal feature spaces, namely the
input space $\mathcal{Z}=\mathbb{R}^{512}$, the latent space
$\mathcal{W}=\mathbb{R}^{512}$, the augmented latent space
$\mathcal{W}+=\mathbb{R}^{9216}$, and the style space
$\mathcal{S}=\mathbb{R}^{9088}$. In this paper, we use $u$ to denote a feature
code in any of the above spaces. A generator (e.g., a StyleGAN) $g$ transforms
$u$ to a generated image $x=g(u)$. We use $p$ to denote a pixel. $x(p)$ can be
obtained by bilinear interpolation.

We use $f$ to denote a differentiable function on $x$. For a face image in
this paper, $f$ can be a classifier, a facial landmark regression model, a
face pose estimator or any customized functions. In Section 3.3, we will
describe a series of examples of $f$. We can cascade $f$ with $g$, and obtain
a predictor on $u$ as $h(u)=f(g(u))$.

We use $\odot$ to denote element-wise multiplication. We use $\overline{m}$ to
denote the opposite of a mask $m$. We use a capital letter to denote a matrix
and sometimes abuse it as a set made up of its column vectors. We use
$\mathsf{span}(X)$ to denote the linear subspace spanned by column vectors in
$X$. We use $\mathsf{numel}(x)$ to denote the size of a vector, an image, or a
feature map. We use $\begin{bmatrix}x\end{bmatrix}_{\text{condition(x)}}$ to
denote the matrix stacked by all the vectors which satisfy given conditions.

In this section, we mainly study the eigenvector matrix of $\frac{\partial
h_{*}^{*}}{\partial u}^{\top}\frac{\partial h_{*}^{*}}{\partial u}$. We split
the eigenvector matrix into two blocks
$\begin{bmatrix}V_{*}^{*}&W_{*}^{*}\end{bmatrix}$, where
$V_{*}^{*}=V(h_{*}^{*})$ contains eigenvectors with non-zero eigenvalues while
$W_{*}^{*}=W(h_{*}^{*})$ corresponds to eigenvalues near zero. $*$ refers to
any superscripts or subscripts.

###  3.2 Jacobian Analysis

####  3.2.1 Basic Formulation

We start by a setup similar to [44]. Suppose we would like to find a direction
vector $n$ in the StyleGAN feature space which can change the appearance of
the mouth. We denote a predictor as

$h_{0}(u)=g(u)\odot m,$ (1)

where $m$ is a binary mask indicating the mouth region. We use the following
formulation to denote the change of appearance:

$\ell(u,n,\alpha)=\|h_{0}(u+\alpha
n)-h_{0}(u)\|^{2}\approx\alpha^{2}n^{\top}J^{\top}Jn,$ (2)

where $J_{0}=\frac{\partial h_{0}}{\partial u}$ is the Jacobian matrix of $h$,
$n$ is a unit vector, and $\alpha$ is a small step on the direction of $n$.
Obviously (2) is maximized by the eigenvector with the largest eigenvalue of
$J_{0}^{\top}J_{0}$ and minimized by the eigenvector the smallest eigenvalue.
We hereby denote the eigenvector matrix of $J_{0}^{\top}J_{0}$ as
$\begin{bmatrix}V_{0}&W_{0}\end{bmatrix}$, where $W_{0}$ corresponds to
eigenvalues near zero. Perturbing $u$ in subspace $\mathsf{span}(V_{0})$
changes (activate) the value of $h_{0}(u)$, while perturbation in subspace
$\mathsf{span}(W_{0})$ does not change (suppress) the value of $h_{0}(u)$.

We illustrate this procedure by an example in Figure 2a. As can be noticed in
Figure 2b, perturbations in $V_{0}$ might also cause $h(u)$ to change in the
region of $\overline{m}$ (i.e. the face color). To suppress this unnecessary
change, we repeat the above procedure for $h_{1}(u)=g(u)\odot\overline{m}$ and
obtain $\begin{bmatrix}V_{1}&W_{1}\end{bmatrix}$. Perturbations in the linear
span intersection

$\mathsf{span}(V_{0})\cap\mathsf{span}(W_{1}),$ (3)

will change the value of $x$ in the region of $m$ but preserve the value of
$x$ in $\overline{m}$ (Figure 2c).

####  3.2.2 Implementation Tricks

$J=\frac{\partial h}{\partial u}$ can be obtained by executing
$\mathsf{numel}(h(u))$ times of backward pass for each element of $h(u)$. When
$\mathsf{numel}(h(u))$ is large, e.g., $h(u)$ can be an image-like map, it is
computationally expensive to directly compute $J$. Not to mention that the
computational cost of $J^{\top}J$ is also high for large $J$. To alleviate
this cost, we can approximate $J^{\top}J$ directly by considering
$\frac{\partial\ell}{\partial n}\approx 2\alpha^{2}n^{\top}J^{\top}J$.
$\alpha$ is a selected constant parameter. If we select $n$ as a one-hot
vector and execute backward pass to compute $\frac{\partial\ell}{\partial n}$,
we obtain one row of $J^{\top}J$. By enumerating all the one-hot $n$, we can
compute $J^{\top}J$ by $\mathsf{numel}(n)$ times of backward pass. In
practice, the above two implementations of $J^{\top}J$ can be selected
according to the dimension of $h(u)$.

We next consider to compute the basis vectors $V$ of
$\mathsf{span}(V_{0})\cap\mathsf{span}(W_{1})$. In [44], the basis vectors are
obtained as $V=W_{1}{W_{1}}^{\top}V_{0}$. In practice, we would like the
columns of $V$ to be sorted by their impact on $h(u)$.
$W_{1}{W_{1}}^{\top}V_{0}$ does not guarantee this, even though $V_{0}$ is
sorted by the eigenvalue of $J_{0}^{\top}J_{0}$. A trick to obtain sorted
basis vectors is to compute $V$ as the eigenvectors of

${W_{1}}^{\top}J_{0}^{\top}J_{0}W_{1}.$ (4)

###  3.3 Criterion for Interpretable Control

####  3.3.1 Masked Photometry

(1) provides a straight-forward criterion to measure the photometric change of
the generated images. The mask $m$ can be generated by a face parsing network
or by a manually labeled region as in [44]. We have illustrated the example in
Figure 2a-c previously. To easy reference, we denote this criterion as
$h_{\text{mp}}^{\text{mou}}$ by setting $m$ as a mouth mask $m^{\text{mou}}$
for (1). The corresponding subspace for (3) is thus written as

$\mathsf{span}(V_{\text{mp}}^{\text{mou}})\cap\mathsf{span}(V_{\text{mp}}^{\overline{\text{mou}}}).$
(5)

####  3.3.2 Facial Landmarks

Using masked photometry to compute (3) enables to locally manipulate the
generated images. However, such image change might be entangled with both
appearance and geometry. We believe that better disentanglement of appearance
and geometry could contribute to better interpretability and control in the
generation procedure. In Section 3.3.2 and 3.3.3, we use facial landmarks to
construct criterions to achieve elaborate control over the face geometry.

Consider a facial landmark detector $f_{\text{fl}}$ which is differentiable to
images. We define

$\displaystyle h^{m}_{\text{fl}}(u)$
$\displaystyle=\begin{bmatrix}q\end{bmatrix}_{q\in Q\wedge m(q)=1},$ (6)
$\displaystyle Q$ $\displaystyle=f_{\text{fl}}(g(u)),$ (7)

where $m$ is a mask to select targeted facial landmarks. $h^{m}_{\text{fl}}$
provides a flexible approach to manipulate face geometry. We show an example
in Figure 2e-f to manipulate the shape of face boundary. Denote $m$ to select
face boundary landmarks. We obtain $V^{m}_{\text{fl}}$ as in Section 3.2.
Figure 2e shows the manipulation results on a direction in
$\mathsf{span}(V^{m}_{\text{fl}})$. On one hand, we notice that supervision by
landmarks enables us to flexibly discover geometric controls which are unknown
previously. On the other hand, we notice that the manipulation on face
boundary will also deform face geometry at other areas, e.g., open the mouth.
To alleviate this entanglement, we can compute $W^{\overline{m}}_{\text{fl}}$
and project the manipulation vector into
$\mathsf{span}(V^{m}_{\text{fl}})\cap\mathsf{span}(W^{\overline{m}}_{\text{fl}})$
as shown in Figure 2f.

####  3.3.3 Aligned Photometry

We have disentangled the geometric shape change in face generation using
facial landmarks. We then use facial landmarks to disentangle the facial
appearance change. This is useful in the cases of changing the face expression
or face shape while preserving the face appearance. We first decompose the
whole image by Delaunay mesh $\mathsf{Delaunay}(Q,i,c)$ triangulated on a
facial landmark set $Q$:

$\displaystyle\mathsf{Delaunay}(Q,i,c)$
$\displaystyle=\begin{bmatrix}q_{v_{0}(i)}&q_{v_{1}(i)}&q_{v_{2}(i)}\end{bmatrix}c,$
(8) $\displaystyle Q$ $\displaystyle=f_{\text{fl}}(g(u)),$ (9)

where $i$ denotes the triangle facet index. $q_{*}$ are landmarks in $Q$ and
$v_{*}(i)$ denotes the landmark index of each triangle vertex in $Q$. $c$
denotes the 3D bary-centric coordinates of a point which sum up to $1$. Face
shape change can be approximately modeled by the deformation of the Delaunay
mesh. Consider a set of points uniformly distributed on the Delaunay mesh
$P=\\{(i,c)\\}$. No matter how the face deformed, $P$ persists consistent
semantics and relative positions on a face. We show an example of $P$ in
Figure 2d, where the red points from $P$ keep their relative positions with
respect to the face under face motion. We can then use Delaunay mesh to denote
a aligned photometry on a generated image:

$\displaystyle h^{m}_{\text{ap}}(u)$
$\displaystyle=\begin{bmatrix}x(p)\end{bmatrix}_{p\in P^{\prime}\wedge
m(p)=1},$ (10) $\displaystyle P^{\prime}$
$\displaystyle=\\{\mathsf{Delaunay}(Q,i,c)|(i,c)\in P\\},$ (11)

where (10) can be realized by bilinear interpolation. $m$ defines a mask to
filter the control region.

We illustrate the effectiveness of aligned photometry in Figure 2g. We notice
that the face color is changed in Figure 2f. To suppress this appearance
change, we further intersect the latent subspace with $W_{\text{ap}}$.
$W_{\text{ap}}$ is obtained from (10) by setting $m$ as true on the foreground
region. $\mathsf{span}(W_{\text{ap}})$ allows controls to deform the image and
preserves photometry in corresponding areas. We can see in Figure 2g that the
face color is preserved when modifying the face boundary. In addition, we
observe that the magnitude of face boundary change is reduced in more
restricted subspaces along Figure 2d-f, though the manipulation magnitudes are
the same.

####  3.3.4 Face Identity Feature

In some scenarios, we might require the face identity not to be deviated too
much. To preserve the face identity, we can exploit a differentiable face
feature extractor $f_{\text{id}}$ to create a criterion to restrict the
subspace,

$h_{\text{id}}(u)=f_{\text{id}}(g(u)).$ (12)

Figure 2h illustrates the effect of $h_{\text{id}}$. We notice that the eye
shape is more similar to the original image and the face identity is better
preserved.

####  3.3.5 More Customized Criterions

As is shown in this section, the proposed formulation is able to make use of
any flexibly designed criterion to restrict latent subspace discovery. We
provide the above examples which possess good interpretability. As will be
shown in our experiments, we are able to disentangle a variety of facial
features, e.g., shape, color, appearance, and id, by combining the above
criterions. Beyond the above criterions, we would like to further note that
readers can customize more flexible criterions to discover unknown latent
subspaces. We provide two more examples below.

We can control the face color of using the formulation by computing a masked
average color. We denote

$\displaystyle h_{\text{mac}}^{m}(u)$
$\displaystyle=\underset{m(p)=1}{\mathsf{mean}}(x(p)),$ (13) $\displaystyle
h_{\text{res}}^{m}(u)$
$\displaystyle=\begin{bmatrix}x(p)-h_{\text{mac}}^{m}(u)\end{bmatrix}_{m(p)=1},$
(14)

where $m$ represents the face skin area. The masked average color
$h_{\text{mac}}^{m}(u)$ captures the rough color of the face and
$h_{\text{res}}^{m}(u)$ captures the residual face appearance. By constructing
the subspace
$\mathsf{span}(V_{\text{mac}}^{m})\cap\mathsf{span}(W_{\text{res}}^{m})$, we
obtain control directions which manipulate the face color but preserves the
face appearance.

We can also control to change the dominant edges by constructing a criterion
reflecting the high frequency component of an image. Define
$f_{\text{low}}(x)$ as the low-frequency component of an image, which can be
obtained by Discrete Wavelet Transform (DWT) or just up/down-sampling. We can
then denote the low and high frequency components as

$\displaystyle h_{\text{low}}^{m}$ $\displaystyle=f_{\text{low}}(g(u)),$ (15)
$\displaystyle h_{\text{high}}^{m}$ $\displaystyle=g(u)-h_{\text{low}}(g(u)),$
(16)

As will be shown in Section 5 and Figure 3, this criterion discovers
interesting face deformation subspaces.

##  4 Counterfactual Analysis on Face Attribution

By constructing interpretable criterions, we can solve various interpretable
latent subspaces to control image generation. With the discovered subspaces,
we can now answer the question in our title, i.e. we can execute
counterfactual analysis to explain how the attractiveness perceived by a
classifier is affected by the modification in interpretable latent subspaces.

Consider a latent space sample $u$ and a face attribution classifier
$\mathsf{logit}(x)$. A counterfactual can be obtained by gradient descent to
optimize a perturbation $\Delta u$ on the classifier output
$\mathsf{logit}(g(u+\Delta u))$. To guarantee that the generated
counterfactuals have interpretable semantics, we restrict $\Delta
u\in\mathsf{span}(V)$, where $V$ denotes the bases of any subspaces or their
intersection as derived in Section 3.3.

Figure 1 illustrates an example of generated counterfactuals on a given
sampled image. The counterfactuals are generated in three latent subspaces:
eye shape, mouth shape, and lip color. See LABEL:tab:exp-formulations in the
appendix for their formulations. By optimizing $\mathsf{logit}(g(u+\Delta u))$
in each derived subspace, we can obtain counterfactuals with concrete
semantics as restricted by the corresponding latent subspaces. The
attractiveness score perceived by the classifier is increased in each
counterfactual and the modifications are restricted to preserve
intepretability and locality. We notice that the resulted bigger eyes, smaller
mouth, and red lips are also consistent to common sense of attractiveness. We
will discuss more examples in the experiment section.

Skin color |  |  |  |  |
---|---|---|---|---|---
| Black/white | Blue/yellow | Red/green | Pink/white | Green/red
Mouth shape |  |  |  |  |
| Curvy and wide smile | Curvey and narrow smile | Smile width | Curvy and wide smile | Asymmetric smile
Mouth shape (id) |  |  |  |  |
| Curvy and wide smile | Curvey and narrow smile | Smile width | Curvy and wide smile | Asymmetric smile
Eye photomet |  |  |  |  |
| Open/close | Dark/bright | Brow ridge | Eye height and brow | Eye width and brow
Nose photomet |  |  |  |  |
| Vertical length | Red/white | Nose size and nostril | Nose width | Orange/blue
High frequency |  |  |  |  |
Figure 3: Visualization of the discovered interpretable latent subspaces in
$\mathcal{S}$. We select and visualize the manipulation effects of 5
representative principle components in each subspace. The figure is trimmed to
save space and please check LABEL:fig:exp-subspace-full in the appendix for
the full version. See Section 5.2.2 for details.

##  5 Experiments

###  5.1 Experiment Setup

We take the official StyleGAN2 PyTorch implementation [15] and the $1024\times
1024$ model pre-trained on FFHQ as our generator. We use a face parsing pre-
trained model [34] based on BiSeNet and a pre-trained 68-facial-landmark
detector from [4]. The face attribute classifier to explain is trained on
CelebA dataset [21] using [33].

We split an eigenvector matrix into $V$ and $W$ according to relative
eigenvalue magnitudes. Note that the modification magnitude is coupled by the
eigenvalue and the perturbation magnitude. To uniformly reflect the
modification magnitude in different criterions, we define a relative
eigenvalue as follows. Denote the largest eigenvalue as $\lambda_{0}$.
Eigenvectors whose eigenvalues are smaller than $\epsilon\lambda_{0}$ are put
in $W$ and the rest are kept in $V$. $\epsilon$ is selected between
$10^{-3}\text{-}10^{-2}$ to trade-off the change of modified areas and the
stability of the suppressed areas.

###  5.2 Latent Subspace Discovery

####  5.2.1 Comparison of Latent Space

In Section 3, our formulation is capable to solve latent subspaces in
different latent spaces of $\mathcal{S},\mathcal{W}+,\mathcal{W}$ and
$\mathcal{Z}$. In our experiments, we mainly explore the latent subspaces in
$\mathcal{S}$, since it possesses better disentanglement and richer semantics.
Readers can find qualitative and quantitative comparison between the 4 latent
spaces in LABEL:sec:space-comparison-sup in the appendix.

####  5.2.2 Discovered Subspaces

In this section, we construct 12 different formulations to restrict latent
subspaces to show the effectiveness of our approach in discovering subspaces.
The corresponding subspace formulations are summarized in LABEL:tab:exp-
formulations. For each criterion, we solve the subspace on 1-2 training
images, select $5$ representative principle components, and visualize the
modified images in Figure 3. We exaggerate the control magnitude to make the
modification more recognizable for readers. As pointed in [40], such
exaggeration might introduce artifacts and harm image quality. Several
interesting properties are observed from the visualization.

  * •

The visualized principle components represent the modification directions with
top magnitudes, but do not necessarily correspond to realistic face
attributes. For example, we see various unrealistic colors are decomposed for
the face skin and the nose. It is easy to understand that we can obtain
realistic colors in the subspace by linearly combining the components as
bases.

  * •

We observe that modification overflows to unintended regions in some cases,
indicating that the disentanglement is not perfect. We notice that such
overflow happens mainly in cases where landmark-related criterions are used,
e.g. face boundary and eye boundary. The fact that we exaggerate the
modification magnitudes also increases the overflow.

  * •

We illustrate the effect of face identity features by comparing subspaces
“mouth shape” and “mouth shape (id)”. The restriction on face identity
effectively reduces the unintended modification and generates more similar
faces. We observe that the reduced modification is mainly on eyes and mouth.

|  |  |  |  |  |  |  |
---|---|---|---|---|---|---|---|---
|  |  |  |  |  |  |  |
|  |  |  |  |  |  |  |
|  |  |  |  |  |  |  |
Original image | Face color | Eye shape | Eye photometry | Hair photometry | Lip color | Mouth shape | Face boundary |
Figure 4: Counterfactuals generated in interpretable subspaces to increase the
predicted scores of the attractiveness classifier. See Section 5.3 for
details. Corresponding difference maps can be found in LABEL:fig:attractive-
diff in the appendix.

####  5.2.3 Comparison with Previous Approaches

We further conduct experiments to compare and analyze the performance with
StyleSpace [40]. Please find qualitative and quantitative results in
LABEL:sec:comparison-sup in the appendix.

####  5.2.4 Transferability, Generality and Individuality

Similar to [44], our subspaces discovery approach can be either directly
applied on images for modification, or applied on some images for training to
re-use the solved controls on other test images. In our experiments, most
solved subspaces show good transferability. Unless specifically explained, we
use subspaces solved from 1-2 training images, and generate figures in this
paper from test set.

On the other hand, we notice that the discovered subspaces are sometimes also
related to the individuality of training images. We include some further
experiments in LABEL:sec:transferability-sup in our appendix.

###  5.3 Counterfactual Analysis

To examine the effectiveness of our proposed approach of counterfactual
analysis, We selected 4 representative face attributes from CelebA including
“attractive”, “heavy make-up”, “smiling”, and “pale skin” to experiment on
counterfactual explanations.

Figure 4 shows example counterfactuals generated to increase the score of the
attractiveness classifier. As can be noticed, counterfactuals generated in the
subspace of eye shape and eye photometry tend to have bigger and darker eyes.
Counterfactuals with lip color modification tend to be redder lipsticked. This
goes consistent with the common standard of beauty. Analysis in other
subspaces further discovers that the classifier favors light skin, pointed
face, small mouth and colorful hair, which is similar to the modern Asian
standard of beauty. We suspect this might be related to the preference of
dataset annotators, who are probably Asian since CelebA is created by an Asian
institution. To highlight the difference of the counterfactuals, we visualize
the corresponding difference map in LABEL:fig:attractive-diff in our appendix.

As is pointed in [40], the attribute of attractiveness is highly subjective.
Our counterfactual analysis does not aim to study the public standard of
beauty, but rather to analyze the behavior of the specific classifier. This
analysis does not reflect the opinion of the authors or the dataset creators
on the judgement of beauty. There exist multiple directions to enhance the
classifier score and our proposed approach only produces one possible
solution.

The average accuracy of our classifier is $90\%$. It should also be noticed
that explanation effectiveness is affected by both the quality of subspace
disentanglement in the generator and the prediction accuracy of the
classifier.

More results on “heavy make-up”, “smiling”, and “pale skin” are shown in
LABEL:sec:exp-counterfactual-materials in our appendix.

##  6 Discussions

We proposed an approach to flexibly explore interpretable latent subspaces for
generators like StyleGAN. This approach not only helps discover unknown
controls to manipulate images, but also can be used to generate counterfactual
explanations for image recognition. We believe this approach provides a
preliminary but new perspective to the explainability study of CNN. In this
section, we discuss the limitation and future plan to finalize the paper.

Limitation. The fundamental assumption for all the recent literature on latent
subspace control lies in the semantic disentanglement of the latent space of
StyleGAN. The richness of our discovered subspace further proves this
assumption. However, we find that the disentanglement is still limited. The
poor transferability of the face boundary control and the overflowed
modification in unintended regions indicate that the disentanglement could be
further improved.

As is shown in LABEL:fig:heavy_makeup in the appendix, the counterfactuals
does not always provide satisfactory explanation. For example, the subspace
modification might overflow to unintended region. The unintended modification
might compensate or conflict with the desired manipulation. The overfitting
effect might also drive the classifier to favor certain controls but ignore
others.

Outlook. As mention in Section 2, though explainability has been an active ML
research area recently, studies to explain image recognition on fixed
structures like faces is still limited. We believe our proposed approach is
valuable to promote the study in this area. We find the approach might inspire
several future studies. First, the flexibility of our formulation could
inspire the discovery of more unknown latent subspaces for GAN. Second, the
interpretable subspaces are only a very small portion of the latent space. It
remains an important problem on how the rest subspaces are affecting the
classification results. Last but not the least, besides explaining face
attribution, the effectiveness of the face identity feature criterion further
implies that the approach might also be potential to explain face
verification.

In terms of the long-term impact, we believe our new perspective of
interpretable counterfactuals will serve as a valuable promotion to practical
applications of interpretable AI such as vision-based medical diagnosis.

## Acknowledgement

We thank Zongze Wu for his explanation of the StyleSpace source code.

## References

  * Abdal et al. [2021] Rameen Abdal, Peihao Zhu, Niloy J Mitra, and Peter Wonka.  Styleflow: Attribute-conditioned exploration of stylegan-generated images using conditional continuous normalizing flows.  _ACM Transactions on Graphics (TOG)_ , 40(3):1–21, 2021.
  * Bau et al. [2018] David Bau, Jun-Yan Zhu, Hendrik Strobelt, Bolei Zhou, Joshua B Tenenbaum, William T Freeman, and Antonio Torralba.  Gan dissection: Visualizing and understanding generative adversarial networks.  _arXiv preprint arXiv:1811.10597_ , 2018.
  * Bodria et al. [2021] Francesco Bodria, Fosca Giannotti, Riccardo Guidotti, Francesca Naretto, Dino Pedreschi, and Salvatore Rinzivillo.  Benchmarking and survey of explanation methods for black box models.  _arXiv preprint arXiv:2102.13076_ , 2021.
  * Bulat and Tzimiropoulos [2017] Adrian Bulat and Georgios Tzimiropoulos.  How far are we from solving the 2d & 3d face alignment problem? (and a dataset of 230,000 3d facial landmarks).  In _International Conference on Computer Vision_ , 2017.
  * Collins et al. [2020] Edo Collins, Raja Bala, Bob Price, and Sabine Susstrunk.  Editing in style: Uncovering the local semantics of gans.  In _Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition_ , pages 5771–5780, 2020.
  * Dhurandhar et al. [2018] Amit Dhurandhar, Pin-Yu Chen, Ronny Luss, Chun-Chen Tu, Paishun Ting, Karthikeyan Shanmugam, and Payel Das.  Explanations based on the missing: Towards contrastive explanations with pertinent negatives.  _arXiv preprint arXiv:1802.07623_ , 2018.
  * Dombrowski et al. [2021] Ann-Kathrin Dombrowski, Jan E Gerken, and Pan Kessel.  Diffeomorphic explanations with normalizing flows.  In _ICML Workshop on Invertible Neural Networks, Normalizing Flows, and Explicit Likelihood Models_ , 2021.
  * Goetschalckx et al. [2019] Lore Goetschalckx, Alex Andonian, Aude Oliva, and Phillip Isola.  Ganalyze: Toward visual definitions of cognitive image properties.  In _Proceedings of the IEEE/CVF International Conference on Computer Vision_ , pages 5744–5753, 2019.
  * Goodfellow et al. [2014] Ian Goodfellow, Jean Pouget-Abadie, Mehdi Mirza, Bing Xu, David Warde-Farley, Sherjil Ozair, Aaron Courville, and Yoshua Bengio.  Generative adversarial nets.  _Advances in neural information processing systems_ , 27, 2014.
  * Goyal et al. [2019] Yash Goyal, Amir Feder, Uri Shalit, and Been Kim.  Explaining classifiers with causal concept effect (cace).  _arXiv preprint arXiv:1907.07165_ , 2019.
  * Härkönen et al. [2020] Erik Härkönen, Aaron Hertzmann, Jaakko Lehtinen, and Sylvain Paris.  Ganspace: Discovering interpretable gan controls.  _arXiv preprint arXiv:2004.02546_ , 2020.
  * Jahanian et al. [2019] Ali Jahanian, Lucy Chai, and Phillip Isola.  On the” steerability” of generative adversarial networks.  _arXiv preprint arXiv:1907.07171_ , 2019.
  * Jiang and Zeng [2021] Haoran Jiang and Dan Zeng.  Explainable face recognition based on accurate facial compositions.  In _Proceedings of the IEEE/CVF International Conference on Computer Vision_ , pages 1503–1512, 2021.
  * Karras et al. [2019] Tero Karras, Samuli Laine, and Timo Aila.  A style-based generator architecture for generative adversarial networks.  In _Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition_ , pages 4401–4410, 2019.
  * Karras et al. [2020a] Tero Karras, Miika Aittala, Janne Hellsten, Samuli Laine, Jaakko Lehtinen, and Timo Aila.  Training generative adversarial networks with limited data.  _arXiv preprint arXiv:2006.06676_ , 2020a.
  * Karras et al. [2020b] Tero Karras, Samuli Laine, Miika Aittala, Janne Hellsten, Jaakko Lehtinen, and Timo Aila.  Analyzing and improving the image quality of stylegan.  In _Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition_ , pages 8110–8119, 2020b.
  * Kingma and Dhariwal [2018] Diederik P Kingma and Prafulla Dhariwal.  Glow: Generative flow with invertible 1x1 convolutions.  _arXiv preprint arXiv:1807.03039_ , 2018.
  * Kingma and Welling [2013] Diederik P Kingma and Max Welling.  Auto-encoding variational bayes.  _arXiv preprint arXiv:1312.6114_ , 2013.
  * Lang et al. [2021] Oran Lang, Yossi Gandelsman, Michal Yarom, Yoav Wald, Gal Elidan, Avinatan Hassidim, William T Freeman, Phillip Isola, Amir Globerson, Michal Irani, et al.  Explaining in style: Training a gan to explain a classifier in stylespace.  _arXiv preprint arXiv:2104.13369_ , 2021.
  * Li et al. [2021] Bo Li, Peng Qi, Bo Liu, Shuai Di, Jingen Liu, Jiquan Pei, Jinfeng Yi, and Bowen Zhou.  Trustworthy ai: From principles to practices.  _arXiv preprint arXiv:2110.01167_ , 2021.
  * Liu et al. [2015] Ziwei Liu, Ping Luo, Xiaogang Wang, and Xiaoou Tang.  Deep learning face attributes in the wild.  In _Proceedings of International Conference on Computer Vision (ICCV)_ , December 2015.
  * Nitzan et al. [2020] Yotam Nitzan, Amit Bermano, Yangyan Li, and Daniel Cohen-Or.  Face identity disentanglement via latent space mapping.  _ACM Transactions on Graphics (TOG)_ , 39(6):1–14, 2020.
  * Patashnik et al. [2021] Or Patashnik, Zongze Wu, Eli Shechtman, Daniel Cohen-Or, and Dani Lischinski.  Styleclip: Text-driven manipulation of stylegan imagery.  In _Proceedings of the IEEE/CVF International Conference on Computer Vision_ , pages 2085–2094, 2021.
  * Plumerault et al. [2020] Antoine Plumerault, Hervé Le Borgne, and Céline Hudelot.  Controlling generative models with continuous factors of variations.  _arXiv preprint arXiv:2001.10238_ , 2020.
  * Radford et al. [2021] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, et al.  Learning transferable visual models from natural language supervision.  _arXiv preprint arXiv:2103.00020_ , 2021.
  * Sauer and Geiger [2021] Axel Sauer and Andreas Geiger.  Counterfactual generative networks.  In _International Conference on Learning Representations_ , 2021.  URL https://openreview.net/forum?id=BXewfAYMmJw.
  * Shen and Zhou [2021] Yujun Shen and Bolei Zhou.  Closed-form factorization of latent semantics in gans.  In _Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition_ , pages 1532–1540, 2021.
  * Shen et al. [2020] 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.
  * Singla et al. [2019] Sumedha Singla, Brian Pollack, Junxiang Chen, and Kayhan Batmanghelich.  Explanation by progressive exaggeration.  _arXiv preprint arXiv:1911.00483_ , 2019.
  * Sixt et al. [2020] Leon Sixt, Martin Schuessler, Philipp Weiß, and Tim Landgraf.  Interpretability through invertibility: A deep convolutional network with ideal counterfactuals and isosurfaces.  2020\.
  * Spingarn et al. [2021] Nurit Spingarn, Ron Banner, and Tomer Michaeli.  {GAN} ”steerability” without optimization.  In _International Conference on Learning Representations_ , 2021.  URL https://openreview.net/forum?id=zDy_nQCXiIj.
  * Tewari et al. [2020] Ayush Tewari, Mohamed Elgharib, Gaurav Bharaj, Florian Bernard, Hans-Peter Seidel, Patrick Pérez, Michael Zollhofer, and Christian Theobalt.  Stylerig: Rigging stylegan for 3d control over portrait images.  In _Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition_ , pages 6142–6151, 2020.
  * d-li14 [2019] d-li14.  face-attribute-prediction.  https://github.com/d-li14/face-attribute-prediction, 2019.
  * zllrunning [2019] zllrunning.  face-parsing.PyTorch.  https://github.com/zllrunning/face-parsing.PyTorch, 2019.
  * Van Looveren and Klaise [2019] Arnaud Van Looveren and Janis Klaise.  Interpretable counterfactual explanations guided by prototypes.  _arXiv preprint arXiv:1907.02584_ , 2019.
  * Voynov and Babenko [2020] Andrey Voynov and Artem Babenko.  Unsupervised discovery of interpretable directions in the gan latent space.  In _International Conference on Machine Learning_ , pages 9786–9796. PMLR, 2020.
  * Wachter et al. [2017] Sandra Wachter, Brent Mittelstadt, and Chris Russell.  Counterfactual explanations without opening the black box: Automated decisions and the gdpr.  _Harv. JL & Tech._, 31:841, 2017.
  * Wang and Ponce [2021] Binxu Wang and Carlos R Ponce.  The geometry of deep generative image models and its applications.  _arXiv preprint arXiv:2101.06006_ , 2021.
  * Williford et al. [2020] Jonathan R Williford, Brandon B May, and Jeffrey Byrne.  Explainable face recognition.  In _European Conference on Computer Vision_ , pages 248–263. Springer, 2020.
  * Wu et al. [2021] Zongze Wu, Dani Lischinski, and Eli Shechtman.  Stylespace analysis: Disentangled controls for stylegan image generation.  In _Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition_ , pages 12863–12872, 2021.
  * Yang et al. [2021] Ceyuan Yang, Yujun Shen, and Bolei Zhou.  Semantic hierarchy emerges in deep generative representations for scene synthesis.  _International Journal of Computer Vision_ , 129(5):1451–1466, 2021.
  * Yin et al. [2019] Bangjie Yin, Luan Tran, Haoxiang Li, Xiaohui Shen, and Xiaoming Liu.  Towards interpretable face recognition.  In _Proceedings of the IEEE/CVF International Conference on Computer Vision_ , pages 9348–9357, 2019.
  * Zhang et al. [2021] Yu Zhang, Peter Tiňo, Aleš Leonardis, and Ke Tang.  A survey on neural network interpretability.  _IEEE Transactions on Emerging Topics in Computational Intelligence_ , 2021.
  * Zhu et al. [2021] 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.