This is the official implementation of the paper "DETRs with Hybrid Matching".
Authors: Ding Jia, Yuhui Yuan, Haodi He, Xiaopei Wu, Haojun Yu, Weihong Lin, Lei Sun, Chao Zhang, Han Hu
2022.09.14 We support H-Deformable-DETR w/ ViT-L (MAE) achieves 56.6 AP on COCO val with 4-scale feature maps without using LSJ (large scale jittering) adopted by the original ViT-Det.
We provide a set of baseline results and trained models available for download:
Name | Backbone | query | LSJ | encoder | epochs | AP | download |
---|---|---|---|---|---|---|---|
H-Deformable-DETR + tricks | ViT-B | 300 | ❌ | 6 | 12 | 50.6 | model |
H-Deformable-DETR + tricks | ViT-B | 300 | ❌ | 2 | 12 | 49.8 | model |
H-Deformable-DETR + tricks | ViT-B | 300 | ❌ | 0 | 12 | 47.1 | model |
H-Deformable-DETR + tricks | ViT-L | 300 | ❌ | 6 | 12 | 51.1 | model |
H-Deformable-DETR + tricks | ViT-L | 300 | ❌ | 6 | 36 | 55.5 | model |
H-Deformable-DETR + tricks | ViT-L | 300 | ❌ | 6 | 75 | 56.5 | model |
H-Deformable-DETR + tricks | ViT-L | 300 | ❌ | 6 | 100 | 56.6 | model |
We test our models under python=3.7.10,pytorch=1.10.1,cuda=10.2
. Other versions might be available as well.
- Clone this repo
git https://github.com/HDETR/H-Deformable-DETR.git
cd H-Deformable-DETR
- Install Pytorch and torchvision
Follow the instruction on https://pytorch.org/get-started/locally/.
# an example:
conda install -c pytorch pytorch torchvision
- Install other needed packages
pip install -r requirements.txt
pip install openmim
mim install mmcv-full
pip install mmdet
- Compiling CUDA operators
cd models/ops
python setup.py build install
# unit test (should see all checking is True)
python test.py
cd ../..
Please download COCO 2017 dataset and organize them as following:
coco_path/
├── train2017/
├── val2017/
└── annotations/
├── instances_train2017.json
└── instances_val2017.json
GPUS_PER_NODE=8 ./tools/run_dist_launch.sh 8 <config path> \
--coco_path <coco path>
To train/eval a model with the swin transformer backbone, you need to download the backbone from the offical repo frist and specify argument--pretrained_backbone_path
like our configs.
GPUS_PER_NODE=8 ./tools/run_dist_launch.sh 8 <config path> \
--coco_path <coco path> --eval --resume <checkpoint path>
You can refer to Deformable-DETR to enable training on multiple nodes.
- models/backbone.py
- models/swin_transformer.py
- mmcv_custom
- datasets/coco.py
- datasets/__init__.py
- main.py
- engine.py
- models/deformable_detr.py
- models/deformable_transformer.py
- models/ops/modules/ms_deform_attn.py
- models/ops/functions/ms_deform_attn_func.py
- util/misc.py
- wandb: for logging
- mmdet: for swin backbones
- mmcv: for swin backbones
- timm: for swin backbones
If you find H-Deformable-DETR useful in your research, please consider citing:
@article{jia2022detrs,
title={DETRs with Hybrid Matching},
author={Jia, Ding and Yuan, Yuhui and He, Haodi and Wu, Xiaopei and Yu, Haojun and Lin, Weihong and Sun, Lei and Zhang, Chao and Hu, Han},
journal={arXiv preprint arXiv:2207.13080},
year={2022}
}
@article{zhu2020deformable,
title={Deformable detr: Deformable transformers for end-to-end object detection},
author={Zhu, Xizhou and Su, Weijie and Lu, Lewei and Li, Bin and Wang, Xiaogang and Dai, Jifeng},
journal={arXiv preprint arXiv:2010.04159},
year={2020}
}