Your ViT is Secretly an Image Segmentation Model
- Publication
- CVPR 2025Conference
- First submitted to arXiv
- arXiv:2503.19108
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{segmentationeomt2025,
title = {{Your ViT is Secretly an Image Segmentation Model}},
author = {Tommie Kerssies and Niccolò Cavagnero and Alexander Hermans and Narges Norouzi and Giuseppe Averta and Bastian Leibe and Gijs Dubbelman and Daan de Geus},
year = {2025},
eprint = {2503.19108},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2503.19108}
}
By 2024, the usual recipe for getting top segmentation results out of a ViT was a ViT backbone with a convolutional ViT-Adapter hung on the side to produce multi-scale features, followed by Mask2Former's pixel decoder, followed by Mask2Former's Transformer decoder. Four big components, each with a pile of custom operations.
This combination is certainly accurate, routinely reaching 57 or 58 PQ on COCO panoptic segmentation. But think about it for a moment. A pretrained ViT like DINOv2 already has features good enough that a single linear layer on top can do semantic segmentation and depth estimation. Does segmentation really still need all these add-ons?
A team from Eindhoven University of Technology in the Netherlands, RWTH Aachen University in Germany and the Polytechnic University of Turin in Italy answers with the paper's title, which says your ViT is already a segmentation model.
Defining the Problem

The top half contrasts the two architectures. On the left, the ViT and the Adapter pass features back and forth several times, and then come two decoders; on the right there's just one ViT.
Each of these extra components is there for a reason. A ViT outputs only one resolution, while segmentation is generally thought to need multi-scale features and the locality of convolution, hence the Adapter; the multi-scale features need fusing, hence the pixel decoder; masks and classes need producing, hence the Transformer decoder.
The authors have two hypotheses. First, large-scale pretraining, especially masked image modeling pretraining like DINOv2's, has already taught the ViT to extract the dense, fine-grained semantics segmentation needs. Second, a large ViT has enough parameters to do the segmentation itself, without add-ons. If both hold, the benefit of these components should fade away as the model and the pretraining get bigger.
Solving the Problem
Taking It Apart, Piece by Piece
The authors start from ViT-Adapter plus Mask2Former and remove one component at a time. The setup is COCO panoptic segmentation with a DINOv2-pretrained ViT-L and input, with speed measured on an H100 with FlashAttention-2 and torch.compile enabled, at batch size 1. Table 1 of the paper:
| Step | Params | GFLOPs | FPS | PQ |
|---|---|---|---|---|
| (0) ViT-Adapter + Mask2Former | 349M | 830 | 29 | 57.1 |
| (1) Drop Adapter | 342M | 700 | 36 | 56.7 |
| (2) Drop pixel decoder | 337M | 685 | 61 | 56.9 |
| (3) Drop multi-scale | 328M | 673 | 64 | 56.7 |
| (4) Drop Transformer decoder | 316M | 828 | 61 | 56.2 |
| (5) Drop masked attention = EoMT | 316M | 669 | 128 | 56.0 |
What each step does:
- Drop the Adapter. With no CNN supplying multi-scale features, they follow ViTDet and build a pyramid directly from the ViT's stride-16 output , upsampling it into and with transposed convolutions and downsampling it into with a convolution.
- Drop the pixel decoder. All four scales come from the same , so there's no need to spend effort fusing them; they go straight to the Transformer decoder.
- Drop multi-scale. The queries' cross-attention looks only at ; only when computing the masks is upsampled to , to keep the output resolution.
- Drop the Transformer decoder. This step is the core of EoMT, and the next section covers it in detail.
- Drop masked attention. This relies on a training trick, covered in the section after that.
The first three steps cost only 0.4 PQ and make it 2.2 times faster. With everything removed, PQ goes from 57.1 to 56.0 and speed from 29 to 128 images per second, 4.4 times faster.
Note that GFLOPs only drop from 830 to 669, less than 20%, yet speed more than quadruples. The authors explain that once everything is stripped away, the whole model is just a standard ViT, which can take full advantage of Transformer-specific optimizations like FlashAttention and the compiler; custom operations like the original multi-scale deformable attention slow everything down even when their computation is small.
Putting the Queries Inside the ViT

Once the Transformer decoder is gone, where do the queries read the image? EoMT's answer is to put them directly inside the ViT.
Let's walk through it with ViT-L. ViT-L has 24 blocks. A image is cut into patches, giving patch tokens. The first 20 blocks are left completely untouched and process only these 1600 tokens, exactly like an ordinary ViT.
Just before block 21, learnable query tokens are attached, making the sequence length . The last 4 blocks do self-attention and MLP as usual, only now the sequence includes the queries.
This one self-attention does both of the jobs in Mask2Former's decoder. Query-to-query attention corresponds to the decoder's self-attention, letting the queries coordinate who takes which object; query-to-patch attention corresponds to the decoder's cross-attention, letting the queries read the image content. What used to take two steps gets done together in a single ViT MHSA. The patches can also see the queries, which the original decoder never allowed.
The final mask module follows Mask2Former's design. Each query token passes through a linear layer to get class scores, and through a 3-layer MLP to get a mask embedding, whose dot product with the patch features upsampled to () gives the mask.
Why put the queries in the last 4 blocks instead of from the start? Keeping the first 20 blocks as they are leaves the image features learned in pretraining undisturbed; only the last few blocks double as the decoder. is the best setting for ViT-L in the appendix experiments.
Masked in Training, Unmasked at Inference
Mask2Former's masked attention is very useful, with each query looking only within the mask it predicted at the previous layer. EoMT wants that benefit too.

The method is to have the mask module predict an intermediate mask for each query before each of the last 4 blocks, and then fill it into the self-attention mask, masking only the query-to-patch region. The other three regions are computed as usual. The effect is the same as Mask2Former's masked cross-attention.
The problem is that this is expensive. The mask module has to run before every block, with the step that upsamples features to costing the most, and the standard attention operation has to be modified as well. That's why the GFLOPs in step (4) of the table above jump back from 673 to 828.
The authors want masked attention to help convergence during training, and none of it at inference. Simply removing it at inference doesn't work; the model breaks. Their solution is called mask annealing.

A block isn't fixed as masked or unmasked; instead, each query has the mask applied with probability . At the start of training and everything is masked; then, starting from the earlier blocks, the probability is gradually lowered to 0. In COCO's 12-epoch schedule, for example, block 21 stops masking around epoch 4, while block 24 holds out until epoch 10. In the last two epochs, the model trains with no masking at all, which is exactly how it runs at inference.
For the training setup, they use AdamW with a learning rate of and layer-wise learning rate decay of 0.8; COCO trains for 12 epochs, ADE20K for 31 and Cityscapes for 107.
Discussion
What If Annealing Is Removed?
Table 7 of the paper compares four combinations (COCO panoptic, ViT-L):
| Training | Inference | FPS | PQ |
|---|---|---|---|
| Masked | Masked | 61 | 56.2 |
| Masked | Unmasked | 128 | 27.4 |
| Unmasked | Unmasked | 128 | 53.2 |
| mask annealing | Unmasked | 128 | 56.0 |
Train with masking and simply drop it at inference, and PQ falls to 27.4; the model is effectively broken. Never masking at all doesn't break it, but costs 3 points. Mask annealing is only 0.2 below masking throughout, at twice the speed.
Pretraining Decides Everything
Whether the hypotheses hold comes down to pretraining. Table 2 of the paper swaps in four kinds of pretraining, all with ViT-L:
| Pretraining | ViT-Adapter + Mask2Former | EoMT | Gap |
|---|---|---|---|
| DINOv2 | 57.1 | 56.0 | −1.1 |
| EVA-02 | 56.7 | 55.5 | −1.2 |
| ImageNet-21K (supervised) | 53.9 | 50.0 | −3.9 |
| ImageNet-1K (supervised) | 50.4 | 44.3 | −6.1 |
DINOv2 and EVA-02 are both large-scale masked image modeling pretraining, and EoMT trails by only a little over 1 point. Switch to supervised classification pretraining on ImageNet, and the gap widens to 4 to 6 points; the add-on components matter again.
Bigger Model, Smaller Gap
Table 3 of the paper compares four ViT sizes, all with DINOv2 pretraining:
| ViT size | ViT-Adapter + Mask2Former | EoMT | Gap |
|---|---|---|---|
| S | 50.5 (33 FPS) | 44.7 (330 FPS) | −5.8 |
| B | 54.4 (32 FPS) | 50.6 (261 FPS) | −3.8 |
| L | 57.1 (29 FPS) | 56.0 (128 FPS) | −1.1 |
| g | 57.7 (20 FPS) | 57.0 (55 FPS) | −0.7 |
With ViT-S, EoMT trails by nearly 6 points; at ViT-g, by only 0.7. Small models really do need the add-ons' help; large models manage on their own.
The speed angle is more interesting. EoMT with ViT-L gets 56.0 PQ at 128 images per second; the full combination with ViT-B gets 54.4 PQ at 32 images per second. With a bigger model and a simpler architecture, the result is both faster and more accurate. The authors conclude that compute should go into scaling up the ViT itself, not into adding components.
Against Other Methods
On COCO panoptic segmentation (Table 4 of the paper), with the input enlarged to , EoMT with ViT-L gets 58.3 PQ at 30 images per second; ViT-Adapter-L plus Mask2Former under the same conditions gets 59.7 PQ at 10 images per second. MaskDINO with Swin-L gets 58.3 PQ at 14 images per second.
On semantic segmentation (Table 5 of the paper), EoMT gets 84.2 mIoU at 25 images per second on Cityscapes, against 84.5 at 7 images per second for the full combination; on ADE20K it's 58.4 versus 58.9, at 92 versus 21 images per second.
The gap on instance segmentation is a bit larger (Table 6 of the paper). At input, EoMT gets 45.2 AP and the full combination 47.6 AP. Comparing from another angle, the authors point out that EoMT with input gets 48.8 AP at 30 images per second, still better than the full combination at (47.6 AP at 29 images per second).
More Than Speed
Because EoMT is just a standard ViT, techniques developed for ViTs apply to it directly. The authors tried ALGM, a token-merging method designed specifically for semantic segmentation (Table 9 of the paper). On Cityscapes, EoMT's computation drops from 4350 to 1183 GFLOPs, throughput rises 31% and mIoU is unchanged. Applied to the full combination, the same method brings computation down from 5200 to 3031 GFLOPs, yet throughput doesn't change at all, because the extra components and the feature exchange between the Adapter and the ViT all need the merged tokens restored.
Out-of-distribution generalization (Table 8 of the paper) likewise benefits from pretraining. Trained on Cityscapes and tested on BRAVO, a set of out-of-distribution data, Mask2Former with a Swin-L backbone drops to 69.4 mIoU, while both models with DINOv2 backbones stay around 77 to 78, with EoMT at 77.2.
Conclusion
With the ViT-Adapter, the pixel decoder, the multi-scale features and the Transformer decoder removed, what's left of EoMT is a ViT with query tokens attached in its last 4 blocks; mask annealing then lets inference skip even masked attention. On a DINOv2-pretrained ViT-L, PQ drops by only 1.1 and speed goes up 4.4 times.
This conclusion comes with conditions. Switch to supervised pretraining on ImageNet and the gap widens to 4 to 6 points; a small model like ViT-S also trails by nearly 6 points, and there the add-on components still earn their place.
If you have a DINOv2 ViT-L or bigger, try EoMT first; if all you have is a ViT-S, better hang on to the Mask2Former add-ons.