kdwonn / SaG

Official repository of the "Shatter and Gather: Learning Referring Image Segmentation with Text Supervision (ICCV'23)"
https://southflame.github.io/sag/
32 stars 2 forks source link
iccv2023 referring-image-segmentation shatter-and-gather weakly-supervised-learning

Shatter and Gather: Learning Referring Image Segmentation with Text Supervision

arXiv Badge

plot

This repository contains the official source code for our paper:

Shatter and Gather: Learning Referring Image Segmentation with Text Supervision Dongwon Kim1, Namyup Kim1, Cuiling Lan2, and Suha Kwak1
1POSTECH CSE, 2Microsoft Research Asia
ICCV, Paris, 2023.

Dataset setup

Setting

Data preparation

python build_batches.py -d Gref -t train 
python build_batches.py -d Gref -t val 
python build_batches.py -d unc -t train 
python build_batches.py -d unc -t val 
python build_batches.py -d unc -t testA 
python build_batches.py -d unc -t testB 
python build_batches.py -d unc+ -t train 
python build_batches.py -d unc+ -t val 
python build_batches.py -d unc+ -t testA 
python build_batches.py -d unc+ -t testB 

Final ./data directory structure

./data
├─ refcoco
│   ├─ Gref
│   │   ├─ train_batch
│   │   │   ├─ Gref_train_0.npz
│   │   │   ├─ Gref_train_1.npz
│   │   │   └─ ...
│   │   ├─ train_image
│   │   ├─ train_label
│   │   ├─ val_batch
│   │   ├─ val_image
│   │   └─ val_label
│   ├─ unc
│   │   └─ ...
│   └─ unc+
│       └─ ...
├─ phrasecut
│   └─ images
│      ├─ refer_train_ris.json
│      ├─ refer_val_ris.json
│      └─  refer_test_ris.json
├─ Gref_emb.npy
├─ referit_emb.npy
├─ vocabulary_Gref.txt
└─ vocabulary_referit.txt

Environment setup

Instructions:

conda create -n sag python=3.10 -y
conda activate sag
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu11
pip install einops tqdm wandb transformers
pip install matplotlib timm opencv-python

Train & eval

sh ./train_eval_gref.sh # Gref
sh ./train_eval_unc.sh # UNC
sh ./train_eval_unc+.sh # UNC+

Acknowledgement

Parts of our codes are adopted from the following repositories.

Dataset Setup instruction is from TF-phrasecut-public repository.