Polite Teacher: Semi-Supervised Instance Segmentation With Mutual Learning and Pseudo-Label Thresholding

We present Polite Teacher, a simple yet effective method for the task of semi-supervised instance segmentation. The proposed architecture relies on the Teacher-Student mutual learning framework. To filter out noisy pseudo-labels, we use confidence thresholding for bounding boxes and mask scoring for masks. The approach has been tested with CenterMask, a single-stage anchor-free detector. Tested on the COCO 2017 val dataset, our architecture significantly (approx. +8 pp. in mask AP) outperforms the baseline at different supervision regimes. To the best of our knowledge, this is one of the first works tackling the problem of semi-supervised instance segmentation and the first one devoted to an anchor-free detector. The code is available: github.com/AI-Clearing/PoliteTeacher.


INTRODUCTION
The advent of deep learning transformed computer vision pipelines both in academia and industry.However, progress is often hindered, since deep learning models are expensive to train for several reasons.Leaving the hardware and computational expenses aside, the vast share of costs often comes from providing the right amount of samples to learn from.For a number of supervised problems in computer vision, it is relatively easy to obtain data.However, labelling them is often the real source of expenses.Semi-supervised learning methods are tailored to deal with the situation in which there are enough data samples, but access to the labels is severely limited.
Semantic segmentation (sometimes called dense classification) is a classical computer vision task of assigning each pixel a category.This enables clustering images into semantically coherent parts.Object detection is concerned with the location and identification of semantic objects on images.Instance segmentation combines these two -it is concerned with locating and identifying entities with pixel-wise accuracy.While an intense research activity can be observed in the areas of semi-supervised semantic segmentation (Tarvainen & Valpola, 2017;Chen et al., 2021) and object detection Liu et al. (2021;2022b), very little attention has been devoted to semi-supervised instance segmentation methods in the computer vision community.
We propose Polite Teacher, a simple yet effective method for the task of semi-supervised instance segmentation.The architecture is built on the Teacher-Student framework.Its politeness in the name is an acronym for pseudo-label thresholding, which is concerned with filtering noisy pseudo-labels in detection and mask heads.Our contribution is two-fold: • We present Polite Teacher -one of the first works devoted to semi-supervised instance segmentation and the first one devoted to modern anchor-free detectors.Our approach uses mask scoring (Huang et al., 2019) for the pseudo-mask thresholding.
• The presented method significantly (approx.+8 pp. in mask AP) improves baseline performance with different supervision regimes on COCO 2017 and sets the new baseline for further comparison, becoming de facto the new state-of-the-art for this dataset.
The paper is organised as follows.Section 2 contains a comprehensive survey of related research.
In Section 3, we present the details of our method -Polite Teacher.The results of the evaluation are discussed in Section 4, along with the detailed analysis and ablation studies.The paper is concluded with a short summary in Section 5.

RELATED RESEARCH
This section presents a comprehensive survey of areas adjacent to our work.We present recent research in the area of instance segmentation.Then, we summarise the recent progress in semisupervised learning.Finally, we combine these two areas and briefly discuss the body of knowledge for semi-supervised instance segmentation.
Instance segmentation.Instance segmentation is a computer vision problem concerned with pixel-wise delineating instances of semantic classes.As it can be perceived as a combination of object detection and semantic segmentation, the advances in instance segmentation are tightly coupled with the two aforementioned tasks (especially the former).In recent years, two kinds of object detectors were popular: single-and two-staged.A typical example of the latter category is Faster R-CNN (Ren et al., 2015).It consists of the backbone feature extractor (eg.ResNet) and two heads: the region proposals network (RPN) and the second one for final detections (RoI -the region of interests head).The proposal candidates are searched on a pre-defined set of anchors using RPN and they are later refined with the RoI head.He et al. (2017) introduced Mask R-CNN, which added the mask head to Faster R-CNN to solve segmentation tasks on predicted bounding boxes.Mask scoring (Huang et al., 2019) adds another head on top of that -it regresses the IoU (intersection over union) score of the predicted masks to improve model robustness.Single-stage detectors try to achieve the outcomes of the aforementioned architecture in a single pass.This often results in higher speed at the expense of precision.A notable examples of such detectors include the YOLO family (Redmon et al., 2016) or RetinaNet (Lin et al., 2017).More recently, Lee & Park (2020) proposed CenterMask, an anchor-free instance segmentation framework targeted at real-time applications.It is build on FCOS (Tian et al., 2020), which details are discussed in Section 3. The architecture of CenterMask2 introduces spatial attention-guided masks (SAG-Mask) along with backbone feature extractors tailored for instance segmentation.Recently, there is a surge of research on architectures utilising the concept of self-attention (also called transformers).Dosovitskiy et al. (2021) introduced the visual transformer (ViT), which successfully adapted self-attention to computer vision.This seminal work has sparked research interest in transformers in the vision community.For instance, DINO (Caron et al., 2021) adapts the Teacher-Student paradigm and self-supervised learning for various vision tasks, such as object detection.Recently, MaskDINO (Li et al., 2022) added mask prediction to DINO and topped several instance segmentation benchmarks.However, while displaying exceptional performance, solutions purely based on ViT suffer from quadratic computational complexity, which hinders their adoption.
Semi-supervised learning.Semi-supervised learning techniques can be framed as a middle ground between supervised and unsupervised learning since data with and without labels participate in the learning process.It is related to weakly supervised and self-supervised learning.Some approaches to the problem of semi-supervised learning such as Γ model (Rasmus et al., 2015), Π model or temporal ensembling (Laine & Aila, 2017) use the notion of self-ensembling.However, more modern ones are focused on the non-standard architecture during the training phase, often incorporating multiple subnetworks.For instance, Tarvainen & Valpola (2017) introduced Mean Teacher, which is a popular semi-supervised training framework.It overcomes the limitations of Temporal Ensembling and Π models.Instead of using the standard gradient-based approach, the teacher is updated using the exponential moving average (EMA).Unbiased Teacher (Liu et al., 2021) builds on top of the Mean Teacher framework -it does add focal loss and confidence thresholding of pseudo labels.Focal loss borrowed from the work of Lin et al. (2017) helps with the class imbalance, whereas confidence bounding box thresholding reduces the influence of noisy pseudo-labels.The recent Ubiased Teacher v2 (Liu et al., 2022b) extends it to anchor-free detectors and tackles the issue of the pseudo-labelling on bounding box regression.Besides the Teacher-Student paradigm, there are also other approaches.Cross pseudo supervision for semantic segmentation (Chen et al., 2021) is an example of a consistency regularisation method.Here, two networks are trained on the output of each other and are penalised for discrepancies in predictions.Contrastive methods con-stitute another approach to semi-supervised learning.For instance, regional contrast, abbreviated as ReCo (Liu et al., 2022a) belongs to this category.While using the Teacher-Student framework, this model introduces a dedicated loss function and utilises the semantic relationship between classes.
Semi-supervised instance segmentation.Contrary to object detection and semantic segmentation, instance segmentation in the semi-supervised setting received little attention among scholars so far.Concurrently to our work, Wang et al. (2022) presented Noisy Boundaries (NB).This framework also uses the Teacher-Student paradigm and introduces different bounding box thresholds per category, drawing from the work of Radosavovic et al. (2018).The NB architecture has also two special features: the noise-tolerant mask head and boundary preserving re-weighting.While the noisetolerant head works with low-level resolution features to suppress the noise on mask boundaries, the boundary preserving map is focused on highlighting the boundary region for the segmentation part.
At the time of writing this publication, the problem of semi-supervised instance segmentation with anchor-free detectors has never been tackled in the literature.

POLITE TEACHER
This section is devoted to the introduction of Polite Teacher.First, we formulate the problem we are solving -semi-supervised instance segmentation.Then, we introduce the architecture of our solution -used detectors, the Teacher-Student learning paradigm, and pseudo-label thresholding.
The section is concluded with a detailed description of the used loss function.
Problem formulation.We consider the problem of semi-supervised instance segmentation.Instance segmentation is a computer vision task which combines object detection and semantic segmentation.Semi-supervised setting means that only part of the data available during the training phase is labelled.More formally, we consider training dataset D consisting of a set of Here, x i and y i stand for images and their labels (instances categories along with their bounding boxes and masks) respectively.Typically, N unsup >> N sup .In this work, we assume that D sup and D unsup come from the same distribution.

ARCHITECTURE
The architecture of Polite Teacher depends on several components.The first one is the detector, which is used twice due to the Teacher-Student paradigm.We use CenterMask (Lee & Park, 2020).This is a single-stage anchor-free detector, which has a relatively simple architecture and therefore it is easy to tune.Two such networks are then framed in the Teacher-Student paradigm to handle both labelled and unlabelled data.Finally, two-fold pseudo-label thresholding takes place to remove noisy ones.The first one uses bounding box uncertainty, and the second one rejects masks with an estimated low IoU score.
Detector.To properly present CenterMask, FCOS should be discussed first.Tian et al. (2020) introduced Fully Convolutional One-Stage Object Detector (abbreviated as FCOS), an anchor-free object detector.In general, one-stage detectors due to the lack of the proposal generation phase have fewer hyper-parameters to tune and therefore there are easier to train.Being anchor-free means eliminating pre-defined anchors, which diminishes the computational burden related to calculating IoU scores.FCOS frames detection as a per-pixel prediction task, which resembles semantic segmentation.Three loss components are subject to optimisation: classification, regression, and centre-ness.While classification works similarly to other detectors, the regression targets are quite different.Instead of predicting bounding box corners (like in e.g.Faster R-CNN), the four regressed values are l (the distance from the centre of a bounding box to its left border), t (top), r (right), b (bottom).Finally, the centre-ness denotes the centre of a given bounding box.Ground-truth centre-ness for (l * , t * , r * , b * ) is defined as follows: Intuitively, this approach promotes bounding boxes which are located at the centre of a given object.
x Aug weak (x) Lee & Park (2020) introduced CenterMask, which extends FCOS for the task of instance segmentation.This is done similarly to how Faster R-CNN (Ren et al., 2015) is extended by Mask R-CNN (He et al., 2017).However, there are some differences.For instance, the RoI assignment function is redefined due to the different levels of the feature pyramid (FPN) which are used.Instead of the mask head from Mask R-CNN, CenterMask utilises the spatial attention-guided mask (abbreviated as SAG-Mask).For x, which here mean features extracted from RoI align, the attention-guided feature map is calculated as follows: where σ denotes sigmoid function, conv 3×3 is convolutional layer with 3 × 3 filter, P max and P avg are the results of max and average pooling, and concat stands for the concatenation.
Teacher-Student Learning.We adopt a 2-step training procedure.In the first step, the model is trained using only labelled data (D sup ), which makes this part a standard supervised instance segmentation.Instead of using a fixed number of batches for this step -as burn-in stage in Unbiased Teacher (Liu et al., 2021) -we rather train it as long as it converges in terms of mask AP and take the best model θ to ensure the highest results.Naturally, this step is expected to take longer with a higher number of supervised examples.In the second step, mutual Teacher-Student learning with pseudo-labels takes part.The best model from the first step is used and copied to be used as student and teacher models (θ s ← θ, θ t ← θ).The model can be trained with the burn-in stage as well.
Teacher and student models receive the same input data -they are augmented differently, though.
The teacher receives moderately augmented images (weak augmentations -we use random flipping), whereas the student consumes visibly perturbed images (strong augmentations -same as weak, plus colour jitter, random grayscale, gaussian blur, and random patch erasing).During the training, the predictions from the teacher model serve as pseudo-labels (bounding boxes with their classes and masks) for the student.The teacher is updated using the exponential moving average -see equations 6 and 7 in the next subsection.Figure 1 illustrates the unsupervised part of the process (the second step).
Pseudo-Label Thresholding.As the teacher is used to generate pseudo-labels ŷ in the semisupervision regime, they can be noisy -especially with a high share of unsupervised data.Therefore, Polite Teacher uses two-step pseudo-label thresholding: one is concerned with bounding boxes, whereas the second one refines the masks.Similarly to STAC Sohn et al. (2020) and Unbiased Teacher (Liu et al., 2021), we introduce a bounding box confidence threshold -τ cls .Bounding boxes with a classification score smaller than τ cls are discarded and not used further in the training.
The sigmoid output of the classification is treated here as confidence.Inspired by the work of Huang et al. (2019), we also use a mask-scoring mechanism.It regresses the IoU values of the generated masks and improves instance segmentation performance due to the prioritisation of more accurate masks.While not directly designed for the task of semi-supervised learning, the output of this block can be used for filtering noisy pseudo-masks in a straight-forward manner.That is, only masks satisfying ŷIoU > τ IoU are used in the unsupervised learning stage.The other ones are considered uncertain and receive zero gradients.

OPTIMISATION
The overall batch-wise loss L for supervised {(x i , y i )} Bsup i=1 and unsupervised {(x j , ŷj )} Bunsup j=1 examples in a batch is computed as follows: where L sup is the loss of the supervised part, and L unsup is the loss of the unsupervised part.The unsupervised part is scaled by λ.The supervised component is calculated as follows: L sup (x, y) = L sup cls (x, y) + L sup centre (x, y) + L sup box (x, y) + L sup mask (x, y) + L sup IoU (x, y) , (4) where L sup cls is the supervised classification loss, L sup centre is the supervised centreness loss, L sup box represents the supervised bounding box regression loss, and L sup mask is the supervised segmentation mask loss, and L sup mask IoU is the supervised segmentation mask scoring loss.Regarding the pseudo-labelling loss, we use the following definition: where L unsup cls is the unsupervised classification loss, L unsup mask is the unsupervised segmentation mask loss, and L unsup IoU is the unsupervised segmentation mask scoring loss.Regarding the particular loss functions implementation, we follow FCOS and CenterMask: L sup cls is focal loss (Lin et al., 2017), L sup box is UnitBox IoU loss (Yu et al., 2016), L sup centre is binary cross-entropy loss, L sup mask is average binary cross-entropy loss (He et al., 2017), and L sup IoU is L 2 loss.The same losses are used for unsupervised components (where applicable).
The student is trained using a standard stochastic gradient descent, whereas the teacher can be perceived as an ensemble of the students: (7) Here θ t and θ s represent the teacher and student model parameters respectively and α is the EMA coefficient (a hyperparameter).Following Liu et al. (2021), the teacher trained in such a way is more robust to the sudden changes of decision boundaries caused by the minority classes in batches -especially in the presence of pseudo-labels.An important practical implication of this is the fact that there is no need to store gradients for the teacher model, which reduces GPU memory usage (compared to simply training two models).

EVALUATION
This section describes the evaluation of Polite Teacher.We start with discussing the training setup, implementation details, and dataset.Then, we present the result of our main experiment, which is followed by the detailed analysis and ablation studies of particular components of Polite Teacher.

SETUP
Setup and implementation.All the experiments were performed either on a2-highgpu-4g instances on Google Cloud Platform (4xA100, 40 GB RAM each) or various machines with 8 GPUs (up to 16 GB RAM each) on the proprietary cluster (each of which contained Titan V, RTX 2080 Ti, or Titan X GPUs).Polite Teacher was developed on CenterMask2 and Unbiased Teacher codebase -both built on the Detectron2 framework (Wu et al., 2019).
Data and evaluation metrics.We evaluate Polite Teacher on the MS-COCO 2017 dataset (Lin et al., 2014) using different supervision regimes (1%, 2%, 5% and 10% supervised).The supervisedunsupervised split is taken from the Unbiased Teacher Liu et al. (2021) -while it was originally meant to be used for evaluation of semi-supervised object detection, it can be used with our method as well.We report evaluation results on val subset, as the test one is not publicly available.The reported metric used in this study is mask mAP (mean average precision, simply called AP later on), which is calculated as an average of AP with IoU thresholds set from 0.5 to 0.95 (with 0.05 intervals).Bounding box AP is also reported for selected experiments.Lee & Park (2020).The results for two-stage detectors are taken from the work of Wang et al. (2022).Notice that it uses a random split of the dataset -in particular, this is different from the one used by us.Therefore, these results cannot be directly compared, but we report them in order to trace the comparison with their baselines.(Radosavovic et al., 2018) 3.8 (+0.30) 11.8 (+2.40) 20.4 (+3.10) 24.2 (+2.20)NB (Wang et al., 2022) 7.7 (+4.20) 16.3 (+6.90) 24.9 (+7.60) 29.2 (+7.20)

Architecture
Hyperparameters.As base hyperparameters, we used the ones set in CenterMask2.The EMA coefficient α for Teacher learning is set to 0.9996.The models were trained for up to 270,000 batches with stochastic gradient descent.We used batch size 32 (16 supervised and 16 unsupervised samples) with a learning rate γ = 0.006, weight decay of 0.0001 and momentum 0.9.Similarly to the CenterMask2, the learning rate has been decreased by a factor of 10 on steps 210,000 and 250,000.However, such a long training was often not necessary, as models overfitted on much earlier stages.These experiments have been early stopped.Regarding the pseudo-label threshodling, we used τ cls = 0.6 and τ IoU = 0.9.The unsupervised weight has been set to λ = 2.More details on the last three values are in Section 4.3.We use ResNet-50 backbone (He et al., 2016) for all the experiments.
For the vast majority of our experiments, we thought that our method will be the first one devoted to semi-supervised instance segmentation.The recent Noisy Boundaries (NB) approach (Wang et al., 2022), a concurrent work to Polite Teacher, is also concerned with this problem and has been evaluated on a similar percentage of supervision on COCO 2017.However, these are different splits.We did not perform direct comparisons, as we were not aware of this work for the majority of our research -we report these results for scientific integrity, though.In general, Noisy Boundaries reported a smaller increase in the mask AP (especially with low supervision), although for fair comparison such claims should be made after running the models on exactly the same supervised/unsupervised data splits.It is also unclear how much of this difference can be attributed to the different detectors (a two-staged Mask R-CNN has been used).Following Wang et al. (2022), we also report the results for Data Distillation (DD) method Radosavovic et al. (2018), which was evaluated jointly with NB.It was developed for the task of omni-supervised (known also as webly-supervised) learning, a special case of semi-supervised learning in which unlabelled data from the Internet are considered during the training.At the heart of this approach lies the pipeline of different data transformations.
The results are later ensembled to provide pseudo-labels.In this section, a detailed analysis of the influence of hyperparameters and ablation studies is presented.Unless otherwise specified, all the configuration is the same as in Section 4.1.All experiments have been performed with the 5% supervision regime.
Influence of bounding box filtering threshold.In this experiment, we investigate the importance of bounding box filtering thresholds.To separate the influence of sole bounding box filtering, we did not include mask IoU in the optimisation -it is a subject of another experiment.That is, L sup IoU (x i , y i ) and L unsup IoU (x j , ŷj ) has been not taken into account in equations 4 and 5 respectively.As it turns out, even this significantly improves mask AP over baselines.Table 2 and Figure 3 (left) present AP values for this experiment.The bounding box threshold value with the highest bounding box and mask AP was 0.6.Interestingly, this is a slightly smaller threshold than in the original Unbiased Teacher paper (0.7).The difference might stem from the different neural network architectures (Faster R-CNN vs CenterMask).Note that this experiment used suboptimal λ = 0.75 from Equation 3 and hence the results are slightly worse compared to the following experiments.This is because the experiment to determine the correct unsupervised loss weight was yet to be carried out at this point.
Influence of unsupervised loss weight.We also examine the influence of the weight of unsupervised loss, which is denoted as λ in equation 3. Figure 3 (centre) and Table 3 24.37 25.43 25.36 26.37 25.69 25.53 25.20 20.53 results of this study.Similarly to the previous experiment, we did not include L sup IoU (x i , y i ) and L unsup IoU (x j , ŷj ) from equations 4 and 5 as the optimisation components.We used τ bbox = 0.6, which is the result of the previous experiment.The highest mask AP has been obtained at λ = 2.0.Interestingly, in Unbiased Teacher, which is a similar architecture, this parameter was set to λ = 4.0.
Influence of mask scoring filtering threshold.In this experiment, we investigate the importance of mask filtering threshold τ IoU .We use τ cls = 0.6 and λ = 2.0, as these two values provided best results in the previous experiments.Figure 3 (right) and Table 4 present the detailed results of this experiment.Compared to the results without mask scoring, the best value (τ IoU = 0.9) yielded insignificant differences in mask AP (+0.03 pp.) and bounding box AP (−0.03 pp.).Interestingly, the conducted experiment displayed a convex-like U-shaped relationship between τ cls and mask AP.Passing all pseudo-masks resulted in the highest bbox AP, whereas filtering most of them yielded the highest mask AP.
Ablation on pseudo-bounding box thresholding.For an ablation study, we compare the baseline CenterMask model to the Teacher-Student with bounding box thresholding.Essentially, such a model is very similar to Unbiased Teacher (Liu et al., 2021), which is proven to greatly improve results for semi-supervised object detection.While raw CenterMask achieved 18.04% on 5% supervision, Polite Teacher yielded 26.46% mask AP, which is a +8.42 pp.increase (see tables 1 and 3).This suggests that much of the mask AP gain can be attributed to the Teacher-Student paradigm with bounding box thresholding.
Ablation on pseudo-mask thresholding.In this ablation, we compare the model with bounding box thresholding to the model with bounding box and mask thresholding (that is, Polite Teacher).Judging only by mask AP, the influence of the pseudo-mask filtering threshold on the final results can be easily neglected, as shown in Figure 3 (right).However, applying mask scoring resulted in visibly faster convergence.The model with mask scoring reached 26% mask AP in 40k steps, whereas the model without it needed 74K steps to reach the same value, which is almost two times longer.The highest mask AP values have been reached at 47k (26.39%) and 99k step (26.37%) respectively, which is also close to two times longer.The detailed figures for this run are in tables 3 and 4. In order to check the stability of this behaviour, we repeat these experiments (Figure 4).
Variance examination.Due to the computational limitations, we are not reporting results as a series of experiments with their means and standard deviations.However, to assess the variance of the proposed method we carried out a separate experiment, in which we ran Polite Teacher training with 5% supervised data several times -each time with a different seed value.Figure 4 presents mean evaluation results per each step (batch), along with the standard deviations.While the experiment has shown non-homogeneous variance for the variant with mask scoring, the maximum mask AP values are similar: 26.39, 26.39, 26.01, 25.85 with a mean of 26.16 (σ = 0.27).The variant without mask scoring achieved 26.03, 25.99, 25.99 max mask API (mean 26.00, σ = 0.02) -that is, an order of magnitude smaller variance, but at the expense of slower convergence and lower metrics value.
Interestingly, for the model with the mask scoring head, without the last run, the mean would be 26.26(σ = 0.22).While it seems that the last run missed the local optima and much of the per-step variance can be attributed to it, we report all the obtained results for scientific integrity.The high variance might suggest that another hyperparameter should be introduced (e.g.mask scoring head weight) or learning rate should be readjusted.

SUMMARY
We presented Polite Teacher, a simple and effective architecture for semi-supervised instance segmentation.Tested with a CenterMask, a single-stage detector, our approach yielded approx.+8 pp.mask AP on different supervision regimes with COCO 2017, while it introduces only three hyperparameters to tune.A certain limitation of this study is the lack of validation on other datasets.
Similarly, more single-stage detectors, as well as two-stage detectors can be taken into consideration.For more robust evaluation results, several runs of the experiments to explore variance on different values of supervision might be carried out.Therefore, future work should consider validating methods with more detectors, backbones and datasets.Providing a direct comparison with Noisy Boundaries (Wang et al., 2022) might be considered as well.A natural next step would consider taking pseudo-bounding boxes and pseudo-centre-ness regression into account.

Figure 2 :
Figure 2: Qualitative Polite Teacher results on COCO 2017 val with different supervision regimes.

Table 1 :
Results with ResNet50 backbone.Oracle results reported by
Results for experiments controlled for different hyperparameters values in the 5% supervision regime (see Section 4.3, as well as Table2, 3, and 4).

Table 4 :
Influence of mask scoring filtering threshold.