Source-linked AI summary

Mask DINO: Towards A Unified Transformer-based Framework for Object Detection and Segmentation

Feng Li, Hao Zhang, Huaizhe xu, Shilong Liu, Lei Zhang, Lionel M. Ni, Heung-Yeung Shum

arXiv:2206.02777v3cs.CV

TL;DR

DETR-like models are specialized, and straightforward extensions across tasks can underperform or hurt the original task. Mask DINO adds a mask branch to DINO and achieves the best results across three segmentation tasks among models under one billion parameters.

  • Problem

    DETR-like Transformer models remain specialized, and straightforward extensions to other tasks can lag the original task while trivial multi-task training may hurt it.

    Source: §3.2 · p. 3
  • Method

    Mask DINO extends DINO with a parallel mask branch, reusing its content queries to predict binary masks for image segmentation tasks.

    Source: §1 · p. 2
  • Results

    Mask DINO achieves the best results on instance, panoptic, and semantic segmentation among models under one billion parameters.

    Source: §5 · p. 9
  • Takeaways & Limitations

    The results show that detection and segmentation can help each other in query-based models.

    Source: §5 · p. 9

    At large scale, the segmentation head’s GPU-memory demand requires smaller images and fewer queries than DINO, impacting detection performance and preventing new state-of-the-art detection results.

    Source: §5 · p. 9

Abstract

from arXiv · show

In this paper we present Mask DINO, a unified object detection and segmentation framework. Mask DINO extends DINO (DETR with Improved Denoising Anchor Boxes) by adding a mask prediction branch which supports all image segmentation tasks (instance, panoptic, and semantic). It makes use of the query embeddings from DINO to dot-product a high-resolution pixel embedding map to predict a set of binary masks. Some key components in DINO are extended for segmentation through a shared architecture and training process. Mask DINO is simple, efficient, and scalable, and it can benefit from joint large-scale detection and segmentation datasets. Our experiments show that Mask DINO significantly outperforms all existing specialized segmentation methods, both on a ResNet-50 backbone and a pre-trained model with SwinL backbone. Notably, Mask DINO establishes the best results to date on instance segmentation (54.5 AP on COCO), panoptic segmentation (59.4 PQ on COCO), and semantic segmentation (60.8 mIoU on ADE20K) among models under one billion parameters. Code is available at \url{https://github.com/IDEACVR/MaskDINO}.

1. Introduction

Mask DINO extends DINO into a unified Transformer framework for object detection and image segmentation, using shared architecture and training to let the tasks benefit from each other. It adds a mask branch and components for aligning detection’s region-level features with pixel-level segmentation.

Introduction

  • Although unified CNN models demonstrate task cooperation, Transformer detection and segmentation remain ununified; applying DINO to segmentation or Mask2Former to detection performs poorly, and trivial multi-task training can hurt original tasks.This motivates a shared Transformer architecture for detection and segmentation.Source: §1 · pp. 1–2
  • Mask DINO adds a mask branch parallel to DINO’s box branch, dot-producting DINO content queries with a 1/4-resolution pixel embedding map to predict binary masks for all segmentation tasks.The pixel map comes from backbone and Transformer encoder features.Source: §1 · p. 2
  • Its segmentation components combine dense-prior mask queries as anchors, initial masks that enhance boxes, unified mask denoising, and hybrid bipartite matching for boxes and masks.The components aim to improve feature alignment and segmentation performance.Source: §1 · p. 2
  • With Objects365-pretrained SwinL, Mask DINO achieves the best results among models under one billion parameters: 54.5 AP for COCO instance, 59.4 PQ for COCO panoptic, and 60.8 mIoU for ADE20K semantic segmentation.The framework uses detection pre-training on the large-scale Objects365 dataset.Source: §1 · p. 2
  • With ResNet-50, Mask DINO outperforms DINO by +0.8 AP on COCO detection and Mask2Former by +2.6 AP on COCO instance, +1.1 PQ on COCO panoptic, and +1.5 mIoU on ADE20K semantic segmentation.All comparisons use the same setting.Source: §1 · p. 2

2. Related Work

Prior work advanced Transformer-based detection and unified multiple segmentation tasks, but existing approaches left a gap in combining strong detection and segmentation in one framework.

Detection

  • Transformer detectors [1] [18] [22] [37] advanced from DETR [1] through DAB-DETR [22], DN-DETR [18], and DINO [37], but DETR-like segmentation remained inferior to specialized models.DETR [1] introduced end-to-end query-based detection with bipartite matching; its segmentation head demonstrated feasibility, not competitive segmentation performance.Source: §2 · pp. 2–3

Segmentation

  • Segmentation spans instance, semantic, and panoptic tasks; Mask2Former [3] unifies all three but leaves object detection untouched.Mask R-CNN and HTC [2] target instance segmentation, while FCN [25] and U-Net [30] target semantic segmentation; panoptic models [15] [35] are usually inferior to specialized models. Mask2Former [3] improves MaskFormer [5] with masked attention, but its specialized designs are reported unsuitable for box prediction.Source: §2 · p. 3

Unified Methods

  • Unified frameworks can exploit shared localization and visual representations, but prior systems remained limited: Mask R-CNN and HTC [2] handle only instance segmentation, while DETR [1] lags in segmentation.The paper identifies mutual assistance between detection and segmentation as an open problem; adding DETR’s segmentation head to DINO produces inferior instance-segmentation results.Source: §2 · p. 3

3. Mask DINO

Mask DINO extends DINO with a mask-prediction branch and minimal changes to its detection components, using a shared framework for detection and segmentation. The section motivates this design by identifying why straightforwardly adding detection or segmentation heads to specialized Transformer models performs poorly.

3.1. Preliminaries: DINO

  • DINO [37] uses dynamically updated 4D anchor queries to guide deformable attention, alongside denoising, mixed query selection, and look-forward-twice.Its multi-scale features support sparse, soft attention constrained by the updated anchors; contrastive denoising accelerates convergence, while look-forward-twice improves box-gradient back-propagation.Source: §3.1 · p. 3

3.2. Why a universal model has not replaced the specialized models in DETR-like models?

  • 4.5 AP worse than DINO for generated boxes and -3.5 AP for masks versus Mask2Former show the limits of simply adding task heads.The section attributes the mismatch to segmentation queries lacking instance-position information and detection queries lacking pixel-level representations. Mask2Former’s decoder also lacks suitable positional priors, uses inflexible high-resolution masked attention, and does not refine boxes layer by layer; detection-oriented designs in DINO are not optimal for segmentation.Source: §3.2 · pp. 3–4, Table 1 · p. 4, Table 2 · p. 4

3.3. Our Method: Mask DINO

  • Mask DINO adds a decoder mask branch to DINO while retaining its detection architecture with minimal modifications.The framework extends several DINO components for segmentation, marking the added segmentation design separately from the original DINO model.Source: §3 · p. 3, §3.3 · p. 4

3.4. Segmentation branch

  • Mask DINO dot-products each decoder content query with a pixel embedding map fused from backbone and encoder features to predict a mask.The map fuses a 1/4-resolution backbone feature with an upsampled 1/8-resolution Transformer encoder feature; the branch uses a simple interpolation step for 2x upsampling.Source: §3.4 · pp. 4–5

3.5. Unified and Enhanced Query Selection

  • Unified query selection predicts classification, boxes, and masks from encoder features, selecting top-ranked tokens as content queries and initializing both content and anchor-box queries.Because early masks are more accurate than boxes, Mask DINO derives boxes from predicted masks to provide improved decoder anchor initialization.Source: §3.5 · p. 5

3.6. Segmentation Micro Design

  • Mask DINO extends denoising to masks by training mask prediction from randomly noised boxes, and adds mask loss to bipartite matching for more consistent box-mask pairs.The matching cost combines classification, box, and mask losses.Source: §3.6 · pp. 5–6
  • For panoptic segmentation, Mask DINO removes box loss and box matching for “stuff” categories while retaining their box predictions for region localization and deformable-attention features.The design sets “stuff” box loss to the mean for “thing” categories and is described as accelerating training and yielding additional panoptic-segmentation gains.Source: §3.6 · p. 6

4. Experiments

Mask DINO unifies detection and segmentation, reporting strong results across the four tasks and showing that joint training and shared components benefit performance. Experiments span COCO, ADE20K, and Cityscapes, with ResNet-50 and SwinL backbones.

4. Experiments

  • Experiments compare Mask DINO with specialized models across detection, instance, panoptic, and semantic segmentation on COCO, ADE20K, and Cityscapes.Main experiments use batch size 16 and A100 GPUs with 40GB memory; ResNet-50 experiments use four A100 GPUs without extra data, with ResNet-50 and SwinL used for main and state-of-the-art results.Source: §4 · pp. 6–7

4.2. Comparison with SOTA Models

  • 54.5 AP instance, 59.4 PQ panoptic, and 60.8 mIoU semantic: Mask DINO reports the best results among models under one billion parameters.With SwinL and DINO pre-trained on Objects365, it outperforms Mask2Former on all three tasks, including by +2.5 AP on instance segmentation. Compared with SwinV2-G, it uses 1/15 the model size and 1/5 the backbone pre-training dataset.Source: Table 7 · p. 7, §4.2 · p. 8

4.1. Main Results

  • Mask DINO surpasses Mask2Former by +2.7 AP and +2.6 AP on instance segmentation in the 12- and 50-epoch settings, respectively.It reaches 44.2 AP in 24 epochs, and mask-enhanced box initialization improves detection by +1.2 AP, exceeding DINO by 0.8 AP. On SwinL without extra data, it achieves the best detection and instance segmentation performance among DETR-like models.Source: §4.1 · p. 7
  • Mask DINO exceeds previous best panoptic results by 1.0 PQ and 1.1 PQ in the 12- and 50-epoch settings, respectively.It outperforms Mask2Former on both thing and stuff PQ; box-oriented deformable attention extracts query features and also works with stuff categories.Source: §4.1 · pp. 7–8
  • On ADE20K and Cityscapes, Mask DINO outperforms Mask2Former by 1.6 and 0.6 mIoU, respectively.These semantic segmentation experiments use a ResNet-50 backbone and 100 queries.Source: §4.1 · p. 8

4.2. Comparison with SOTA Models

  • Unifying four tasks lets one model be pre-trained on a large-scale dataset and fine-tuned for each task in 10–20 epochs, compared with 100 epochs for Mask2Former.The paper presents this as a simpler model design and a more computationally efficient alternative; it also notes that detection pre-training helps panoptic and semantic segmentation, including stuff categories.Source: §4.2 · p. 8

4.3. Ablation Studies

  • Ablations show that query selection, multi-scale decoder features, joint task training, more decoder layers, unified matching, and decoupled box prediction each contribute to performance.Mask-enhanced box initialization uses mask predictions to improve anchor boxes; mask query selection reaches 39.6 AP without the decoder, while Mask2Former’s learnable-query masks lag by 38.5 AP. More feature scales benefit detection and segmentation, and training both tasks together outperforms training either alone; more decoder layers help both tasks, unified matching outperforms box-only or mask-only matching, and decoupled thing/stuff box prediction speeds early training and improves final panoptic results. Removing all proposed components causes large drops, indicating that simply combining detection and segmentation does not align their features for mutual cooperation.Source: §4.3 · pp. 8–9

5. Conclusion

Mask DINO is a unified Transformer framework for detection and segmentation that outperforms specialized models across three segmentation tasks, while exposing limits to task cooperation and large-scale detection performance.

  • Mask DINO achieves the best results on instance, panoptic, and semantic segmentation among models under one billion parameters, outperforming previous specialized models.Source: §5 · p. 9
  • As a minimal-modification extension of DINO, Mask DINO unifies detection and segmentation and shows that detection and segmentation can help each other in query-based models.Semantic and panoptic segmentation can benefit from visual representations pre-trained on large-scale detection data.Source: §5 · p. 9
  • In COCO panoptic segmentation, segmentation tasks do not mutually assist, and mask AP lags behind a model trained only with instances.Source: §5 · p. 9
  • At large scale, Mask DINO does not achieve new state-of-the-art detection performance because memory limits require smaller images and fewer queries than DINO, impacting detection.The authors plan to optimize implementation to develop a more universal and efficient model that promotes task cooperation.Source: §5 · p. 9

A. Visualization analysis

Mask DINO’s visualization analysis motivates unifying detection and segmentation: box predictions can guide mask attention, while DINO-style query selection and deformable attention improve segmentation. Its decoder outputs provide better mask proposals than Mask2Former and help attention cover instances and background regions.

A. Visualization analysis

  • Mask DINO’s 0-th decoder-layer masks are better region proposals than Mask2Former’s, whose outputs remain far from the ground-truth masks.The comparison is shown in Fig. 2(a)(b)(c).Source: A. Visualization analysis · p. 12
  • Box AP is usually 4+ AP higher than mask AP, motivating box predictions to guide attention toward meaningful regions and improve mask features.The passage points to Table 3 and previous studies for this gap.Source: A. Visualization analysis · p. 12
  • Mask2Former’s first decoder-layer prediction covers less than half of the ground-truth mask, potentially preventing the next layer’s attention from seeing the whole instance.Fig. 2(d)(e) compares this prediction with Mask DINO’s corresponding output.Source: A. Visualization analysis · p. 12
  • Boxes can guide deformable attention to an appropriate region for background stuff, while deformable attention efficiently handles multi-scale features.The visualization is shown in Fig. 2(f)(g); unlike hard masked attention, deformable attention does not ignore features outside a provided mask.Source: A. Visualization analysis · p. 12
  • DINO [37] and DETR-like advances such as query selection and deformable attention [18] [40] motivate extending detection improvements to segmentation.The passage also cites Mask RCNN, HTC [2], and DETR [1] as examples of detection models extended to segmentation.Source: A. Visualization analysis · p. 12

B. Implementation details

The authors make their code available in the supplementary materials and provide implementation descriptions.

B. Implementation details

B.1. General settings

The section specifies Mask DINO’s evaluation datasets and metrics, backbones, loss design, architecture, training schedules, and augmentation settings.

Evaluation datasets and metrics

  • COCO 2017 [21] covers detection and instance segmentation on thing categories and panoptic segmentation on thing-plus-stuff; ADE20K covers semantic segmentation, using AP, mask AP, PQ, and mIoU.Unless otherwise stated, models train on the train split and are evaluated on the validation split; panoptic reporting also includes AP_thing and AP_stuff.Source: §B.1 · p. 12

Backbones

  • Experiments use ResNet-50 [12] and SwinL [24]; SwinL models are detection-pretrained on Objects365 before fine-tuning, and detection pretraining improves all segmentation tasks.The paper reports frames per second for Mask2Former and Mask DINO on the same A100 GPU, averaging batch-size-1 inference time across the validation set.Source: §B.1 · p. 12

Loss function

  • Joint training combines classification, box, and mask losses, using focal, L1/GIoU, cross-entropy, dice, and point losses.The coefficients are λcls = 4, λL1 = 5, λgiou = 2, λce = 5, and λdice = 5; point loss is used for mask-loss efficiency [3] [4] [17].Source: §B.1 · p. 12

Basic hyper-parameters

  • Mask DINO retains DINO’s [37] backbone–Transformer encoder–decoder, increases decoder depth from six to nine layers, and uses 300 queries.Training uses batch size 16; COCO segmentation runs for 50 epochs, ADE20K semantic segmentation for 160K iterations, and Cityscapes semantic segmentation for 90K iterations. The initial learning rate is 1 × 10^-4, with drops at specified epoch or training-step fractions.Source: §B.1 · p. 12

Augmentations and multi-scale setting

  • COCO training uses Mask2Former [3] augmentations, adding LSJ [7,10] and fixed 1024×1024 crops versus DINO [37]; multi-scale inputs use four ResNet-50 and five SwinL scales.The same passage specifies the augmentation and multi-scale settings for these models.Source: Table 16 · p. 13

B.2. Denoising training

Following DN-DETR [18], Mask DINO trains the decoder to reconstruct ground-truth objects from noised boxes and labels, using the boxes to supervise mask reconstruction. Noised queries are used only during training and removed at inference.

B.2. Denoising training

  • Noised boxes and labels are concatenated with original decoder queries during training, then removed at inference; reconstructing masks from noised boxes improves segmentation training.The noised labels and boxes provide the decoder’s content and positional query inputs.Source: §B.2 · p. 13
  • Label noise randomly flips a ground-truth label to another dataset label with probability p = 0.2 before label embedding forms decoder content queries.The method uses label flipping for label noise.Source: §B.2 · p. 13
  • Box noise perturbs center coordinates and scales width and height to [(1 − λ2), (1 + λ2)] of their originals, with λ1 = λ2 = 0.4.Boxes serve as DINO’s positional queries [37]; the center shift is bounded by λ1.Source: §B.2 · p. 13

C. Large models setting

For SwinL large models, Mask DINO follows DINO’s Objects365 pretraining setting and uses task-specific fine-tuning schedules and training configurations.

C. Large models setting

  • SwinL models are pretrained for object detection on Objects365, then fine-tuned for COCO instance and panoptic segmentation and ADE20K semantic segmentation.COCO fine-tuning runs for 24 epochs with 1.2× scale (1280 × 1280) on 16 A100 GPUs; ADE20K fine-tuning runs for 160k iterations with 900 queries and 8 A100 GPUs, using EMA, which helps semantic segmentation.Source: C. Large models setting · p. 14

D. SOTA Results on COCO test-dev

The section presents Mask DINO’s COCO test-dev results in Table 16.

D. SOTA Results on COCO test-dev

Loading 2206.02777v3…