# TransCAM: Transformer Attention-based CAM Refinement for Weakly Supervised
Semantic Segmentation

Ruiwen Li1 Zheda Mai2 Chiheb Trabelsi1 Zhibo Zhang1 Jongseong Jang3 Scott
Sanner1
1University of Toronto  2Optimy AI  3LG AI Research
{ruiwen.li<EMAIL_ADDRESS><EMAIL_ADDRESS>
<EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS>

###### Abstract

Weakly supervised semantic segmentation (WSSS) with only image-level
supervision is a challenging task. Most existing methods exploit Class
Activation Maps (CAM) to generate pixel-level pseudo labels for supervised
training. However, due to the local receptive field of Convolution Neural
Networks (CNN), CAM applied to CNNs often suffers from partial activation —
highlighting the most discriminative part instead of the entire object area.
In order to capture both local features and global representations, the
Conformer has been proposed to combine a visual transformer branch with a CNN
branch. In this paper, we propose TransCAM, a Conformer-based solution to WSSS
that explicitly leverages the attention weights from the transformer branch of
the Conformer to refine the CAM generated from the CNN branch. TransCAM is
motivated by our observation that attention weights from shallow transformer
blocks are able to capture low-level spatial feature similarities while
attention weights from deep transformer blocks capture high-level semantic
context. Despite its simplicity, TransCAM achieves a new state-of-the-art
performance of 69.3% and 69.6% on the respective PASCAL VOC 2012 validation
and test sets, showing the effectiveness of transformer attention-based
refinement of CAM for WSSS. Code is available at
https://github.com/liruiwen/TransCAM.

##  1 Introduction

Semantic segmentation is a fundamental computer vision task that assigns
semantic labels to every pixel in an image. Recent years have seen significant
progress in deep-learning-based semantic segmentation methods [9, 31, 3].
However, these methods require an enormous amount of training data with pixel-
level class labels. Such data needs massive fine-grained annotations and is
expensive to obtain; hence much effort has been devoted to weakly supervised
semantic segmentation (WSSS) that intends to train a segmentation model with
weak supervision such as bounding boxes [12, 24], scribbles [30], points [4],
or image-level class labels [41, 6, 50, 1]. The image-level class label is the
most accessible form of annotation since it already exists in large-scale
datasets like ImageNet [34]. Therefore, we focus on WSSS using only image-
level class labels in this work.

|  |  |
---|---|---|---
|  |  |
|  |  |
(a) image |  (b) ResNet- CAM |  (c) Conformer- CAM |  (d) TransCAM (ours)
Figure 1: Comparisons of CAMs generated by different networks or methods: (a)
the input images, (b) conventional CAMs generated from a ResNet-38 network (c)
conventional CAMs generated from the CNN branch of a Conformer-S network (d)
CAMs generated by our method.

To tackle WSSS with only image-level labels, most existing approaches rely on
Class Activation Maps [51] (CAM) to generate the initial seeds for
localization. Specifically, these methods often train a CNN classification
network with image-level labels, from which CAM are generated and refined as
pixel-level pseudo labels. Then a fully-supervised semantic segmentation
network is trained using the pseudo labels as ground-truth annotations.
Clearly, the success of WSSS is critically dependent on the accuracy of the
pseudo labels. However, a major obstacle of CAM-derived pseudo labels for WSSS
is the partial activation issue — CAM generated by the classification model
tend to highlight the most discriminative part of an object instead of the
entire object area [2, 41, 6, 28] as demonstrated in Figure 1 (b). Recent work
has pointed out the root cause of this issue is an intrinsic characteristic of
CNNs: the local receptive field only captures small-range feature dependencies
[18, 11]. Although various methods have been proposed to encourage a larger
activation area aligned with the entire object region [29, 41, 42, 2, 28, 27],
little work has directly addressed the local receptive field deficiencies of
the CNN when applied to WSSS.

Recently, transformers [39] have demonstrated tremendous success in many
computer vision tasks [14, 38], but they are much less explored for WSSS. The
Vision Transformer (ViT) [14] leverages multi-head self-attention and multi-
layer perceptrons to capture long-range semantic correlations, which are
crucial for localizing the entire object; however, in contrast to the CNN, the
ViT often ignores local feature details of objects that are also important for
WSSS applications. In order to leverage advantages of both the CNN and ViT
architectures, hybrid combinations of the two have been developed [43, 33, 13,
10, 47]. In particular, the Conformer [33] utilizes a CNN branch and a
transformer branch to fuse local features and global representations
interdependently at multiple scales.

As a first contribution of our work, we show the Conformer is more effective
as a backbone for WSSS when compared to commonly used ResNets [20, 45]. As
shown in Figure 1 (b) & (c), the Conformer generates CAM with more extensive
coverage on the target object and more accurate pseudo labels from CAM. This
leads to better WSSS performance as shown in Table 1. We believe this
improvement derives from the Conformer’s ability to couple local features with
global representations, which is important to alleviate the partial activation
issue of CAM. Nonetheless, CAM generated from Conformer’s CNN branch are only
influenced by the self-attention weights from the transformer branch in an
implicit manner (through the Feature Coupling Units (FCU)), as shown in Figure
2, leading to poor performance on the WSSS task (Section 4.3).

To address this issue in a second contribution of our work, we propose a
simple, efficient, and effective method called TransCAM that explicitly
leverages the attention weights from the transformer branch of the Conformer
to refine the CAM generated from the CNN branch. TransCAM is motivated by our
observation that attention weights from the shallow transformer blocks are
able to capture low-level spatial feature similarities while attention weights
from deep transformer blocks capture high-level semantic context (Section
4.3.3). Based on this observation, we construct an attention map that embeds
both low-level and high-level spatial feature affinities by averaging the
multi-head self-attention weights from all transformer blocks. The CAM
generated from the CNN branch is refined by this attention map with a simple
dot product. As illustrated in Figure 2, TransCAM does not rely on any
additional components nor complex calculations. It simply leverages the
feature affinities embedded in the Conformer backbone and enhances the CAM
with a single-step dot product refinement. Thorough experiments demonstrate
the effectiveness of TransCAM — despite its relative simplicity, TransCAM
achieves a new state-of-the-art performance of 69.3% and 69.6% on the
respective PASCAL VOC 2012 [15] validation and test sets.

We summarize our main contributions:

  * •

We propose the first transformer-based solution (TransCAM) for WSSS to address
the partial activation limitations of CAM due to the inherent deficiencies of
the CNN’s local receptive field.

  * •

TransCAM explicitly utilizes the inherent attention weights from the
transformer branch of the Conformer to improve the CAM generated from the CNN
branch. It is based on our observation that the attention weights capture both
low-level and high-level spatial feature affinities. TransCAM does not rely on
any additional components nor complex calculations, thus also making it a
simple high-performance baseline for further research.

  * •

TransCAM achieves state-of-the-art performance for WSSS on the PASCAL VOC 2012
dataset with image-level annotations.

##  2 Related Work

###  2.1 Weakly Supervised Semantic Segmentation (WSSS)

Most recent solutions to WSSS with image-level annotations use Class
Activation Maps (CAM) [51] to generate the pixel-level pseudo labels and then
train the segmentation model with the pseudo labels in a fully supervised
manner. CAM combines the feature map before the global average pooling layer
with the weights of the last fully connected layer to score and visualize the
contribution of each pixel to the classification result. However, it tends to
focus on the most discriminative part of the target object.

Existing works that deal with this issue are mainly divided into two
categories. The first category makes the network focus on more complete object
regions. Adversarial erasing [42, 21] removes the most discriminative part of
an object to encourage larger activation on non-discriminative object regions;
Sun et al. [37] explores cross-image semantic relations, while Chang et al.
leverages a sub-category objective for object pattern mining; SEAM [41]
exploits consistency regularization for CAM equivalence under affine
transformations; AdvCAM [28] generates an attribution map from an image that
is manipulated against adversarial attack. The second category refines the
initial pseudo labels for segmentation via post-processing. SEC [25] refines
CAM following three principles: seed, expand, and constrain; AffinityNet [2]
uses a network to predict the semantic affinity between neighboring pixels and
then uses the prediction result for semantic propagation via random walk;
IRNet [1] further explores the boundary activation map for determining pixel
affinity; AuxSegNet [46] adopts auxiliary tasks and learns cross-task affinity
to propagate the CAM. Despite the collective progress made by these works,
little research has directly addressed the local receptive field deficiencies
of the CNN when applied to WSSS, which is the key problem that we tackle in
this work.

###  2.2 Self-attention for WSSS

The self-attention mechanism [39] has substantially improved various computer
vision tasks including semantic segmentation. Non-local neural networks [40]
apply it to convolutional neural networks to capture long-range feature
dependencies. Some recent WSSS works also adopt self-attention modules to
capture semantic affinities. CIAN [17] leverages self-attention to obtain more
extensive and consistent activation regions from the activation maps of two
images with the same class objects. SEAM [41] adopts self-attention to capture
pixel affinity that can be used to refine CAM. EDAM [44] applies self-
attention to model the intra-image and inter-image homogeneity. However, these
methods require attaching extra components to the end of the backbone output,
which increases the model complexity and ignores low-level semantic
correlations. Our proposed method leverages the inherent multi-head attention
weights in the transformer blocks to capture low- and high-level feature
affinities.

###  2.3 Transformer-based Weakly Supervised Object Localization

The transformer [39] architecture is initially proposed to handle sequential
data for natural language processing tasks. The Vision Transformer (ViT) [14]
splits an input image into sequential patches and feeds them into the original
transformer encoder to obtain the visual representation for the image
classification task. TS-CAM [18] applies the visual transformer to the weakly
supervised object localization task by coupling the patch token with the
semantic-agnostic attention map. Although the visual transformer captures
global representations, it ignores local feature details. To this end, LCTR
[11] utilizes cross-patch information to enhance the local perception
capability while retaining global information. To date, none of these methods
have been extended to WSSS.

##  3 Methodology

Figure 2: TransCAM leverages the dual-branch Conformer network (yellow part)
with $L$ convolution and transformer blocks. It refines the CAM $M_{c}$
generated from the CNN branch with the Attention Map $A^{*}$, and the
resulting CAM $M_{c}^{*}$ has significantly improved object coverage. The
Attention Map $A^{*}$ is constructed by averaging the multi-head self-
attention weights from all transformer blocks and excluding all the class
token weights (slice). TransCAM does not rely on any additional components nor
complex calculations. It simply leverages the low-level and high-level spatial
feature affinities embedded in the Conformer backbone to enhance the CAM with
a single-step dot product refinement.

###  3.1 Preliminaries

####  3.1.1 The Conformer network

The Conformer [33] is a dual network structure aiming to couple CNN-based
local features with transformer-based global representations for enhanced
representation learning, as shown in Figure 2 (yellow part). Specifically, the
Conformer consists of a stem module to extract initial local features, a CNN
branch, a transformer branch, and Feature Coupling Units (FCUs) to
progressively fuse local features in the CNN branch with global
representations in the transformer branch. Note that the CNN and transformer
branches have the same number of ($L$) repeated convolution and transformer
blocks, respectively.

The first transformer block projects the output from the stem module using a
convolution to generate the patch embeddings. Then, the patch embeddings are
prepended with a class token, used as the input for the multi-head self-
attention (MHSA) module. As for later transformer blocks, it takes the output
of the FCU and adds to the token embeddings from the previous transformer
block; the result concatenated with the class token is used as the input for
the MHSA module. We denote the input and the output for the MHSA module in the
$l$-th block by $X^{l}\in\mathbb{R}^{(1+N)\times D}$ and
$\tilde{X}^{l}\in\mathbb{R}^{(1+N)\times D}$, where $1$, $N$, $D$ represents
the class token, the spatial dimension of token embeddings, and transformer
embedding dimensions, respectively.

The CNN branch adopts a feature pyramid structure, where the resolution of
feature maps decreases with network depth while the channel number increases.
Each convolution block in the CNN branch contains multiple bottlenecks, which
comprises a down-projection convolution, a spatial convolution, and an up-
projection convolution, following the definitions in ResNet [20].

####  3.1.2 Class Activation Map

A Class Activation Map (CAM) [51] for a particular class indicates the
discriminative image regions used by the CNN to identify that class, which is
often used to generate pseudo labels in WSSS. It can be applied to a trained
classification network that contains a feature extracting network, a Global
Average Pooling (GAP) layer, and a linear classification layer. The activation
map is generated by multiplying the feature maps from the last convolution
layer with the target-specific weights of the classification layer. The
generation of the activation map that is related to the $c$-th class can be
formulated as:

$M_{c}=\theta_{c}^{\intercal}f$ (1)

where $M_{c}\in\mathbb{R}^{f_{h}\times f_{w}}$ is the class-specific
activation map, $\theta_{c}\in\mathbb{R}^{f_{c}\times 1}$ are the weights of
the classification layer that correspond to the $c$-th object, and
$f\in\mathbb{R}^{f_{c}\times f_{h}\times f_{w}}$ is the feature map from the
last convolution layer ($f_{c},f_{h},f_{w}$ are the number of channels, the
height, and the width of the feature map respectively). For WSSS, one can also
implement CAM using fully convolutional networks without the linear
classification layer [22].

###  3.2 CAM Generation from Conformer

We adopt the Conformer as the backbone network for the initial pseudo label
generation. For the original Conformer network, the last bottleneck of the
final convolution has a spatial convolution with stride 2 for down-scaling. We
modify it with stride 1 to get higher resolution feature maps for better
segmentation performance and match the size of the Attention Map described in
Section 3.4. After the modification, the feature maps $f$ from the CNN branch
are of the size $f_{c}\times\sqrt{N}\times\sqrt{N}$ where $f_{c}$ is the
number of channels, and $N$ denotes the spatial dimension of token embeddings.

CAM is an efficient method to localize objects given image class labels. We
use CAM to generate the activation map
$M\in\mathbb{R}^{C\times\sqrt{N}\times\sqrt{N}}$ from the CNN branch of the
Conformer where C and N are the respective number of classes (including the
background class) and spatial dimension of token embeddings. As shown in
Figure 1 (b) & (c), the CAM from the Conformer highlights more extensive
object regions compared to the CAM from conventional CNNs [36, 20] since the
Conformer employs the MHSA mechanism with the global receptive field to
capture long-range feature dependencies. However, it is still hard to achieve
ideal performance for the WSSS task if we directly use CAM from the Conformer
for pseudo label generation since the CAM is only influenced by the self-
attention weights from the transformer branch in an implicit manner (through
FCU) and does not fully exploit the feature affinity information from the
attention weights for localization.

###  3.3 Attention Map Generation

We assume that the weights of the multi-head self-attention module in the
$l$-th transformer block are $A^{l}\in\mathbb{R}^{S\times(1+N)\times(1+N)}$,
where $S$ is the number of heads. The attention weights $A^{l}$ are computed
as:

$A^{l}=\mathrm{softmax}(\frac{Q^{l}{K^{l}}^{\intercal}}{\sqrt{D/S}})$ (2)

where $Q^{l}$ and $K^{l}$ are the key and query representations projected from
$X^{l}$ in the $l$-th transformation block. To aggregate the semantic context
captured by all heads, we take the average of $A^{l}$ across all heads to get
$\bar{A^{l}}\in\mathbb{R}^{(1+N)\times(1+N)}$.
$\bar{A^{l}}_{i,j}\in\mathbb{R}$ reveals how much the $j$-th input token
embedding contributes to the $i$-th output token embedding of the MHSA module
in the $l$-th transformer block, and $\bar{A^{l}}$ (excluding the weights for
the class token) captures spatial feature affinities in $l$-th transformation
block in general.

In order to acquire a single attention map, we can compute the average
attention weights $\bar{A}\in\mathbb{R}^{(1+N)\times(1+N)}$ over different
transformer blocks:

$\bar{A}=\frac{1}{L}\sum_{l}{\bar{A^{l}}}$ (3)

To better understand what information the attention weights from different
blocks capture, we compare the average attention weights in shallow blocks
(first half), denoted by AS; deep blocks (second half), denoted by AD and all
blocks, denoted by AA in Figure 3. It can be observed that AS tends to assign
high weights to the pixels that are similar in texture to the reference point,
which correlates with the fact that shallow transformer blocks leverage the
local feature captured by the early convolution blocks. AD reveals the ability
of the Attention Map to capture high-level semantics, e.g., it manages to
capture three persons instead of two for AS in the first image; it highlights
the eyes and ears of the cat in the fourth image. However, it looks noisy
because token embeddings in deep layers reflect complex semantic context. AA
is able to leverage both low-level local feature similarities from shallow
blocks and high-level semantic context from deep blocks. It can also smooth
the noise in the attention weights from deep blocks. Based on this
observation, we believe that it is crucial to combine both low-level and high-
level feature affinities for CAM refinement, and therefore, we compute the
average attention weights $\bar{A}$ over all transformer blocks.

We ignore the attention weights in $\bar{A}$ that are related to the class
token since they only imply the contribution of each token embedding to the
classification result but do not reflect the spatial feature affinities. The
final Attention Map $A^{*}\in\mathbb{R}^{N\times N}$ can be computed as:

$A^{*}=(\bar{A}_{i,j})_{2\leq i\leq N+1,2\leq j\leq N+1}$ (4)

|  |  |
---|---|---|---
|  |  |
|  |  |
|  |  |
|  |  |
|  |  |
(a) images | (b) AS | (d) AD | (e) AA
Figure 3: Visualization of input images with reference points (red dots) and
the Attention Maps of the reference points. We show the Attention Maps
generated by different weighting methods: averaging attention weights in
shallow blocks (AS), deep blocks (AD), and all blocks (AA).

###  3.4 Attention-based CAM refinement

The attention weights contain semantic information that could be leveraged to
generate CAM with extensive object coverage. Multiple methods could be used to
fuse the semantic information with CAM as shown in Section 4.3. We propose to
leverage the spatial feature affinities captured by $A^{*}$ to refine the CAM
$M_{c}$ via matrix multiplication:

$M_{c}^{*}=\mathrm{\Gamma^{\sqrt{N}\times\sqrt{N}}}(A^{*}\cdot\mathrm{\Gamma^{N\times
1}}(M_{c}))$ (5)

where $M_{c}^{*}\in\mathbb{R}^{\sqrt{N}\times\sqrt{N}}$ is the refined CAM,
$\mathrm{\Gamma^{N\times 1}}$ is the reshape operator that flattens $M_{c}$ to
match the size of the patch embeddings, and
$\mathrm{\Gamma^{\sqrt{N}\times\sqrt{N}}}$ is the operator that reshapes to
the dimension of $M_{c}$. $M_{c}^{*}$ explicitly exploits the context
information from the transformer attention weights and can be used to generate
an initial pseudo label with extensive object coverage for the WSSS task.

###  3.5 Training and Pseudo Label Generation

We apply the GAP layer to the activation map $M$ from the CNN branch to obtain
the prediction vector $z_{conv}\in\mathbb{R}^{C}$. Following the original
Conformer, we attach a linear layer to the class token at the end of the
transformer branch and obtain the prediction vector
$z_{trans}\in\mathbb{R}^{C}$. We use the weighted sum of $z_{conv}$ and
$z_{trans}$ as the prediction logits:
$z^{\prime}=w_{conv}z_{conv}+w_{trans}z_{trans}$, where
$z^{\prime}\in\mathbb{R}^{C}$, $w_{conv}\in\mathbb{R}$,
$w_{trans}\in\mathbb{R}$ denotes the final logits, the weight for convolution
logits, the weight for transformer logits, respectively. We employ multi-label
soft margin loss for network training. The classification loss defined for
$C-1$ foreground image labels is formulated as:

$\mathcal{L}_{cls}=-\frac{1}{C-1}\sum_{c=1}^{C-1}[y_{c}\mathrm{log}(\frac{1}{1+e^{-z^{\prime}_{c}}})+(1-y_{c})\mathrm{log}(\frac{e^{-z^{\prime}_{c}}}{1+e^{-z^{\prime}_{c}}})]$
(6)

where $z^{\prime}_{c}\in\mathbb{R}$ is the logit of the $c$-th object, and
$y_{c}\in\\{0,1\\}$ is the ground truth class annotation of the $c$-th object.
After we have the trained classification model, to generate the pseudo labels,
we set the background score as:

$M^{bkg}_{h,w}=\tau$ (7)

where $\tau\in[0,1]$ denotes the hard threshold parameter at the position
($h$, $w$), $1\leq h\leq H$, $1\leq w\leq W$, $H$ and $W$ are the height and
the width of the image. During inference, we apply elementwise min-max
normalization to all refined foreground CAMs ${M^{*}_{c}}_{1\leq c\leq C-1}$
and concatenate them together. We up-sample the normalized result to the size
of the input image, then we append $M^{bkg}$ with the result denoted as
$\hat{M^{*}}\in C\times H\times W$. The pixel-level pseudo label is calculated
as:

$Y_{h,w}=\mathrm{argmax}_{c}\hat{M^{*}}_{h,w}$ (8)

where $Y_{h,w}\in\\{1,...,C\\}$ denotes the class label of the pixel at
position $h,w$.

##  4 Experiments

###  4.1 Dataset and Evaluation Metric

We evaluate our method on the PASCAL VOC 2012 segmentation benchmark [15].
There are 21 object categories in the dataset, including 20 foreground objects
and the background. The official dataset is split into 1464 images for
training, 1449 images for validation, and 1456 images for testing. Following
the conventional experimental protocol used in the previous works [41, 2, 27,
23, 50], we build an augmented train set with 10582 images by taking
additional annotations from the Semantic Boundary Dataset [19]. We leverage
only image-level class labels during training. To measure the performance of
our method, we use the mean Intersection-over-Union (mIoU) as the evaluation
metric.

###  4.2 Implementation Details

We adopt Conformer-S [33] with pre-trained weights on ImageNet [34] as the
backbone network. The Conformer-S network has 37.7M parameters, which is less
than ResNet-101 (44.5M). The dual-branch importance weights
$(w_{conv},w_{trans})$ are set to (0.5, 0.5), and the performance of other
weights are reported in Section 4.3. Our model is trained on a single Tesla
V100 GPU with 32GB RAM. We use standard data augmentations during training:
random scaling, random horizontal flipping, color jittering, and random
cropping. We randomly re-scale the training image in the range of [320, 640]
and crop them into the size of 512$\times$512 as the network input. We train
our model for 20 epochs with the AdamW [32] optimizer and batch size 8. The
learning rate is set to 0.00005, and the weight decay is set to 0.0005. During
inference, aggregating prediction maps from multi-scaled input of a test image
is commonly used to boost the final performance. We resize a test image into
256$\times$256, 512$\times$512, and 768$\times$768 during inference.

###  4.3 Ablation Studies

We conduct ablation studies with results validated on PASCAL VOC 2012 train
set to verify the effectiveness of our proposed approach. In all experiments,
the background score $\tau$ is set to the value that gives the best mIoU for
the generated pseudo labels on the train set in order to ensure a fair
comparison.

method | mIoU (%)
---|---
ResNet-38-CAM† | 47.16
ResNet-38-CAM [41] | 47.43
ResNet-50-CAM [1] | 48.30
Conformer-S-CAM | 51.70
Table 1: Comparison of pseudo labels produced by CAM with different backbones.
† denotes our implementation.

####  4.3.1 CAM with different backbones

In previous works, CNN models such as ResNet-38 [45] and ResNet-50 [20] are
widely used to generate the initial pseudo labels. Table 1 compares the pseudo
labels generated by CAM with ResNet-38, ResNet-50, and Conformer-S [33]
backbone. CAM with Conformer-S outperforms CAM with ResNet-50 by 3.4%,
verifying that Conformer generates CAM with more extensive object coverage.
Thanks to the interactive fusion of CNN features and transformer embeddings,
the Conformer captures local features and global representations; thus it
serves as an effective backbone for the WSSS task.

####  4.3.2 Coupling CAM with attention weights

We denote our baseline: the CAM from the Conformer-S CNN branch without
coupling Attention Map as Conformer-S-CAM. We explore different ways to
leverage the context information from the attention weights for CAM
refinement. One approach is to employ the attention weights $A^{cls}$ for the
class token. $A^{cls}$ highlights the crucial pixels for image classification
without focusing on local areas. Although $A^{cls}$ is not distinguishable for
object classes, we can fuse it with CAM by Hadamard product to make it aware
of object categories. We denote this method as ClsAttn. Another approach to
couple attention weights with CAM is aggregating the patch attention maps
based on the patch activation values obtained from CAM, denoted by AttnAgg.
The detailed calculations and the qualitative results of ClsAttn and AttnAgg
are given in the Appendix. Table 2 shows the performance comparison of our
proposed method with Conformer-S-CAM, ClsAttn, and AttnAgg. Both ClsAttn and
AttnAgg do not have noticeable improvement from the baseline, while our
proposed approach increases the mIoU by 13.15%. It verifies the effectiveness
of our method that leverages spatial feature affinities for CAM refinement.

method | mIoU (%)
---|---
Conformer-S-CAM (baseline) | 51.70
ClsAttn | 51.15
AttnAgg | 51.87
TransCAM (ours) | 64.85
Table 2: Comparison with our baseline and different attention-based refinement
approaches.

####  4.3.3 Leveraging attention weights in all blocks

There are 12 transformer blocks in the Conformer-S network. We compare
different methods for generating the final Attention Map $A^{*}$: averaging
attention weights in shallow blocks (Block 1-6), denoted by AS; deep blocks
(Block 6-12), denoted by AD; all blocks (Block 1-12), denoted by AA. Table 3
shows the difference in mIoU of applying these attention weighting methods. AA
achieves better performance than AS and AD in terms of mIoU, verifying the
importance of combining low-level feature affinities and high-level semantic
correlations for CAM refinement.

method | mIoU (%)
---|---
AS | 60.39
AD | 63.89
AA | 64.85
Table 3: Comparison of various attention weighting methods that average
attention weights from different transformer blocks.

####  4.3.4 Importance weights for dual branches

We experiment with different combinations of importance weights for logits
$(w_{conv},w_{trans})$, which control the relative importance of the CNN
branch and the transformer branch for image classification. As shown in Figure
4, logit weights have little impact on the pseudo label quality when
$w_{conv}>0.1$ for both our method and our baseline (Conformer-S-CAM). The
performance is expected to be low when $w_{conv}$ is 0 since the essential
weights for CAM generation are not trained. In other experiments, we report
the performance with $(w_{conv},w_{trans})$ assigned to $(0.5,0.5)$.

Figure 4: Impact of importance weights for dual-branch logits on the pseudo label in terms of mIoU. When $w_{conv}>0.1$, the importance weights have little influence on the pseudo label performance. (a) |
---|---
(b) |
(c) |
Figure 5: Qualitative semantic segmentation results on PASCAL VOC 2012 val
set. (a) Original images; (b) Ground truth labels; (c) Prediction of the
segmentation model trained on TransCAM generated pseudo labels.

method | bkg | aero | bike | bird | boat | bottle | bus | car | cat | chair | cow | table | dog | horse | mbk | person | plant | sheep | sofa | train | tv | mIoU
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---
SEC [25] | 82.4 | 62.9 | 26.4 | 61.6 | 27.6 | 38.1 | 66.6 | 62.7 | 75.2 | 22.1 | 53.5 | 28.3 | 65.8 | 57.8 | 62.3 | 52.5 | 32.5 | 62.6 | 32.1 | 45.4 | 45.3 | 50.7
AdvErasing [42] | 83.4 | 71.1 | 30.5 | 72.9 | 41.6 | 55.9 | 63.1 | 60.2 | 74.0 | 18.0 | 66.5 | 32.4 | 71.7 | 56.3 | 64.8 | 52.4 | 37.4 | 69.1 | 31.4 | 58.9 | 43.9 | 55.0
PSA [2] | 88.2 | 68.2 | 30.6 | 81.1 | 49.6 | 61.0 | 77.8 | 66.1 | 75.1 | 29.0 | 66.0 | 40.2 | 80.4 | 62.0 | 70.4 | 73.7 | 42.5 | 70.7 | 42.6 | 68.1 | 51.6 | 61.7
SEAM [41] | 88.8 | 68.5 | 33.3 | 85.7 | 40.4 | 67.3 | 78.9 | 76.3 | 81.9 | 29.1 | 75.5 | 48.1 | 79.9 | 73.8 | 71.4 | 75.2 | 48.9 | 79.8 | 40.9 | 58.2 | 53.0 | 64.5
FickleNet [27] | 89.5 | 76.6 | 32.6 | 74.6 | 51.5 | 71.1 | 83.4 | 74.4 | 83.6 | 24.1 | 73.4 | 47.4 | 78.2 | 74.0 | 68.8 | 73.2 | 47.8 | 79.9 | 37.0 | 57.3 | 64.6 | 64.9
Chang et al. [6] | 88.8 | 51.6 | 30.3 | 82.9 | 53.0 | 75.8 | 88.6 | 74.8 | 86.6 | 32.4 | 79.9 | 53.8 | 82.3 | 78.5 | 70.4 | 71.2 | 40.2 | 78.3 | 42.9 | 66.8 | 58.8 | 66.1
Ours | 91.3 | 81.9 | 35.4 | 84.7 | 67.6 | 67.9 | 87.5 | 80.5 | 86.5 | 31.4 | 73.9 | 52.5 | 84.0 | 74.9 | 74.6 | 79.0 | 44.7 | 84.1 | 47.0 | 78.4 | 46.6 | 69.3

Table 4: Categorical semantic segmentation performance on PASCAL VOC 2012 val. Method | w/o p.p. | w/ p.p.
---|---|---
$\mathrm{Mixup}$-$\mathrm{CAM\;_{BMVC20}}$ [5] | 50.1 | 61.9
$\mathrm{Chang\>\textit{et al.}\;_{CVPR20}}$ [6] | 50.9 | 63.4
$\mathrm{SEAM\;_{CVPR20}}$ [41] | 55.4 | 63.6
$\mathrm{AdvCAM\;_{CVPR21}}$ [28] | 55.6 | 67.8
$\mathrm{CPN\;_{ICCV21}}$ [50] | 57.4 | 68.0
TransCAM | 64.9 | 70.2
Table 5: Comparison of pseudo labels with and without post-processing (p.p.) in terms of mIoU on PASCAL VOC 2012 train set Method |  Backbone |  Sup. |  val |  test
---|---|---|---|---
$\mathrm{PSA\;_{CVPR18}}$ [2] |  ResNet38 |  $\mathcal{I}$ |  61.7 |  63.7
$\mathrm{IRN\;_{CVPR19}}$ [1] |  ResNet50 |  $\mathcal{I}$ |  63.5 |  64.8
$\mathrm{FickleNet\;_{CVPR19}}$ [27] |  ResNet101 |  $\mathcal{I+S}$ |  64.9 |  65.3
$\mathrm{CIAN\;_{AAAI20}}$ [17] |  ResNet101 |  $\mathcal{I}$ |  64.3 |  65.3
$\mathrm{SSDD\;_{ICCV19}}$ [35] |  ResNet38 |  $\mathcal{I}$ |  64.9 |  65.5
$\mathrm{SEAM\;_{CVPR20}}$ [41] |  ResNet38 |  $\mathcal{I}$ |  64.5 |  65.7
$\mathrm{Chang\>\textit{et al.}\;_{CVPR20}}$ [6] |  ResNet101 |  $\mathcal{I}$ |  66.1 |  65.9
$\mathrm{BES\;_{ECCV20}}$ [7] |  ResNet101 |  $\mathcal{I}$ |  65.7 |  66.6
$\mathrm{CONTA\;_{NIPS20}}$ [49] |  ResNet38 |  $\mathcal{I}$ |  66.1 |  66.7
$\mathrm{MCIS\;_{ECCV20}}$ [37] |  ResNet101 |  $\mathcal{I+S}$ |  66.2 |  66.9
$\mathrm{ICD\;_{CVPR20}}$ [16] |  ResNet101 |  $\mathcal{I+S}$ |  67.8 |  68.0
$\mathrm{AdvCAM\;_{CVPR21}}$ [28] |  ResNet101 |  $\mathcal{I}$ |  68.1 |  68.0
$\mathrm{Yao\>\textit{et al.}\;_{CVPR21}}$ [48] |  ResNet101 |  $\mathcal{I+S}$ |  68.3 |  68.5
$\mathrm{CPN\;_{ICCV21}}$ [50] |  ResNet38 |  $\mathcal{I}$ |  67.8 |  68.5
$\mathrm{AuxSegNet\;_{ICCV21}}$ [46] |  ResNet38 |  $\mathcal{I+S}$ |  69.0 |  68.6
TransCAM (ours) |  ResNet38 |  $\mathcal{I}$ |  69.3 |  69.6
Table 6: Comparison with state-of-the-art methods on PASCAL VOC val and test
set in terms of mIoU (%). The Backbone refers to the segmentation network.
Sup. specifies whether image-level labels ($\mathcal{I}$) or off-the-shelf
saliency maps ($\mathcal{S}$) are used.

###  4.4 Comparison with State-of-the-art

We adopt PSA [2] for post-processing following previous work [41, 50] to
improve the mIoU of our pixel-level pseudo labels. The PSA-refined pseudo
labels achieve 69.14% mIoU on the PASCAL VOC 2012 train set. Then, the dense
CRF [26] is employed to improve the pseudo labels obtained in the previous
step. The final pseudo labels achieve 70.23% mIoU on the PASCAL VOC 2012 train
set. Table 5 compares the pseudo labels obtained by TransCAM (with and without
post-processing) with other recent methods. For pseudo labels without post-
processing, TransCAM outperforms others by a large margin; it has a smaller
performance improvement after applying post-processing, possibly since it has
already leveraged semantic affinities that PSA relies on for refinement.

We train the classical segmentation model DeepLab [8] with ResNet38 [45]
backbone (pre-trained on ImageNet) on the post-processed pseudo labels in a
fully-supervised manner. Table 4 shows our categorical mIoU performance on the
PASCAL VOC 2012 val set. Figure 5 gives some qualitative semantic segmentation
results on the PASCAL VOC 2012 val set, which shows that TransCAM performs
well on some relatively hard examples where multiple objects are presented in
an image. Table 6 compares the performance of TransCAM with previous methods.
TransCAM achieves 69.3% and 69.6% mIoU on the PASCAL VOC 2012 val and test
sets, respectively, which represents the state-of-the-art performance for
approaches that adopt the ResNet38 segmentation backbone. Moreover, TransCAM
performs 1% better on the test set than the previous state-of-the-art
AugSegNet [46] method that uses additional saliency supervision.

##  5 Conclusion

We proposed TransCAM, a transformer-CNN hybrid solution to solve limitations
of class activiation maps (CAM) for weakly supervised semantic segmentation
(WSSS) due to partial activation that is intrinsic to the use of CNNs.
Specifically, TransCAM explicitly leverages the attention weights from the
transformer branch of the Conformer to refine the CAM generated from the CNN
branch. TransCAM is motivated by our observation that attention weights from
shallow transformer blocks are able to capture low-level spatial feature
similarities while attention weights from deep transformer blocks capture
high-level semantic context. Our method is simple, efficient, and effective
for generating high-quality pixel-level pseudo labels as the first
transformer-based approach in WSSS. Despite its simplicity, TransCAM achieves
a new state-of-the-art performance on both the PASCAL VOC 2012 validation and
test sets.

## References

  * [1] Jiwoon Ahn, Sunghyun Cho, and Suha Kwak.  Weakly supervised learning of instance segmentation with inter-pixel relations.  In Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, pages 2209–2218, 2019.
  * [2] Jiwoon Ahn and Suha Kwak.  Learning pixel-level semantic affinity with image-level supervision for weakly supervised semantic segmentation.  In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 4981–4990, 2018.
  * [3] Vijay Badrinarayanan, Alex Kendall, and Roberto Cipolla.  Segnet: A deep convolutional encoder-decoder architecture for image segmentation.  IEEE transactions on pattern analysis and machine intelligence, 39(12):2481–2495, 2017.
  * [4] Amy Bearman, Olga Russakovsky, Vittorio Ferrari, and Li Fei-Fei.  What’s the point: Semantic segmentation with point supervision.  In European conference on computer vision, pages 549–565. Springer, 2016.
  * [5] Yu-Ting Chang, Qiaosong Wang, Wei-Chih Hung, Robinson Piramuthu, Yi-Hsuan Tsai, and Ming-Hsuan Yang.  Mixup-cam: Weakly-supervised semantic segmentation via uncertainty regularization.  arXiv preprint arXiv:2008.01201, 2020.
  * [6] Yu-Ting Chang, Qiaosong Wang, Wei-Chih Hung, Robinson Piramuthu, Yi-Hsuan Tsai, and Ming-Hsuan Yang.  Weakly-supervised semantic segmentation via sub-category exploration.  In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 8991–9000, 2020.
  * [7] Liyi Chen, Weiwei Wu, Chenchen Fu, Xiao Han, and Yuntao Zhang.  Weakly supervised semantic segmentation with boundary exploration.  In European Conference on Computer Vision, pages 347–362. Springer, 2020.
  * [8] Liang-Chieh Chen, George Papandreou, Iasonas Kokkinos, Kevin Murphy, and Alan L Yuille.  Semantic image segmentation with deep convolutional nets and fully connected crfs.  arXiv preprint arXiv:1412.7062, 2014.
  * [9] Liang-Chieh Chen, George Papandreou, Iasonas Kokkinos, Kevin Murphy, and Alan L Yuille.  Deeplab: Semantic image segmentation with deep convolutional nets, atrous convolution, and fully connected crfs.  IEEE transactions on pattern analysis and machine intelligence, 40(4):834–848, 2017.
  * [10] Yinpeng Chen, Xiyang Dai, Dongdong Chen, Mengchen Liu, Xiaoyi Dong, Lu Yuan, and Zicheng Liu.  Mobile-former: Bridging mobilenet and transformer.  arXiv preprint arXiv:2108.05895, 2021.
  * [11] Zhiwei Chen, Changan Wang, Yabiao Wang, Guannan Jiang, Yunhang Shen, Ying Tai, Chengjie Wang, Wei Zhang, and Liujuan Cao.  Lctr: On awakening the local continuity of transformer for weakly supervised object localization.  arXiv preprint arXiv:2112.05291, 2021.
  * [12] Jifeng Dai, Kaiming He, and Jian Sun.  Boxsup: Exploiting bounding boxes to supervise convolutional networks for semantic segmentation.  In Proceedings of the IEEE international conference on computer vision, pages 1635–1643, 2015.
  * [13] Zihang Dai, Hanxiao Liu, Quoc Le, and Mingxing Tan.  Coatnet: Marrying convolution and attention for all data sizes.  Advances in Neural Information Processing Systems, 34, 2021.
  * [14] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al.  An image is worth 16x16 words: Transformers for image recognition at scale.  arXiv preprint arXiv:2010.11929, 2020.
  * [15] Mark Everingham, Luc Van Gool, Christopher KI Williams, John Winn, and Andrew Zisserman.  The pascal visual object classes (voc) challenge.  International journal of computer vision, 88(2):303–338, 2010.
  * [16] Junsong Fan, Zhaoxiang Zhang, Chunfeng Song, and Tieniu Tan.  Learning integral objects with intra-class discriminator for weakly-supervised semantic segmentation.  In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 4283–4292, 2020.
  * [17] Junsong Fan, Zhaoxiang Zhang, Tieniu Tan, Chunfeng Song, and Jun Xiao.  Cian: Cross-image affinity net for weakly supervised semantic segmentation.  In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pages 10762–10769, 2020.
  * [18] Wei Gao, Fang Wan, Xingjia Pan, Zhiliang Peng, Qi Tian, Zhenjun Han, Bolei Zhou, and Qixiang Ye.  Ts-cam: Token semantic coupled attention map for weakly supervised object localization.  In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 2886–2895, 2021.
  * [19] Bharath Hariharan, Pablo Arbeláez, Lubomir Bourdev, Subhransu Maji, and Jitendra Malik.  Semantic contours from inverse detectors.  In 2011 international conference on computer vision, pages 991–998. IEEE, 2011.
  * [20] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun.  Deep residual learning for image recognition.  In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 770–778, 2016.
  * [21] Qibin Hou, PengTao Jiang, Yunchao Wei, and Ming-Ming Cheng.  Self-erasing network for integral object attention.  Advances in Neural Information Processing Systems, 31, 2018.
  * [22] Sangheum Hwang and Hyo-Eun Kim.  Self-transfer learning for weakly supervised lesion localization.  In International conference on medical image computing and computer-assisted intervention, pages 239–246. Springer, 2016.
  * [23] Sanghyun Jo and In-Jae Yu.  Puzzle-cam: Improved localization via matching partial and full features.  In 2021 IEEE International Conference on Image Processing (ICIP), pages 639–643. IEEE, 2021.
  * [24] Anna Khoreva, Rodrigo Benenson, Jan Hosang, Matthias Hein, and Bernt Schiele.  Simple does it: Weakly supervised instance and semantic segmentation.  In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 876–885, 2017.
  * [25] Alexander Kolesnikov and Christoph H Lampert.  Seed, expand and constrain: Three principles for weakly-supervised image segmentation.  In European conference on computer vision, pages 695–711. Springer, 2016.
  * [26] Philipp Krähenbühl and Vladlen Koltun.  Efficient inference in fully connected crfs with gaussian edge potentials.  Advances in neural information processing systems, 24, 2011.
  * [27] Jungbeom Lee, Eunji Kim, Sungmin Lee, Jangho Lee, and Sungroh Yoon.  Ficklenet: Weakly and semi-supervised semantic image segmentation using stochastic inference.  In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 5267–5276, 2019.
  * [28] Jungbeom Lee, Eunji Kim, and Sungroh Yoon.  Anti-adversarially manipulated attributions for weakly and semi-supervised semantic segmentation.  In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 4071–4080, 2021.
  * [29] Kunpeng Li, Ziyan Wu, Kuan-Chuan Peng, Jan Ernst, and Yun Fu.  Tell me where to look: Guided attention inference network.  In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 9215–9223, 2018.
  * [30] Di Lin, Jifeng Dai, Jiaya Jia, Kaiming He, and Jian Sun.  Scribblesup: Scribble-supervised convolutional networks for semantic segmentation.  In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 3159–3167, 2016.
  * [31] Jonathan Long, Evan Shelhamer, and Trevor Darrell.  Fully convolutional networks for semantic segmentation.  In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 3431–3440, 2015.
  * [32] Ilya Loshchilov and Frank Hutter.  Decoupled weight decay regularization.  arXiv preprint arXiv:1711.05101, 2017.
  * [33] Zhiliang Peng, Wei Huang, Shanzhi Gu, Lingxi Xie, Yaowei Wang, Jianbin Jiao, and Qixiang Ye.  Conformer: Local features coupling global representations for visual recognition.  In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 367–376, 2021.
  * [34] Olga Russakovsky, Jia Deng, Hao Su, Jonathan Krause, Sanjeev Satheesh, Sean Ma, Zhiheng Huang, Andrej Karpathy, Aditya Khosla, Michael Bernstein, et al.  Imagenet large scale visual recognition challenge.  International journal of computer vision, 115(3):211–252, 2015\.
  * [35] Wataru Shimoda and Keiji Yanai.  Self-supervised difference detection for weakly-supervised semantic segmentation.  In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 5208–5217, 2019.
  * [36] Karen Simonyan and Andrew Zisserman.  Very deep convolutional networks for large-scale image recognition.  arXiv preprint arXiv:1409.1556, 2014.
  * [37] Guolei Sun, Wenguan Wang, Jifeng Dai, and Luc Van Gool.  Mining cross-image semantics for weakly supervised semantic segmentation.  In European conference on computer vision, pages 347–365. Springer, 2020.
  * [38] Hugo Touvron, Matthieu Cord, Matthijs Douze, Francisco Massa, Alexandre Sablayrolles, and Hervé Jégou.  Training data-efficient image transformers & distillation through attention.  In International Conference on Machine Learning, pages 10347–10357. PMLR, 2021.
  * [39] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin.  Attention is all you need.  Advances in neural information processing systems, 30, 2017.
  * [40] Xiaolong Wang, Ross Girshick, Abhinav Gupta, and Kaiming He.  Non-local neural networks.  In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 7794–7803, 2018.
  * [41] Yude Wang, Jie Zhang, Meina Kan, Shiguang Shan, and Xilin Chen.  Self-supervised equivariant attention mechanism for weakly supervised semantic segmentation.  In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 12275–12284, 2020.
  * [42] Yunchao Wei, Jiashi Feng, Xiaodan Liang, Ming-Ming Cheng, Yao Zhao, and Shuicheng Yan.  Object region mining with adversarial erasing: A simple classification to semantic segmentation approach.  In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 1568–1576, 2017.
  * [43] Haiping Wu, Bin Xiao, Noel Codella, Mengchen Liu, Xiyang Dai, Lu Yuan, and Lei Zhang.  Cvt: Introducing convolutions to vision transformers.  In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 22–31, 2021.
  * [44] Tong Wu, Junshi Huang, Guangyu Gao, Xiaoming Wei, Xiaolin Wei, Xuan Luo, and Chi Harold Liu.  Embedded discriminative attention mechanism for weakly supervised semantic segmentation.  In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 16765–16774, 2021.
  * [45] Zifeng Wu, Chunhua Shen, and Anton Van Den Hengel.  Wider or deeper: Revisiting the resnet model for visual recognition.  Pattern Recognition, 90:119–133, 2019.
  * [46] Lian Xu, Wanli Ouyang, Mohammed Bennamoun, Farid Boussaid, Ferdous Sohel, and Dan Xu.  Leveraging auxiliary tasks with affinity learning for weakly supervised semantic segmentation.  In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 6984–6993, 2021.
  * [47] Yufei Xu, Qiming Zhang, Jing Zhang, and Dacheng Tao.  Vitae: Vision transformer advanced by exploring intrinsic inductive bias.  Advances in Neural Information Processing Systems, 34, 2021.
  * [48] Yazhou Yao, Tao Chen, Guo-Sen Xie, Chuanyi Zhang, Fumin Shen, Qi Wu, Zhenmin Tang, and Jian Zhang.  Non-salient region object mining for weakly supervised semantic segmentation.  In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 2623–2632, 2021.
  * [49] Dong Zhang, Hanwang Zhang, Jinhui Tang, Xian-Sheng Hua, and Qianru Sun.  Causal intervention for weakly-supervised semantic segmentation.  Advances in Neural Information Processing Systems, 33:655–666, 2020\.
  * [50] Fei Zhang, Chaochen Gu, Chenyue Zhang, and Yuchao Dai.  Complementary patch for weakly supervised semantic segmentation.  In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 7242–7251, 2021.
  * [51] Bolei Zhou, Aditya Khosla, Agata Lapedriza, Aude Oliva, and Antonio Torralba.  Learning deep features for discriminative localization.  In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 2921–2929, 2016.

##  A Attention weights coupling approaches

This section provides additional discussion and compares TransCAM with two
approaches to explicitly couple CAM with attention weights as mentioned in
Section 4.3: ClsAttn and AttnAgg. ClsAttn employs the attention weights for
the class token while AttnAgg aggregates the attention weights based on the
activation scores from CAM. Figure 6 illustrates these two attention weight
coupling approaches with the detailed calculation provided below:

###  A.1 ClsAttn

We employ the attention weights $A^{cls}$ that attribute to the class token:

$A^{cls}=(\bar{A}_{i,j})_{i=1,2\leq j\leq N+1}$ (9)

Recall that $\bar{A}$ represents the average of the self-attention weights
across all blocks and all heads, and $\bar{A}_{i,j}$ denotes on average how
much the $j$-th input token embedding contributes to the $i$-th output token
embedding in all layers. $A^{cls}\in\mathbb{R}^{1\times N}$ highlights the
crucial pixels for image classification (mainly highlights foreground
objects), however, it is class-agnostic (indistinguishable for different
target classes). We fuse it with the CAM $M_{c}$ via Hadamard product to make
it aware of object categories:

$M_{c}^{ClsAttn}=\mathrm{\Gamma}^{\sqrt{N}\times\sqrt{N}}(A_{cls})\odot M_{c}$
(10)

where $M_{c}^{ClsAttn}$ is the CAM coupled with attention weights by
$ClsAttn$.

###  A.2 AttnAgg

We assume that $(A^{*})^{\intercal}=[A^{*}_{1};A^{*}_{2};...;A^{*}_{N}]$,
where $A^{*}_{i}\in\mathbb{R}^{N\times 1}$ denotes the attention weights
(excluding class token weights) that attribute to the $i$-th token,
highlighting the pixels correlated to the $i$-th patch. We aggregate
$A^{*}_{i}$ based on the activation score of the $i$-th patch, which is
determined by the value at the $i$-th location of the CAM $M_{c}$:

$M_{c}^{AttnAgg}=\mathrm{\Gamma}^{\sqrt{N}\times\sqrt{N}}(\sum_{i}(\mathrm{\Gamma}^{N}M_{c})_{i}A^{*}_{i})$
(11)

Compared with the class-agnostic attention weights $A^{*}$, $M_{c}^{AttnAgg}$
is aware of object categories and facilities better object localization
ability.

Figure 7 shows the qualitative comparison of the activation maps generated by
ClsAttn, AttnAgg, and TransCAM. ClsAttn usually leads to under-activated CAMs
due to possible extreme values at local areas. AttnAgg leads to more extensive
object coverage but at the risk of highlighting irrelevant objects since it
relies on the class-agnostic attention weights for localization to a large
extent. The result verifies TransCAM to be the most proper attention weights
coupling approach for the WSSS task.

##  B Performance with Different Conformer Architectures

In this section, we evaluate the initial pseudo label performance generated by
TransCAM with different ImageNet[34] pre-trained Conformer architectures:
Conformer-Ti, Conformer-S, and Conformer-B. These architectures mainly differ
in terms of CNN and transformer embedding dimensions, and the number of heads
for the multi-head self-attention modules. Table 7 shows these architectures,
the number of parameters, the ImageNet top-1 validation accuracy, and their
performance on PASCAL VOC train set. Conformer-S outperforms the smaller size
Conformer-Ti by 6.01% mIoU. However, Conformer-B leads to a slight drop in
mIoU (0.47%), although it has more parameters and higher pretraining accuracy.
Our result shows that Conformer-S is the best architecture for TransCAM,
considering the model size and mIoU performance.

architecture |  params (M) |  acc. (%) | mIoU (%)
---|---|---|---
Conformer-Ti |  23.5 |  81.3 | 58.84
Conformer-S |  37.7 |  83.4 | 64.85
Conformer-B |  83.3 |  84.1 | 64.38
Table 7: Comparison of different ImageNet-pre-trained Conformer architectures
along with their number of parameters and pretraining accuracy.

##  C Additional Semantic Segmentation Results

This section includes additional semantic segmentation results that we did not
have space to include in the main paper. Table 8 shows the categorical
semantic segmentation performance on PASCAL VOC 2012 test set. In 13 out of 21
classes, TransCAM outperforms other compared methods.

ClsAttn |
---|---
AttnAgg |
Figure 6: ClsAttn couples CAM with attention weights that corresponds to the
class token via Hadamard product; AttnAgg aggregates the patch attention
weights based on the corresponding activation score from CAM.

method | bkg | aero | bike | bird | boat | bottle | bus | car | cat | chair | cow | table | dog | horse | mbk | person | plant | sheep | sofa | train | tv | mIoU
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---
SEC [25] | 83.5 | 56.4 | 28.5 | 64.1 | 23.6 | 46.5 | 70.6 | 58.5 | 71.3 | 23.2 | 54.0 | 28.0 | 68.1 | 62.1 | 70.0 | 55.0 | 38.4 | 58.0 | 39.9 | 38.4 | 48.3 | 51.7
PSA [2] | 89.1 | 70.6 | 31.6 | 77.2 | 42.2 | 68.9 | 79.1 | 66.5 | 74.9 | 29.6 | 68.7 | 56.1 | 82.1 | 64.8 | 78.6 | 73.5 | 50.8 | 70.7 | 47.7 | 63.9 | 51.1 | 63.7
SSDD [35] | 89.5 | 71.8 | 31.4 | 79.3 | 47.3 | 64.2 | 79.9 | 74.6 | 84.9 | 30.8 | 73.5 | 58.2 | 82.7 | 73.4 | 76.4 | 69.9 | 37.4 | 80.5 | 54.5 | 65.7 | 50.3 | 65.5
BES[7] | 89.0 | 72.7 | 30.4 | 84.6 | 47.5 | 63.0 | 86.8 | 80.7 | 85.2 | 30.1 | 76.5 | 56.4 | 81.8 | 79.9 | 77.0 | 67.8 | 48.6 | 82.3 | 57.2 | 54.0 | 46.7 | 66.6
Ours | 91.2 | 82.2 | 36.2 | 89.8 | 57.8 | 65.1 | 85.7 | 81.5 | 84.2 | 28.3 | 77.4 | 55.9 | 82.1 | 80.0 | 78.9 | 76.5 | 48.0 | 84.7 | 57.2 | 72.7 | 45.8 | 69.6

Table 8: Categorical semantic segmentation performance on PASCAL VOC 2012 test
set.

---
(a) image |  (b) label |  (c) baseline |  (d) ClsAttn |  (e) AttnAgg |  (f) TransCAM

Figure 7: Qualitative comparison of different attention coupling methods. (a)
input image; (b) the target class label; (c) Conformer-S-CAM (baseline); (d)
ClsAttn; (e) AttnAgg; (f) TransCAM (ours)


11institutetext: Darmstadt University of Technology, Karolinenpl. 5, 64289
Darmstadt, Germany 22institutetext: University Hospital Frankfurt, Theodor-
Stern-Kai 7, 60590 Frankfurt am Main, Germany

# Detecting when pre-trained nnU-Net models fail silently for Covid-19 lung
lesion segmentation††thanks: Supported by the Bundesministerium für Gesundheit
(BMG) with grant [ZMVI1-2520DAT03A]. The final authenticated version of this
manuscript will be published in Lecture Notes in Computer Science, Medical
Image Computing and Computer Assisted Intervention - MICCAI 2021 (doi will
follow).

Camila Gonzalez(✉) 11 0000-0002-4510-7309 Karol Gotkowski 11 Andreas Bucher 22
Ricarda Fischbach 22 Isabel Kaltenborn 22 Anirban Mukhopadhyay 11

###### Abstract

Automatic segmentation of lung lesions in computer tomography has the
potential to ease the burden of clinicians during the Covid-19 pandemic. Yet
predictive deep learning models are not trusted in the clinical routine due to
_failing silently_ in out-of-distribution (OOD) data. We propose a lightweight
OOD detection method that exploits the Mahalanobis distance in the feature
space. The proposed approach can be seamlessly integrated into state-of-the-
art segmentation pipelines without requiring changes in model architecture or
training procedure, and can therefore be used to assess the suitability of
pre-trained models to new data. We validate our method with a patch-based nnU-
Net architecture trained with a multi-institutional dataset and find that it
effectively detects samples that the model segments incorrectly.

###### Keywords:

out-of-distribution detection uncertainty estimation distribution shift.

##  1 Introduction

Automatic lung lesion segmentation in the clinical routine would significantly
lessen the burden of radiologists, standardise quantification and staging of
Covid-19 as well as open the way for a more effective utilisation of hospital
resources. With this hope, several initiatives have gathered Computed Axial
Tomography (CAT) scans and ground-truth annotations from expert thorax
radiologists and released them to the public [6, 20, 23]. Experts have
identified ground glass opacities (GGOs) and consolidations as characteristic
of a pulmonary infection onset by the SARS-CoV-2 virus [24]. Deep learning
models have shown good performance in segmenting these lesions. Particularly
the fully-automatic nnU-Net framework [11] secured top spots (9 out of 10,
including the first) in the leaderboard for the Covid-19 Lung CT Lesion
Segmentation Challenge [7].

Such frameworks would ideally be utilised in the clinical practice. However,
deep learning models are known to fail for data that considerably diverges
from the training distribution. CAT scans are particularly prone to this
domain shift problem [4]. The data showcased in the challenge is multi-centre
and diverse in terms of patient group and acquisition protocol. A model
trained with it would be presumed to produce good predictions for a wide
spectrum of institutions. Yet when we evaluate a nnU-Net model on three other
datasets, we notice a considerable drop in segmentation quality (see Fig. 1
(a)). Lung lesions do not manifest in large connected components (see Fig 4),
so it is not trivial for a novice radiologist to identify an incorrect
segmentation.

Clinicians can still leverage models trained with large amounts of
heterogeneous data, but only alongside a process that identifies when the
model is unsuitable for a new data sample. Widely-used segmentation frameworks
_are not designed with OOD detection in mind_ , and so a method is needed that
reliably identifies OOD samples post-training while requiring minimal
intervention.

Several strategies have shown good OOD detection performance in classification
models. Hendrycks and Gimpel [8] propose using the maximum softmax output as
an OOD detection baseline. Guo et al. [5] find that replacing the regular
softmax function with a temperature-scaled variant produces truer estimates.
This can be complemented by adding perturbations to the network inputs [19].
Other methods [10, 17] instead look at the KL divergence of softmaxed outputs
from the uniform distribution. Some approaches use OOD data during training to
explicitly train an outlier detector [1, 9, 17]. Bayesian-inspired techniques
can also be used for outlier detection. Commonly-used are Monte Carlo Dropout
[3] and Deep Ensembles [16]. These have shown promising results in the field
of medical image segmentation [12, 13, 21]. Approaches that modify the
architecture or training procedure have shown better performance in some
cases, but their applicability to widely-used segmentation frameworks is
limited [2, 15, 22].

We propose a method for OOD detection that is lightweight and seamlessly
integrates into complex segmentation frameworks. Inspired by the work of Lee
et al. [18], our approach estimates a multivariate Gaussian distribution from
in-distribution (ID) training samples and utilises the Mahalanobis distance as
a measure of uncertainty during inference. We compute the distance in a low-
dimensional feature space, and down-sample it further to ensure a
computationally inexpensive calculation. We validate our method on a patch-
based 3D nnU-Net trained with multi-centre data from the Covid-19 Lung CT
Lesion Segmentation Challenge. Our evaluation shows that the proposed method
can effectively identify OOD samples for which the model produces faulty
segmentations, and provides good model calibration estimates. Our
contributions are:

  * •

The introduction of a lightweight, flexible method for OOD detection that can
be integrated into any segmentation framework.

  * •

An extension of the nnU-Net framework to provide clinically-relevant
uncertainty estimates.

##  2 Materials and Methods

We start by summarising the particularities of the nnU-Net framework in Sec.
2.1. In Sec. 2.2, we outline our proposed method for OOD detection, which
follows a _three-step process_ : (1) estimation of a Gaussian distribution
from training features (2) extraction of uncertainty masks for test images and
(3) calculation of subject-level uncertainty scores.

###  2.1 Patch-based nnU-Net

The nnU-Net framework is a standardised baseline for medical image
segmentation [11]. Without deviating from traditional U-Net architectures
[26], it has won several grand challenges by automatically customising the
architecture and training configuration to the data at hand [7]. The framework
also performs pre- and post-processing steps, such as adapting voxel spacing
and contrast normalisation, during both training and inference. In this work
we utilise the patch-based full-resolution variant, which is recommended for
most applications [11], but our method can be integrated into any other
architecture. For the patch-based architecture, training images are first
divided into overlapping patches with a sliding window approach, resulting in
$N$ patches $\left\\{x_{i}\right\\}^{N}_{i=1}$. Predictions for each patch are
multiplied by a filtering operation that weights centre-voxels more heavily,
and then aggregated into an output mask with the dimensions of the original
image.

Figure 1: (a) Dice coefficient of a model trained with Challenge data,
evaluated with ID (Challenge) test data as well as on three other datasets.
(b) The euclidean distance $D_{\mathcal{E}}$ does not recognize that
$\hat{z_{1}}$ (purple marker) is closer than $\hat{z_{2}}$ (blue marker) to
the distribution of training samples (gray markers), with mean $\mu$ (green
marker) and covariance $\Sigma$. This difference intensifies in high-
dimensional spaces, where it is common for regions close to the mean to be
underrepresented.

###  2.2 Estimation of a subject-level uncertainty score

We are interested in capturing epistemic uncertainty, which arises from a lack
of knowledge about the data-generating process. Quantifying it for image
regions instead of region boundaries is challenging, particularly for OOD data
[14]. One computationally inexpensive way to assess epistemic uncertainty is
to calculate the distance between training and testing activations in a low-
dimensional feature space. As a model is unlikely to produce reasonable
outputs for features far from any seen during training, this is a reliable
signal for bad model performance [18]. Model activations have covariance and
the activations of typical input images do not necessarily resemble the mean
[27], so the euclidean distance is not appropriate to identify unusual
activation patterns; a problem that exacerbates in high-dimensional spaces.
The Mahalanobis distance $D_{\mathcal{M}}$ rescales samples into a space
without covariance, supplying a more effective way to identify typical
patterns in deep model features. Fig. 1 (b) illustrates a situation where the
euclidean distance assumes that $\hat{z_{2}}$ is closer to the training
distribution than $\hat{z_{1}}$, when $\hat{z_{2}}$ is highly unusual and
$\hat{z_{1}}$ is a probable sample.

In the following we describe the steps we perform to extract a subject-level
uncertainty value. Note that only one forward pass is necessary for each
image, keeping the computational overhead to a minimum.

####  2.2.1 Estimation of the training distribution:

We start by estimating a multivariate Gaussian $\mathcal{N}(\mu,\Sigma)$ over
model features. For all training inputs $\left\\{x_{i}\right\\}^{N}_{i=1}$,
features $\mathcal{F}(x_{i})=z_{i}$ are extracted from the encoder
$\mathcal{F}$ of the pre-trained model. For modern segmentation networks, the
dimensionality of the extracted features $z_{i}$ is too large to calculate the
covariance $\Sigma$ in an acceptable time frame. We thus project the latent
space into a lower subspace by average pooling. Finally, we flatten this
subspace and estimate the empirical mean $\mu$ and covariance $\Sigma$.

$\mu=\frac{1}{N}\sum_{i=1}^{N}\hat{z_{i}},\quad\Sigma=\frac{1}{N}\sum_{i=1}^{N}(\hat{z_{i}}-\mu)(\hat{z_{i}}-\mu)^{T}$
(1)

####  2.2.2 Extraction of uncertainty masks:

During inference, we estimate an uncertainty mask for a subject following the
process outlined in Fig. 2. For each patch $x_{i}$, features are extracted and
projected into $\hat{z_{i}}$. Next, the Mahalanobis distance (Eq. 2) to the
Gaussian distribution estimated in the previous step is calculated.

$D_{\mathcal{M}}(\hat{z_{i}};\mu,\Sigma)=(\hat{z_{i}}-\mu)^{T}\Sigma^{-1}(\hat{z_{i}}-\mu)$
(2)

Each distance is a point estimate for the corresponding model input. These are
aggregated in a similar fashion to how network outputs are combined to form a
prediction mask. Following the example of the patch-based nnU-Net, a zero-
filled tensor is initialised with the dimensionality of the original image.
After assessing the distance for a patch, the value is replicated to the
specified patch size and a filtering operation is applied to weight centre
voxels more heavily. Finally, patch-level uncertainties are aggregated to an
image-level mask.

Figure 2: Extracting an uncertainty mask based on the Mahalanobis distance
$D_{\mathcal{M}}$ for an image during inference, in combination with a patch-
based nnU-Net architecture.

####  2.2.3 Subject-level uncertainty:

The process described above produces an uncertainty mask with the
dimensionality of the CAT scan. In order to effectively identify highly
uncertain samples, we aggregate these into a subject-level uncertainty
$\mathcal{U}$ by averaging over all voxels. We then normalise uncertainties
between the minimum and doubled maximum values represented in an ID validation
set – which we assume to be available during training – to ensure
$\mathcal{U}\in\left[0,1\right]$.

##  3 Experimental Setup

We work with a total of four datasets for segmentation of Covid-19-related
findings. The Challenge dataset [6] contains chest CAT scans for patients with
a confirmed SARS-CoV-2 infection from an array of institutions. The data is
heterogeneous in terms of age, gender and disease severity. We use the 199
cases made available under the Covid Segmentation Grand Challenge, which we
randomly divide into 160 cases to train the model, 4 validation and 35 test
cases.

We evaluate our method with two publicly available datasets and an in-house
one. The public datasets encompass cases for patients with and without
confirmed infections. Mosmed [23] contains fifty cases and the Radiopedia
dataset [20], a further twenty. Finally, we utilise an in-house dataset
consisting of fifty patients who were tested positive for SARS-CoV-2 with an
RT PCR test. All fifty scans were reviewed for diagnostic image quality. The
annotations for the in-house data were performed slice-by-slice by two
independent readers trained in the delineation of GGOs and pulmonary
consolidations. Central vascular structures and central bronchial structures
were excluded from all segmentations. All delineations were reviewed by an
expert radiologist reader. For the public datasets, the segmentation process
is outlined in the corresponding publications.

With the Challenge data, we train a patch-based nnU-Net [11] on a Tesla T4
GPU. Our configuration has a patch size of $\left[28,256,256\right]$, and
adjacent patches overlap by half that size. To reduce the dimensionality of
the feature space, we apply average pooling with a kernel size of
$\left(2,2,2\right)$ and stride $\left(2,2,2\right)$ until the dimensionality
falls below $1e4$ elements. With the Scikit Learn library (version 0.24) [25],
calculating $\Sigma$ requires 85 seconds for $1e5$ samples. Our code is
available under github.com/MECLabTUDA/Lifelong-nnUNet (branch ood_detection).

We compare our approach to state-of-the-art techniques to assess uncertainty
information by performing inference on a trained model. _Max. Softmax_
consists of taking the maximum softmax output [8]. _Temp. Scaling_ performs
temperature scaling on the outputs before applying the softmax operation [5],
for which we test three different temperatures
$T=\left\\{10,100,1000\right\\}$. _KL from Uniform_ computes the KL divergence
from an uniform distribution [10]. Note that all three methods output a
confidence score (higher is more certain), which we invert to obtain an
uncertainty estimate (lower is more certain). Finally, _MC Dropout_ consists
of doing several forward passes whilst activating the Dropout layers that
would usually be dormant during inference. We perform $10$ forward passes and
report the standard deviation between outputs as an uncertainty score. For all
methods, we calculate a subject-level metric by averaging uncertainty masks,
and normalise the uncertainty range between the minimum and doubled maximum
uncertainty represented in ID validation data.

##  4 Results

We start this section by analysing the performance of the proposed method in
detecting samples that vary significantly from the training distribution. We
then examine how well the model estimates segmentation performance. Lastly, we
qualitatively evaluate our method for ID and OOD examples.

####  4.0.1 OOD detection:

We first assess how effective our method is at identifying samples that are
not ID (Challenge data). Due to the heterogeneity of the Challenge dataset, in
practice data from an array of institutions would be considered ID. However,
for our evaluation datasets there is a drop in performance which should
manifest in higher uncertainty estimates. As is common practice in OOD
detection [19], we find the uncertainty boundary that achieves a $95\%$ true
positive rate (TPR) on the ID validation set, where a true positive is a
sample correctly identified as ID. We report for the ID test data and all OOD
data the false positive rate (FPR) and Detection Error $\ =0.5\ (1-TPR)+0.5\
FPR$ at $95\%$ TPR. Tab. 1 summarizes our findings. All methods that utilise
the network outputs after one forward pass have a high detection error and
FPR, while the MC Dropout approach manages to identify more OOD samples. Our
proposed method displays the lowest FPR and detection error.

Table 1: Detection Error (lower is better) and FPR (lower is better) for the boundary of 95% TPR, ESCE (lower is better) and (mean±sd) Dice (higher is better) for subjects with an uncertainty below the 95% TPR boundary. The results are reported for ID test data and all OOD samples. Method |  Det. Error |  FPR |  ESCE |  Dice
---|---|---|---|---
Max. Softmax [8] |  0.334 |  0.583 |  0.319 |  0.582 ±0.223
Temp. Scaling $T=10$ [5] |  0.508 |  0.758 |  0.407 |  0.601 ±0.233
Temp. Scaling $T=100$ [5] |  0.361 |  0.550 |  0.408 |  0.589 ±0.233
Temp. Scaling $T=1000$ [5] |  0.500 |  1.000 |  0.408 |  0.592 ±0.233
KL from Uniform [10] |  0.415 |  0.717 |  0.288 |  0.600 ±0.215
MC Dropout [3] |  0.177 |  0.183 |  0.215 |  0.614 ±0.234
Ours |  0.082 |  0.050 |  0.125 |  0.744 ±0.143

Segmentation performance: While the detection of OOD samples is a first step
in assessing the suitability of a model, an ideal uncertainty metric would
inversely correlate with model performance, informing the user of the likely
quality of a prediction without requiring manual annotations. For this we
calculate the Expected Segmentation Calibration Error (ESCE). Inspired by Guo
et al. [5], we divide the $N$ test scans into $M=10$ interval bins $B_{m}$
according to their normalised uncertainty. Over all bins, the absolute
difference is added between average Dice $(Dice(B_{m}))$ and inverse average
uncertainty $(1-\mathcal{U}(B_{m}))$ for samples in the bin, weighted by the
number of samples.

$ESCE=\sum^{M}_{m=1}\frac{\left|B_{m}\right|}{N}\left|Dice(B_{m})-(1-\mathcal{U}(B_{m}))\right|$
(3)

The results are reported in Tab. 1 (forth column). Our proposed approach shows
the lowest $ESCE$ at 0.125. The average Dice of admitted samples (fifth
column) lies at 0.744, which is consistent with the ID expected performance of
the model (see Fig. 1 (a)).

Figure 3: Dice coefficient against normalised uncertainty for OOD (gray
triangles) and test ID (black circles) samples. The vertical gray line marks
the boundary of 95% TPR for ID validation data. To the right of this line,
samples are classified as OOD. The lower left (red) quadrant is clinically
most relevant. Unlike MC Dropout, our method does not fail silently by
assigning low uncertainties to low-Dice samples.

Fig. 3 depicts the Dice coefficient plotted against the uncertainty for our
proposed approach and MC Dropout, which has the second lowest calibration
error. Relevant for a safe use of the model in clinical practice is the lower
left (red) quadrant, where _silent failures_ are located. Whereas MC Dropout
fails to identify OOD samples with faulty predicted segmentations, our
proposed method assigns these cases high uncertainty estimates. The only OOD
samples that fall below the 95% TPR uncertainty boundary for our method have
Dice scores over 0.6 (upper left quadrant with green background). However, our
method shows room for improvement in the upper right (yellow) quadrant. Here,
OOD samples for which the model produces good predictions are estimated to
have a high uncertainty. An ideal calibration would place all samples in the
upper left (green) and lower right (blue) quadrants.

Qualitative evaluation: Fig. 4 depicts two example images alongside
corresponding ground truths and predictions. The top row shows a example from
the Challenge dataset for which the model produces an adequate segmentation.
The bottom contains a scan from the Mosmed dataset. The model oversegments the
lesion at the middle left lobe and incorrectly marks two additional regions at
the left and right superior lobes. Only our proposed method signals a possible
error in the lower row with a high uncertainty, while producing a low
uncertainty estimate for the upper row.

Figure 4: Upper row: a good prediction. Lower row: a prediction for an OOD
sample where two lesions are erroneously segmented in the superior lung lobes.
Despite the considerable differences to the ground truth, these errors are not
directly noticeable for the inexpert observer, as GGOs can manifest in
superior lobes [24].

##  5 Conclusion

Increasingly, institutions are taking part in initiatives to gather large
amounts of annotated, heterogeneous data and release it to the public. This
could potentially alleviate the work burden of medical practitioners by
allowing the training of robust segmentation models. Open-source end-to-end
frameworks contribute to this process. But regardless of the variety of the
training data, it is necessary to assess whether a model is well-suited to new
samples. This is particularly true when it is not trivial to identify a faulty
output, such as for the segmentation of SARS-CoV-2 lung lesions. There is
currently a disconnect between methods for OOD detection, which often require
special training or architectural considerations, and widely-used segmentation
frameworks. We find that calculating the Mahalanobis distance to features in a
low-dimensional subspace is a lightweight and flexible way to signal when a
model prediction should not be trusted. Future work should explore how to
better identify high-quality predictions. For now, our work increases
clinicians’ trust while translating trained neural networks from challenge
participation to real clinics.

## References

  * [1] Bevandić, P., Krešo, I., Oršić, M., Šegvić, S.: Simultaneous semantic segmentation and outlier detection in presence of domain shift. In: German Conference on Pattern Recognition. pp. 33–47. Springer (2019)
  * [2] Blundell, C., Cornebise, J., Kavukcuoglu, K., Wierstra, D.: Weight uncertainty in neural network. In: International Conference on Machine Learning. pp. 1613–1622. PMLR (2015)
  * [3] Gal, Y., Ghahramani, Z.: Dropout as a bayesian approximation: Representing model uncertainty in deep learning. In: International Conference on Machine Learning. pp. 1050–1059. PMLR (2016)
  * [4] 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)
  * [5] Guo, C., Pleiss, G., Sun, Y., Weinberger, K.Q.: On calibration of modern neural networks. In: International Conference on Machine Learning. pp. 1321–1330. PMLR (2017)
  * [6] Harmon, S.A., Sanford, T.H., Xu, S., Turkbey, E.B., Roth, H., Xu, Z., Yang, D., Myronenko, A., Anderson, V., Amalou, A., et al.: Artificial intelligence for the detection of covid-19 pneumonia on chest ct using multinational datasets. Nature communications 11(1), 1–7 (2020). https://doi.org/https://doi.org/10.1038/s41467-020-17971-2
  * [7] Henderson, E.: Leading pediatric hospital reveals top ai models in covid-19 grand challenge. https://www.news-medical.net/news/20210112/Leading-pediatric-hospital-reveals-top-AI-models-in-COVID-19-Grand-Challenge.aspx, accessed: 2021-02-28
  * [8] Hendrycks, D., Gimpel, K.: A baseline for detecting misclassified and out-of-distribution examples in neural networks. In: International Conference on Learning Representations (2017)
  * [9] Hendrycks, D., Mazeika, M., Dietterich, T.: Deep anomaly detection with outlier exposure. In: International Conference on Learning Representations (2018)
  * [10] Hendrycks, D., Mazeika, M., Kadavath, S., Song, D.: Using self-supervised learning can improve model robustness and uncertainty. Advances in Neural Information Processing Systems 32, 15663–15674 (2019)
  * [11] Isensee, F., Jaeger, P.F., Kohl, S.A., Petersen, J., Maier-Hein, K.H.: nnu-net: a self-configuring method for deep learning-based biomedical image segmentation. Nature Methods 18(2), 203–211 (2021)
  * [12] Jungo, A., Balsiger, F., Reyes, M.: Analyzing the quality and challenges of uncertainty estimations for brain tumor segmentation. Frontiers in Neuroscience 14, 282 (2020)
  * [13] Jungo, A., Reyes, M.: Assessing reliability and challenges of uncertainty estimations for medical image segmentation. In: International Conference on Medical Image Computing and Computer-Assisted Intervention. pp. 48–56. Springer (2019)
  * [14] Kendall, A., Gal, Y.: What uncertainties do we need in bayesian deep learning for computer vision? Advances in Neural Information Processing Systems 30, 5574–5584 (2017)
  * [15] Kohl, S.A., Romera-Paredes, B., Meyer, C., Fauw, J.D., Ledsam, J.R., Maier-Hein, K.H., Eslami, S.A., Rezende, D.J., Ronneberger, O.: A probabilistic u-net for segmentation of ambiguous images. In: Proceedings of the 32nd International Conference on Neural Information Processing Systems. pp. 6965–6975 (2018)
  * [16] Lakshminarayanan, B., Pritzel, A., Blundell, C.: Simple and scalable predictive uncertainty estimation using deep ensembles. Advances in Neural Information Processing Systems 30, 6402–6413 (2017)
  * [17] Lee, K., Lee, H., Lee, K., Shin, J.: Training confidence-calibrated classifiers for detecting out-of-distribution samples. In: International Conference on Learning Representations (2018)
  * [18] Lee, K., Lee, K., Lee, H., Shin, J.: A simple unified framework for detecting out-of-distribution samples and adversarial attacks. In: Advances in Neural Information Processing Systems. pp. 7167–7177 (2018)
  * [19] Liang, S., Li, Y., Srikant, R.: Enhancing the reliability of out-of-distribution image detection in neural networks. In: International Conference on Learning Representations (2018)
  * [20] Ma, J., Ge, C., Wang, Y., An, X., Gao, J., Yu, Z., Zhang, M., Liu, X., Deng, X., Cao, S., Wei, H., Mei, S., Yang, X., Nie, Z., Li, C., Tian, L., Zhu, Y., Zhu, Q., Dong, G., He, J.: Covid-19 ct lung and infection segmentation dataset (2020). https://doi.org/10.5281/zenodo.3757476, https://doi.org/10.5281/zenodo.3757476
  * [21] Mehrtash, A., Wells, W.M., Tempany, C.M., Abolmaesumi, P., Kapur, T.: Confidence calibration and predictive uncertainty estimation for deep medical image segmentation. IEEE transactions on medical imaging 39(12), 3868–3878 (2020)
  * [22] Monteiro, M., Le Folgoc, L., Coelho de Castro, D., Pawlowski, N., Marques, B., Kamnitsas, K., van der Wilk, M., Glocker, B.: Stochastic segmentation networks: Modelling spatially correlated aleatoric uncertainty. In: Larochelle, H., Ranzato, M., Hadsell, R., Balcan, M.F., Lin, H. (eds.) Advances in Neural Information Processing Systems. vol. 33, pp. 12756–12767. Curran Associates, Inc. (2020)
  * [23] Morozov, S., Andreychenko, A., Pavlov, N., Vladzymyrskyy, A., Ledikhova, N., Gombolevskiy, V., Blokhin, I.A., Gelezhe, P., Gonchar, A., Chernina, V.Y.: Mosmeddata: Chest ct scans with covid-19 related findings dataset. arXiv preprint arXiv:2005.06465 (2020)
  * [24] Parekh, M., Donuru, A., Balasubramanya, R., Kapur, S.: Review of the chest ct differential diagnosis of ground-glass opacities in the covid era. Radiology 297(3), E289–E302 (2020)
  * [25] Pedregosa, F., Varoquaux, G., Gramfort, A., Michel, V., Thirion, B., Grisel, O., Blondel, M., Prettenhofer, P., Weiss, R., Dubourg, V., Vanderplas, J., Passos, A., Cournapeau, D., Brucher, M., Perrot, M., Duchesnay, E., Louppe, G.: Scikit-learn: Machine learning in python. Journal of Machine Learning Research 12 (01 2012)
  * [26] Ronneberger, O., Fischer, P., Brox, T.: U-net: Convolutional networks for biomedical image segmentation. In: International Conference on Medical Image Computing and Computer-Assisted Intervention. pp. 234–241. Springer (2015)
  * [27] Wei, D., Zhou, B., Torrabla, A., Freeman, W.: Understanding intra-class knowledge inside cnn. arXiv preprint arXiv:1507.02379 (2015)