This repo is a PyTorch implementation of applying Switch EMA to object detaction and instance segmentation with Mask R-CNN and RetinaNet on COCO. The code is based on MMDetection.
Please note that we simply follow the hyper-parameters of PVT and ConvNeXt, which may not be the optimal ones for MogaNet. Feel free to tune the hyper-parameters to get better performance.
Install MMDetection from souce code, or follow the following steps. This experiment uses MMDetection>=2.19.0, and we reproduced the results with MMDetection v2.26.0 and Pytorch==1.10.
pip install openmim
mim install mmcv-full
pip install mmdet
Apex (optional) for Pytorch<=1.6.0:
git clone https://github.com/NVIDIA/apex
cd apex
python setup.py install --cpp_ext --cuda_ext --user
By default, we run experiments with fp32 or fp16 (Apex). If you would like to disable apex, modify the type of runner as EpochBasedRunner
and comment out the following code block in the configuration files:
fp16 = None
optimizer_config = dict(
type="DistOptimizerHook",
update_interval=1,
grad_clip=None,
coalesce=True,
bucket_size_mb=-1,
use_fp16=True,
)
Download COCO2017 and prepare COCO experiments according to the guidelines in MMDetection.
We train the model on a single node with 8 GPUs (a batch size of 16) by default. Start training with the config as:
PORT=29001 bash dist_train.sh /path/to/config 8
To evaluate the trained model on a single node with 8 GPUs, run:
bash dist_test.sh /path/to/config /path/to/checkpoint 8 --out results.pkl --eval bbox # or `bbox segm`
Our implementation is mainly based on the following codebases. We gratefully thank the authors for their wonderful works.