Home

Awesome

A<sup>2</sup>U Matting

<p align="center"> <img src="example.png" width="800" title="Example"/> </p>

The official repository for paper:

Learning Affinity-Aware Upsampling for Deep Image Matting, CVPR2021

Prerequisite

git clone https://github.com/dongdong93/a2u_matting.git
cd a2u_matting/scripts
git clone https://github.com/mapillary/inplace_abn.git
cd inplace_abn
python setup.py install
cd ../Biupdownsample
python setup.py develop

Installation

Our code has been tested on Python 3.6, Pytorch 1.3.1, CUDA 10.0 (inplace_abn only supports CUDA>=10.0). See other required packages in requirements.txt.

Demo

sh demo.sh

Our model trained on the Adobe Image Matting dataset can be downloaded from:

ModelSADMSEGradConnconfig
Ours32.100.007816.3329.00./config/adobe.yaml

Disclaimer:

Another pretrained model on the Adobe Image Matting dataset with 'unshare' setting can be downloaded from:

ModelSADMSEGradConnconfig
Ours-unshare31.870.007514.2529.17./config/adobe_unshare.yaml

As covered by ADOBE IMAGE MATTNG DATASET LICENSE AGREEMENT, the trained models included in this repository can only be used/distributed for non-commercial purposes.

Training

Data Preparation

$PATH_TO_DATASET/Combined_Dataset
├──── Training_set
│    ├──── alpha (431 images)
│    ├──── fg (431 images)
│    └──── train2014 (82783 images)
├──── Test_set
│    ├──── alpha (50 images)
│    ├──── merged (1000 images)
│    └──── trimaps (1000 images)

Backbone

Download the pretrained ResNet34 from here and save to ./pretrained. (It will be automatically downloaded)

Train your model

sh train.sh

Models will be saved to ./savemodel by default. FYI, it can be trained with 2 1080Ti using the provided config files.

Inference

sh test.sh

Results will be saved to ./results by default. Quantitative metrics should be measured by matlab_testcode/test_withpic.m. The python version is for reference only.

Citation

If you find this work or code useful for your research, please consider citing:

@inproceedings{dai2021learning,
  title={Learning Affinity-Aware Upsampling for Deep Image Matting},
  author={Dai, Yutong and Lu, Hao and Shen, Chunhua},
  booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  pages={6841--6850},
  year={2021}
}

References

IndexNet Matting

GCA Matting

CARAFE

Contact

yutong.dai@adelaide.edu.au