Few-Shot Segmentation via Capturing Interclass and Intraclass Cues Using Class Activation Map

Few-shot segmentation is a challenging task due to the limited class cues provided by a few of annotations. Discovering more class cues from known and unknown classes is the essential to few-shot segmentation. Existing method generates class cues mainly from common cues intra new classes where the similarity between support images and query images is measured to locate the foreground regions. However, the support images are not sufficient enough to measure the similarity since one or a few of support mask cannot describe the object of new class with large variations. In this paper, we capture the class cues by considering all images in the unknown classes, i.e., not only the support images but also the query images are used to capture the foreground regions. Moreover, the class-level labels in the known classes are also considered to capture the discriminative feature of new classes. *e two aspects are achieved by class activation map which is used as attention map to improve the feature extraction. A new few-shot segmentation based on mask transferring and class activation map is proposed, and a new class activation map based on feature clustering is proposed to refine the class activation map. *e proposed method is validated on Pascal Voc dataset. Experimental results demonstrate the effectiveness of the proposed method with larger mIoU values.


Introduction
Image segmentation [1] aims to segment object regions from images, which is fundamental to many computer vision tasks [2]. Based on the deep learning-based method [3][4][5][6][7], the existing segmentation models can segment object well when sufficient annotations are given [8]. However, the existing segmentation methods still have two drawbacks. Firstly, the annotation generation is time consuming. e number of annotations is usually so small that it is hard to train the segmentation models from a few of annotations. e other is that the segmentation models work badly on new classes, i.e., the segmentation models only recognize the objects in the training dataset and cannot segment regions of classes unknown.
To solve the drawbacks, few-shot segmentation [9][10][11][12][13][14] is proposed. Given a set of images of new classes, with a few of annotations (support images), the aim of few-shot segmentation is to segment region of query images efficiently.
However, the intuitive method of refining the segmentation model by a few of annotations is proved to be ineffective. Few-shot segmentation faces the challenges of discovering object cues from limited annotations. To this end, researchers have proposed many methods to enhance few-shot segmentation [15][16][17]. ese methods can be summarized to provide segmentation cues from existing annotations of known classes where the annotations are sufficient to train the model. erefore, the class-agnostic guided model that transfers segmentation cues from support mask to query mask can be trained firstly and is then used in reference stage to locate the foreground regions in query image directly. Several strategies such as mask transferring and prototype feature are used. e few-shot segmentation has been improved obviously.
Meanwhile, few-shot segmentation still faces the lack of object priors although many existing annotation datasets are used. Two reasons caused such challenge. Firstly, there are large variation interclasses, which make the knowledge transferring between known class and new class very hard. Secondly, there is large variation intraclass. erefore, a few of annotations cannot describe all the types of classes and leads to bad guidance. In other words, the foreground priors are still limited by current few-shot segmentation manner.
In this paper, we propose a new few-shot segmentation method that considers two aspects, namely, interclass cue and intraclass cue to capture more sufficient segmentation cues from known and unknown classes. e first one captures the semantic relationships between the existing classes and unknown classes and is used to capture the discriminative cue through comparing existing classes and unknown classes. e second one captures the common cues intraclasses, that is, the common features shared by the query and support images are captured to locate the object. e two aspects are achieved by class activation maps (CAMs). A classification model considering only class-level labels is first built. en, class activation map is extracted based on the feedback analysis. Afterwards, since the discriminative regions are usually small, we expand the discriminative region using the feature clustering method guided by support masks. Finally, the CAM is introduced into the few-shot segmentation mask as an attention map to enhance the query image segmentation. e contributions of the proposed method are listed as follows: (1) A new few-shot segmentation method based on the segmentation cues interclass and intraclass is proposed (2) Class activation map is used to capture the segmentation cues, and a new attention module is proposed to add the class activation map in to the few-shot segmentation network (3) An extension method based on the clustering method is proposed to enlarging class activation map

Related Work
Few-shot segmentation aims to segment regions of new classes with a few annotated images given, which is a fundamental task in computer computing [18,19]. e few-shot segmentation task is always formulated as an information guidance model, where the common knowledge that can be used in segmentation task is learned in the support branch and transferred between the support branch and the query branch. ere are two key components in existing few-shot segmentation methods, of which the first component is a class prior extraction module in the support branch, and the second component is a guidance network to transfer the extracted knowledge between branches.
As for class prior extraction, multiple types of class prior have been proposed and can be further categorized into the weight-based methods and prototype-based methods. e weight-based methods consider the weight of a classifier as the class prior. e most representative work in the weightbased methods is OSLSM [10], which leverages a conditional branch to generate parameters for query branch. e current state-of-the-art methods are prototypebased methods. e prototype-based methods can be further divided into the global prototype, the fusion of global and local prototype, and the prototype of background. e global prototype-based methods consider the converted deep features from the support branch into the class prototype, e.g., PANet [20] and CANet [21] learn a class-specific global prototype with a masked average pooling operation. e second type of prototype-based methods takes the global and local prototypes into consideration simultaneously and has the ability to extract features with more semantic knowledge. e most representative methods are PPNet [22] and PMMs [22], where the first method decomposes the holistic class representation into a set of partaware prototypes with k-means and the second correlates the diverse image regions with multiple prototypes to enforce the prototype-based representation with the aid of the EM algorithm.
e third type of prototype-based methods employs the background prototype to enhance the semantic knowledge of foreground. e most representative methods are MLCNet [23] and SCNet [24], where the first method introduces a mining branch that exploits latent novel classes via transferable subclusters and the second method generates self-contrastive background prototypes directly from the query image, enabling the construction of complete sample pairs to form a complementary and auxiliary segmentation task.
As for the design of guidance network between support branch and query branch, multiple types of guidance module have been proposed and can be further categorized into the feature-level guidance network and the parameterlevel guidance network. e feature-level guidance conducts similarity propagation based on the extracted features by diverse branches. e representative methods include PFENet [25], which generates the prior mask based on the cosine similarity between features, and then employ the feature enrichment module to propagate this similarity in multiple resolutions. LTM [26] proposed a nonparametric and class-agnostic transformation method, where the relationship of the local features is calculated in a high-dimension metric embedding space based on cosine distance, and then are mapped from the low-level local relationships to high-level semantic cues with the generalized inverse matrix of the annotation matrix. e parameter-level guidance network considers the model parameter of the last specific layer as the class prior and uses the parameter transformation from support branch to query branch to achieve the guidance. e most representative work is CWT [27], where the guidance is conducted at the classification layer only; it proposed a Classifier Weight Transformer to dynamically adapt the support-set trained classifier's weights to each query image in an inductive way.

e Pipeline of the Proposed Method.
e pipeline of the proposed method is shown in Figure 1, where the proposed method consists of four steps: the classification step, the CAM generation step, the mask generation step, and the mask refinement step. e classification step is to train a classification network by considering all the existing classes and the new classes based on image-level labels only and output the class activation map that represents the discriminative regions of the unknown classes via gradient feedback forward. en, since the initial CAM is usually very small, the CAM generation step expands the CAM using the clustering strategy. Afterwards, the mask generation step generates the segmentation mask in terms of soft values based on mask transferring strategy where the CAM generated in the second step is used as attention map to enhance the features of the query image. Finally, the mask refinement step is to improve the segmentation mask based on classical segmentation framework. We next detail the four steps.

Classification
Step.
e aim of the classification step is to train a classification model by considering the known classes and new classes and extracts the discriminative regions of new classes that distinct the new class from the existing classes. erefore, the rough location of new classes can be obtained in the query image.
Specifically, a training dataset C B , C N consisting of the existing classes and the new classes is constructed firstly. Here, C B � C 1 , . . . , C N−1 is composed of existing classes with number N − 1. C N � C N1 , . . . C Nk is the image set of new classes. Based on all classes, a classification network is trained, and the classification map C 0 is extracted using Grad-CAM methods.
Meanwhile, the regions are usually small due to the fact that the rough image-level labels cannot obtain the whole region of the object but a small area. e next step expands the highlighted region using feature clustering.

CAM Generation
Step.
e CAM generation step expands the class activation maps based on the idea that the regions located by the initial step can be treated as the class center, and the rest pixels similar with the region highlighted can be treated as the object regions. erefore, we use the clustering method to obtain the similar pixels.
Specifically, the CAM generation step consists of three substeps: pixel clustering, cluster selection, and CAM generation. In the first step, the K-means clustering [28] is used to cluster the pixels into n g clusters based on the deep features obtained in the classification step. For each cluster, each pixel is given the activation value in the class activation map, and the mean value of the cluster is obtained through averaging the activation values. e mean value represents the important for the pixel to the class, and the mean value is used as the activation value for all the pixels in the cluster. us, a new class activation map M is obtained.

Mask Generation
Step. Mask generation step segments foreground regions of query image based on the class activation map M. Here, a few-shot segmentation network based on transferring is used, and the class activation map M is embedded into the network to enhance the guidance.

Few-Shot Segmentation
Network. e few-shot segmentation network is constructed by the method in [26], of which the idea is to obtain the query mask M q (with size n × n) based on the relationships as follows: where M q and M s are the query mask and support mask, respectively, and the two masks are reshaped into column vector. R is the matrix product of M q and M s , with size n 2 × n 2 . It is seen that value one in R means that the values in M q and M s are all value one. Otherwise, the value in R is zero.
Once R is known, the query mask can be obtained by us, the few-shot segmentation problem changes to obtain the Matrix product R, which can be estimated by the feature similarity of the pixels in the support and query images, i.e., the foreground pixels have the similar features, and have similarity distance of value one. Otherwise, the distance is value zero.
Based on the formulation above, the few-shot segmentation network can be constructed as a two-branch based network, with a guidance model by formula (2). e network is shown in Figure 1.
Specifically, given a support image I s with support mask M s and query image I q , a two-branch based network is used to extract the pixel features. One is the support branch that extracts the features of support image F s , and the other is the query branch that extracts the features of query image F q . en, the similarity matrix M sq of F s and F q is calculated via calculating the discrete cosine distance, where where M sq (i, j) is the value at location (i, j). F s i { } and F q j are the i th feature and j th feature in F s and F q . d is the discrete cosine distance. erefore, M sq refers to the similarity of pixels, which is similar with the similarity relationships of masks, and can be used to estimate the matrix product R.
en, M sq is used to estimate the matrix product R and is used to obtain the query mask via (2).
Note that estimating R using the pixel feature is challenging. us, we use the support mask to filter the foreground regions via element-wise production.

Feature Enhancement via CAM.
Different from the few-shot segmentation method in [26], we introduce the class activation map which carries the discriminative cues through all classes to enhance the features of query image. Specifically, as shown in Figure 1, the query image is sent into the classification network to form the initial classification map. en, the clustering algorithm is used to refine the class activation map. e class activation map is then used as attention map to refine the deep features of query image, and the refined features guide the segmentation of query image.

Mask Refinement
Step.
e output of few-shot segmentation branch is the soft mask of query image. To obtain the binary mask, a threshold can be used to obtain the hard mask from the soft mask. However, the results are sensitive to the selection of threshold. erefore, a segmentation mask is used to segment the final mask from the soft mask, where the soft mask is used as foreground probability map, and the segmentation network is performed to obtain the final hard segmentation mask. We use the method in [8] to implement the mask refinement.

Dataset.
We next verify the proposed method based on the Pascal Voc dataset which consists of 20 classes. Similar with the existing few-shot segmentation method, the 20 classes are split into two class set. One is training set that trains the few-shot segmentation network. e other is the test set that validates the segmentation quality of the network. To fully validate the few-shot segmentation model, four splits are used. e details are found in Table 1.

Implementation Details.
We implement our method on Titan-XP GPU. Pytorch is used to realize our method. e network is optimized by Adam optimizer with the initial learning rate 1e − 4. Several backbones such as VGG16, ResNet50, and ResNet 101 are used for sufficient evaluation.
e pretrained backbone network based on ImageNet [29] is used for training.

Subjective Results.
We first display some subjective results in Figure 2, where the input image, the prediction results, and the ground truth results are displayed. It is seen that the prediction results are similar with the ground truth results, which demonstrates the fact that our method can segment these new classes of images successfully.

Objective Results.
We objectively evaluate the proposed method by mIoU and FB-IoU values that are usually used for few-shot segmentation evaluation. e results are shown in Table 2, where 1-shot and 5-shot mean the few-shot segmentation with one and five support annotations, respectively.
ree backbones such as VGG16, ResNet 50, and ResNet 101 are considered. We can see that ResNet 101 obtains the best results due to the deeper layers in the networks. e results by ResNet 50 are better than VGG 16, which is also caused by the deeper network that captures more semantic features.

Comparison with Existing Methods.
We also compare our method with the existing state-of-the-art methods. e comparison methods are displayed in Table 2. It is seen that our method outperforms these comparison methods, which demonstrate the effectiveness of the proposed method, especially for the comparison with the method in [26], our method can be considered as a improvement of the method [26]. It is seen that our method is better than the method in 4 Complexity [26] which demonstrates the effectiveness of our strategy that introduces the class activation map to capture both the cues interclass and intraclass.

Discussion
e existing few-shot segmentation methods usually focus on the learning class-agnostic model, which is based on the level interclasses only. Such class-agnostic model can lead to good generalization on new classes, which however also lacks the class cues of new classes. Based on the existing class-agnostic model, we try to add new segmentation cues through the discriminative cues interclass and the common cues intraclasses, which is the level of both interclass and intraclass. erefore, better segmentation results can be obtained by our method.
It is seen that our method is based on the method in [26] (LTM), which proposed a few-shot segmentation method via estimating the relationship matrix of masks that is an interesting idea. However, our method is different from LTM [26]. Firstly, our main contribution is using the class activation map to capture the segmentation cues interclass and intraclass, which is not considered in [26]. Secondly, an attention module is added in LTM, which can add the CAM segmentation cues to enhance the segmentation. erefore, our method can be considered as an extension to LTM [26] with better segmentation results."

Conclusion
is paper proposed a new few-shot segmentation method that uses the class activation map to enhance the generation of object priors by considering the common cues intraclass and the discriminative cues interclass. e proposed network consists of four steps: classification step, CAM generation step, mask generation step, and mask refinement step, which are used to generate the initial CAM via class classification, to generate the CAM via feature clustering, to generate the segmentation mask, and to refine the segmentation mask, respectively. e proposed method is validated on Pascal Voc dataset. e experimental results demonstrate that the consideration of common cues intraclass and the discriminative cues interclasses can enhance the few-shot segmentation in terms of large IoU values.
Data Availability e datasets used for validation are available from https:// host.robots.ox.ac.uk/pascal/VOC/. e detailed results are listed in the paper. More results can be found from the corresponding author on reasonable request.

Conflicts of Interest
e authors declare that they have no conflicts of interest.