{"id":16907846,"url":"https://github.com/xvjiarui/gcnet","last_synced_at":"2025-05-16T06:07:26.819Z","repository":{"id":37432387,"uuid":"183435481","full_name":"xvjiarui/GCNet","owner":"xvjiarui","description":"GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond","archived":false,"fork":false,"pushed_at":"2021-02-16T05:05:58.000Z","size":3281,"stargazers_count":1205,"open_issues_count":28,"forks_count":164,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-04-08T16:05:53.857Z","etag":null,"topics":["computer-vision","deep-learning","instance-segmentation","object-detection"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xvjiarui.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-25T13:01:24.000Z","updated_at":"2025-04-03T08:38:11.000Z","dependencies_parsed_at":"2022-08-19T06:11:33.401Z","dependency_job_id":null,"html_url":"https://github.com/xvjiarui/GCNet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xvjiarui%2FGCNet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xvjiarui%2FGCNet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xvjiarui%2FGCNet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xvjiarui%2FGCNet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xvjiarui","download_url":"https://codeload.github.com/xvjiarui/GCNet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254478190,"owners_count":22077676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computer-vision","deep-learning","instance-segmentation","object-detection"],"created_at":"2024-10-13T18:49:06.907Z","updated_at":"2025-05-16T06:07:21.803Z","avatar_url":"https://github.com/xvjiarui.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GCNet for Object Detection\n\n[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/global-context-networks/object-detection-on-coco-minival)](https://paperswithcode.com/sota/object-detection-on-coco-minival?p=global-context-networks)\n[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/global-context-networks/instance-segmentation-on-coco-minival)](https://paperswithcode.com/sota/instance-segmentation-on-coco-minival?p=global-context-networks)\n[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/global-context-networks/object-detection-on-coco)](https://paperswithcode.com/sota/object-detection-on-coco?p=global-context-networks)\n[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/global-context-networks/instance-segmentation-on-coco)](https://paperswithcode.com/sota/instance-segmentation-on-coco?p=global-context-networks)\n\n\nBy [Yue Cao](http://yue-cao.me), [Jiarui Xu](http://jerryxu.net), [Stephen Lin](https://scholar.google.com/citations?user=c3PYmxUAAAAJ\u0026hl=en), Fangyun Wei, [Han Hu](https://sites.google.com/site/hanhushomepage/).\n\nThis repo is a official implementation of [\"GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond\"](https://arxiv.org/abs/1904.11492) on COCO object detection based on open-mmlab's [mmdetection](https://github.com/open-mmlab/mmdetection). The core operator GC block could be find [here](https://github.com/xvjiarui/GCNet/blob/master/mmdet/ops/gcb/context_block.py). \nMany thanks to mmdetection for their simple and clean framework. \n\n*Update on 2020/12/07*\n\nThe extension of GCNet got accepted by TPAMI ([PDF](https://arxiv.org/pdf/2012.13375.pdf)).\n\n*Update on 2019/10/28*\n\nGCNet won the **Best Paper Award** at ICCV 2019 Neural Architects Workshop!\n\n*Update on 2019/07/01*\n\nThe code is refactored. \nMore results are provided and all configs could be found in `configs/gcnet`.\n\n**Notes**: Both PyTorch official SyncBN and Apex SyncBN have some stability issues. \nDuring training, mAP may drops to zero and back to normal during last few epochs. \n\n*Update on 2019/06/03*\n\nGCNet is supported by the official mmdetection repo [here](https://github.com/open-mmlab/mmdetection/tree/master/configs/gcnet). \nThanks again for open-mmlab's work on open source projects.\n\n## Introduction\n\n**GCNet** is initially described in [arxiv](https://arxiv.org/abs/1904.11492). 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.\n\n## Citing GCNet\n\n```\n@article{cao2019GCNet,\n  title={GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond},\n  author={Cao, Yue and Xu, Jiarui and Lin, Stephen and Wei, Fangyun and Hu, Han},\n  journal={arXiv preprint arXiv:1904.11492},\n  year={2019}\n}\n```\n\n## Main Results\n\n### Results on R50-FPN with backbone (fixBN)\n\n|  Back-bone |       Model      | Back-bone Norm |       Heads      |     Context    | Lr schd | Mem (GB) | Train time (s/iter) | Inf time (fps) | box AP | mask AP | Download |\n|:---------:|:----------------:|:-------------:|:----------------:|:--------------:|:-------:|:--------:|:-------------------:|:--------------:|:------:|:-------:|:--------:|\n|  R50-FPN |       Mask       |     fixBN     |    2fc (w/o BN)   |        -       |    1x   |    3.9   |        0.453        |      10.6      |  37.3  |   34.2  | [model](https://1drv.ms/u/s!AkEXj14LxwVpffUWWM4A0tFYYCk?e=IM6zgo)|\n|  R50-FPN |       Mask       |     fixBN     |    2fc (w/o BN)   | GC(c3-c5, r16) |    1x   |    4.5   |        0.533        |      10.1      |  38.5  |   35.1  | [model](https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/gcnet/mask_rcnn_r16_gcb_c3-c5_r50_fpn_1x_20190602-c550c707.pth)|\n|  R50-FPN |       Mask       |     fixBN     |    2fc (w/o BN)   |  GC(c3-c5, r4) |    1x   |    4.6   |        0.533        |       9.9      |  38.9  |   35.5  | [model](https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/gcnet/mask_rcnn_r4_gcb_c3-c5_r50_fpn_1x_20190602-18ae2dfd.pth)|\n|  R50-FPN |       Mask       |     fixBN     |    2fc (w/o BN)   |        -       |    2x   |     -    |          -          |        -       |  38.2  |   34.9  | [model](https://1drv.ms/u/s!AkEXj14LxwVpf7epsyY_qoEN9Eg?e=CqN9yI)|\n|  R50-FPN |       Mask       |     fixBN     |    2fc (w/o BN)   | GC(c3-c5, r16) |    2x   |     -    |          -          |        -       |  39.7  |   36.1  | [model](https://1drv.ms/u/s!AkEXj14LxwVpfFrg1q0y6j6KKy4?e=NdeFXG)|\n|  R50-FPN |       Mask       |     fixBN     |    2fc (w/o BN)   |  GC(c3-c5, r4) |    2x   |     -    |          -          |        -       |  40.0  |   36.2  | [model](https://1drv.ms/u/s!AkEXj14LxwVpfllzv_nSW9WnDQ8?e=OzaGaL)|\n\n### Results on R50-FPN with backbone (syncBN)\n\n|  Back-bone |       Model      | Back-bone Norm |       Heads      |     Context    | Lr schd | Mem (GB) | Train time (s/iter) | Inf time (fps) | box AP | mask AP | Download |\n|:---------:|:----------------:|:-------------:|:----------------:|:--------------:|:-------:|:--------:|:-------------------:|:--------------:|:------:|:-------:|:--------:|\n|  R50-FPN |       Mask       |     SyncBN    |    2fc (w/o BN)   |        -       |    1x   |    3.9   |        0.543        |      10.2      |  37.2  |   33.8  | [model](https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/gcnet/mask_rcnn_r50_fpn_syncbn_1x_20190602-bccc62fa.pth)|\n|  R50-FPN |       Mask       |     SyncBN    |    2fc (w/o BN)   | GC(c3-c5, r16) |    1x   |    4.5   |        0.547        |       9.9      |  39.4  |   35.7  | [model](https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/gcnet/mask_rcnn_r16_gcb_c3-c5_r50_fpn_syncbn_1x_20190602-a0169c20.pth)|\n|  R50-FPN |       Mask       |     SyncBN    |    2fc (w/o BN)   |  GC(c3-c5, r4) |    1x   |    4.6   |        0.603        |       9.4      |  39.9  |   36.2  | [model](https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/gcnet/mask_rcnn_r4_gcb_c3-c5_r50_fpn_syncbn_1x_20190602-ace08792.pth)|\n|  R50-FPN |       Mask       |     SyncBN    |    2fc (w/o BN)   |        -       |    2x   |    3.9   |        0.543        |      10.2      |  37.7  |   34.3  | [model](https://1drv.ms/u/s!AkEXj14LxwVpgQART6Djedy3UeL7?e=MvalDU)|\n|  R50-FPN |       Mask       |     SyncBN    |    2fc (w/o BN)   | GC(c3-c5, r16) |    2x   |    4.5   |        0.547        |       9.9      |  39.7  |   36.0  | [model](https://1drv.ms/u/s!AkEXj14LxwVpgQJHhiNkyVHcbHab?e=qiZ97L)|\n|  R50-FPN |       Mask       |     SyncBN    |    2fc (w/o BN)   |  GC(c3-c5, r4) |    2x   |    4.6   |        0.603        |       9.4      |  40.2  |   36.3  | [model](https://1drv.ms/u/s!AkEXj14LxwVpgQEBgYg6XZnder10?e=VeeWeq)|\n|  R50-FPN |       Mask       |     SyncBN    | 4conv1fc (SyncBN) |        -       |    1x   |     -    |          -          |        -       |  38.8  |   34.6  | [model](https://1drv.ms/u/s!AkEXj14LxwVpgQTW281dmK9sfiA1?e=xwK5Tw)|\n|  R50-FPN |       Mask       |     SyncBN    | 4conv1fc (SyncBN) | GC(c3-c5, r16) |    1x   |     -    |          -          |        -       |  41.0  |   36.5  | [model](https://1drv.ms/u/s!AkEXj14LxwVpgQOpmj-j0ctBAZog?e=q9pu4D)|\n|  R50-FPN |       Mask       |     SyncBN    | 4conv1fc (SyncBN) |  GC(c3-c5, r4) |    1x   |     -    |          -          |        -       |  41.4  |   37.0  | [model](https://1drv.ms/u/s!AkEXj14LxwVpgQW2a6BmnRJhqWbe?e=ECVmTx)|\n\n### Results on stronger backbones\n\n|  Back-bone |       Model      | Back-bone Norm |       Heads      |     Context    | Lr schd | Mem (GB) | Train time (s/iter) | Inf time (fps) | box AP | mask AP | Download |\n|:---------:|:----------------:|:-------------:|:----------------:|:--------------:|:-------:|:--------:|:-------------------:|:--------------:|:------:|:-------:|:--------:|\n| R101-FPN |       Mask       |     fixBN     |    2fc (w/o BN)   |        -       |    1x   |    5.8   |        0.571        |       9.5      |  39.4  |   35.9  | [model](https://1drv.ms/u/s!AkEXj14LxwVpcZ9zKY77ptT4l9U?e=Xgm8j3)|\n| R101-FPN |       Mask       |     fixBN     |    2fc (w/o BN)   | GC(c3-c5, r16) |    1x   |    7.0   |        0.731        |       8.6      |  40.8  |   37.0  | [model](https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/gcnet/mask_rcnn_r16_gcb_c3-c5_r101_fpn_1x_20190602-f4456442.pth)|\n| R101-FPN |       Mask       |     fixBN     |    2fc (w/o BN)   |  GC(c3-c5, r4) |    1x   |    7.1   |        0.747        |       8.6      |  40.8  |   36.9  | [model](https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/gcnet/mask_rcnn_r4_gcb_c3-c5_r101_fpn_1x_20190602-1ee20d5f.pth)|\n| R101-FPN |       Mask       |     SyncBN    |    2fc (w/o BN)   |        -       |    1x   |    5.8   |        0.665        |       9.2      |  39.8  |   36.0  | [model](https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/gcnet/mask_rcnn_r101_fpn_syncbn_1x_20190602-b2a0e2b7.pth)|\n| R101-FPN |       Mask       |     SyncBN    |    2fc (w/o BN)   | GC(c3-c5, r16) |    1x   |    7.0   |        0.778        |       9.0      |  41.1  |   37.4  | [model](https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/gcnet/mask_rcnn_r16_gcb_c3-c5_r101_fpn_syncbn_1x_20190602-717e6dbd.pth)|\n| R101-FPN |       Mask       |     SyncBN    |    2fc (w/o BN)   |  GC(c3-c5, r4) |    1x   |    7.1   |        0.786        |       8.9      |  41.7  |   37.6  | [model](https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/gcnet/mask_rcnn_r4_gcb_c3-c5_r101_fpn_syncbn_1x_20190602-a893c718.pth)|\n| X101-FPN |       Mask       |     SyncBN    |    2fc (w/o BN)   |        -       |    1x   |    7.1   |        0.912        |       8.5      |  41.2  |   37.3  | [model](https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/gcnet/mask_rcnn_x101_32x4d_fpn_syncbn_1x_20190602-bb8ae7e5.pth)|\n| X101-FPN |       Mask       |     SyncBN    |    2fc (w/o BN)   | GC(c3-c5, r16) |    1x   |    8.2   |        1.055        |       7.7      |  42.4  |   38.0  | [model](https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/gcnet/mask_rcnn_r16_gcb_c3-c5_x101_32x4d_fpn_syncbn_1x_20190602-c28edb53.pth)|\n| X101-FPN |       Mask       |     SyncBN    |    2fc (w/o BN)   |  GC(c3-c5, r4) |    1x   |    8.3   |        1.037        |       7.6      |  42.9  |   38.5  | [model](https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/gcnet/mask_rcnn_r4_gcb_c3-c5_x101_32x4d_fpn_syncbn_1x_20190602-930b3d51.pth)|\n| X101-FPN |   Cascade Mask   |     SyncBN    |    2fc (w/o BN)   |        -       |    1x   |     -    |          -          |        -       |  44.7  |   38.3  | [model](https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/gcnet/cascade_mask_rcnn_x101_32x4d_fpn_syncbn_1x_20190602-63a800fb.pth)|\n| X101-FPN |   Cascade Mask   |     SyncBN    |    2fc (w/o BN)   | GC(c3-c5, r16) |    1x   |     -    |          -          |        -       |  45.9  |   39.3  | [model](https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/gcnet/cascade_mask_rcnn_r16_gcb_c3-c5_x101_32x4d_fpn_syncbn_1x_20190602-3e168d88.pth)|\n| X101-FPN |   Cascade Mask   |     SyncBN    |    2fc (w/o BN)   |  GC(c3-c5, r4) |    1x   |     -    |          -          |        -       |  46.5  |   39.7  | [model](https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/gcnet/cascade_mask_rcnn_r4_gcb_c3-c5_x101_32x4d_fpn_syncbn_1x_20190602-b579157f.pth)|\n| X101-FPN | DCN Cascade Mask |     SyncBN    |    2fc (w/o BN)   |        -       |    1x   |     -    |          -          |        -       |  47.1  |   40.4  | [model](https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/gcnet/cascade_mask_rcnn_dconv_c3-c5_x101_32x4d_fpn_syncbn_1x_20190602-9aa8c394.pth)|\n| X101-FPN | DCN Cascade Mask |     SyncBN    |    2fc (w/o BN)   | GC(c3-c5, r16) |    1x   |     -    |          -          |        -       |  47.9  |   40.9  | [model](https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/gcnet/cascade_mask_rcnn_r16_gcb_dconv_c3-c5_x101_32x4d_fpn_syncbn_1x_20190602-b86027a6.pth)|\n| X101-FPN | DCN Cascade Mask |     SyncBN    |    2fc (w/o BN)   |  GC(c3-c5, r4) |    1x   |     -    |          -          |        -       |  47.9  |   40.8  | [model](https://open-mmlab.s3.ap-northeast-2.amazonaws.com/mmdetection/models/gcnet/cascade_mask_rcnn_r4_gcb_dconv_c3-c5_x101_32x4d_fpn_syncbn_1x_20190602-b4164f6b.pth)|\n\n**Notes**\n- `GC` denotes Global Context (GC) block is inserted after 1x1 conv of backbone. \n- `DCN` denotes replace 3x3 conv with 3x3 Deformable Convolution in `c3-c5` stages of backbone.\n- `r4` and `r16` denote ratio 4 and ratio 16 in GC block respectively. \n- Some of models are trained on 4 GPUs with 4 images on each GPU.\n\n## Requirements\n\n- Linux(tested on Ubuntu 16.04)\n- Python 3.6+\n- PyTorch 1.1.0\n- Cython\n- [apex](https://github.com/NVIDIA/apex) (Sync BN)\n\n## Install\n\na. Install PyTorch 1.1 and torchvision following the [official instructions](https://pytorch.org/).\n\nb. Install latest apex with CUDA and C++ extensions following this [instructions](https://github.com/NVIDIA/apex#quick-start). \nThe [Sync BN](https://nvidia.github.io/apex/parallel.html#apex.parallel.SyncBatchNorm) implemented by apex is required.\n\nc. Clone the GCNet repository. \n\n```bash\n git clone https://github.com/xvjiarui/GCNet.git \n```\n\nd. Compile cuda extensions.\n\n```bash\ncd GCNet\npip install cython  # or \"conda install cython\" if you prefer conda\n./compile.sh  # or \"PYTHON=python3 ./compile.sh\" if you use system python3 without virtual environments\n```\n\ne. Install GCNet version mmdetection (other dependencies will be installed automatically).\n\n```bash\npython(3) setup.py install  # add --user if you want to install it locally\n# or \"pip install .\"\n```\n\nNote: You need to run the last step each time you pull updates from github. \nOr you can run `python(3) setup.py develop` or `pip install -e .` to install mmdetection if you want to make modifications to it frequently.\n\nPlease refer to mmdetection install [instruction](https://github.com/open-mmlab/mmdetection/blob/master/INSTALL.md) for more details.\n\n## Environment\n\n### Hardware\n\n- 8 NVIDIA Tesla V100 GPUs\n- Intel Xeon 4114 CPU @ 2.20GHz\n\n### Software environment\n\n- Python 3.6.7\n- PyTorch 1.1.0\n- CUDA 9.0\n- CUDNN 7.0\n- NCCL 2.3.5\n\n## Usage\n\n### Train\n\nAs in original mmdetection, distributed training is recommended for either single machine or multiple machines.\n\n```bash\n./tools/dist_train.sh \u003cCONFIG_FILE\u003e \u003cGPU_NUM\u003e [optional arguments]\n```\n\nSupported arguments are:\n\n- --validate: perform evaluation every k (default=1) epochs during the training.\n- --work_dir \u003cWORK_DIR\u003e: if specified, the path in config file will be replaced.\n\n### Evaluation\n\nTo evaluate trained models, output file is required.\n\n```bash\npython tools/test.py \u003cCONFIG_FILE\u003e \u003cMODEL_PATH\u003e [optional arguments]\n```\n\nSupported arguments are:\n\n- --gpus: number of GPU used for evaluation\n- --out: output file name, usually ends wiht `.pkl`\n- --eval: type of evaluation need, for mask-rcnn, `bbox segm` would evaluate both bounding box and mask AP. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxvjiarui%2Fgcnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxvjiarui%2Fgcnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxvjiarui%2Fgcnet/lists"}