CP2: Copy-Paste Contrastive Pretraining for Semantic Segmentation

Feng Wang, Huiyu Wang, Chen Wei, Alan L. Yuille, Wei Shen

Introduction

Self-supervised learning (SSL) has revolutionized computer vision, with methods like MoCo and SimCLR achieving remarkable results on image-level classification. However, a significant performance gap remains when transferring these models to dense prediction tasks like semantic segmentation. Standard SSL methods typically focus on global image representations, often neglecting the spatial nuances required to distinguish individual pixels.

The authors of CP2 identify two primary challenges:

  1. Spatial Neglect: Traditional SSL assumes a single label for an entire image, ignoring internal spatial variance.
  2. Architectural Misalignment: Backbones pretrained for classification often use different strides or dilated convolutions compared to segmentation models. Furthermore, randomly initialized segmentation heads can introduce "poisonous" gradients that degrade the pretrained backbone during early finetuning.

Methodology: The CP2 Framework

To address these issues, the researchers propose Copy-Paste Contrastive Pretraining (CP2). This framework optimizes models specifically for dense prediction by bridging the gap between image-level and pixel-level understanding.

The CP2 framework utilizes a copy-paste mechanism and dual-loss objective to align features for segmentation.

The Copy-Paste Mechanism

The core of CP2 is a data augmentation strategy where a random crop (the "foreground") from one image is pasted onto two different "background" images. This creates two distinct views that share the same foreground object but have entirely different contexts. This synthetic composition provides a "pseudo-ground truth" for spatial awareness without requiring manual annotations.

Dual-Loss Objective

The model is trained using a combination of two losses:

  • Dense Contrastive Loss ($L_{dense}$): Operates at the pixel level, forcing foreground pixel features to be similar across views while distinguishing them from background features.
  • Instance Contrastive Loss ($L_{ins}$): Operates at the object level by using masked pooling to create a global representation of the foreground, which is then compared against a memory bank of other instances.

Quick Tuning

A key practical innovation is Quick Tuning. Instead of exhaustive pretraining, CP2 can be used to "warm up" a segmentation model (both backbone and head) that has already been pretrained for classification. By tuning for a short period (e.g., 20 epochs), the model adapts to the dense prediction architecture, preventing the performance drop typically seen when adding a random head.

Experimental Setup

The framework was evaluated using the following datasets:

  • Pretraining: ImageNet-1k (unlabeled).
  • Evaluation: PASCAL VOC 2012, Cityscapes, and ADE20k.

Results and Key Insights

CP2 demonstrates significant improvements over classification-oriented baselines. On PASCAL VOC, a ResNet-50 backbone with CP2 achieved 78.6% mIoU, a +2.7% improvement over MoCo v2.

Performance comparison showing the impact of Quick Tuning on mIoU across different training epochs.

The "Quick Tuning" approach proved exceptionally efficient. Adding just 20 epochs of CP2 to an 800-epoch MoCo v2 model yielded a 1.4% mIoU gain on VOC, outperforming other dense-prediction SSL models that require much longer training cycles.

Key Takeaways:

  • Head Pretraining is Crucial: Pretraining the segmentation head alongside the backbone mitigates architectural misalignment.
  • Synthetic Supervision Works: Simple copy-paste operations provide enough spatial signal to learn robust dense features.
  • Efficiency: CP2 offers a high-performance-to-compute ratio through its Quick Tuning capability.

Conclusion and Future Work

While CP2 sets a new benchmark for self-supervised segmentation, some limitations remain. The use of simple rectangular masks suggests that the learned foreground representations are still somewhat idealized. Future research could explore more complex image composition techniques to better handle cluttered scenes. Nonetheless, CP2 provides a powerful and efficient bridge for transferring SSL models to the domain of semantic segmentation.

Summary updated

BibTeX
@inproceedings{wang2022cp,
  author = {Feng Wang and Huiyu Wang and Chen Wei and Alan L. Yuille and Wei Shen},
  title = {{CP2: Copy-Paste Contrastive Pretraining for Semantic Segmentation}},
  booktitle = {European Conference on Computer Vision},
  year = {2022},
  doi = {10.1007/978-3-031-20056-4\_29},
}
Figure