Home

Awesome

Learning Mask-aware CLIP Representations for Zero-Shot Segmentation

PWC PWC PWC PWC PWC

This is the official implementation of our conference paper : "Learning Mask-aware CLIP Representations for Zero-Shot Segmentation" (NeurIPS 2023).

:fire: News: Our paper MAFT+ is accepted to ECCV 2024 oral!

<div align="center"> <img src="resources/vis1-720.gif" width="48%"> <img src="resources/vis2-720.gif" width="48%"> </div>

Introduction

Recently, pre-trained vision-language models have been increasingly used to tackle the challenging zero-shot segmentation task. To maintain the CLIP's zero-shot transferability, previous practices favour to freeze CLIP during training. However, in the paper, we reveal that CLIP is insensitive to different mask proposals and tends to produce similar predictions for various mask proposals of the same image. This issue mainly relates to the fact that CLIP is trained with image-level supervision. To alleviate this issue, we propose a simple yet effective method, named Mask-aware Fine-tuning (MAFT). Specifically, Image-Proposals CLIP Encoder (IP-CLIP Encoder) is proposed to handle arbitrary numbers of image and mask proposals simultaneously. Then, mask-aware loss and self-distillation loss are designed to fine-tune IP-CLIP Encoder, ensuring CLIP is responsive to different mask proposals while not sacrificing transferability. In this way, mask-aware representations can be easily learned to make the true positives stand out. Notably, our solution can seamlessly plug into most existing methods without introducing any new parameters during the fine-tuning process.

Tab of Content

<span id="6"></span>

Installation

  1. Clone the repository
    git clone https://github.com/jiaosiyu1999/MAFT.git
    
  2. Navigate to the project directory
    cd MAFT
    
  3. Install the dependencies
    bash install.sh
    cd freeseg/modeling/heads/ops
    sh make.sh
    

<span id="2"></span>

Data Preparation

See Preparing Datasets for MAFT. The data should be organized like:

datasets/
  ade/
      ADEChallengeData2016/
        images/
        annotations_detectron2/
      ADE20K_2021_17_01/
        images/
        annotations_detectron2/
  coco/
        train2017/
        val2017/
        stuffthingmaps_detectron2/
  VOCdevkit/
     VOC2012/
        images_detectron2/
        annotations_ovs/      
    VOC2010/
        images/
        annotations_detectron2_ovs/
            pc59_val/
            pc459_val/      

<span id="3"></span>

Usage

<span id="5"></span>

  1. step1 train an existing "froen CLIP" network, e.g., FreeSeg:
    python train_net.py --config-file configs/coco-stuff-164k-156/mask2former_freeseg.yaml --num-gpus 4 
  1. step2 Fine-tune CLIP Image Encoder with MAFT: (Note: the the step1 model should be load.)
   python train_net.py --config-file configs/coco-stuff-164k-156/mask2former_maft.yaml --num-gpus 4

<span id="6"></span>

Cite

If you find it helpful, you can cite our paper in your work.

@inproceedings{jiao2023learning,
  title={Learning Mask-aware CLIP Representations for Zero-Shot Segmentation},
  author={Jiao, Siyu and Wei, Yunchao and Wang, Yaowei and Zhao, Yao and Shi, Humphrey},
  booktitle={Thirty-seventh Conference on Neural Information Processing Systems},
  year={2023}
}