D ENSE G AUSSIAN P ROCESSES FOR F EW -S HOT S EGMENTATION
Anonymous authors
Paper under double-blind review
A BSTRACT
Few-shot segmentation is a challenging dense prediction task, which entails segmenting a novel query image given only a small annotated support set.
The key problem is thus to design a method that aggregates detailed information from the support set, while being robust to large variations in appearance and context.
To this end, we propose a few-shot segmentation method based on dense Gaussian process (GP) regression.
Given the support set, our dense GP learns the mapping from local deep image features to mask values, capable of capturing complex appearance distributions.
Furthermore, it provides a principled means of capturing uncertainty, which serves as another powerful cue for the ﬁnal segmentation, obtained by a CNN decoder.
Instead of a one-dimensional mask output, we further exploit the end-to-end learning capabilities of our approach to learn a high-dimensional output space for the GP.
Our approach sets a new state-of-the-art for both 1-shot and 5-shot FSS on the PASCAL-5 i and COCO-20 i benchmarks, achieving an absolute gain of +14 . 9 mIoU in the COCO-20 i 5-shot setting.
Furthermore, the segmentation quality of our approach scales gracefully when increasing the support set size, while achieving robust cross-dataset transfer.
I NTRODUCTION
Image few-shot segmentation (FSS) of semantic classes (Shaban et al., 2017) has received increased attention in recent years.
The aim is to segment novel query images based on only a handful annotated training samples, usually referred to as the support set .
The FSS method thus needs to extract information from the support set in order to accurately segment a given query image.
The problem is highly challenging, since the query image may present radically different views, contexts, scenes, and objects than what is represented in the support set.
The core component in any FSS framework is the mechanism that extracts information from the support set to guide the segmentation of the query image.
However, the design of this module presents several challenges.
First, it needs to aggregate detailed yet generalizable information from the support set, which requires a ﬂexible representation.
Second, the FSS method should effectively leverage larger support sets, achieving scalable segmentation performance when increasing its size.
While perhaps trivial at ﬁrst glance, this has proved to be a major obstacle for many state-of-the-art methods, as visualized in Fig.
Third, the method is bound to be queried with appearances not included in the support set.
To achieve robust predictions even in such common cases, the method needs to assess the relevance of the information in the support images in order to gracefully revert to e.g. learned segmentation priors when necessary.
We address the aforementioned challenges by densely aggregating information in the support set using Gaussian Processes (GPs).
Speciﬁcally, we use a GP to learn a mapping between dense local deep feature vectors and their corresponding mask values.
The mask values are assumed to have a jointly Gaussian distribution with covariance based on the similarity between the corresponding feature vectors.
This permits us to extract detailed relations from the support set, with the capability of modeling complex, non-linear mappings.
As a non-parametric model, the GP further effectively beneﬁts from additional support samples, since all given data is retained.
As shown in Fig.
1, the segmentation accuracy of our approach improves consistently with the number of support samples.
Lastly, the predictive covariance from the GP provides a principled measure of the uncertainty based on the similarity with local features in the support set.
PASCAL-5 i
COCO-
i 0 .
[Figure]
[Figure] [Figure]
[Figure] [Figure] [Figure] [Figure]
[Figure]
e g m e n t a t i o n P e r f o r m a n
[Figure]
m I o
U )
[Figure]
Our GP-based method effectively leverages larger support sets, achieving substantial improvements in segmentation accuracy.
Our method also excels in the extreme one-shot case, even outperforming all previously reported results on COCO- 20 i for any support size.
Our FSS approach is learned end-to-end through episodic training, treating the GP as a layer in a neural network.
This further enables us to learn the output space of the GP.
To this end, we encode the given support masks with a neural network in order to achieve a multi-dimensional output representation.
In order to generate the ﬁnal masks, our decoder module employs the predicted mean query encodings, together with the covariance information.
Our decoder is thus capable of reasoning about the uncertainty when fusing the predicted mask encodings with learned segmentation priors.
Lastly, we further improve our FSS method by integrating dense GPs at multiple scales.
We perform comprehensive experiments on two benchmarks: PASCAL- 5 i (Shaban et al., 2017) and
COCO- 20 i (Nguyen & Todorovic, 2019).
Our proposed DGPNet outperforms existing methods for 1-shot and 5-shot by a large margin, setting a new state-of-the-art on both benchmarks.
When using the ResNet101 backbone, our DGPNet achieves an absolute gain of 14 . 9 for 5-shot segmentation on the challenging COCO- 20 i benchmark, compared to the best reported results in the literature.
We further demonstrate the cross-dataset transfer capabilities of our DGPNet approach from COCO- 20 i to PASCAL and perform detailed ablative studies to probe the effectiveness of our contributions.
R ELATED W ORK
Few-Shot Segmentation The earliest work in few-shot segmentation (FSS), by Shaban et al.
(2017), proposed a method for predicting the weights of a linear classiﬁer based on the support set, which was further built upon in later works (Siam et al., 2019; Liu et al., 2020a; Boudiaf et al., 2021).
Instead of learning the classiﬁer directly, Rakelly et al.
(2018) proposed to construct a global conditioning prototype from the support set and concatenate it to the query representation, with several subsequent works (Dong & Xing, 2019;
Zhang et al., 2020; Wang et al., 2019; Nguyen & Todorovic, 2019; Zhang et al., 2019b;
Liu et al., 2020c; Azad et al., 2021;
Liu et al., 2020b; Xie et al., 2021; Wang et al., 2021).
A major limitation of these methods is the unimodality assumption.
To alleviate this problem, Zhang et al.
(2021) construct additional prototypes by a self-guided module, while Yang et al.
(2020a)
; Liu et al.
(2020c)
; Li et al.
(2021) instead cluster multiple prototypes to create a richer representation.
However, clustering introduces extra hyperparameters, such as the number of clusters, as well as optimization difﬁculties.
In contrast, our method is not restricted in any such sense, and only requires us to choose an appropriate kernel.
Some recent works consider pointwise correspondences between the support and query set.
These works have mostly focused on attention or attention-like mechanisms (Zhang et al., 2019a;
Yang et al., 2020b; Hu et al., 2019; Tian
[Figure]
F
F
G
U
G
F
U Mask encoder 𝚲 Image encoder
Decoder
[Figure]
et al., 2020; Wang et al., 2020).
In contrast with these methods, we construct a principled posterior functions, which greatly aids the decoder.
Combining GPs and Neural Networks While early work focused on combining GPs and neural networks in the standard supervised classiﬁcation setting (Salakhutdinov & Hinton, 2009; Wilson et al., 2016; Calandra et al., 2016), there has recently been an increased interest in utilizing Gaussian processes in the context of few-shot classiﬁcation (Patacchiola et al., 2020; Snell & Zemel, 2021).
Previous works employ the GP in the classiﬁcation setting and as the ﬁnal output layer in the network, and optimize proxies of either the predictive or marginal log likelihood directly.
Note that the classiﬁcation likelihood is non-gaussian, and hence computing the exact posterior and marginal likelihoods of the model becomes intractable.
Here, we go beyond this limitation and propose an internal dense GP model of the support features, where the posterior predictive distribution is used as input to a CNN decoder.
Moreover, this allows us to learn the output space of the GP to further increase its expressive power.
To the best of our knowledge, we are the ﬁrst to introduce a dense GP approach for the challenging dense prediction task of few-shot segmentation.
M ETHOD 3. F EW - SHOT S EGMENTATION
Few-shot segmentation is a dense few-shot learning task (Shaban et al., 2017).
The aim is to learn to segment objects from novel classes, given only a small set of annotated images.
A single instance of this problem, referred to as an episode , comprises a small set of annotated samples, called the support set , and a set of samples on which prediction is to be made, the query set .
Formally, we denote the support set as { ( I S k , M S k ) }
Kk =1 , comprising K image-mask pairs I S k 2 R H [-
 ×-]0 ⇥ W 0 ⇥ 3 and
M S k 2 { 0 , 1 } H 0 ⇥ W 0 .
A query image is denoted as I Q 2 R H 0 ⇥ W 0 ⇥ 3 and the aim is to predict its corresponding segmentation mask M Q 2 { 0 , 1 } H 0 ⇥ W 0 .
To develop our approach, we ﬁrst provide a general formulation for addressing the FSS problem, which applies to several recent methods, including prototype-based (Li et al., 2021;
Liu et al., 2020a) and correlation-based (Tian et al., 2020; Wang et al., 2020) ones.
Our formulation proceeds in three steps: feature extraction, few-shot learning, and prediction.
In the ﬁrst step, deep features are extracted from the given images,
[Equation]
These features provide a more disentangled and invariant representation, which greatly aids the problem of learning from a limited number of samples.
The main challenge in FSS, namely how to most effectively leverage the annotated support samples, is encapsulated in the second step.
As a general approach, we consider a learner module ⇤ that employs the support set in order to ﬁnd a function f , which associates each query feature x Q 2 R D with an output y Q 2 R E .
The goal is to achieve an output y Q that is strongly correlated with the ground-truth query mask, allowing it to act as a strong cue in the ﬁnal prediction.
Formally, we express this general formulation as,
[Equation]
The learner ⇤ aggregates information in the support set { x S k , M S k } k in order to predict the function f .
This function is then applied to query features equation 2.
In the ﬁnal step of our formulation, output from the function f on the query set is ﬁnally decoded by a separate network as
[Equation] U ( y Q , x Q ) to predict the segmentation [Equation]
The general formulation in equation 2 encapsulates several recent approaches for few-shot segmentation.
In particular, prototype-based methods, for instance PANet (Wang et al., 2019), are retrieved by letting ⇤ represent a mask-pooling operation.
The function f thus computes the cosine-similarity between the pooled feature vector and the input query features.
In general, the design of the learner ⇤ represents the central problem in few-shot segmentation, since it is the module that extracts information from the support set.
Next, we distinguish three key desirable properties of this module.
3. M OTIVATION
As discussed above, the core component in few-shot segmentation is the few-shot learner ⇤ .
Much research effort has therefore been diverted into its design (Nguyen & Todorovic, 2019;
Liu et al., 2020a; Wang et al., 2020;
Liu et al., 2020c; Yang et al., 2020a; Li et al., 2021).
To motivate our approach, we ﬁrst identify three important properties that the learner should possess.
Flexibility of f
The intent in few-shot segmentation is to be able to segment a wide range of classes, unseen during training.
The image feature distributions of different unseen classes are not necessarily linearly separable (Allen et al., 2019).
Prototypical few-shot learners, which are essentially linear classiﬁers, would fail in such scenarios.
Instead, we need a mechanism that can learn and represent more complex functions f .
Scalability in support set size K An FSS method should be able to effectively leverage additional support samples and therefore achieve substantially better accuracy and robustness for larger support sets.
However, many prior works show little to no beneﬁt in the 5-shot setting compared to 1-shot.
As shown by Li et al.
(2021) and Boudiaf et al.
(2021), it is crucial that new information is effectively incorporated into the model without averaging out useful cues.
Uncertainty Modeling Since only a small number of support samples are available in FSS, the network needs to regularly handle unseen appearances in the query images.
For instance, the query may include novel backgrounds, scenes, and objects.
Since the function f predicted by the learner is not expected to generalize to such unseen scenarios, the network should instead utilize neighboring predictions or learned priors.
However, this can only be achieved if f models and communicates the uncertainty of its prediction to the decoder.
3. D ENSE G AUSSIAN P ROCESS F EW -S HOT L EARNER
In this work, we propose a dense Gaussian Process (GP) learner for few-shot segmentation.
As a few-shot learning component, the GP possesses all three properties identiﬁed in the previous section.
It can represent ﬂexible and highly non-linear functions by selecting an appropriate kernel.
As a nonparametric model, it further effectively beneﬁts from additional support samples since all given data is retained.
The GP explicitly models the uncertainty in the prediction by learning a probabilistic distribution over a space of functions.
Furthermore, both the learning and inference steps of the GP are differentiable functions.
While computational cost is a well-known challenge when deploying
GPs, we demonstrate that even simple strategies can be used to keep the number of training samples at a tractable level for the FSS problem.
Our dense GP learner predicts a distribution of functions f from the input features x to an output y .
Let x S 2 R KHW ⇥
D denote the matrix of all support image features and x Q 2 R HW ⇥ D the matrix retaining the query features.
Let y S and y Q be the corresponding outputs.
The former is obtained from the support masks and the latter is to be predicted with the GP.
The key assumption in the Gaussian process is that the support and query outputs y S , y Q are jointly Gaussian according to,
[Equation]
For simplicity, we set the output prior means, µ S and µ Q , to zero.
The covariance matrix K in equation 3 is deﬁned by the input features at those points and a kernel  : R D ⇥ R D !
R .
In our experiments, we adopt the commonly used squared exponential (SE) kernel
[Equation]
with scale parameter  f and length parameter ` .
The kernel can be viewed as a similarity measure.
If two features are similar, then the corresponding outputs are correlated.
Next, the posterior probability distribution of the query outputs is inferred.
The rules for conditioning in a joint Gaussian gives us (Rasmussen & Williams, 2006)
[Equation]
5) where
[Equation]
The measurements y S are assumed to have been obtained with some additive i.i.d.
Gaussian noise with variance  2 y .
This corresponds to adding a scaled identity matrix  2 y I to the support covariance matrix K SS .
The equations 4-7 thus predict the distribution of the query outputs, represented by the mean value and the covariance.
Note that the asymptotic complexity is O (( KWH ) 3 ) .
We therefore need to work on a sufﬁciently low resolution.
Next, we introduce a way to incorporate more information into the predicted outputs while maintaining a low resolution.
3. L EARNING THE GP O UTPUT S PACE
The decoder strives to transform the query outputs predicted by the few-shot learner into an accurate mask.
This is a challenging task given the low resolution and the desire to generalize to classes unseen during ofﬂine training.
We therefore explore whether additional information can be encoded into the outputs, y Q , in order to guide the decoder.
This information could for instance include the shape of the mask or which of the object’s parts is at a given location.
To this end, we train a mask-encoder to construct the outputs,
[Equation]
Here, G is a neural network with learnable parameters.
The aforementioned formulation allows us to learn the GP output space during the meta-training stage.
To the best of our knowledge, this has not previously been explored in the context of GPs.
There is some reminiscence to the attention mechanism in transformers (Vaswani et al., 2017).
The transformer queries, keys, and values correspond to our query features x Q , support features x S , and support outputs y S .
A difference is that in few-shot segmentation, there is a distinction between the features used for matching and the output - the features stem from the image whereas the output stems from the mask.
As mask encoder G , we employ a lightweight residual convolutional neural network.
The network predicts multi-dimensional outputs for the support masks that are then reshaped into y S
R KHW ⇥ E .
These are fed into equation 6 when the posterior probability distribution of the query outputs is inferred.
The two matrix-vector multiplications are transformed into matrix-matrix multiplications and the result µ Q|S 2 R HW ⇥
E is a matrix containing the multi-dimensional mean.
The covariance in equation 7 is kept unchanged.
This setup corresponds to the assumption that the covariance is isotropic over the output feature channels and that the different output feature channels are independent.
3. F INAL M ASK P REDICTION
Next, we decode the predicted distributions of the query outputs in order to predict the ﬁnal mask.
Since the output of the GP is richer, including uncertainty and covariance information, we ﬁrst need to consider what information to give to the ﬁnal decoder network.
We employ the following output features from the GP.
GP output mean The multi-dimensional mean µ Q|S represents the best guess of y Q .
Ideally, it contains a representation of the mask M Q to be predicted.
The decoder works on 2D feature maps and µ Q|S is therefore reshaped as z µ 2 R H ⇥ W ⇥ E .
GP output covariance The covariance ⌃ Q|S captures both the uncertainty in the predicted query output y Q and the correlation between different query outputs.
The former lets the decoder network to identify uncertain regions in the image, and instead rely on, e.g., learnt priors or neighbouring predictions.
Moreover, local correlations can tell whether two locations of the image are similar.
For each query output, we employ the covariance between it and each of its spatial neighbours in an N ⇥ N region.
We represent it as a 2D feature map z ⌃ 2 R H ⇥ W ⇥ ( N 2 ) by vectorizing the Ncovariance values in the N ⇥ N neighborhood.
For more details, see Appendix E.
Shallow image features Shallow image features, extracted from early layers of deep neural networks, are of high resolution and permit precise localization of object boundaries (Bhat et al., 2018).
We therefore store feature maps extracted from earlier layers of F and feed them into the decoder.
These serve to guide the decoder as it transforms the low-resolution output mean into a precise, high-resolution mask.
We ﬁnally predict the query mask by feeding the above information into a decoder U ,
[Equation]
As a decoder U , we adopt DFN (Yu et al., 2018).
DFN processes its input at one scale at a time, starting with the coarsest scale.
In our case, this is the mean and covariance.
At each scale, the result at the previous scale is upsampled and processed together with any input at that scale.
After processing the ﬁnest scaled input, the result is upsampled to the mask scale and classiﬁed with a linear layer and a softmax function.
3. FSS L EARNER P YRAMID
Many computer vision tasks beneﬁt from processing at multiple scales or multiple feature levels.
While deep, high-level features directly capture the presence of objects or semantic classes, the mid-level features capture object parts Tian et al.
In semantic segmentation, methods begin with high-level features and then successively adds mid-level features while upsampling (Long et al., 2015).
In object detection, a detection head is applied to each level in a feature pyramid (Lin et al., 2017).
Tian et al.
(2020) discusses and demonstrates the beneﬁt of using both mid-level and highlevel features for few-shot segmentation.
We therefore adapt our framework to be able to process features at different levels.
We take features from our image encoder F extracted at multiple levels A .
Let the support and query features at level a 2 A be denoted as x a S and x a Q .
From the mask encoder G we extract corresponding support outputs y a S .
We then introduce a few-shot learner ⇤ a for each level a .
For efﬁcient inference, the support features and outputs are sampled on a grid such that the total stride compared to the original image is 32.
The query features retain their resolution.
Each few-shot learner then infers a posterior distribution over the query outputs y a Q , parameterized by µ a Q|S and ⌃ a Q|S .
These are then fed into the decoder, which processes them one scale at a time.
E XPERIMENTS
We validate our proposed approach by conducting comprehensive experiments on two FSS benchmarks: PASCAL- 5 i (Shaban et al., 2017) and COCO- 20 i (Nguyen & Todorovic, 2019).
4. E XPERIMENTAL S ETUP
Datasets We conduct experiments on the PASCAL- 5 i (Shaban et al., 2017) and COCO- 20 i (Nguyen & Todorovic, 2019) benchmarks.
PASCAL-
i is composed of PASCAL VOC 2012 (Everingham et al., 2010) with additional SBD (Hariharan et al., 2011) annotations.
The dataset comprisescategories split into 4 folds.
For each fold, 15 categories are used for training and the remaining 5 for testing.
COCO- 20 i (Nguyen & Todorovic, 2019) is more challenging and is built from MSCOCO (Lin et al., 2014).
Similar to PASCAL- 5 i , COCO- 20 i benchmark is split into 4 folds.
For each fold, 60 base classes are used for training and the remaining 20 for testing.
Implementation Details Following previous works, we employ ResNet-50 and ResNet-101 (He et al., 2016)
backbones pre-trained on ImageNet (Russakovsky et al., 2015) as image encoders.
We let the dense GP work with feature maps produced by the third and the fourth residual module.
In addition, we place a single convolutional projection layer that reduces the feature map down todimensions.
As mask encoder, we use a light-weight CNN (see Appendix E).
We use  2 y = 0 .
1 ,  2 f = 1 , and ` 2 = p D in our GP.
We train our models for 20k and 40k iterations `a 8 episodes for
PASCAL- 5 i and COCO- 20 i , respectively.
On one NVIDIA A100 GPU, this takes up to 10 hours.
We use the AdamW (Kingma & Ba, 2015; Loshchilov & Hutter, 2019) optimizer with a weight decay factor of 10  3 and a cross-entropy loss with 1-4 background-foreground weighting.
We use a learning rate of 5 · 10  5 for all parameters save for the image encoder, which uses a learning rate of 10  6 .
The learning rate is decayed with a factor of 0 .
1 when 10k iterations remain.
We freeze the batch normalization layers of the image encoder.
Episodes are sampled in the same way as we evaluate.
We randomly ﬂip images horizontally followed by resizing to a size of 384 ⇥ 384 for
PASCAL- 5 i and 512 ⇥ 512 for COCO- 20 i .
Well-documented code will be made publicly available.
Evaluation We evaluate our approach on each fold by randomly sampling 5k and 20k episodes respectively, for PASCAL- 5 i and COCO- 20 i .
This follows the work of Tian et al.
(2020) in which it is observed that the procedure employed by many prior works, using only 1000 episodes, yields fairly high variance.
Additionally, following Wang et al.
; Liu et al.
(2020c)
; Boudiaf et al.
Zhang et al.
(2021), our results in the state-of-the-art comparison are computed as the average ofruns with different seeds.
We also report the standard deviation.
Performance is measured in terms of mean Intersection over Union (mIoU).
First, the IoU is calculated per class over all episodes in a fold.
The mIoU is then obtained by averaging the IoU over the classes.
As in the original work on
FSS by Shaban et al.
(2017), we calculate the IoU on the original resolution of the images.
4. S TATE - OF - THE -A RT C OMPARISON
We compare our proposed DGPNet with existing FSS approaches on PASCAL- 5 i and COCO- 20 i benchmarks.
Table 1 presents the state-of-the-art comparison on both benchmarks.
Following prior works, we report results given a single support example, 1-shot , and given ﬁve support examples, 5-shot .
Our proposed DGPNet sets a new state-of-the-art on both benchmarks.
Among the previous approaches, SAGNN (Xie et al., 2021) achieves mIoU scores of 62.1 and 62.8 for 1-shot and 5-shot segmentation, respectively on PASCAL- 5 i using ResNet50.
RePri (Boudiaf et al., 2021) obtains mIoU scores of 59.1 and 66.8 for 1-shot and 5-shot segmentation, respectively.
Our DGPNet achieves superior performance with mIoU scores of 63.5 and 73.5 for 1-shot and 5-shot segmentation, respectively.
When using the ResNet101 backbone, PFENet (Tian et al., 2020) achieves the best 1-shot segmentation performance of 60.1 among existing methods.
Our DGPNet outperforms
PFENet (Tian et al., 2020) by achieving mIoU score of 64.8.
Similarly, our DGPNet signiﬁcantly outperforms the best reported 5-shot results in literature (65.6 by RePri (Boudiaf et al., 2021)), with an absolute gain of 9.8.
[Figure]
[Table]
On the challenging COCO- 20 i benchmark, DENet (Liu et al., 2020a) obtains mIoU scores of 42.
and 43.0 for 1-shot and 5-shot segmentation, respectively using ReNet50.
Our DGPNet outperforms DENet (Liu et al., 2020a), achieving mIoU scores of 45.0 and 56.2 for 1-shot and 5-shot segmentation, respectively.
When using ResNet101, DGPNet obtains absolute gains of 8.2 and 15.
for 1-shot and 5-shot segmentation, respectively, compared to the best reported results in literature.
Our per-fold results, including the standard deviation for each fold, are provided in appendix A.3.
Qualitative examples are found in Figure 3 and
Appendix F.
Scaling Segmentation Performance with Increased Support Size As discussed earlier, the FSS approach is desired to effectively leverage additional support samples, thereby achieving superior accuracy and robustness for larger shot-sizes.
We therefore analyze the effectiveness of the proposed
DGPNet by increasing the number of shots on PASCAL- 5 i and COCO- 20 i .
Figure 1 shows the results on the two benchmarks.
We use the model trained for 5-shot for in all cases, except for 1-shot.
Compared to most existing works, our DGPNet effectively beneﬁts from additional support samples, achieving remarkable improvement in segmentation accuracy with larger support sizes.
[Table]
Cross-dataset Evaluation In Table 2, we present the cross-dataset evaluation capabilities of our
DGPNet from COCO- 20 i to PASCAL.
For this cross-dataset evaluation experiment, we followed the same protocol as in Boudiaf et al.
(2021), where the folds are constructed to ensure that there is no overlap with COCO- 20 i training folds.
When using the same ResNet50 backbone, our approach obtains 1-shot and 5-shot mIoU of 68. and 77.5, respectively with absolute gains of 5.
and 11.3 over RePRI (Boudiaf et al., 2021).
Further, DGPNet achieves segmentation mIoU of 70.1 and 78.5 in 1-shot and 5-shot setting, respectively using ResNet101.
For more details on the experiment, see Appendix A.1.
4. A BLATION S TUDY
Here, we analyze the impact of the key components in our proposed architecture.
We ﬁrst investigate the choice of kernel,  .
Then, we analyze the impact of the predictive covariance provided by the GP and the beneﬁts of learning the GP output space.
Last, we experiment with dense GPs at multiple feature levels.
All experiments in this section are conducted with the ResNet50 backbone.
Detailed experiments are provided in the Appendix.
[Table]
Choice of Kernel Going from a linear few-shot
learner to a more ﬂexible function requires an appropriate choice of kernel.
We consider the homogenous linear kernel as our baseline.
Note that the homogenous linear kernel is equivalent to Bayesian linear regression under appropriate priors (Rasmussen & Williams, 2006).
To make our learner more ﬂexible, we consider two additional choices of kernels, the Exponential and
Squared Exponential (SE) kernels.
The kernel equations are given in Appendix C. In Table 3, results on both the PASCAL and COCO benchmarks are presented.
Both the Exponential and SE kernels greatly outperform the linear kernel, with the SE kernel leading to a signiﬁcant gain of 5.5 in mIoU. These results show the beneﬁt of a more ﬂexible and scalable learner
[Table]
Incorporating Uncertainty and Learning the
GP Output Space
We adopt the SE kernel and analyze the performance of letting the decoder process the predictive covariance provided by the dense GP.
With the covariance in a 5 ⇥window, we obtain a gain of 1.7 mIoU. Then, we add the mask-encoder and learn the GP output space (GPO).
This leads to a 1.7 improvement in isolation, or a 2.5 mIoU gain together with the covariance
[Table]
[Table] Multilevel Representations Finally, we investigate the effect of introducing a multilevel hierarchy of dense GPs.
Speciﬁcally we investigate using combinations of stride 16 and 32 features.
The results are reported in Table 5.
The results show the beneﬁt of using dense GPs at different feature levels, leading to an average gains of 1.4 mIoU.
C ONCLUSION
We have proposed a few-shot learner based on Gaussian process regression for the few-shot segmentation task.
The GP models the support set in deep feature space and its ﬂexibility permits it to capture complex feature distributions.
It makes probabilistic predictions on the query image, providing both a point estimate and additional uncertainty information.
These predictions are fed into a CNN decoder that predicts the ﬁnal segmentation.
The resulting approach sets a new state-of-theart on PASCAL- 5 i and COCO- 20 i , with absolute improvements of up to 14.9 mIoU. Our approach scales well with larger support sets during inference, even when trained for a ﬁxed number of shots.
Reproducibility Statement
In addition to the data, implementation, and evaluation details provided in section 4.1, we also provide (i) pseudo-code for the Gaussian Process; (ii) the details of the input to the decoder, and (iii) a table including all trainable layers of our network.
We have tried to be complete and believe that this information is sufﬁcient to reproduce our results.
In addition, the code for both training and evaluation will be made publicly available.
Furthermore, due to the stochastic nature of the task, we follow Tian et al.
and try to reduce the latter by sampling more episodes, 5000 for PASCAL- 5 i and 20000 for COCO- 20 i .
We additionally train and evaluate our ﬁnal approach with ﬁve different seeds.
Both the performance mean and standard deviation are reported in Table 1.
Ethics Statement Computer vision has the potential to automate many tasks, both in the form of autonomous agents and in the form of big-data processing.
There is a wide range of potential beneﬁts in doing so, such as enabling robots to perform hazardous tasks or via advanced driving assistance systems reduce the number of accidents in trafﬁc.
However, there are also challenges.
Automation may require changes to societal systems and can be used for ill.
We do not perceive few-shot segmentation as particularly problematic.
Instead, few-shot segmentation enables the introduction of new categories without the need of large-scale data collection.
Approaches based on episodic training, including our approach, are instead trained only on standard computer vision datasets.
We see two potential beneﬁts.
First, it democratizes semantic segmentation as the cost of data collection is reduced.
Secondly, with large-scale data collection there is always a risk of privacy infringement.
Reducing the amount of data necessary mitigates these risks.
S UPPLEMENTARY M ATERIAL
We ﬁrst provide additional results in Appendix A. Then, in Appendix B we provide analyses of the covariance neighborhood size and the effect of training the image encoder.
The equations for the different kernels used in our ablation study are shown in Appendix C. In Appendix D, we list the runtimes of the different components in our approach.
Appendix E contains pseudo-code for our dense GP, a list detailing the trainable layers of our approach, and the details on how the output of the GP is presented to the decoder.
Finally, in Appendix F, we provide a qualitative comparison and qualitative results.
A A DDITIONAL R ESULTS
We provide the per-fold results on the COCO-20 i to PASCAL transfer experiment and a list of the classes included; the per-shot results used to generate Figure 1 in the main paper; and the per-fold results used in the state-of-the-art comparison.
A. C ROSS - DATASET E VALUATION
We supply additional details on the cross-dataset evaluation experiment.
This experiment was proposed by Boudiaf et al.
and we follow their setup.
First, our approach is trained on each of the four folds of COCO- 20 i .
Next, we test each of the four versions on PASCAL, using only the classes held-out during training.
We list the classes of each fold in Table 7.
The full per-fold results are presented in Table 6. [Figure] [Table] [Figure]
[Table] [Figure] [Table] [Figure]
[Table]
[Table]
A. 1-10 S HOT R ESULTS
Here, we provide the full results from 1-10 shots, which was used to generate Figure 1.
In Tableand 9 our results on PASCAL- 5 i and COCO- 20 i are presented.
Note that our approach was trained for 1 shot in the 1-shot setting
[Table]
and 5 shots in the other nine settings
[Table]
[Table]
[Table]
A. P ER -F OLD R ESULTS
In this section [Table] we provide the full results for our state-of-the-art comparison.
In Tables 10 andthe per-fold results for both ResNet50 and ResNet101 are presented.
In general our results are stable for all folds
[Table]
[Table]
[Table]
B D ETAILED A NALYSIS
We present results from two additional experiments.
First, the size of the local covariance region is analyzed.
Then, we investigate the impact of freezing the backbone during episodic training.
B. A DDITIONAL C OVARIANCE N EIGHBORHOOD E XPERIMENTS
In section 3.5 we show how the covariance with neighbors in a local region is fed to the decoder.
In Table
[Table]
we supply additional results with different sized windows.
We experiment with N{ 1 , 3 , 5 , 7 } .
Larger windows improve the results but the improvement seems to saturate after N =
[Table] [Table]
B. E FFECT OF T RAINING THE I MAGE E NCODER
In Table 13 we compare our ﬁnal approach trained with a frozen and unfrozen backbone.
Several prior works found it beneﬁcial to freeze the image encoder during episodic training.
In contrast, we ﬁnd it beneﬁcial to not freeze it and keep learning visual representations.
By differentiating through our GP learner during episodic training, the proposed method can thus reﬁne the underlying feature representations, which is another important advantage of our approach.
However, our approach still improves upon state-of-the-art when employing a frozen backbone.
B. A DDITIONAL B ASELINE E XPERIMENTS
We supply three additional baseline experiments to validate the effect of the proposed DGP-module. We evaluate three variants: (i) We remove the GP (the f-branch) and let the decoder rely only on the shallow features.
(ii)
We replace the GP with the Prior-mask learning mechanism proposed in
[Table]
PFENet.
(iii)
We replace the GP with a prototype-based approach where the support features are mask-pooled and the result compared to the query features using cosine-similarity, similar to e.g.
PANet.
Results on PASCAL and COCO are reported in the Table 14.
Our approach outperforms all baselines by a large margin.
This further validates the superiority of our GP module.
[Table]
C K ERNEL D ETAILS
In this section we provide the deﬁnitions of the kernels used in our ablation study.
First we deﬁne the homogenous linear kernel as,
[Equation]
As was noted in the paper
[Table]
this kernel corresponds to Bayesian Linear Regression with a speciﬁc prior.
One could also consider learning a bias parameter, however we chose not to learn such parameters for reasons of method simplicity.
Next we consider the exponential kernel,
[Equation]
This kernel behaves similarly as the SE kernel, however with a sharper peak and slower rate of decay.
For completeness we additionally deﬁne the SE kernel here again,
[Equation]
We chose the length of the exponential kernel as ` = p D and the squared exponential kernel as ` 2 = p D , we found the performance in general to be robust to different values of ` .
Note that we used the same value of ` for both benchmarks and for all number of shots.
In Table 15 we provide a kernel hyperparameter sensitivity analysis.
We run one experiment per value and choose the values to cover one order of magnitude centered around the values adopted. Perturbing the hyperparameters with a factor of 0 . 3 or 3 . 0 leads to minor but statistically signiﬁcant drops in performance. One exception is increasing  2 f by a factor of 3 . 0 , which does not adversely affect performance. [Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
D R UNTIMES
We show the runtime of our method in Table 16.
We partition the timing into different parts.
The
Gaussian process (GP) is split into two.
One part preparing and decomposing the support set matrix
[Table]
in equation 6 and equation 7 of the main paper [Table] and another part computing the mean and covariance of the query given the pre-computed matrix decomposition [Table]
The timings are measured in the 1-shot and 5-shot settings on images from COCO- 20 i of 512 ⇥resolution, using either a single episode per forward or a batch of 20 episodes in parallel.
We run the method in evaluation mode via torch.no grad() .
Timing is measured by injecting cuda events around function calls and measuring the elapsed time between them.
The events are inserted via torch.cuda.
Event(enable timing=
True) .
We run our approach on a single NVIDIA
V100 for 1000 episodes and report the average timings of each part.
E A DDITIONAL I MPLEMENTATION D ETAILS
We provide code for the Gaussian Process inference, the neural network layers that make up the modules used in our approach, and the details of how the predictive output distribution from the GP is fed to the decoder.
E. C ODE FOR G AUSSIAN P ROCESS
Pseudo-code for the dense GP is shown in Listing 1.
Equation 7 involves the multiplication with a matrix inverse.
It is in practice computed via the Cholesky decomposition and solving the resulting systems of linear equations.
For brevity and clarity, we omit device casting and simplify the solve implementation.
In practice, we use the standard triangular solver in PyTorch, torch.triangular solve .
GP q, y s, x s, y, ): """ Produces the predictive posterior distribution of the GP.
After each line, we comment the shape of the output, with sizes defined as: the the the query image the of support feature vectors the support images output space
I = torch.eye(S)
K_ss =
kernel(x_s, x_s)
#(B,S,S)
K_qq =
kernel(x_q, x_q)
#(B,Q,Q)
K_sq =
kernel(x_s, x_q)
#(B,Q,S)
L_ss = torch.cholesky(K_ss + sigma_y * 2 * I)
#(B,S,S) [Table]
mu_q = (K_sq.
T @
solve(L_ss.
T, solve(L_ss, y_s))
#(B,Q,M) v = solve(L_ss, K_sq) #(B,S,Q) cov_q = K_qq - v.T @ v #(B,Q,Q) return mu_q, cov_q Listing 1: PyTorch implementation of the Gaussian Process utilized in the proposed approach. Here, the learning and inference is combined in a single step.
The @ operator denotes matrix multiplication and solve the solving of a linear system of equations.
The .T is the batched matrix transpose.
E. T RAINABLE L AYER L IST
In Table 17 we report the trainable neural network layers used in our approach.
The image encoder listed is either a ResNet50 (He et al., 2016) or a ResNet101 (He et al., 2016) with two projection layers.
The results of layer3 and layer4 are each fed through a linear projection layer, layer3 out and layer4 out respectively, to produce feature maps at stride 16 and stride 32.
These two feature maps are then fed into one GP each in the GP pyramid.
The support masks is fed through another
ResNet (He et al., 2016) in order to produce the support outputs.
The GPs are integrated as neural network layers, but do not contain any learnable parameters.
The decoder is a DFN (Yu et al., 2018).
We do not adopt the border network used in their work and we skip the global average pooling.
We also feed it shallow feature maps extracted from the query.
The shallow feature maps are the results of layer1 and layer2 in the image encoder, at
E. F INAL M ASK P REDICTION D ETAILS
In 3.5 we transformed the output of the GP before presenting it to the decoder, restoring spatial structure.
We present the equations for doing so.
Let ( · ) · denote tensor indexing.
The mean representation fed to the decoder is found as
[Equation]
For the covariance we consider spatial neighbours within a square N ⇥ N window.
Let  =
( N  1) / [-
-]2 and ( i, j ) 2 {   , . . .
,  } 2 be the possible offsets within the window.
Then, the covariance representation fed to the decoder is
[Equation]
F Q UALITATIVE R ESULTS
We provide qualitative results on PASCAL- 5 i and COCO- 20 i .
First, we compare the our ﬁnal approach to a baseline on the COCO- 20 i benchmark.
The baseline also relies on dense GPs - but uses a linear kernel, does not utilize the predictive covariance or learn the GP output space, and uses a single feature level (stride 32).
Our ﬁnal approach instead adopts the SE kernel, adds the predictive covariance in a local 5 ⇥ 5 region, learns the output space, and employs dense GPs at two feature levels (stride 16 and stride 32).
The results are shown in Figure 4.
Our ﬁnal approach signiﬁcantly outperforms the baseline in these examples, making only minor mistakes.
In Figure 5 we show qualitative results of our ﬁnal approach on the PASCAL- 5 i dataset.
Our approach accurately segments the class of interested, even details such as sheep legs.
In Figure 6, we show results on COCO- 20 i .
We provide a qualitative comparison between different support set sizes in Figure 7. For this comparison, we use COCO- 20 . In general, the 1-shot setting is quite challenging for several classes due to major variations in where the object appears and what it looks like. If the single support sample is too different from the query sample, the model tends to struggle.
With ﬁve support samples, the model performs far better.
At ﬁve, the beneﬁt of additional support samples seems to saturate, with ten samples often bringing only marginal improvements.
An example is the train episode in Figurewhere minor improvements are obtained when going from ﬁve to ten support samples.
Support
Query
Baseline
Ours
Support Set
Query
Ours
[Figure]
Query
Ours
[Figure]