Deformable 可变形的DETR

This repository is an official implementation of the paper Deformable DETR: Deformable Transformers for End-to-End Object Detection.

该存储库是论文《可变形DETR:用于端到端对象检测的可变形变压器》的正式实现。

https://github.com/fundamentalvision/deformable-detr

Introduction

Deformable DETR is an efficient and fast-converging end-to-end object detector. It mitigates the high complexity and slow convergence issues of DETR via a novel sampling-based efficient attention mechanism.

可变形DETR是一种高效且快速收敛的端到端对象检测器。通过一种新颖的基于采样的有效注意力机制,缓解了DETR的高复杂性和缓慢收敛的问题。

Abstract摘要

DETR has been recently proposed to eliminate the need for many hand-designed components in object detection while demonstrating good performance. However, it suffers from slow convergence and limited feature spatial resolution, due to the limitation of Transformer attention modules in processing image feature maps. To mitigate these issues, we proposed Deformable DETR, whose attention modules only attend to a small set of key sampling points around a reference. Deformable DETR can achieve better performance than DETR (especially on small objects) with 10× less training epochs. Extensive experiments on the COCO benchmark demonstrate the effectiveness of our approach.

最近提出了DETR,以消除目标检测中对许多手工设计组件的需求,同时表现出良好的性能。但是,由于Transformer注意模块在处理图像特征图时的局限性,它收敛缓慢且特征空间分辨率有限。为了缓解这些问题,提出了可变形DETR,其关注模块仅关注参考周围的一小部分关键采样点。可变形的DETR可以比DETR(尤其是在小物体上)获得更好的性能,训练时间减少10倍。在COCO Benchmark数据集上进行的大量实验证明了方法的有效性。

License

This project is released under the Apache 2.0 license.

项目是根据Apache 2.0许可发布的

Changelog

See changelog.md for detailed logs of major changes.

有关主要更改的详细日志,请参见changelog.md

Citing 引用可变形Deformable DETR

If you find Deformable DETR useful in your research, please consider citing:

如果发现Deformable可变形DETR在研究中很有用,考虑引用以下内容:

@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}

}

Main Results

Note:

  1. All models of Deformable DETR are trained with total batch size of 32.
  2. Training and inference speed are measured on NVIDIA Tesla V100 GPU.
  3. "Deformable DETR (single scale)" means only using res5 feature map (of stride 32) as input feature maps for Deformable Transformer Encoder.
  4. "DC5" means removing the stride in C5 stage of ResNet and add a dilation of 2 instead.
  5. "DETR-DC5+" indicates DETR-DC5 with some modifications, including using Focal Loss for bounding box classification and increasing number of object queries to 300.
  6. "Batch Infer Speed" refer to inference with batch size = 4 to maximize GPU utilization.
  7. The original implementation is based on our internal codebase. There are slight differences in the final accuracy and running time due to the plenty details in platform switch.

笔记:

  1. 所有可变形DETR的模型都经过训练,总批次大小为32。
  2. 训练和推理速度是在NVIDIA Tesla V100 GPU上测量的。
  3. “可变形DETR(单比例)”表示仅将(步幅32的)res5特征图用作可变形变压器编码器的输入特征图。
  4. “ DC5”表示消除ResNet的C5阶段的步幅,而改为增加2。
  5. “ DETR-DC5 +”表示对DETR-DC5进行了一些修改,包括使用Focal Loss进行边界框分类以及将目标查询数增加到300。
  6. “批处理推断速度”指的是批处理大小= 4以最大程度地利用GPU的推理。
  7. 原始实现基于内部代码库。由于平台切换器中的大量细节,最终精度和运行时间略有不同。

Installation

Requirements

  • Linux, CUDA>=9.2, GCC>=5.4
  • Python>=3.7

We recommend you to use Anaconda to create a conda environment: 建议使用Anaconda创建一个conda环境:

conda create -n deformable_detr python=3.7 pip

Then, activate the environment:

conda activate deformable_detr

  • PyTorch>=1.5.1, torchvision>=0.6.1

For example, if your CUDA version is 9.2, you could install pytorch and torchvision as following: 如果CUDA版本是9.2,则可以按以下方式安装pytorch和torchvision:

conda install pytorch=1.5.1 torchvision=0.6.1 cudatoolkit=9.2 -c pytorch

  • Other requirements

pip install -r requirements.txt

Compiling CUDA operators

cd ./models/ops

sh ./make.sh

# unit test (should see all checking is True)

python test.py

Usage

Dataset preparation

Please download COCO 2017 dataset and organize them as following: 请下载COCO 2017数据集并按以下方式组织它们:

code_root/

└── data/

└── coco/

├── train2017/

├── val2017/

└── annotations/

├── instances_train2017.json

└── instances_val2017.json

Training

Training on single node

For example, the command for training Deformable DETR on 8 GPUs is as following: 例如,用于在8个GPU上训练可变形DETR的命令如下:

GPUS_PER_NODE=8 ./tools/run_dist_launch.sh 8 ./configs/r50_deformable_detr.sh

Training on multiple nodes

For example, the command for training Deformable DETR on 2 nodes of each with 8 GPUs is as following: 例如,用于在每个具有8个GPU的2个节点上训练Deformable DETR的命令如下:

On node 1:

MASTER_ADDR=<IP address of node 1> NODE_RANK=0 GPUS_PER_NODE=8 ./tools/run_dist_launch.sh 16 ./configs/r50_deformable_detr.sh

On node 2:

MASTER_ADDR=<IP address of node 1> NODE_RANK=1 GPUS_PER_NODE=8 ./tools/run_dist_launch.sh 16 ./configs/r50_deformable_detr.sh

Training on slurm cluster

If you are using slurm cluster, you can simply run the following command to train on 1 node with 8 GPUs: 如果使用的是Slurm集群,只需运行以下命令即可在具有8个GPU的1个节点上进行训练:

GPUS_PER_NODE=8 ./tools/run_dist_slurm.sh <partition> deformable_detr 8 configs/r50_deformable_detr.sh

Or 2 nodes of each with 8 GPUs:

GPUS_PER_NODE=8 ./tools/run_dist_slurm.sh <partition> deformable_detr 16 configs/r50_deformable_detr.sh

Some tips to speed-up training

  • If your file system is slow to read images, you may consider enabling '--cache_mode' option to load whole dataset into memory at the beginning of training.
  • You may increase the batch size to maximize the GPU utilization, according to GPU memory of yours, e.g., set '--batch_size 3' or '--batch_size 4'.
  • 如果文件系统读取图像的速度较慢,则可以考虑在训练开始时启用'--cache_mode'选项以将整个数据集加载到内存中。
  • 可以根据自己的GPU内存来增加批处理大小以最大程度地利用GPU,例如,设置'--batch_size 3'或'--batch_size 4'。

Evaluation

You can get the config file and pretrained model of Deformable DETR (the link is in "Main Results" session), then run following command to evaluate it on COCO 2017 validation set:

可以获取可变形DETR的配置文件和预训练模型(链接在“主要结果”会话中),然后运行以下命令在COCO 2017验证集中对其进行评估:

<path to config file> --resume <path to pre-trained model> --eval

You can also run distributed evaluation by using ./tools/run_dist_launch.sh or ./tools/run_dist_slurm.sh.

Deformable 可变形的DETR的更多相关文章

  1. R-CNN论文学习

    Rich feature hierarchies for accurate object detection and semantic segmentation Tech report (v5) pr ...

  2. Deformable Convolutional Networks-v1-v2(可变形卷积网络)

    如何评价 MSRA 视觉组最新提出的 Deformable ConvNets V2? <Deformable Convolutional Networks>是一篇2017年Microsof ...

  3. 深度学习方法(十三):卷积神经网络结构变化——可变形卷积网络deformable convolutional networks

    上一篇我们介绍了:深度学习方法(十二):卷积神经网络结构变化--Spatial Transformer Networks,STN创造性地在CNN结构中装入了一个可学习的仿射变换,目的是增加CNN的旋转 ...

  4. 关于DPM(Deformable Part Model)算法中模型结构的解释

    关于可变部件模型的描写叙述在作者[2010 PAMI]Object Detection with Discriminatively Trained Part Based Models的论文中已经有说明 ...

  5. 论文阅读笔记四十:Deformable ConvNets v2: More Deformable, Better Results(CVPR2018)

    论文源址:https://arxiv.org/abs/1811.11168 摘要 可变形卷积的一个亮点是对于不同几何变化的物体具有适应性.但也存在一些问题,虽然相比传统的卷积网络,其神经网络的空间形状 ...

  6. 论文阅读笔记三十八:Deformable Convolutional Networks(ECCV2017)

    论文源址:https://arxiv.org/abs/1703.06211 开源项目:https://github.com/msracver/Deformable-ConvNets 摘要 卷积神经网络 ...

  7. Deformable ConvNets

    Deformable ConvNets 论文 Deformable Convolutional Networks(arXiv:1703.06211) CNN受限于空间结构,具有较差的旋转不变性,较弱的 ...

  8. DPM(Deformable Part Model)原理详解(汇总)

    写在前面: DPM(Deformable Part Model),正如其名称所述,可变形的组件模型,是一种基于组件的检测算法,其所见即其意.该模型由大神Felzenszwalb在2008年提出,并发表 ...

  9. AI:IPPR的数学表示-CNN稀疏结构进化(Mobile、xception、Shuffle、SE、Dilated、Deformable)

    接上一篇:AI:IPPR的数学表示-CNN基础结构进化(Alex.ZF.Inception.Res.InceptionRes). 抄自于各个博客,有大量修改,如有疑问,请移步各个原文.....  前言 ...

随机推荐

  1. Sublime插件安装和使用

    Sublime插件安装和使用 插件安装的方式: 插件安装方式一:直接安装 下载插件安装包,然后把安装解压到packages目中,按成安装(菜单->首选项->浏览插件) 插件安装方法二:使用 ...

  2. js去重的两种方法

    去重 去重方法和思路也很多,这里就介绍两种吧. 方法一: 1 2 3 4 5 6 7 8 9 10 11 function unique1(arr) {       var res = [],     ...

  3. android安全学习、工具库、框架

    在介绍android工具之前,先理清android中出现的文件格式: java:android源码 class:java编译后生成: dex: 由dx工具编译class而成,由dalvik执行: sm ...

  4. featuretools的几个高级特性

    摘要:记录工作中用到的featuretools的部分高级特性. 1.防止信息泄露 在调用dfs时,将主表的观测时间列连同id列作为cutoff_time,可以在构造特征时自动将子表中在cutoff_t ...

  5. Python数模笔记-Sklearn(4)线性回归

    1.什么是线性回归? 回归分析(Regression analysis)是一种统计分析方法,研究自变量和因变量之间的定量关系.回归分析不仅包括建立数学模型并估计模型参数,检验数学模型的可信度,也包括利 ...

  6. MySQL密码复杂度与密码过期策略介绍

    前言: 年底了,你的数据库是不是该巡检了?一般巡检都会关心密码安全问题,比如密码复杂度设置,是否有定期修改等.特别是进行等保评测时,评测机构会要求具备密码安全策略.其实 MySQL 系统本身可以设置密 ...

  7. 最优运输(Optimal Transfort):从理论到填补的应用

    目录 引言 1 背景 2 什么是最优运输? 3 基本概念 3.1 离散测度 (Discrete measures) 3.2 蒙日(Monge)问题 3.3 Kantorovich Relaxation ...

  8. 【BUAA软工】提问回顾与个人总结

    链接到以前提问题的博客 在之前的博客我曾经提问过以下几个问题 为什么单元测试必须由写程序的人完成? 过早优化,过早泛华:何时为过早? 为何使用goto语句? 用户需求分析:分而治之,如何分? 兼容性测 ...

  9. .NET平台系列9 .NET Core 3.0 / .NET Core 3.1 详解

    系列目录     [已更新最新开发文章,点击查看详细] .NET Core 3.0 于 2019年9月23日发布,重点是增加对同时支持使用 Windwos Forms.WPF 和 Entity Frm ...

  10. 如何安装多个jdk并方便切换系统jdk版本

    如何安装多个jdk并方便切换系统jdk版本 前言 在安装myeclipse时,压缩包中附带1.8.0的jdk,顺便安装并配置环境变量后发现系统默认的jdk变为了1.8.0.随后发现eclipse只支持 ...