Contrastive Multi-Task Dense Prediction

Siwei Yang, Hanrong Ye, Dan Xu

Dense prediction tasks in computer vision—such as semantic segmentation, depth estimation, and surface normal prediction—require per-pixel labels. While training separate models for each task is common, Multi-Task Learning (MTL) offers a more efficient alternative by sharing a single backbone. However, effectively modeling the relationships between these tasks often necessitates complex, computationally expensive architectural modules that slow down inference.

A recent AAAI-2023 paper, "Contrastive Multi-Task Dense Prediction," introduces a novel approach to capture cross-task interactions during training without any added cost during inference.

Cross-task Contrastive Regularization (CCR)

The authors propose Cross-task Contrastive Regularization (CCR), a method that leverages contrastive learning to enforce feature consistency across tasks. The core idea is that features representing the same semantic object should be more similar across different task heads than features representing different objects.

The CCR framework integrates a contrastive regularization module during training, which is discarded during inference to maintain efficiency.

Unlike traditional methods that use attention mechanisms or affinity maps—which must be computed at runtime—CCR acts as a loss-based regularizer. It uses a triplet loss to pull "positive" pixel pairs (same category/attribute) together and push "negative" pairs (different category/attribute) apart in a shared feature space.

Technical Innovations: Sampling and Continuous Labels

Implementing contrastive learning for dense prediction presents two main challenges: the high number of pixels and the presence of continuous labels (like depth).

Handling Continuous Labels

While discrete labels (e.g., semantic classes) easily define positive and negative pairs, continuous labels do not. The authors introduced a top-k strategy: for a given anchor pixel in a continuous task, pixels with the smallest attribute distances are treated as positives, while those with the largest distances are negatives.

Semi-Hard Pixel Sampling

To ensure training stability and efficiency, the model does not compare every pixel. Instead, it employs a sampling strategy to identify "hard" positives and "semi-hard" negatives, providing the most informative gradient signals for the triplet loss.

The CCR module uses specific sampling strategies for both discrete and continuous ground truth (GT) to define anchor, positive, and negative pairs.

Performance and Efficiency

The CCR method was evaluated on the NYUD-v2 and Pascal-Context benchmarks, setting new state-of-the-art (SOTA) records.

  • NYUD-v2: CCR outperformed the previous leading model, InvPT, across segmentation, depth, and surface normal tasks.
  • Pascal-Context: The model achieved a significant 80.23 mIoU in semantic segmentation.
  • The "Free Lunch": Because the CCR module and its associated projectors are only used during training, the final model retains the inference speed of a standard multi-task baseline. In ablation studies, CCR improved the multi-task performance metric ($\Delta_m$) from -2.02% to +2.10%, effectively turning a performance penalty into a gain.

Conclusion

By treating cross-task interaction as a regularization problem rather than an architectural one, the authors have provided a "free lunch" for multi-task dense prediction. CCR allows models to learn rich, inter-task relationships implicitly, resulting in superior accuracy with zero additional computational overhead during deployment.

Reference: Yang, S., Ye, H., & Xu, D. (2023). Contrastive Multi-Task Dense Prediction. Proceedings of the AAAI Conference on Artificial Intelligence.

Summary updated

BibTeX
@inproceedings{yang2023contrastive,
  author = {Siwei Yang and Hanrong Ye and Dan Xu},
  title = {{Contrastive Multi-Task Dense Prediction}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2023},
  doi = {10.1609/aaai.v37i3.25424},
}
Figure