Your ViT is Secretly an Image Segmentation Model

EoMT (Encoder-only Mask Transformer) is a panoptic/semantic/instance segmentation model that uses a plain ViT with no task-specific machinery.

  • Paper: Kerssies, Cavagnero, Hermans, Norouzi, Averta, Leibe, Dubbelman and de Geus (TU Eindhoven / Polytechnic of Turin / RWTH Aachen), Your ViT is Secretly an Image Segmentation Model, CVPR 2025, arXiv:2503.19108, code at tue-mps.org/eomt.
  • Claim (negative and deflationary): the task-specific machinery that state-of-the-art ViT segmentation models bolt onto a plain ViT encodes inductive biases that a sufficiently large, sufficiently pre-trained ViT has already learned for itself.
  • Machinery removed: a convolutional adapter (ViT-Adapter) for multi-scale features, a pixel decoder to fuse those scales, and a Transformer decoder with masked cross-attention (Mask2Former, M2F).
  • Core idea: add learnable query tokens and a small mask head to a plain ViT; accuracy barely moves while speed multiplies.
  • Headline result: EoMT with ViT-L reaches 56.0 PQ at 128 FPS on COCO val2017, against ViT-Adapter-L + Mask2Former’s 57.1 PQ at 29 FPS, i.e. faster for PQ.

ViT-Adapter + Mask2Former vs. EoMT: architecture and the PQ/FPS trade-off
Left: what the two pipelines contain. Right: Panoptic Quality vs. FPS (log scale) across DINOv2-pre-trained ViT sizes on COCO val2017. EoMT occupies the whole right side of the curve.

Motivation

The standard recipe for ViT segmentation is a stack of compensations for the ViT’s two “deficiencies” relative to a CNN: a ViT is single-scale (one patch size, one resolution) and globally-attentive (no local convolutional prior). ViT-Adapter injects convolutional multi-scale features into the ViT via multi-scale deformable attention (see Deformable DETR) and extracts ; Mask2Former’s pixel decoder fuses them into ; the Transformer decoder runs blocks of masked cross-attention plus query self-attention over learnable queries.

The paper’s two hypotheses:

  1. Large-scale pre-training already provides the fine-grained information. Masked-image-modeling objectives such as DINOv2 and EVA-02 teach the ViT to extract dense, semantically fine-grained patch features — exactly what these components were added to supply.
  2. Larger ViTs have the capacity to do the rest themselves. With more learnable parameters, the ViT can absorb the segmentation-specific computation that the decoder was doing.

If both hold, the components are redundant, and their cost — which is disproportionately in latency, not FLOPs — is pure waste.

Preliminaries

A ViT splits into non-overlapping patches, linearly projects them into patch tokens , and applies blocks

with Norm layer normalization. Reordering the final tokens spatially yields .

In a Mask Transformer, queries produce per-query class logits from a linear layer and mask logits by an MLP yielding a mask embedding and a dot product with the features . Each ground-truth segment is assigned to a unique query.

Removing the task-specific components

Intermediate configurations from ViT-Adapter + Mask2Former down to a single-scale Transformer decoder
Fig. A of the paper: configurations (0)–(3) of the ablation ladder, before the decoder itself is dissolved into the ViT.

The paper strips the pipeline one stage at a time (Tab. 1, ViT-L, DINOv2, COCO val2017):

  • (1) Remove the adapter. Build the feature pyramid directly from , following ViTDet: for each scale, repeat a (transposed) convolution with stride , GELU, a depthwise convolution, and a final Norm until the target resolution is reached — upscaling to , downscaling to .
  • (2) Remove the pixel decoder. With all scales derived from one backbone map, there is nothing left to consolidate across hierarchy stages; feed straight to the Transformer decoder.
  • (3) Remove multi-scale processing. Queries cross-attend exclusively to ; only is still computed, purely to keep mask logits at high resolution.
#ConfigurationParamsGFLOPsFPSPQ
(0)ViT-Adapter + Mask2Former349M8302957.1
(1)w/o ViT-Adapter342M7003656.7
(2)w/o pixel decoder337M6856156.9
(3)w/o multi-scale328M6736456.7
(4)w/o Transformer decoder316M8286156.2
(5)w/o masking = EoMT316M66912856.0

Steps (1)–(3) cost PQ and buy a speedup. The FPS gain far outruns the FLOPs gain — the removed components are latency-heavy relative to their arithmetic, because they break the highly optimized plain-ViT execution path (FlashAttention, torch.compile, fused kernels) with custom ops. Step (4) increases FLOPs and lowers FPS, since folding the decoder into the ViT means the mask module is applied repeatedly for masked attention, with upscaling dominating; step (5) removes masked attention at inference and recovers everything.

Architecture

EoMT architecture: queries concatenated to patch tokens after the first L1 blocks
Learnable queries are concatenated to the patch tokens after ViT blocks; the last blocks process both jointly and feed the mask module.

EoMT is a plain ViT plus two small additions:

  • Queries. After the first unchanged encoder blocks, learnable query tokens are concatenated to the patch token sequence. The remaining blocks process the concatenated sequence with ordinary MHSA per Eq. (1). A standard Mask Transformer separates (i) query–query self-attention and (ii) query-to-patch cross-attention into sequential operations; EoMT’s single self-attention over the joint sequence performs both at once, at zero architectural cost. The last blocks therefore do double duty: process patch tokens as before and replace the Transformer decoder.
  • Mask module. As in Mask2Former: a linear layer on the query tokens for class logits, and a three-layer MLP followed by a dot product with the upscaled features for mask logits.

The token overhead is small: adding 200 queries to a model processing images at patch size is tokens per block, but only for the last blocks. With , for ViT-L, total tokens processed across the ViT rise by only .

Masked attention and mask annealing

Masked self-attention: the per-query masks gate the query-to-patch block of the attention matrix
The joint self-attention matrix over queries and patch tokens. Only the query-to-patch quadrant is masked, mimicking M2F’s masked cross-attention.

Mask2Former’s masked cross-attention (a query attends only to its own predicted mask region) improves accuracy but requires predicting and applying an intermediate mask before every decoder block. EoMT can reproduce it during training: the shared mask module is applied before each of the last blocks, and the predicted mask gates the query-to-patch quadrant of the joint self-attention matrix. Query-to-query, patch-to-query and patch-to-patch attention stay unmasked.

Doing this at inference is exactly the expense that ruins step (4) above. The fix is mask annealing: for each block, apply the mask for a given query with probability , starting at and decaying block by block to over training, earlier blocks annealing first. The model benefits from masked attention’s faster convergence early on, then learns to operate without it, and at inference is a plain ViT with no intermediate modules and no modified attention op.

Mask annealing schedule per block over training epochs
Masking probability per block over 12 epochs (ViT-L, , blocks 21–24). Annealing is staggered: earlier blocks are freed first.

Ablating the alternatives (Tab. 7 / Tab. C, COCO val2017):

TrainingInferenceGFLOPsFPSPQ
MaskingMasking8286156.2
Maskingw/o masking66912827.4 ()
w/o maskingw/o masking66912853.2 ()
Mask annealingw/o masking66912856.0 ()

Simply disabling masking at inference after training with it is catastrophic ( PQ) — a train/test mismatch, not a free lunch. Never masking is merely bad (). Annealing gets essentially the masked-training PQ at masked-free inference speed, more than doubling throughput. The same trick also works for the ViT-Adapter + M2F baseline (Tab. C: vs ).

Hyperparameters

Section 4.1 and Appendix A.

SettingValue
Default backboneDINOv2-L (vit_large_patch14_reg4_dinov2 via timm), input, patch size
Other backbonesDINOv2 ViT-g/L/B/S, EVA-02-L, DeiT-III ViT-L (IN21K and IN1K)
(blocks processing queries)3 for ViT-S/B, 4 for ViT-L, 5 for ViT-g
Queries 200 for panoptic and instance, 100 for semantic
OptimizerAdamW, learning rate , mixed precision
Layer-wise LR decay (LLRD)factor 0.8
LR decaypolynomial, factor 0.9
Mask annealingpolynomial, factor 0.9; from 1.0 to 0.0
LR warm-uptwo-stage linear: 500 iterations warming up the randomly initialized parameters with pre-trained weights frozen, then 1000 iterations warming up the pre-trained parameters; initial LR 0 in both cases
Epochs12 ( schedule) on COCO, 31 on ADE20K, 107 on Cityscapes
Loss with , , (as Mask2Former)
AugmentationMask2Former’s: horizontal flip, scale jitter, padding, random crop; color jitter additionally on ADE20K and Cityscapes; large-scale jitter (–) for panoptic/instance, normal-scale jitter (–) for semantic
Patch embedding / pos. emb. resizingFlexiViT-style kernel resize to plus bicubic interpolation of positional embeddings, done before fine-tuning and kept fixed
Inferencepadded inference (resize longer side, zero-pad to square) for panoptic/instance; windowed sliding-window inference for semantic
Benchmarking hardwareNVIDIA H100, FlashAttention-2, torch.compile, batch size 1; FLOPs via fvcore

Results

Model size (COCO val2017, Tab. 3)

SizeMethodParamsGFLOPsFPSPQ
gViT-Adapter + M2F1209M25102057.7
gEoMT w/ masking1164M26893557.2
gEoMT1164M22615557.0 ()
LViT-Adapter + M2F349M8302957.1
LEoMT316M66912856.0 ()
BViT-Adapter + M2F121M3473254.4
BEoMT93M21626150.6 ()
SViT-Adapter + M2F47M1653350.5
SEoMT24M5833044.7 ()

This is the paper’s central scaling claim: the gap shrinks monotonically with model size — PQ at ViT-S, at ViT-B, at ViT-L, at ViT-g. Task-specific components matter when the ViT is small; they become nearly irrelevant when it is large. And because EoMT is so much faster, the speed budget that would buy a ViT-B baseline buys a ViT-L EoMT — the trade is favourable in both directions.

Pre-training (COCO val2017, ViT-L, Tab. 2)

Pre-trainingViT-Adapter + M2F PQEoMT PQGap
DINOv257.156.0
EVA-0256.755.5
IN21K (DeiT-III)53.950.0
IN1K (DeiT-III)50.444.3

Same story along the other axis. With supervised ImageNet pre-training the components are worth – PQ; with masked-image-modeling vision foundation models they are worth ~. The paper attributes this to MIM objectives producing the patch-level semantic understanding segmentation needs.

Benchmarks

  • Panoptic (Tab. 4). EoMT ViT-L at : 56.0 PQ / 128 FPS on COCO, 50.6 PQ / 128 FPS on ADE20K; at : 58.3 PQ / 30 FPS COCO, 51.7 PQ ADE20K. EoMT ViT-g at : 59.2 PQ / 12 FPS COCO, 52.8 PQ ADE20K. For comparison, Mask2Former + ViT-Adapter-L at gets 59.7 PQ at 10 FPS (4817 GFLOPs vs EoMT’s 4146), and Mask2Former + Swin-L (IN21K) 57.8 PQ at 24 FPS. On COCO, EoMT is on par with state of the art while up to faster.
  • Semantic (Tab. 5). Cityscapes val: EoMT ViT-L 84.2 mIoU at 25 FPS (4350 GFLOPs) vs ViT-Adapter-L + M2F 84.5 at 7 FPS (5200 GFLOPs) — faster for mIoU, and up to faster elsewhere. ADE20K val: 58.4 mIoU at 92 FPS vs 58.9 at 21 FPS.
  • Instance (Tab. 6). COCO val2017: EoMT ViT-L 45.2 AP at 128 FPS () and 48.8 AP at 30 FPS (), against ViT-Adapter-L + M2F 47.6 AP at 29 FPS and 48.9 AP at 10 FPS. The accuracy drop is somewhat larger here than for the other tasks, but the AP/FPS trade-off is still better.

Out-of-distribution generalization

Being ViT-only, EoMT can be initialized from vision foundation models, which are the strongest OOD performers. Trained on Cityscapes train, evaluated on BRAVO (Tab. 8): DINOv2-based models reach – mIoU vs Swin-L + M2F’s , despite similar in-distribution mIoU (–); EoMT gets 84.2 mIoU / 77.2 mIoU. On OOD confidence estimation (Tab. E) EoMT reaches AUPRC 89.7, far above ViT-Adapter-L + M2F’s 68.7 and Swin-L + M2F’s 56.8 — it assigns low confidence to the whole OOD object rather than to fragments of it.

Token merging (Tab. 9)

Because EoMT stays close to a plain ViT, it inherits generic ViT optimizations. Applying ALGM token merging (no retraining, batch size 32, Cityscapes val) raises throughput from 38 to 50 images/s () at unchanged 84.2 mIoU. ViT-Adapter + M2F’s FLOPs drop under ALGM (5200 → 3031) but throughput does not move at all ( img/s either way), bottlenecked by its extra components and the cost of “unmerging” tokens for adapter interaction.

ablation (Tab. D)

Number of ViT blocks that also process queries, ViT-L on COCO: PQ / 126 FPS; / 127; / 128; / 128. Performance is flat and FPS is essentially unaffected, so is chosen as the ViT-L default.

Limitations

  • The claim is conditional on scale. At ViT-S and ViT-B, EoMT loses and PQ. The paper’s title is only true for large models; for small ones the adapter and decoder are still doing real work. Similarly, with plain ImageNet pre-training the gap reopens to PQ.
  • Absolute accuracy is not state of the art. At matched input size, ViT-Adapter-L + M2F is still ahead (59.7 vs 58.3 PQ at ); EoMT wins on the trade-off, not on the top number.
  • Instance segmentation degrades most ( vs AP at ), suggesting single-scale features hurt more for tight per-instance boundaries than for panoptic/semantic labelling.
  • Mask annealing is a training-schedule hyperparameter (polynomial factor 0.9, staggered per block) with no principled derivation, and the failure mode when it is mishandled is severe ( PQ when masking is dropped abruptly).
  • The FPS advantages are measured on an H100 with FlashAttention-2 and torch.compile; part of the win is that plain ViTs are what current kernels are optimized for, so the margin is hardware- and toolchain-dependent (torch.compile had to be disabled for some baselines due to compilation errors, and full precision used for OneFormer with DiNAT-L).
  • EoMT does not remove the mask module or the upscaling, which remain the most compute-intensive non-ViT operations at inference.

See also

  • SAM — the other “plain ViT plus a small head” segmentation design, with a heavyweight ViT encoder and a lightweight prompt-conditioned mask decoder
  • SAM2 — extends that line to video
  • DETR — origin of the learnable-query, set-prediction formulation that Mask Transformers and EoMT’s queries inherit
  • Deformable DETR — supplies the multi-scale deformable attention used by ViT-Adapter and Mask2Former’s pixel decoder, the machinery EoMT deletes
  • LW-DETR — the same “a plain ViT encoder is enough” argument, made for real-time detection
  • Implementing Research Papers