Home

Awesome

GCNet for Object Detection

PWC PWC PWC PWC

By Yue Cao, Jiarui Xu, Stephen Lin, Fangyun Wei, Han Hu.

This repo is a official implementation of "GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond" on COCO object detection based on open-mmlab's mmdetection. The core operator GC block could be find here. Many thanks to mmdetection for their simple and clean framework.

Update on 2020/12/07

The extension of GCNet got accepted by TPAMI (PDF).

Update on 2019/10/28

GCNet won the Best Paper Award at ICCV 2019 Neural Architects Workshop!

Update on 2019/07/01

The code is refactored. More results are provided and all configs could be found in configs/gcnet.

Notes: Both PyTorch official SyncBN and Apex SyncBN have some stability issues. During training, mAP may drops to zero and back to normal during last few epochs.

Update on 2019/06/03

GCNet is supported by the official mmdetection repo here. Thanks again for open-mmlab's work on open source projects.

Introduction

GCNet is initially described in arxiv. Via absorbing advantages of Non-Local Networks (NLNet) and Squeeze-Excitation Networks (SENet), GCNet provides a simple, fast and effective approach for global context modeling, which generally outperforms both NLNet and SENet on major benchmarks for various recognition tasks.

Citing GCNet

@article{cao2019GCNet,
  title={GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond},
  author={Cao, Yue and Xu, Jiarui and Lin, Stephen and Wei, Fangyun and Hu, Han},
  journal={arXiv preprint arXiv:1904.11492},
  year={2019}
}

Main Results

Results on R50-FPN with backbone (fixBN)

Back-boneModelBack-bone NormHeadsContextLr schdMem (GB)Train time (s/iter)Inf time (fps)box APmask APDownload
R50-FPNMaskfixBN2fc (w/o BN)-1x3.90.45310.637.334.2model
R50-FPNMaskfixBN2fc (w/o BN)GC(c3-c5, r16)1x4.50.53310.138.535.1model
R50-FPNMaskfixBN2fc (w/o BN)GC(c3-c5, r4)1x4.60.5339.938.935.5model
R50-FPNMaskfixBN2fc (w/o BN)-2x---38.234.9model
R50-FPNMaskfixBN2fc (w/o BN)GC(c3-c5, r16)2x---39.736.1model
R50-FPNMaskfixBN2fc (w/o BN)GC(c3-c5, r4)2x---40.036.2model

Results on R50-FPN with backbone (syncBN)

Back-boneModelBack-bone NormHeadsContextLr schdMem (GB)Train time (s/iter)Inf time (fps)box APmask APDownload
R50-FPNMaskSyncBN2fc (w/o BN)-1x3.90.54310.237.233.8model
R50-FPNMaskSyncBN2fc (w/o BN)GC(c3-c5, r16)1x4.50.5479.939.435.7model
R50-FPNMaskSyncBN2fc (w/o BN)GC(c3-c5, r4)1x4.60.6039.439.936.2model
R50-FPNMaskSyncBN2fc (w/o BN)-2x3.90.54310.237.734.3model
R50-FPNMaskSyncBN2fc (w/o BN)GC(c3-c5, r16)2x4.50.5479.939.736.0model
R50-FPNMaskSyncBN2fc (w/o BN)GC(c3-c5, r4)2x4.60.6039.440.236.3model
R50-FPNMaskSyncBN4conv1fc (SyncBN)-1x---38.834.6model
R50-FPNMaskSyncBN4conv1fc (SyncBN)GC(c3-c5, r16)1x---41.036.5model
R50-FPNMaskSyncBN4conv1fc (SyncBN)GC(c3-c5, r4)1x---41.437.0model

Results on stronger backbones

Back-boneModelBack-bone NormHeadsContextLr schdMem (GB)Train time (s/iter)Inf time (fps)box APmask APDownload
R101-FPNMaskfixBN2fc (w/o BN)-1x5.80.5719.539.435.9model
R101-FPNMaskfixBN2fc (w/o BN)GC(c3-c5, r16)1x7.00.7318.640.837.0model
R101-FPNMaskfixBN2fc (w/o BN)GC(c3-c5, r4)1x7.10.7478.640.836.9model
R101-FPNMaskSyncBN2fc (w/o BN)-1x5.80.6659.239.836.0model
R101-FPNMaskSyncBN2fc (w/o BN)GC(c3-c5, r16)1x7.00.7789.041.137.4model
R101-FPNMaskSyncBN2fc (w/o BN)GC(c3-c5, r4)1x7.10.7868.941.737.6model
X101-FPNMaskSyncBN2fc (w/o BN)-1x7.10.9128.541.237.3model
X101-FPNMaskSyncBN2fc (w/o BN)GC(c3-c5, r16)1x8.21.0557.742.438.0model
X101-FPNMaskSyncBN2fc (w/o BN)GC(c3-c5, r4)1x8.31.0377.642.938.5model
X101-FPNCascade MaskSyncBN2fc (w/o BN)-1x---44.738.3model
X101-FPNCascade MaskSyncBN2fc (w/o BN)GC(c3-c5, r16)1x---45.939.3model
X101-FPNCascade MaskSyncBN2fc (w/o BN)GC(c3-c5, r4)1x---46.539.7model
X101-FPNDCN Cascade MaskSyncBN2fc (w/o BN)-1x---47.140.4model
X101-FPNDCN Cascade MaskSyncBN2fc (w/o BN)GC(c3-c5, r16)1x---47.940.9model
X101-FPNDCN Cascade MaskSyncBN2fc (w/o BN)GC(c3-c5, r4)1x---47.940.8model

Notes

Requirements

Install

a. Install PyTorch 1.1 and torchvision following the official instructions.

b. Install latest apex with CUDA and C++ extensions following this instructions. The Sync BN implemented by apex is required.

c. Clone the GCNet repository.

 git clone https://github.com/xvjiarui/GCNet.git 

d. Compile cuda extensions.

cd GCNet
pip install cython  # or "conda install cython" if you prefer conda
./compile.sh  # or "PYTHON=python3 ./compile.sh" if you use system python3 without virtual environments

e. Install GCNet version mmdetection (other dependencies will be installed automatically).

python(3) setup.py install  # add --user if you want to install it locally
# or "pip install ."

Note: You need to run the last step each time you pull updates from github. Or you can run python(3) setup.py develop or pip install -e . to install mmdetection if you want to make modifications to it frequently.

Please refer to mmdetection install instruction for more details.

Environment

Hardware

Software environment

Usage

Train

As in original mmdetection, distributed training is recommended for either single machine or multiple machines.

./tools/dist_train.sh <CONFIG_FILE> <GPU_NUM> [optional arguments]

Supported arguments are:

Evaluation

To evaluate trained models, output file is required.

python tools/test.py <CONFIG_FILE> <MODEL_PATH> [optional arguments]

Supported arguments are: