Skip to main content
QUICK REVIEW

[Paper Review] SAM-CLIP: Merging Vision Foundation Models towards Semantic and Spatial Understanding

Haoxiang Wang, Pavan Kumar Anasosalu Vasu|arXiv (Cornell University)|Oct 23, 2023
Domain Adaptation and Few-Shot LearningComputer Science13 citations
TL;DR

SAM-CLIP merges SAM and CLIP into a single ViT backbone via multi-task distillation with replay, achieving zero-shot classification, instance segmentation, and state-of-the-art zero-shot semantic segmentation with reduced memory and compute.

ABSTRACT

The landscape of publicly available vision foundation models (VFMs), such as CLIP and Segment Anything Model (SAM), is expanding rapidly. VFMs are endowed with distinct capabilities stemming from their pre-training objectives. For instance, CLIP excels in semantic understanding, while SAM specializes in spatial understanding for segmentation. In this work, we introduce a simple recipe to efficiently merge VFMs into a unified model that absorbs their expertise. Our method integrates techniques of multi-task learning, continual learning, and distillation. Further, it demands significantly less computational cost compared to traditional multi-task training from scratch, and it only needs a small fraction of the pre-training datasets that were initially used to train individual models. By applying our method to SAM and CLIP, we obtain SAM-CLIP: a unified model that combines the capabilities of SAM and CLIP into a single vision transformer. Compared with deploying SAM and CLIP independently, our merged model, SAM-CLIP, reduces storage and compute costs for inference, making it well-suited for edge device applications. We show that SAM-CLIP not only retains the foundational strengths of SAM and CLIP, but also introduces synergistic functionalities, notably in zero-shot semantic segmentation, where SAM-CLIP establishes new state-of-the-art results on 5 benchmarks. It outperforms previous models that are specifically designed for this task by a large margin, including +6.8% and +5.9% mean IoU improvement on Pascal-VOC and COCO-Stuff datasets, respectively.

Motivation & Objective

  • Motivate merging vision foundation models to combine semantic and spatial understanding.
  • Propose an efficient, rehearsal-based distillation method to merge VFMs with minimal forgetting.
  • Demonstrate SAM-CLIP as a single backbone enabling zero-shot classification, instance segmentation, and semantic segmentation.
  • Show that the merged model yields richer representations and new zero-shot capabilities.
  • Assess edge-device suitability through reduced storage and compute needs.

Proposed method

  • Use SAM as base VFM and merge CLIP into its backbone with a multi-head architecture.
  • Apply two-stage training: head probing of the CLIP head, then multi-task distillation with replay data.
  • Distill CLIP and SAM knowledge via KL-type cosine loss and a SAM-specific distillation loss on replay datasets.
  • Freeze non-image modality encoders while allowing the image backbone and heads to learn with reduced learning rates to prevent forgetting.
  • Utilize a two-dataset replay strategy: D_CLIP for CLIP distillation and D_SAM for SAM distillation, with joint optimization L_CLIP + lambda L_SAM.
  • Adopt a two-resolution strategy and resolution adaptation to align CLIP (lower res) and SAM (1024px) training.
  • Present an inference pipeline where a single backbone supports classification, instance segmentation, and semantic segmentation.

Experimental results

Research questions

  • RQ1Can two disparate vision foundation models (SAM and CLIP) be merged into a single backbone without catastrophic forgetting?
  • RQ2Does a rehearsal-based multi-task distillation approach effectively transfer knowledge and preserve original capabilities?
  • RQ3Does SAM-CLIP enable zero-shot semantic segmentation and surpass task-specific models on multiple benchmarks?
  • RQ4Is the merged model more storage- and compute-efficient for edge devices compared to deploying SAM and CLIP separately?
  • RQ5What representations emerge from the merged model and how do they support downstream tasks?

Key findings

  • SAM-CLIP preserves core zero-shot capabilities of both SAM and CLIP with minimal forgetting.
  • The merged model achieves competitive zero-shot classification and instance segmentation results compared to baseline VFMs.
  • SAM-CLIP yields state-of-the-art performance on zero-shot semantic segmentation across five datasets.
  • Head-probing shows SAM-CLIP representations are richer for both semantic and spatial tasks than either SAM or CLIP alone.
  • Resolution-adaptive training enables CLIP-style tasks at 224/336/448px while SAM tasks operate at 1024px.
  • Composing CLIP and SAM heads within SAM-CLIP can further improve zero-shot segmentation quality.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.