zijundeng / DANet

Dual Attention Network for Scene Segmentation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dual Attention Network for Scene Segmentation

Introduction

We propose a Dual Attention Network (DANet) to adaptively integrate local features with their global dependencies based on the self-attention mechanism. And we achieve new state-of-the-art segmentation performance on three challenging scene segmentation datasets, i.e., Cityscapes, PASCAL Context and COCO Stuff-10k dataset.

image

Cityscapes testing set result

We train our DANet-101 with only fine annotated data and submit our test results to the official evaluation server.

image

Usage

  1. Install pytorch
  1. Clone the repository:

    git clone https://github.com/junfu1115/DANet.git 
    cd DANet 
    python setup.py install
  2. Dataset

  • Download the Cityscapes dataset and convert the dataset to 19 categories.
  • Please put dataset in folder ./datasets
  1. Evaluation
  • Download trained model DANet101 and put it in folder ./danet/cityscapes/model

  • Evaluation code is in folder ./danet/cityscapes

  • cd danet

  • For single scale testing, please run:

CUDA_VISIBLE_DEVICES=0,1,2,3 python test.py --dataset cityscapes --model danet --resume-dir cityscapes/model --base-size 2048 --crop-size 768 --workers 1 --backbone resnet101 --multi-grid --multi-dilation 4 8 16 --eval
  • For multi-scale testing, please run:
CUDA_VISIBLE_DEVICES=0,1,2,3 python test.py --dataset cityscapes --model danet --resume-dir cityscapes/model --base-size 2048 --crop-size 1024 --workers 1 --backbone resnet101 --multi-grid --multi-dilation 4 8 16 --eval --multi-scales
  • If you want to visualize the result of DAN-101, you can run:
CUDA_VISIBLE_DEVICES=0,1,2,3 python test.py --dataset cityscapes --model danet --resume-dir cityscapes/model --base-size 2048 --crop-size 768 --workers 1 --backbone resnet101 --multi-grid --multi-dilation 4 8 16
  1. Result:

    The expected scores will show as follows:

    (single scale testing denotes as 'ss' and multiple scale testing denotes as 'ms')

    DANet101 on cityscapes val set (mIoU/pAcc): 79.93/95.97 (ss) and 81.49/96.41 (ms)

We will release the code for training in the next few days!

Citation

If DANet is useful for your research, please consider citing:

@article{fu2018dual,
  title={Dual Attention Network for Scene Segmentation},
  author={Fu, Jun and Liu, Jing and Tian, Haijie, and Fang, Zhiwei, and Lu, Hanqing},
  journal={arXiv preprint arXiv:1809.02983},
  year={2018}
}

Acknowledgement

Thanks PyTorch-Encoding, especially the Synchronized BN!

About

Dual Attention Network for Scene Segmentation

License:Other


Languages

Language:Python 80.1%Language:Cuda 12.2%Language:C++ 7.5%Language:Shell 0.1%Language:Makefile 0.1%