{'fraction_non_alphanumeric': 0.03207766990291262, 'fraction_numerical': 0.00916504854368932, 'mean_word_length': 4.9694019471488176, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Improving Semantic Segmentation through Spatio-Temporal Consistency Learned from Videos

We leverage unsupervised learning of depth, egomotion, and camera intrinsics to improve the performance of single-image semantic segmentation, by enforcing 3D-geometric and temporal consistency of segmentation masks across video frames. The predicted depth, egomotion, and camera intrinsics are used to provide an additional supervision signal to the segmentation model, significantly enhancing its quality, or, alternatively, reducing the number of labels the segmentation model needs. Our experiments were performed on the ScanNet dataset.


Introduction
The computer vision community has seen immense progress in solving a variety of semantic image understanding tasks, such as classification and segmentation. Typically, a deep convolutional network learns to predict labels from pixels, remaining mostly unaware of the geometric and physical constraints that govern the visual world.
Learning from video streams, as opposed to images, offers temporal coherency as a strong cue that can significantly enhance segmentation. These cues are often utilized [12] through dedicated network architectures, capable of both segmenting and correlating objects in time.
3D Multiview consistency is another cue, shown [6,10] to improve semantic segmentation, both as an additional supervision signal to train a single-frame segmenter, and as an additional signal at multi-frame inference time. However, these methods generally require RGBD inputs.
Recent advances in unsupervised depth and egomotion estimation can bring together temporal continuity and multiview consistency as supervision signals for improving segmentation models. A depth prediction model can transform  video sequences to RGBD sequences, correspondences between pixels in neighboring frames can be established, and consistency in segmentation mask across corresponding pixels can be used as a supervision signal. Together with the recently-demonstrated [5] ability to learn the camera intrinsics from unlabeled videos, depth and egomotion prediction networks facilitate adapting techniques that were previously reserved to RGBD input to general unlabeled video.
In this work, we demonstrate the effectiveness of 4D consistency constraints (that is, 3D multiview consistency alongside with temporal continuity) in providing an additional supervision signal for a semantic segmentation task. The latter is trained in a semi-supervised manner, that is, with only a small fraction of the segmentation labels used, whereas the depth, motion and intrinsics models needed for asserting the 4D consistency are trained fully unsupervised. By only using previously-published off-the-shelf networks, we demonstrate that our approach does not require any network architecture tuning, lending itself to future improvements by upgrading the respective models as they become available. The focus of our study can be summarized in three questions: 1. How to construct a training objective that enforces spatio-temporal consistency? 2. How much improvement can the spatio-temporal (4D) consistency constraints provide when training a singleimage semantic segmentation model? 3. How many labels can the consistency constraints replace? The study is performed on the ScanNet [2] dataset.

Related Work
The advantages of learning geometric and semantic tasks jointly have been long recognized [3,13,15]. Eigen and Fergus [3] are among the first to exploit relations between geometry and semantics by learning them jointly. Their work provides empirical evidence for performance improvement when optimizing depth and semantics jointly. Right-left geometric consistency has been used to improve semantic segmentation in a stereo setting [1,8]. Optical flow has been used to improve the temporal consistency of segmentation masks [7,11]. To the best of our knowledge, this work is the first attempt at improving single-image segmentation by employing spatio-temporal consistency using unsupervised depth, egomotion, and camera intrinsics estimates learned from videos.

Method
In this section we discuss the formulation of consistency losses that are based on the idea of self-supervision and the design does not assume access to any task specific supervision. We start with a pair of consecutive images from a video, I t and I t+1 . We have access to the models for depth estimation, camera motion estimation, and semantic segmentation: ∆(·), Ω(·, ·), and Σ(·) respectively. We first estimate the depth d t = ∆(I t ) and the camera motion, i.e., 3D rotation and translation, M t,t+1 = Ω(I t , I t+1 ). Simultaneously, the segmentation model generates the logits masks, L t = Σ(I t ) and L t+1 = Σ(I t+1 ). Using the depth and motion estimates we have a differentiable warping function, ω(·, ·, ·) that gives us an estimated transformation function from I t to I t+1 . We thus have an additional estimate for the logits maskL t+1 = ω(L t , d t , M t,t+1 ). An overview of the proposed method is presented in fig. 1. Now, we employ consistency between the propagated logits mask,L t+1 , and the predicted logits mask, L t+1 . Note that the proposed loss formulation will hold for the backward consistency constraint betweenL t and L t as well, where x is the pixel index in 2D space, c is the class index, W (·, ·) is the normalized weight for the L1 difference as a function of pixel location and class label. We use a combination of 3 different formulations of the weighing function with the respective weights as 0.2, 0.4, and 0.4. 1. Uniform: Mean of the difference, where W (x, c) is constant across both pixel and class indices in the mask. 2. Label prior: Uniform averaging fails to differentiate between the classes that actually appear in the image from those that don't, whereas it is more reasonable to have a higher penalty for the inconsistencies in the former.
Since we do not have the groundtruth labels we useŷ t+1 as a belief for the same and set W (x, ·) = 1ŷ t+1(x) , where 1ŷ t+1(x) is a one-hot vector of the length same as the number of classes with 1 at indexŷ t+1 (x), and y t+1 = argmax(L t+1 ) along the class index axis. 3. Pixel prior: Here, the weight is constant across different classes while the inconsistencies for edge pixels are penalized more than the others. Here, W (·, c) = E(I t+1 ) ∀ c, where E(I t+1 ) is the two-dimensional edge detector output for the image, with one for pixel locations corresponding to the edges.

Models
All models trained in our experiments -depth prediction, egomotion prediction, and semantic segmentation -were taken from other publications, using their respective opensourced code, along with their tuned optimization hyperparameter settings. This choice allows gauging the quality improvements associated with imposing consistency constraints, as opposed to architectural improvements. By applying the consistency constraints in an architectureagnostic manner, we leave an open route to further improvements, by simply replacing the comprising models by better ones, as they become available in the literature. For semantic segmentation we use the NAS-FPN [4] as the backbone architecture with the segmentation classifier design as proposed by Kirillov et al. [9]. For the prediction of depth, egomotion, and camera intrinsics we use the models from Ref. [5]. Both the off-the-shelf models we use are recently proposed, strong models attaining the state of the art performance in the respective tasks.

Dataset
We use ScanNet [2], a dataset of indoor RGB-D video sequences. It consists of 2.5M views across 1500 scans. All the frames in a video sequence are labeled for semantic segmentation masks across 21 classes including a background class. The annotations were obtained by rendering the 3D scans from the sequence of 2D images to get 1500 3D scans. These 3D scans were then manually annotated for segmentation and were projected back to 2D. This is a good dataset  for the proof of concept evaluation of our method as it gives a handle to freely control the available supervision to create an artificial limited supervision setting.

Key Results
The effect of spatio-temporal consistency on the segmentation performance is summarized in Table 1. The fraction of labels used for training is varied from 0.1% to 4%, where the rest of the images were stripped of their labels and only used for imposing spatio-temporal consistency. At or above 4% supervision, we observe a mean intersection over union (MIOU) of 51.1% 1 . For each case, the supervised baseline model is obtained by training the single-image segmentation model on the respective labeled data. The MIOU of the resulting baseline model is summarized in the second row of Table 1. Depth, egomotion, and camera instrinsics models were trained separately, unsupervised, on the entire Scan-Net training dataset. Then the consistency loss in Eq. 1 was switched on as an additional supervision signal for the segmentation model, and the latter continued to train, achieving the MIOU values summarized in the third row of Table 1. We notice that the proposed approach gives consistent improvements across the range of supervision. Higher relative improvements are observed at lower supervision.
Additionally, it is meaningful to analyze the effect of consistency as an alternative to direct supervision. Indeed, supervision obtained through consistency constraints can mimic an increase in the number of labels by up to a factor of four: The baseline MIOU at 2% supervision (49.1%) matches the MIOU with only quarter as much labeled data (49.4%) with the proposed approach. Fig. 2 presents the relative improvement in per-class MIOU for the 0.1% baseline when trained with the proposed consistency constraints. We observe that the relative improvement in the MIOU tends to be the highest for the rarest labels, especially those that are only 5% frequent or Relative improvement (%)   refrigerator  other  picture  bookshelf  counter  chair  curtain  background  showercurtain  floor  toilet   bed  sink  cabinet  window  table  desk  bathtub  door wall sofa  lesser. The spatio-temporal consistency constraints effectively augment the training labels to include more instances of each label. This naturally leads to improved performance for especially less frequent labels. Fig. 3 demonstrates two such examples where the best baseline fails to identify masks for rare labels, "door" and "picture", whereas the proposed consistency-based approach trained with 40 times less direct supervision is able to accurately label the corresponding pixels. The examples also show that the predictions for the proposed model are smoother across pixels corresponding to a particular object with hardly any fragmentation artifacts.  the last two rows of the table are added for reference where the logits are used to generate the pseudo labels. These pseudo labels are then used to train the warped logits using the cross-entropy loss CE = CE(L t+1 ,ŷ t+1 ). We see that this straight-forward approach based on the hard decision on predictions is not nearly as good as the proposed averaging method to impose the consistency.

Ablation Study of consistency constraints
In all the experiments above, the depth, egomotion, and camera intrinsics models supervised the segmentation model via spatio-temporal consistency losses, but not the other way around. Allowing the segmentation model to supervise the other models resulted in no significant improvement in the depth estimation error. While such improvements were observed in prior work [5], they were attributed to the ability of segmentation to identify moving objects. This ability is irrelevant to ScanNet's static scenes. The analyses and the ablation studies presented in this section were done on the 0.1% supervision case.

Conclusion
In this work, we used models predicting depth, egomotion, and camera intrinsics, to provide additional supervision to a semantic segmentation model through spatiotemporal consistency constraints. The latter were shown to reduce the need for direct supervision by a factor of up to four. Enhancement in semantic segmentation performance was observed, especially for the less frequent labels. All models were adopted from prior publications, through our approach that is network-architecture-agnostic.
The method proposed in this work can be readily extended to dynamic scenes. Rather than only estimating camera motion, dynamic scenes require the estimation of 3D object motion relative to the scene. It has been previously shown [5] that segmentation can provide a regularization for 3D motion estimation. The consistency losses developed in this study can provide supervision from the depth and motion model to the segmentation model, closing the loop on the three models, depth, 3D motion and segmentation, peersupervising each other.