# Exploring Attribute Variations in Style-based GANs using Diffusion Models:
Supplementary Document (Appendix)

David S. Hippocampus
Department of Computer Science
Cranberry-Lemon University
Pittsburgh, PA 15213
<EMAIL_ADDRESS>
Use footnote for providing further information about author (webpage,
alternative address)— _not_ for acknowledging funding agencies.

###### Organization of Appendix

  1. A Related works
  2. B Analysis of diverse edit directions
  3. C Generalization of edit directions.
  4. D Comparison with multi-direction based editing methods
  5. E Comparison with single-direction based editing methods
  6. F Dataset Details
  7. G Model architecture
  8. H Computational requirement
  9. I Additional Results
  10. J Editing on 3D faces

##  Appendix A Related works

Latent space-based image editing. Recently, various image and video editing
works have been proposed that leverage semantics in the StyleGAN’s latent
space [shen2020interpreting] to edit images [jahanian2019steerability,
harkonen2020ganspace, abdal2021styleflow, patashnik2021styleclip,
parihar2022everything, tewari2020stylerig, stylespace, parihar2023we,
tzaban2022stitch]. One direction of works obtains a global edit direction in
the latent space for each attribute [shen2020interpreting,
harkonen2020ganspace, jahanian2019steerability, spingarn2020gan]. Traversal
along these global directions edits the corresponding attribute in the
generated image. Another cohort of methods obtains a local direction for each
latent code. Essentially a non-linear mapping is learned between the input
latent code and the desired edit code, using transformer networks
[transformereditsg2, umetani2022user, xu2022transeditor], a mapper network
[patashnik2021styleclip]. To obtain the edit direction for a given attribute,
these works use - attribute classifiers [abdal2021styleflow, liang2021ssflow],
segmentation masks [ling2021editgan], clip-supervision
[patashnik2021styleclip, abdal2022clip2stylegan, zheng2022bridging] or perform
unsupervised decomposition of the latent space [jahanian2019steerability,
harkonen2020ganspace, sefa, latentclr]. StyleFlow [abdal2021styleflow] learns
a conditional normalizing flow network to learn a deterministic mapping from a
source latent to a single edited latent code for each attribute. To enable
editing on real images, encoder-decoder frameworks have been proposed that map
the real image into the $\mathcal{W+}$ space and use StyleGAN’s generator as
the frozen decoder after latent editing [e4e, abdal2019image2stylegan,
alaluf2021hyperstyle, psp].

Non-binary attribute editing. Some editing works try to model the continuous
attribute variations instead of treating attributes as binary. Works like
[patashnik2021styleclip, yang2021beyondbinary] obtain directions for non-
binary attributes such as image style or expression change, but they also use
a single edit direction for the given attribute/style. Unsupervised methods
[latentclr, harkonen2020ganspace] can learn a finite set of disentangled
directions controlling each attribute. StyleSpace [stylespace] learns a set of
disentangled vectors in style space controlling each attribute. However, these
methods learn only a finite set of edit directions and cannot cover all the
possible variations for any given attribute. FLAME [parihar2022everything]
proposed a task of attribute style manipulation, where they generate edit
variations by navigating in the attribute manifold. Furthermore, StyleFusion
[kafri2021stylefusion] showed that a pre-trained StyleGAN could be used to
decompose spatial semantic regions. In contrast to these approaches, we learn
a distribution over edit directions for a given attribute and sample multiple
variations of an edit.

Diffusion Models Diffusion Models (DM) are likelihood-based models that have
achieved state-of-the-art performance in sample generation [ldm] and density
estimation [diffusion-beats-gan]. In contrast to GANs, DMs being likelihood-
based models, prevent mode collapse and learn rich multi-modal distributions.
DMs modeled as hierarchical denoising autoencoders [sohl2015deep, ddpm] are
trained to iteratively denoise images starting from pure noise. Due to the
sequential nature of DMs, applying them in the pixel space for high-resolution
images leads to high training costs and slow inference speeds [diffusion-
beats-gan]. To this end, latent diffusion models (LDMs) [ldm] have been
proposed that first encode the images into much lower dimensional spatial
latent codes and apply DM in the latent space. Subsequently, multiple works
are proposed that perform latent space diffusion for motion synthesis
[diffusion-motion], language generation [diffusion-language-generation], point
clouds generation [diffusion-point-cloud], generating brain imaging
[diffusion-brain-imaging]. In contrast, we compress the image into semantic
$\mathcal{W+}$ space of StyleGAN2 instead of spatial latent space and perform
diffusion process in this highly compressed space.

Figure 1: (Top) Comparison with the baseline edit directions - We randomly
sample five edit directions each from $\mathcal{D}_{a}$ and our method for
each attribute. Observe that using the baseline directions changes the
subject’s identity and other attributes. (Bottom) To visualize the
disentanglement of attributes, we perform editing on a source image with
$1000$ editing vectors from our method and baseline method and take the pixel-
wise difference between the source and the edited image. We plot the per-pixel
standard deviation of the difference image for eyeglass and hairstyle
variations. Observe that for eyeglass edit, our method changes only the region
near the eye, but the baseline method changes other regions such as hair and
mouth. Similarly, for hairstyles, our method performs changes in localized
hair regions.

##  Appendix B Analysis of diverse edit directions

Comparison with baseline edit directions. In summary, our proposed method
first creates a dataset $\mathcal{D}_{a}$ of edit directions using synthetic
image pairs (Sec. 3.1 in the main paper). Later, a DDPM model is trained over
these directions that can generate novel and diverse edit directions (Sec. 3.2
in main paper). A natural question is why we cannot directly use the edit
directions from $\mathcal{D}_{a}$ to perform attribute editing (Baseline). In
other words, is the edit direction space learned by the DDPM actually better
than having the dataset of edit directions? Since the image pairs are
synthetically generated, some of these edit directions are not clean and
entangle multiple attributes and change the subject’s identity as illustrated
in Fig. 1(Top). However, the proposed method can generate diverse edits while
preserving the identity and attributes of the subject.

To further analyze the disentanglement properties, we sample $1000$ edit
directions from $\mathcal{D}_{a}$ and our trained diffusion model to perform
edits on an input source image. We plot per pixel standard deviation of the
$1000$ different images between the source and edit for both methods in Fig.
1(Bottom). We observe that the edits performed by our method change a
localized region of interest in the edited image, whereas the baseline edits
unnecessarily alter other regions. This analysis shows the better
disentanglement properties of the directions generated by our method compared
to baseline directions. Although our model is trained on the dataset
$\matcal{D_{a}}$ of baseline edit directions, it can generate disentangled and
identity-preserving edits. This indicates that the diffusion model is learning
the space defined by the most dominant edit directions and is robust to
outlier directions.

To quantitatively compare the identity preservation ability of our method
against the baseline, we performed the following analysis. We plot the
Euclidean Distance (ED) between face embeddings (extracted from [face-
rec-2020]) of the source and edited image for the two methods in Fig. 2. As
indicated by lower ED scores, our method has better identity preservation
ability than the baseline.

Figure 2: Better identity preservation. Distribution of the Euclidean Distance
(ED) between the face recognition embeddings of edited and the source image
over $1000$ images. Observe that our directions have lower ED demonstrating
better identity preservation.

##  Appendix C Generalization of edit directions.

To analyze the generalization capability of the edit directions for different
editing, we perform editing with a single direction on multiple source images.
Specifically, we sample a set of edit directions for from a trained diffusion
model for hairstyles and eyeglasses and perform edits on six source images as
shown in Fig. 3. Editing with a direction generates similar styles in all the
source images. For example, for hairstyles, $d_{1}$ generates curly hair,
$d_{2}$ generates bangs and $d_{3}$ generates mohawk hairstyle. Observe that
for each eyeglass direction, similar frame shapes are generated. For
eyeglasses, $d_{1}$ generates ellipse-shaped frames, $d_{3}$ generates
similarly shaped yet thicker frames and $d2$ generates round-shaped frames.

Figure 3: Results for editing multiple source images with the same direction.
Each row, other than the source row, results from editing six different source
images using the same edit direction $d_{i}$, sampled using the appropriate
DDPM model. We present results for hairstyle edits on top and eyeglass edits
at the bottom. Observe that for each edit direction, an attribute edit of a
similar style is generated for all the source images.

##  Appendix D Comparison with multi-direction based editing methods

We compare our method for multi-dimensional edits with two methods that can
generate a set of few directions for each attribute - StyleSpace [stylespace]
and LatentCLR [latentclr]. StyleSpace learns the transformation over the style
space of StyleGAN2 to edit any attribute. In their work, it has shown that
there are few $(3-10)$ style codes that can control a single attribute such as
hairstyle or smile. However, for some attributes, e.g., age, there is no
disentangled style code. LatentCLR proposed a contrastive learning approach to
find a finite set of edit directions in the $\mathcal{W}$ latent space, which
contains complementary information. The edit directions for any given
attribute need to be manually selected by carefully inspecting the learned set
of directions. Both methods have some potential to perform more than one edit
per attribute but are limited to only a finite number of edits.

We compare our method against these methods for hairstyle attribute, as we
find maximum directions for hairstyles in both of these methods. Specifically,
we found $8$ directions from StyleSpace (($3-169$, $3-379$, $6-83$, $6-175$,
$6-285$, $6-364$, $12-266$, $12-330$) as reported in [stylespace] and $6$
directions for LatentCLR (when trained with non-linear method). Note that our
method can sample a large number of directions as we have learned a generative
model over edits. To obtain more variation in the edits from StyleSpace and
LatentCLR, we randomly sampled the edit strength from a range of values
working well for the respective methods. We present our results in Fig. 7. Our
method generates diverse variations with minimal entanglement. StyleSpace can
generate a few hairstyle variations, but most of the generated hairstyles are
highly similar (similar hairstyles are highlighted using the same colored
boxes). For LatentCLR, most of the obtained hairstyle directions entangle skin
tone, lighting, and other attributes. Also, for LatentCLR, we observe that
most of the hairstyles have similar structures but have variations in hair
length and color. However, our method can generate a range of diverse
hairstyle edits such as bangs, mohawk, curly, short hair, and further
variation among those. This supports the need for a multi-direction editing
method that can model the distribution over attribute edits that are beyond
finite directions per attribute.

Comparison with Infinite Direction methods. We present qualitative results for
the baseline method, FLAME, and our proposed method for diverse hairstyle
generations in Fig. 4. We can observe that the baseline method changes the
subject’s identity while having limited style variations. On the other hand,
FLAME can generate variations, but the identity and facial expressions of the
subject are altered. The proposed method can generate diverse hairstyle
variations like curls, texture, and bangs while preserving the subject’s
identity and retaining the other attributes.

Figure 4: Qualitative comparison for diverse hairstyle editing. Observe the
superior level of hairstyle variations and identity preservation from our
method.

##  Appendix E Comparison with single-direction based editing methods

We compare edits generated by our method against three state-of-the-art
single-direction based editing methods: InterfaceGAN [shen2020interpreting],
StyleCLIP [patashnik2021styleclip], StyleFlow [abdal2021styleflow] and
CLIP2StyleGAN [abdal2022clip2stylegan]. Note that these methods can generate a
single edit w.r.t. an attribute for a given image, whereas our method is
trained to generate multiple edits w.r.t. an attribute. We performed editing
to generate a single output for eyeglasses, smile, and age attributes using
all these methods. We present the comparison results in Fig. 5. For
CLIP2StyleGAN, we have generated results for only smile and eyeglasses
attributes as CLIP2StyleGAN could not find disentangled edit directions for
age. Our method achieves edits with high realism and disentanglement with
superior identity preservation ability even with a single-directional edit.
StyleFLow also achieves good edits with attribute disentanglement. However,
StyleFlow requires additional attribute classifiers to obtain attribute scores
which are required as input to edit any new input image. In Fig. 6 we compare
our method against diverse edits using single edit direction methods. The
variations in CLIP2StyleGAN and StyleFlow are generated by modifying the
strength of the edit direction.

Figure 5: Qualitative comparison with single direction methods. StyleCLIP and
CLIP2StyleGAN change the identity in age and eyeglass edits, respectively.
InterFaceGAN entangles hair color with eyeglass attribute edits. StyleFlow
changed the hair color while age editing. The proposed method can generate
realistic edits without altering other attributes. Figure 6: Comparison for
diverse attribute edits with single direction based editing methods -
CLIP2StyleGAN [abdal2022clip2stylegan] and StyleFlow [abdal2021styleflow]. The
variations in CLIP2StyleGAN and StyleFlow are generated by increasing the edit
strength. Figure 7: Qualitative comparison with multi-direction based editing
method - LatentCLR [latentclr] and StyleSpace [stylespace] for hairstyle
variations. StyleSpace has $8$ style codes controlling hairstyles, whereas
LatentCLR has $10$ directions in $\mathcal{W}$ space, which alter hairs. To
generate more variations, we modify the strength of edit directions for all
the methods. StyleSpace can generate some hairstyle variations, but most
hairstyles are highly similar (similar hairstyles indicated by the same
colored bounding box). In contrast, our method generates highly diverse
hairstyles, including bangs, curls, short hairs, and further variations among
those. For LatentCLR, we could not find disentangled directions, and most of
the directions entangle hair variations with age, skin color, and identity of
the subject. This supports the intuition to model the rich distribution of
edit directions with a generative model beyond selecting finite edit
directions per attribute.

##  Appendix F Dataset Details

Figure 8: We plot a histogram of the Cosine Similarity of all edit directions
with the mean direction. The spread of values suggests that the editing
directions, although for the same attribute, showcase a large variety.

We create a synthetic dataset of image pairs with a single attribute change to
learn the manifold of diverse attributes. To obtain such a dataset of paired
samples, we employed two approaches: 1) Using existing single-direction
editing method such as StyleCLIP [patashnik2021styleclip] to edit an input
image for a given attribute; 2) Using the “cut-paste" augmentation proposed in
FLAME [parihar2022everything]. Our method performs good quality diverse edits
when trained on the paired dataset obtained by both approaches, suggesting
that our method is agnostic to the pair creation method. Next, we will provide
details of these two approaches with examples.

1\. Existing single-direction editing method. We trained StyleCLIP
[patashnik2021styleclip] mapper with text prompts “bangs hairstyle", “mohawk
hairstyle", “curly hairs", “afro hairstyle", “buzz cut", and “bob cut" for
hairstyles. We use the trained StyleCLIP models to perform single edits on a
subset of CelebA-HQ [karras2017progressive] dataset. Examples of source and
edited images are shown in Fig. 9. We create a dataset of $30K$ image pairs
(edited and source) for each text prompt. The combined dataset of hairstyles
and beards has $160K$ synthetic image pairs each. For the age attribute, we
used SAM [sam_age], a state-of-the-art age editing method, to generate $30K$
image pairs similarly. For car edits, we used StyleCLIP models trained with
text prompts “sports car" and “classic car". To obtain image pairs for
multiple church styles, we used an off-the-shelf style transfer network
[park2020swapping].

Figure 9: Examples of synthetic image pairs.(Top) We present positive and
negative image pairs generated by cut-pasting the attribute region (as
explained in F). The augmented positive image is passed through the encoder
and StyleGAN2 to obtain smooth inversion. (Bottom) Example image pairs
generated by single direction editing method StyleCLIP, given the text prompts
"bangs hairstyle", "mohawk hairstyle" and "curly hairs." Note that the latent
encodings of the negative and positive images are used to obtain the edit
directions.

2\. Cut-paste augmentation. For generating images for smile and eyeglass
attributes, we used cut-paste augmentation as proposed in
[parihar2022everything]. Specifically, we sample a set of “positive" images
$X_{p}$ with attribute $a$ from the CelebA-HQ dataset using the attribute
annotations from CelebA. We sample a set of “negative" images $X_{n}$ that
does not have the attribute $a$. Then we sample an image from $x_{n}\in X_{n}$
and $x_{p}\in X_{p}$ and mask the region of interest/part of the face that
contains $a$ from $x_{p}$ and paste it onto $x_{n}$. For example, for the
smile attribute, we used the mouth region; while for eyeglasses, we used
eyeglass regions to perform cut-paste augmentation. These augmented images,
when passed through the e4e encoder and StyleGAN2 generator, are smoothly
blended due to smoothness prior to StyleGAN generator [chai2021using]. To
obtain part segmentation masks, we use a few shot segmentation network
[tritrong2021repurposing], which uses StyleGAN features to perform
segmentation. Specifically, we used five ground truth segmentations from
CelebAHQ-Mask [CelebAMask-HQ] to train the few shot segmentation models. Some
example image pairs generated by this operation are shown in Fig. 9.

How diverse are the edit directions in the dataset? We show the distribution
of cosine similarity of the edit directions with the mean edit direction in
Fig. 8. Observe that the obtained directions have high diversity and do not
align with the mean direction.

##  Appendix G Model architecture

We implemented our denoising network as an MLP network with $10$ fully
connected layers with $2048$ neurons in each layer. Additionally, we added a
time conditioning by first encoding the timestamp with $128$ dimensional
positional encoding. The encoded time embeddings are passed through another
MLP network of two fully connected layers with $256$ neurons each. Time
conditioning is added to all hidden layers of the base MLP network. A skip
connection is added after each linear layer, followed by a layer norm layer.
Layer norm is not added in the final layer.

##  Appendix H Computational requirement

We performed all our experiments on a single NVIDIA-A5000 GPU. The training
time of DDPM model on a dataset for latent directions is 1 hour on a single
GPU for a batch size of 64, although 3-4 such models can be trained on a
single A5000 at a time since the runs require less memory.

##  Appendix I Additional Results

Sequential editing of multiple attributes. As our method generates global edit
directions, we can combine edit directions for multiple attributes to obtain a
composite edit. We present results for composite editing of three attributes -
smile, hairstyle, and eyeglasses, in Fig. 10. For each attribute, we randomly
sample an edit direction from the trained diffusion model and add it to the
latent code of the source image to perform sequential editing. Observe that
our method can generate consistent edits that combine multiple diverse
attributes.

Figure 10: We sequentially perform smile, hairstyle, and eyeglasses edits with
two variations per attribute.

We present additional results for diverse attribute editing on real and
synthetic images in Fig. 13 and Fig. 11, respectively. For real images, we
first invert the input image into $\mathcal{W+}$ latent space using e4e [e4e]
encoder model. The proposed method can generate diverse and realistic
attribute variations for both real and synthetic datasets. Additionally, we
present results for diverse editing on car styles and church styles in Fig.
12.

Figure 11: Diverse attribute edits for age, smile, eyeglass, and hairstyles on
face images. Figure 12: Diverse attribute edits for car styles - sports car
and classic car and church styles. Figure 13: Diverse attribute edits on real
images. Given a real image, we encode it using e4e [e4e] encoder and perform
diverse attribute editing on the obtained latent code.

##  Appendix J Editing on 3D faces

We present diverse attribute editing results on 3D aware GAN, EG3D [eg3D]. The
proposed method can generate diverse attribute edits that are 3D consistent
and preserve the identity. We present results for editing in 3D along with the
surface maps of the edited geometry in Fig. 14. Observe that the shape of
eyeglasses and hairstyles are changed with diverse edits as visible in the
surface maps. We leave a detailed exploration of other 3D GANs as a future
work.

Figure 14: Diverse attribute variations for 3D aware GANs. Our method can
generate diverse edits which actually alter the 3D geometry of the face, as
shown in the surface maps.


11institutetext: *Equal Contribution
1 Technical University of Denmark, Kongens Lyngby, Denmark
11email: {manli, ninwe<EMAIL_ADDRESS>
2 Slagelse Hospital, Copenhagen, Denmark
3 Region Hovedstaden. Copenhagen, Denmark

# Shortcut Learning in Medical Image Segmentation

Manxi Lin 1*1* Nina Weng 1*1* Kamil Mikolaj 11 Zahra Bashir 22 Morten Bo
Søndergaard Svendsen 33 Martin Tolsgaard 33 Anders Nymark Christensen 11 Aasa
Feragen 11

###### Abstract

Shortcut learning is a phenomenon where machine learning models prioritize
learning simple, potentially misleading cues from data that do not generalize
well beyond the training set. While existing research primarily investigates
this in the realm of image classification, this study extends the exploration
of shortcut learning into medical image segmentation. We demonstrate that
clinical annotations such as calipers, and the combination of zero-padded
convolutions and center-cropped training sets in the dataset can inadvertently
serve as shortcuts, impacting segmentation accuracy. We identify and evaluate
the shortcut learning on two different but common medical image segmentation
tasks. In addition, we suggest strategies to mitigate the influence of
shortcut learning and improve the generalizability of the segmentation models.
By uncovering the presence and implications of shortcuts in medical image
segmentation, we provide insights and methodologies for evaluating and
overcoming this pervasive challenge and call for attention in the community
for shortcuts in segmentation.

###### Keywords:

Shortcut Learning Medical Image Segmentation

##  1 Introduction

Figure 1: Shortcuts such as yellow markers, affect ultrasound segmentation.
The calipers were dilated for illustration.

Shortcut learning, a critical challenge in machine learning, refers to
situations where models latch onto easy-to-learn correlations between input
data and target features that are available at training time, but not
necessarily at test time. This can give models that perform well in during
development, but falter when exposed to real-world practice, where the
“shortcuts” are absent. Shortcut learning receives increasing attention in
medical imaging [16, 18], where learned shortcuts affect high-stakes, high-
risk clinical decisions [10], undermine the trust in machine learning models
[5], and even threatens the model’s fairness [3].

Most current work addresses shortcut learning in classification. Fig. 1
illustrates an example of clinical ultrasound screening images marked with
text and measurement calipers at acquisition time, as a natural part of the
clinical process. The text and calipers correlate strongly with specific
anatomical standard planes, and as demonstrated in [15], this correlation
enables the model to use the markers rather than actual anatomical
characteristics when classifying images into different anatomical planes. This
can cause the model to fail at test time, e.g. sorting images during an
ultrasound examination before calipers are placed.

Shortcut learning has rarely been investigated in other tasks such as image
segmentation – an essential medical image quantification task that demands
exceptional accuracy and generalizability. Intuitively, shortcut learning
might seem less of a risk for image segmentation: In contrast to
classification, segmentation necessitates a precise delineation of organ
boundaries. This task utilizes spatial relationships and textures within the
image, as opposed to standalone, identifiable markers. In Fig. 1, the calipers
and texts provide very little help for identifying the boundaries of
anatomical structures. It thus seems unlikely that the segmentation models
would be affected by shortcut learning.

In this paper, we challenge this prevailing assumption: We illustrate that
shortcut learning can also affect medical image segmentation models, hampering
their performance at test time. We showcase two types of shortcuts in
segmentation with different underlying mechanisms, in two dermatological and
fetal ultrasound segmentation tasks. While the first type mirrors the
shortcuts identified in classification tasks, the other arises from a very
common combination of architecture choices and dataset construction.

##  2 Background and Related Work

A wide range of variables have been shown to act as shortcuts in medical
images. In a large collection of examples, the model learns signs of
treatment, diagnosis notes, or signs of related diseases as proxies of the
target $y$. Known examples include chest tube in chest x-ray as a common
treatment for Pneumothorax [10]; clinical annotations or diagnosis notes which
encode clinicians’ suspected diagnoses, such as ink circling suspicious skin
lesions or rulers measuring their size [16, 18]; text and calipers in
ultrasound [15] annotated primarily on high-quality images; or effects of
disease symptoms such as movement artifact in MRI scans, which can appear as a
result of tremor associated with Parkinson’s disease, or decreased capability
of following instructions of staying still due to diseases such as dementia
[8].

In a different class of shortcuts, the model encodes global information about
the data collection process, such as a hospital or hardware information, e.g
different hospitals might use different scanners and protocols, which give the
images a distinctive ’style’ [7, 24]; data collected from different hospitals
might have different prevalence distributions, e.g. a cancer-specialized
hospital might have more samples of diseased subjects than community hospital;
or frequency filters during the pre-processing of images [22, 23].

Model mistakenly learns the demographic features of the patient, which is
associated with the disease prevalence. Studies have shown that models can
easily learn the race or gender information from chest X-rays [6], increasing
the concerns of using demographic features for prediction, especially when
prevalence varies among groups.

Shortcuts performance differs by the choice of model structures. Studies show
that model structures and loss functions could impact shortcut learning, e.g.
Puli et al. [19] found that the setup of gradient-based optimization of cross-
entropy by empirical ERM is more easily to use shortcuts information; Izmailov
and Kirichenko et al. [9] studied how different choices of model architecture
and pre-training strategy impact shortcut learning.

Whereas most case studies are classification tasks, in this paper, we showcase
that shortcuts can also affect medical image segmentation.

##  3 Shortcut A: Calipers and texts in fetal ultrasound

Organ segmentation is a standard task in fetal ultrasound, where segmentations
are used for measurements as well as to guide predictive models. It is common
to train the segmentation models on clinical screening images, which
frequently feature clinical annotations such as text and measurement calipers
that are specific to each anatomical plane [11]. These annotations are absent
if models are applied in real-time, e.g., to highlight organs during the scan.
Below, we document how text and calipers act as shortcuts for fetal ultrasound
segmentation.

###  3.1 Experiments and observations

####  3.1.1 Data and experiment settings

Our study involved segmenting organs from a collection of 3,775 third-
trimester ultrasound images derived from a proprietary fetal ultrasound
screening dataset. These images represent 13 different fetal anatomical
structures and originate from four specific anatomical views: the fetal head,
femur, abdomen, and the maternal cervix. A medical doctor annotated each
image, with an experienced expert conducting subsequent verifications. We
partitioned the data into training, validation, and test sets, maintaining an
80/10/10 percent split. We utilized a variant of U-Net designed for fetal
ultrasound data [13] employing its public implementation. Models were trained
using the AdamW optimizer for 1,000 epochs with weight decay 1e-6, batch size
32, and early stopping. Training began with a learning rate of 1e-4, which we
adjusted over time following a cosine annealing schedule.

####  3.1.2 Demonstrating shortcut learning

We first validate model performance on two versions of the test set. First, we
use original images with text and calipers, and second, a “clean” version of
the same test set where annotations are artificially removed via the
inpainting strategy from [15]. Tab. 3.1.2 shows a performance drop on the
clean images, indicating that annotations are used as shortcuts.

Table 1: Model performance on a test set with clinical annotations, and with the same annotations artificially removed. We report the average and standard deviation of the per-image Dice coefficient.  Image | Anatomical plane
---|---
Head | Abdomen | Femur | Cervix
Test set w annotation | $76.97\pm 5.10$ | $82.06\pm 6.60$ | $93.82\pm 1.79$ | $76.29\pm 4.05$
Test set w/o annotation | $70.85\pm 8.24$ | $78.85\pm 7.72$ | $91.84\pm 4.87$ | $71.81\pm 4.86$

We further evaluate the impact of these shortcuts in real-time scans in the
clinics. Here, we analyze 110 screen capture video recordings of ultrasound
examinations from a single hospital, where the sonographer sequentially
identified the anatomical structures of the head, abdomen, and femur in 100
videos, and performed cervix examination in the remaining 10 videos. Upon
locating each anatomical feature, the image was frozen and then annotated with
texts and calipers. We observe fluctuations in the segmentation predictions
throughout this process, even when the underlying ultrasound image is frozen,
see Fig. 2, and a video clip example can be found in the supplementary
material. The first row of Tab. 3.1.2 shows the impact of shortcuts on all 110
videos. We quantify segmentation robustness by reporting the difference in
average dice coefficients of the segmentation predictions on the frames at the
start and the end of the annotation process, i.e., the same image with and
without clinical notes.

Figure 2: Illustration of the dynamic variation of model segmentation prediction on the maternal cervix in a video. The similarity score between frames at time $t_{0}$ and the last frame $t_{end}$ is computed by dice score. The selected frame shows that the segmentation prediction is unstable when putting the calipers and texts.  Table 2: Model performance varies during the recorded annotation of a frozen ultrasound plane. The variation is measured with average dice coefficients (%). ‘Baseline’ is the model that suffers from shortcuts while ‘Mitigation’ is the model trained on ‘clean’ images. The mitigated model is better and far more stable.  Model | Anatomical plane
---|---
Head | Abdomen | Femur | Cervix
Baseline | $89.07\pm 14.9$ | $94.75\pm 12.6$ | $91.51\pm 19.6$ | $82.42\pm 10.1$
Mitigation | $98.39\pm 1.30$ | $98.53\pm 1.86$ | $95.38\pm 8.89$ | $97.00\pm 1.20$

####  3.1.3 Mechanism

We are inspired by the conclusion from [15] for image recognition. In our
segmentation task, the shortcut arises from the consistent co-occurrence of
anatomical structures and the calipers and texts within our training dataset.
This co-occurrence leads our segmentation model to rely on these clinical
notes as predictive shortcuts, rather than fully understanding the texture and
shape features of the anatomical structures themselves. This reliance
undermines the model’s ability to perform accurately in practical
applications, posing a significant risk to its clinical applicability.

####  3.1.4 Mitigation

Following [15], we trained a mitigated model on images with annotations
artificially removed. As shown in the second row of Tab. 3.1.2, performance
increases substantially, indicating that text and calipers acted as shortcuts.

##  4 Shortcut B: The combination of zero-padded convolutions and center
cropped training sets

Skin lesions refer to damaged or abnormal skin tissue that differs in
appearance from the surrounding area. Common causes of skin lesions include
abscesses, cysts, tumors, sores, and ulcers [17]. Accurately segmenting skin
lesions is critical for various downstream tasks, such as dermoscopic feature
detection and lesion classification, particularly for detecting malignant skin
cancers.

Here, we utilized the widely-used ISIC skin lesion segmentation dataset [4] to
illustrate our second case of segmentation shortcut learning, which stems from
the combination of two typical design choices in image segmentation: (i) In
skin lesion segmentation datasets, as many other medical imaging segmentation
datasets, images tend to be cropped quite closely around the complete lesion
to be segmented, with the lesion in the center (see Fig. 6). (ii) A very
common modeling choice is to use zero padding in CNN segmentation
architectures to create output predictions with the same shape as the input
image. In addition to ease of implementation, this also enables a full
segmentation, rather than the partial segmentation of the image that a CNN
without padding would deliver.

Original |  |  |  |  |  |  |
---|---|---|---|---|---|---|---
GT |  |  |  |  |  |  |
$M_{ori}$ |  |  |  |  |  |  |
$M_{crop}$ |  |  |  |  |  |  |

Figure 3: Sample lesion images from $\mathbf{ISIC_{CROP}}$ with ground truth
(GT) segmentation and predicted segmentation by $M_{ori}$ and $M_{crop}$. We
clearly see shortcut learning and its mitigation when training on $M_{ori}$
and $M_{crop}$, respectively.

However, the above two design choices combined lead to an unfortunate
correlation between the features of pixels near the boundary and their class
(typically background): For any pixel whose receptive field extends beyond the
original image, its receptive field will contain a band of constant zero
values (Fig. 5), and pixels with such features will – due to the centering of
lesions in the dataset – almost always belong to the background class. In
other words, the combination of zero padding and dataset construction
constitutes a shortcut that lets the model learn that pixels near the image
boundary should be segmented as background.

###  4.1 Experiments and observations

####  4.1.1 Data and experimental settings

We use the ISIC2017 skin lesion dataset [4] with its original train and test
splits. To demonstrate the effect of shortcut learning via center cropping and
zero padding, we create an asymmetrically cropped version,
$\mathbf{ISIC_{CROP}}$, where the original images are cropped into 4 quarters,
one of which is randomly selected (see Fig. 3).

Segmentations were made with a standard UNet [20] trained with Dice loss [21]
using Adam [12] with a learning rate of 0.001, 100 epochs and batch size 16.
All images and masks are resized to $256\times 256$.

####  4.1.2 Demonstrating shortcut learning

Segmentation models $M_{ori}$ and $M_{crop}$ were trained using the original
train splits within ISIC2017 and $\mathbf{ISIC_{CROP}}$, respectively. As
illustrated in Fig 3, $M_{ori}$ has problems segmenting lesions near the
boundary. This is further quantified in Fig. 4 (a), where we show how
segmentation performance decreases in regions near the image boundary.

(a) Ring area given $d$.

(b) Performance of $M_{ori}$.

(c) Performance of $M_{crop}$.

Figure 4: To emphasize the effect of shortcut learning, we separate the image
into yellow bands of increasing distance from the center (a) and compute
segmentation Dice scores within each region. Note how the Dice score of the
shortcut model $M_{ori}$ declines with increasing distance from the center
(b), while the mitigated model $M_{crop}$ maintains its segmentation ability
across the image (c).

####  4.1.3 Mechanism

To understand why zero padding causes shortcut learning, we need to return to
the basics of CNNs: CNN segmentation networks are translation equivalent,
meaning that without zero padding, the CNN does not encode any information
about the spatial location of individual pixels. However, the feature patterns
induced by padding enable the CNN to encode – in a band around the image
border – the distance to the image border. As shown in Fig. 5, this likely
leads to these pixels clustering in feature space due to their special zero
padding features. When using the ISIC2017 dataset to train $M_{ori}$, those
pixels almost exclusively belong to the background, which encourages the model
to simply classify all boundary pixels as background.

Figure 5: Zero padding introduces a change in the features of segmented pixels
whose receptive field contains padding – i.e. those that are near the
boundary. This affects their encoding in feature space.

####  4.1.4 Mitigation

There is a simple yet efficient mitigation strategy: Namely to _not_ center
crop training images (equivalently, augment with random cropping). This is
documented by the $M_{crop}$ model, see Fig. 3 and 4 (c). When lesions are no
longer centered during training, test performance no longer depends on the
distance to the boundary, and the shortcut has been mitigated. Indeed, while
$M_{ori}$ can barely categorize any edging pixels into the class of skin
lesion, $M_{crop}$ clearly accepts the boundary of the image being the skin
lesion.

An alternative mitigation could be to swap zero padding with reflection or
replication. As these would still have distinctive features, shortcut learning
would still be possible, but likely less pronounced as the shortcuts would be
more difficult to learn. Nevertheless, crop augmentation is preferable as it
completely removes the correlation between boundary affinity and segmentation
labels.

##  5 Discussion and conclusion

We have demonstrated that shortcut learning is indeed possible for medical
image segmentation, expanding the current discourse which focuses narrowly on
classification. We have illustrated two rather different shortcut mechanisms.
The ultrasound case mirrors known shortcut mechanisms from image
classification, where text and calipers are used by the algorithm, either to
decide whether or not to segment, or to restrict the area within which to
segment organs. We show that shortcut learning can be mitigated by inpainting
the calipers. Conversely, the interplay of zero padding and center cropped
training sets reveals a different type of shortcut, where modeling choices
contribute to changing the feature representations of certain pixels. In this
context, we note just how prominent center cropping is in popular benchmark
datasets for medical image segmentation ( Fig. 6): it seems likely that
shortcut learning may be a factor in affecting scores in, for instance,
segmentation challenges.

ISIC2017 [4] | LIDC-IDRI [2] | BraTS [14] | Prostate [1]
---|---|---|---
|  |  |

Figure 6: Segmentation mask center distributions illustrate center cropping
within common medical image segmentation benchmark- and challenge datasets.

Shortcut learning versus overfitting. Overfitting occurs when excessively
complex models capture not just meaningful patterns but also random noise in
the training data. This makes the model highly specific to its training set
and less capable of generalizing to new data. In contrast, shortcuts lead
models to learn superficial and misleading patterns that don’t truly represent
the underlying problem. The result is still models that perform well on the
training data while failing to generalize at test time, but the mechanism is
wholly different.

Domain adaptation does not mitigate shortcut learning. Domain adaptation
implicitly assumes that the patterns learned by the algorithm on the original
domain are transferrable to the target domain. In shortcut learning, however,
the algorithm has not necessarily learned the underlying patterns at all,
because the shortcuts have provided a simpler strategy for optimizing the
training loss. As a result, it might not be possible to apply domain
adaptation to transfer a model that has learned shortcuts, to data without
shortcuts.

Beware! Segmentation models are vulnerable to shortcuts. We aim to warn that
shortcut learning is a risk beyond classification, with potential to affect
also pixel-level tasks such as segmentation, detection, super-resolution,
denoising, and artifact removal. Addressing these shortcuts is crucial to
ensure the creation of precise, robust, and dependable machine learning models
that are trustworthy for clinical use. We have shown how simple augmentation
and shortcut inpainting can mitigate our cases of shortcut learning, but
future research should address more generic tools to detect and mitigate
shortcuts in image segmentation.

## References

  * [1] Antonelli, M., Reinke, A., Bakas, S., et al.: The medical segmentation decathlon. Nature Communications (2022). https://doi.org/10.1038/s41467-022-30695-9
  * [2] Armato III, S.G., McLennan, G., Bidaut, L., McNitt-Gray, M.F., Meyer, C.R., Reeves, A.P., Zhao, B., Aberle, D.R., Henschke, C.I., Hoffman, E.A., et al.: The lung image database consortium (lidc) and image database resource initiative (idri): a completed reference database of lung nodules on ct scans. Medical physics 38(2), 915–931 (2011)
  * [3] Brown, A., Tomasev, N., Freyberg, J., Liu, Y., Karthikesalingam, A., Schrouff, J.: Detecting shortcut learning for fair medical ai using shortcut testing. Nature Communications 14(1), 4314 (2023)
  * [4] Codella, N.C., Gutman, D., Celebi, M.E., Helba, B., Marchetti, M.A., Dusza, S.W., Kalloo, A., Liopyris, K., Mishra, N., Kittler, H., et al.: Skin lesion analysis toward melanoma detection: A challenge at the 2017 international symposium on biomedical imaging (isbi), hosted by the international skin imaging collaboration (isic). In: 2018 IEEE 15th international symposium on biomedical imaging (ISBI 2018). pp. 168–172. IEEE (2018)
  * [5] Geirhos, R., Jacobsen, J.H., Michaelis, C., Zemel, R., Brendel, W., Bethge, M., Wichmann, F.A.: Shortcut learning in deep neural networks. Nature Machine Intelligence 2(11), 665–673 (2020)
  * [6] Glocker, B., Jones, C., Bernhardt, M., Winzeck, S.: Algorithmic encoding of protected characteristics in chest x-ray disease detection models. Ebiomedicine 89 (2023)
  * [7] Glocker, B., Robinson, R., Castro, D.C., Dou, Q., Konukoglu, E.: Machine learning with multi-site imaging data: An empirical study on the impact of scanner effects. arXiv preprint arXiv:1910.04597 (2019)
  * [8] Godenschweger, F., Kägebein, U., Stucht, D., Yarach, U., Sciarra, A., Yakupov, R., Lüsebrink, F., Schulze, P., Speck, O.: Motion correction in mri of the brain. Physics in medicine & biology 61(5), R32 (2016)
  * [9] Izmailov, P., Kirichenko, P., Gruver, N., Wilson, A.G.: On feature learning in the presence of spurious correlations. Advances in Neural Information Processing Systems 35, 38516–38532 (2022)
  * [10] Jiménez-Sánchez, A., Juodelyte, D., Chamberlain, B., Cheplygina, V.: Detecting shortcuts in medical images-a case study in chest x-rays. In: 2023 IEEE 20th International Symposium on Biomedical Imaging (ISBI). pp. 1–5. IEEE (2023)
  * [11] Khalil, A., Sotiriadis, A., D’Antonio, F., Da Silva Costa, F., Odibo, A., Prefumo, F., Papageorghiou, A., Salomon, L., et al.: Isuog practice guidelines: performance of third-trimester obstetric ultrasound scan. Ultrasound in Obstetrics & Gynecology 63(1), 131–147 (2024)
  * [12] Kingma, D.P., Ba, J.: Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980 (2014)
  * [13] Lin, M., Zepf, K., Christensen, A.N., Bashir, Z., Svendsen, M.B.S., Tolsgaard, M., Feragen, A.: Dtu-net: Learning topological similarity for curvilinear structure segmentation. In: International Conference on Information Processing in Medical Imaging. pp. 654–666. Springer (2023)
  * [14] Menze, B.H., Jakab, A., Bauer, S., Kalpathy-Cramer, J., Farahani, K., Kirby, J., Burren, Y., Porz, N., Slotboom, J., Wiest, R., et al.: The multimodal brain tumor image segmentation benchmark (brats). IEEE transactions on medical imaging 34(10), 1993–2024 (2014)
  * [15] Mikolaj, K., Lin, M., Bashir, Z., Svendsen, M.B.S., Tolsgaard, M., Nymark, A., Feragen, A.: Removing confounding information from fetal ultrasound images. arXiv preprint arXiv:2303.13918 (2023)
  * [16] Narla, A., Kuprel, B., Sarin, K., Novoa, R., Ko, J.: Automated classification of skin lesions: from pixels to practice. Journal of Investigative Dermatology 138(10), 2108–2110 (2018)
  * [17] National Cancer Institute: Lesion. https://www.cancer.gov/search/results?swKeyword=lesion (2024), accessed: 2024-03-02
  * [18] Nauta, M., Walsh, R., Dubowski, A., Seifert, C.: Uncovering and correcting shortcut learning in machine learning models for skin cancer diagnosis. Diagnostics 12(1), 40 (2021)
  * [19] Puli, A.M., Zhang, L., Wald, Y., Ranganath, R.: Don’t blame dataset shift! shortcut learning due to gradients and cross entropy. Advances in Neural Information Processing Systems 36 (2024)
  * [20] Ronneberger, O., Fischer, P., Brox, T.: U-net: Convolutional networks for biomedical image segmentation. In: Medical Image Computing and Computer-Assisted Intervention–MICCAI 2015: 18th International Conference, Munich, Germany, October 5-9, 2015, Proceedings, Part III 18. pp. 234–241. Springer (2015)
  * [21] Sudre, C.H., Li, W., Vercauteren, T., Ourselin, S., Jorge Cardoso, M.: Generalised dice overlap as a deep learning loss function for highly unbalanced segmentations. In: Deep Learning in Medical Image Analysis and Multimodal Learning for Clinical Decision Support: Third International Workshop, DLMIA 2017, and 7th International Workshop, ML-CDS 2017, Held in Conjunction with MICCAI 2017, Québec City, QC, Canada, September 14, Proceedings 3. pp. 240–248. Springer (2017)
  * [22] Wang, S., Veldhuis, R., Brune, C., Strisciuglio, N.: Frequency shortcut learning in neural networks. In: NeurIPS 2022 Workshop on Distribution Shifts: Connecting Methods and Applications (2022)
  * [23] Wang, S., Veldhuis, R., Brune, C., Strisciuglio, N.: What do neural networks learn in image classification? a frequency shortcut perspective. In: Proceedings of the IEEE/CVF International Conference on Computer Vision. pp. 1433–1442 (2023)
  * [24] Zech, J.R., Badgeley, M.A., Liu, M., Costa, A.B., Titano, J.J., Oermann, E.K.: Variable generalization performance of a deep learning model to detect pneumonia in chest radiographs: a cross-sectional study. PLoS medicine 15(11), e1002683 (2018)

Figure 7: Illustration of how zero padding breaks translation equivariance:
When the lesion moves, parts that stay inside the image have unchanged
segmentation, whereas parts that are closer to the border are systematically
undersegmented.

Figure 8: Illustration of the saliency maps of the segmentation model on the
ultrasound segmentation task. The saliency maps were obtained with Grad-CAM on
the last layer of the U-Net encoder. The saliency maps show the model’s
attention on the proposed shortcuts, i.e., the yellow calipers and texts in
the image.


$Q(\alpha,\gamma)$ in (B.16) (see Lemma A of Knight,  (1989)), that is,

$\displaystyle\begin{pmatrix}\widehat{\alpha}\\\
\widehat{\gamma}\end{pmatrix}=\begin{pmatrix}\sqrt[4]{n}\frac{1}{\|\theta_{0}\|^{2}}\theta_{0}^{\top}(\widehat{\theta}-\theta_{0})\\\
\sqrt[4]{n}^{3}P_{1}^{\top}(\widehat{\theta}-\theta_{0})\\\
q_{n}(\widehat{\beta}-\beta_{0})\end{pmatrix}\to_{D}(a_{2}M)^{-1}\xi=_{D}\frac{\sqrt{a_{1}}}{a_{2}}M^{-1/2}N(0,I_{d}).$

The proof is finished. $\Box$

Proof of Corollary 3.2 We now consider the convergence of
$\widehat{\theta}-\theta_{0}$. Denote
$J=\text{diag}(1/\|\theta_{0}\|,I_{d_{1}-1})$ for convenience. Observe that

$\displaystyle\sqrt[4]{n}(\widehat{\theta}-\theta_{0})=\sqrt[4]{n}(D_{n}JP)^{-1}(D_{n}JP)(\widehat{\theta}-\theta_{0})$
$\displaystyle=$
$\displaystyle\sqrt[4]{n}(D_{n}JP)^{-1}\begin{pmatrix}\sqrt[4]{n}\frac{1}{\|\theta_{0}\|^{2}}\theta_{0}^{\top}(\widehat{\theta}-\theta_{0})\\\
\sqrt[4]{n}^{3}P_{1}^{\top}(\widehat{\theta}-\theta_{0})\end{pmatrix}$
$\displaystyle\to_{D}$ $\displaystyle P^{\top}J^{-1}\text{diag}(1,{\bf
0}_{d_{1}-1})N(0,M^{-1}_{1})=_{D}N(0,\tau_{11}\theta_{0}\theta_{0}^{\top})\quad\Box$