Mask2Former, Dissected
In short. By late 2021, universal segmentation architectures existed and kept losing. MaskFormer handled panoptic, instance, and semantic segmentation with one design, and trailed the best instance specialist by over 9 AP while needing 300 training epochs and a 32 GB GPU per image. Mask2Former [Cheng et al. 2022] closed the gap without abandoning the paradigm, by rebuilding the decoder and the training recipe. Each query predicts a class and a mask. Masked cross-attention restricts the query’s next image read to its current mask, the decoder cycles through three feature scales, and mask losses are evaluated at sampled points. The strongest Swin-L variants reach 57.8 PQ and 50.1 AP on COCO and 57.7 mIoU on ADE20K. With ResNet-50, the COCO schedule falls to 50 epochs and reported training memory to 6 GB.
Contents. 0. Background · 1. The problem · 2. Two paradigms · 3. Set prediction · 4. Architecture · 5. Masked attention · 6. Multi-scale features · 7. Decoder rewiring · 8. Point-sampled losses · 9. Training · 10. Results · 11. Ablations · 12. Limitations · 13. Later work · 14. Conclusion · Appendix A · Appendix B · References · Citation
If you already know DETR and segmentation metrics, start at §4. For a shorter path, read sections 4 through 8 and section 11. Proofs and longer derivations are folded, and the main argument does not depend on them.
0. The background you need
Start here if any of this is new. Skip to §1 if words like attention, embedding, and loss already feel comfortable. The notation table below is a reference to return to, not something to memorize.
Images, pixels, and the job. An image is a grid of pixels. Segmentation assigns labels to those pixels and decides which ones belong to the same region. Section 1 separates the three tasks built from that idea.
Feature maps. A backbone converts the image into a smaller grid where each cell holds a vector that summarizes part of the image. That grid is a feature map. The stride is the shrink factor. At stride 32, a 1024 by 1024 image becomes a 32 by 32 grid. Small objects can lose useful detail at this scale. §6 explains why Mask2Former also uses finer features.
Convolutions. Most vision backbones use convolutions. A convolutional filter is a small grid of learned weights. At each image position, it multiplies those weights by the pixels beneath them and sums the products. Repeating this operation across the image produces a feature map that responds wherever the learned pattern appears. With a filter and input , the output at location is
Here indexes a position inside the filter. A layer applies many filters, adds learned biases, and passes the results through a nonlinearity such as ReLU. Stacking these layers produces a convolutional network.
Embeddings and the dot product. An embedding is a learned vector whose geometry carries information. Related inputs often point in similar directions. The dot product compares two embeddings. For nonzero vectors and with angle between them,
so it is positive when the vectors point in similar directions, zero when they are orthogonal, and negative when they point apart. Mask2Former forms each mask by taking a dot product between a query-derived vector and every pixel embedding, then applying a sigmoid.
Softmax. The scores before softmax are called logits. For logits , softmax assigns each option a weight
which are positive and sum to 1. Softmax can put almost all its weight on a small region, but it does not forbid other locations. Mask2Former adds that restriction explicitly. Sending a forbidden entry’s score to removes it, and the remaining weights still sum to 1.
Attention. Attention is a differentiable lookup. A query is compared with a key at every image location. Softmax turns those comparisons into weights, and the output is the weighted average of the corresponding values. With queries and image locations, stack the queries in and the image keys and values in .
contains every query-key score. Softmax turns each row into weights over locations, and multiplication by returns a weighted average of their values. Dividing by keeps the logits from growing with the key dimension and pushing softmax toward saturation. Cross-attention builds from the queries and from the image. Self-attention builds all three from the same token set. A token is one vector in that set, a query or the vector at one image location. In practice the model runs several of these lookups in parallel, each on its own slice of the feature dimensions. Each slice is called a head, and the head outputs are concatenated and projected back to width .
Transformers and decoders. A Transformer layer combines attention with a per-token network and residual connections. Each token carries a vector . Omitting normalization, the layer applies two updates in order.
The attention step mixes information from the image or from other queries. The feed-forward network then processes each token independently. Residual connections add both updates to the existing token state. Mask2Former stacks nine decoder layers, and each query produces one candidate segment.
Losses, gradients, training. A loss is a single number measuring how wrong the current output is. Training repeats one step. Compute the gradient , the direction in weight space that increases the loss fastest, then move every weight a small step the other way, , where is the learning rate. Sections 3 and 8 define Mask2Former’s loss and explain how its predictions receive training signals.
IoU. Intersection over union compares two regions and with nonempty union.
IoU is 1 when the regions are identical and 0 when they are disjoint. It is used throughout §1 to compare predicted and ground-truth regions.
Sets versus lists. A list has an order. A set does not. Mask2Former’s predictions have no meaningful order, so the loss must keep the same value after any reordering. Section 3 shows how matching provides this invariance.
Notation
| symbol | meaning |
|---|---|
| input image. is the size of the feature map used at decoder layer | |
| the pixel grid, the set of pixel locations of the map under discussion. is its size | |
| shared feature dimension of queries and image features (256 in the reference implementation) | |
| number of object queries (100 by default, 200 for the largest models) | |
| , | number of classes, and the “no-object” class appended to them. This is unrelated to §0’s key matrix |
| prediction , with a soft mask and class | |
| predicted probability that query has class | |
| query features after decoder layer . are the learnable input query features | |
| attention projections. come from image features | |
| mask predictions of layer , resized as logits to the next layer’s attention resolution, then passed through the sigmoid and binarized at | |
| the additive attention mask built from . It is on foreground and elsewhere | |
| per-pixel embeddings from the pixel decoder, at stride 4 | |
| the logistic sigmoid , which squashes a real score into . This is unrelated to §3’s matching permutation | |
| the indicator, with when condition holds and otherwise | |
| BCE, Dice, and class-loss weights. Their values are , , and . The no-object class receives an additional multiplier | |
| number of sampled points for mask losses, |
1. The segmentation problem
Image segmentation groups pixels and labels the groups. Datasets divide categories into things and stuff [Kirillov et al. 2019]. Things are countable objects such as people and cars. Stuff describes regions such as road and sky. Write these category sets as and , with . The symbol means the two sets do not overlap. The three segmentation tasks differ in which groups and identities they retain.
Semantic segmentation is a map on the pixel grid . One label per pixel means that two adjacent cars share one car region. Accumulate the predicted and ground-truth pixels over the evaluation set, then let . Its metric is
where and are the predicted and ground-truth pixel sets of class [Everingham et al. 2015]. Restricting the average to classes with nonzero union removes the case.
Instance segmentation returns one scored mask per detected thing. Mask AP ranks predictions by confidence and measures precision and recall across IoU thresholds from to [Lin et al. 2014].
The core of COCO mask AP
For each class, predictions are ranked by score. A prediction is a true positive when its best unclaimed ground-truth match clears the current IoU threshold.
where the sums visit every pixel of the grid , and is the binarized mask, on the pixels the prediction claims and elsewhere, with the same for the ground truth. On values a product acts as an AND, so each numerator term is exactly when both masks contain the pixel, and the sum counts the intersection. The combination acts as an OR, when either mask contains the pixel, so the denominator counts the union, and the fraction is §0’s intersection over union computed by sums. Finally holds the ground truths of the class still unclaimed when prediction takes its turn, all of them for the top-scoring prediction. If is empty the max is , an automatic false positive. A true positive claims its match, so a duplicate detection of an already-claimed object cannot score twice. Everything else is a false positive. Now fix a score cutoff and keep only the predictions above it. Precision is the fraction of kept predictions that are true positives, and recall is the fraction of ground truths recovered. Sweeping the cutoff from strict to loose traces the precision-recall curve, and AP is the area under that curve, averaged over ten IoU thresholds in the COCO style [Lin et al. 2014]:
Here is the number of ground-truth masks, , and is the interpolated precision, the best precision the curve reaches at recall or beyond. This is the per-category AP. COCO then averages over categories. When a cutoff keeps no detections, COCO records zero precision. A category with no ground-truth instances in the evaluation set is excluded from the mean. A duplicate detection cannot claim an object twice, so confidence ranking matters. This sketch omits crowd and ignore bookkeeping and the per-image detection cap.
Panoptic segmentation [Kirillov et al. 2019] unifies both. Every evaluated pixel receives a class and an instance id, with identities on things and plain categories on stuff. Evaluation first sets aside void pixels, which carry no label, and crowd regions, which group objects the annotators could not separate. Write for matched pairs, for unmatched predictions, and for unmatched ground-truth segments. Quality is
A match requires . PQ is computed per class, then averaged over classes with at least one true-positive, false-positive, or false-negative segment. SQ is the average IoU of the matched pairs. RQ is an F1-like term that penalizes missed and extra segments. Their product follows by multiplying and dividing by when at least one match exists. If but the denominator is nonzero, PQ is and the factorization is not used. The next lemma explains why matches above the threshold are unique.
Lemma (matches are unique). If predicted segments and ground-truth segments are each pairwise disjoint, as the panoptic format requires, then pairs one-to-one. Each segment can match at most one segment from the other set.
Proof: a majority overlap can only happen once
Proof. Suppose a prediction has . Then
So every matching prediction covers more than half of . Now suppose two predictions both matched . The panoptic format keeps predictions disjoint, so and are disjoint subsets of , each larger than . Together they would hold more than pixels inside , which is impossible. So at most one prediction matches . The same argument runs the other way. Since the panoptic format also keeps the ground-truth segments disjoint, and gives , each prediction matches at most one ground truth.
Above the threshold, matching is therefore unambiguous, and greedy matching, pairing segments one at a time with the best still-unclaimed partner, is exact. Contrast this with training-time matching (§3), where predictions overlap freely, costs are soft, and a genuine assignment problem appears.
The output semantics differ, but the underlying problem is still pixel grouping. Mask2Former asks whether one architecture can serve all three tasks.
2. Two paradigms
2.1 Per-pixel classification (2015 onward)
The fully convolutional network (FCN) of [Long et al. 2015] recast semantic segmentation as dense classification. A classifier scores every pixel feature for every class, producing . The per-pixel cross-entropy loss is
where is the softmax of the class scores at pixel and is that pixel’s true class. Cross-entropy is the negative log probability assigned to the correct class. Later models added context through dilated convolutions, pyramid pooling, or attention [Chen et al. 2018, Zhao et al. 2017, Wang et al. 2018, Fu et al. 2019]. Segmenter and SegFormer later used Transformer-based per-pixel classifiers [Strudel et al. 2021, Xie et al. 2021].
A plain per-pixel classifier outputs one category at each pixel. It has no variable for object identity, so it cannot separate two cars that share a class without adding another mechanism. Earlier instance systems added proposals, anchors, grouping rules, or non-maximum suppression. Query-based set prediction provides identities directly and makes the loss invariant to their storage order.
2.2 Mask classification (2017 onward)
Mask R-CNN [He et al. 2017] predicts a binary mask inside each detected box. DETR [Carion et al. 2020] later replaced hand-built proposals with learned queries and one-to-one matching, and its panoptic extension decoded masks from those queries.
MaX-DeepLab [Wang et al. 2021] brought end-to-end set prediction to panoptic segmentation. MaskFormer [Cheng et al. 2021] showed that the same prediction format could outperform per-pixel models on semantic segmentation. K-Net [Zhang et al. 2021] pursued a related design with one dynamic convolution kernel per segment.
The basic idea. Each query predicts a mask and a class. The mask head answers where the segment is. The class head answers what it is. Both heads read the same query, so the predictions are related even though the outputs are separate.
Formally, mask classification predicts
The same prediction format supports all three tasks. Semantic targets contain one mask per class present in the image. Instance targets contain one mask per object. Panoptic targets contain one mask per thing or stuff segment. The architecture and loss keep the same form, while targets, checkpoints, and post-processing remain task-specific.
Example. For the puppy below, one query predicts class and a mask . A small binary version of that mask looks like this.
The matrix says where and the label says what. The model emits mask probabilities rather than hard zeros and ones.
Universal architectures still trailed specialized systems in 2021. MaskFormer reached 40.1 instance AP with a Swin-L backbone, compared with 49.5 for Swin-HTC++ [Chen et al. 2019, Liu et al. 2021]. MaskFormer also trained for 300 epochs and its dense mask losses limited training to one image per 32 GB GPU. Mask2Former’s thesis was that the paradigm was right and the decoder and the recipe were wrong.
3. Set prediction and matching
This matching structure comes from DETR and MaskFormer. Mask2Former changes where the mask costs are evaluated, as §8 explains.
3.1 Matching as an assignment problem
The model returns a fixed set of predictions, 100 by default. Before computing the loss, it finds the lowest-cost one-to-one pairing between predictions and ground truth. The Hungarian algorithm computes this matching. The loss then scores each matched pair, while unmatched predictions are trained as no-object.
Assume an image contains at most real targets. Pad the ground truth with entries up to size , so predictions and targets are both -element sets. Write for the cost of pairing prediction with target , where target carries class and mask . The padded entries have .
The minus sign favors predictions that already assign high probability to the target class. The matcher uses class probability rather than log probability. Its mask terms use the same binary cross-entropy (BCE) and Dice forms used for training. The released code solves a rectangular predictions-by-targets problem over real targets. Padding with zero-cost no-object targets gives the equivalent square matching problem used in the proof below. The classification loss later trains every unmatched prediction as no-object.
In the square view, an assignment is a permutation , where is the set of all reorderings. Restricted to the real targets, it pairs every target with one unique prediction. Padded targets have zero cost, so their order is irrelevant. The total cost is
and the matcher chooses . The classic Hungarian algorithm solves this assignment problem [Kuhn 1955, Munkres 1957]. A later bookkeeping refinement brings the runtime to . The released code calls scipy.optimize.linear_sum_assignment, which uses a modified Jonker-Volgenant algorithm. The code builds the cost matrix on sampled mask points, as §8 describes.
The implementation calls scipy, but the underlying algorithm is useful to understand. A companion maximization problem, the dual, supplies the correctness argument and explains the runtime. The complete derivation is folded below.
The linear program, the duality proof, and a worked 3×3 run
As a linear program. Encode an assignment as with when prediction takes target . Relaxing the integrality to gives a linear program, a minimization of a linear objective over real variables subject only to linear equalities and inequalities,
The relaxation lets a prediction split fractionally across targets, which no real assignment can do. Total unimodularity guarantees that an optimal vertex is still a whole-number permutation. The next argument proves that property from the constraint matrix.
The matrix is the incidence matrix of a bipartite graph. Its rows are the prediction constraints and the target constraints, and each variable appears in exactly two of them, prediction ‘s row and target ‘s row. So the rows carry a 2-coloring, predictions against targets, with every column showing a single 1 in each color. That structure makes the matrix totally unimodular, every square submatrix having determinant , , or .
Lemma (total unimodularity). Every square submatrix of the constraint matrix has .
Proof. Induct on the order of .
Base case (). is a single entry, or , so .
Inductive step (). Suppose the claim holds at every order below . If some column of holds fewer than two 1s, take such a column. Otherwise every column holds exactly two, the most any column can carry. That gives three cases.
- Zero 1s. The column is all zeros, so .
- One 1, at row , column of . Laplace-expand along that column. Only the single nonzero entry contributes, so , where deletes row and column . Now has order , so by the hypothesis, hence .
- Two 1s in every column. Every constraint-matrix column carries its two 1s in one prediction-row and one target-row, so each column of has one 1 among the prediction-rows and one among the target-rows . Summing the rows in picks up exactly one 1 per column, giving the all-ones vector , and summing the rows in gives the same way. So , a nontrivial dependence among the rows, and is singular with .
Every case lands in .
Total unimodularity forces integrality. The feasible set is nonempty, since any permutation matrix sits in it, and bounded, since every , so the minimum is attained at a vertex. Attainment at a vertex is standard. A bounded polyhedron is the convex hull of its finitely many vertices (the Minkowski-Weyl theorem), and a linear objective on a mix of the vertices , with weights summing to , equals the same mix of the vertex values, so no point can beat the best vertex. At a vertex, enough of the constraints are tight to pin down. Those tight constraints hold their variables at , and the surviving basic variables are fixed by the equality constraints. Dropping the one redundant equality (one is redundant because the prediction constraints and the target constraints each sum to the same equation , so any single constraint follows from the other ) leaves a square nonsingular submatrix with , where is a vector of ones. Cramer’s rule writes each entry of as a ratio of two determinants, with one column swapped for over . The numerator is an integer matrix’s determinant, hence an integer, and makes every entry an integer. With and every row and column summing to , each holds a single and the rest , a permutation matrix. The relaxation is therefore exact, its optimum a genuine assignment with nothing to round.
So much for the primal. Every linear program has a companion maximization, its dual, whose value never exceeds the primal minimum. Here the dual attaches a potential to each constraint, per row and per column,
and dual feasibility is exactly the reduced cost staying nonnegative everywhere.
The optimality certificate. Take any row potentials and column potentials , and sum the reduced cost along an assignment :
The reindexing is legitimate because is a permutation. The map hits every row index once, so . The two potential sums do not depend on , so the potentials shift every assignment’s total by the same constant, and is unchanged. Call the potentials feasible when everywhere, and an edge tight when .
Lemma (a tight assignment is optimal). If feasible potentials admit an assignment that uses only tight edges, then minimizes .
Proof. Let be any assignment. Rearranging the certificate identity,
So lower-bounds the cost of every assignment. The tight uses only edges with , so its first sum vanishes and . That equals the lower bound, so no assignment costs less.
A full assignment sitting on tight edges is a certificate that meets that bound. The equality is complementary slackness. An optimal puts weight only where .
The primal-dual algorithm. Instead of checking all assignments, the Hungarian method searches for feasible potentials and a complete matching on tight edges. It maintains two invariants. Reduced costs stay nonnegative, and matched edges stay tight. Consider three predictions against three targets, with prediction in row , target in column , and the costs collected in a matrix written for this example only.
Make zeros. Start with . Row and column reductions create enough zero reduced costs to begin matching. Subtract each row’s minimum from its row, which sets , then subtract each remaining column minimum, . The certificate identity makes this legal because the potentials shift every assignment by the same constant. Here and then .
Read a reduced cost as regret, how much worse a pairing is than the best deal available to its row and column. Every row and every column now holds a zero, and the column pass cannot wipe out a row’s zero, because that zero sits in a column whose minimum is already , so there and the entry survives untouched.
Match on zeros. Pair rows to columns through tight edges only, never reusing a row or a column. Row 1 takes column 2 and row 3 takes column 1. Row 2’s only zero sits in column 2, already taken, so the matching stalls at two pairs.
The tool for getting unstuck is the augmenting path. Call a row or column free while it has no partner. An augmenting path starts at a free row, steps to a column through a zero, steps from that column to its partner row through the matched edge, steps to a new column through another zero, and keeps alternating until it lands on a free column. Flip every edge along it, matched becoming unmatched and back. Each interior row and column trades one partner for another while the two free endpoints gain one, so the matching grows by exactly one pair. Matching as far as possible means flipping augmenting paths until none exists.
None exists here. From the free row 2 the only zero leads to column 2, column 2’s partner is row 1, and row 1 owns no other zero to continue through. Dead end.
Create a new zero. The rows and columns just visited form the alternating tree, here rows and columns . These names are local to this example. Progress needs a zero on an edge from a row in to a column outside . Take the smallest remaining reduced cost on such an edge.
and pay for it with the potentials. Raise by on every tree row and lower by on every tree column. Three checks, one per kind of entry, show the move is safe.
- Tree row, outside column. The reduced cost drops by . By the choice of nothing goes negative, and the minimizer lands exactly on zero. That is the purchased edge, here.
- Tree row, tree column. The raise and the drop cancel, so every edge inside the tree, the matched ones included, stays exactly as tight as it was.
- Outside row, tree column. The reduced cost rises by , harmless for nonnegativity, and the only zeros this can erase are unmatched ones, because a tree column’s partner sits inside the tree.
So the invariants hold and the tree gains ground. The dual objective also rises by , because the tree always holds one more row than column, every column it reaches being matched (a free column would already end an augmenting path) and each matched column bringing its partner row along, so only the root row lacks a column. The lower bound climbs toward the optimum with every lift. With and ,
Augment. The purchased zero at extends the search. Row 2 now reaches column 1, column 1’s partner row 3 joins, and row 3 owns a zero in column 3, which is free. That is an augmenting path, row 2 to column 1 to row 3 to column 3. Flip it. Row 2 takes column 1, row 3 moves to column 3, row 1 keeps column 2, and the matching is perfect.
Read off the certificate. In the original matrix the assignment costs , and the potentials sum to . Primal equals dual, so by the lemma no assignment can cost less, and enumerating all permutations confirms it. The permutation matrix of this matching is the optimal vertex of the linear program, the potentials are the optimal dual solution, and the equality that just closed is complementary slackness checked by hand. On a larger instance nothing new happens. Match through zeros until stuck, buy the cheapest escape zero, augment the moment a free column comes into reach, and stop when every row has a partner.
Each augmentation adds one edge, so at most augmentations finish the matching. One piece of bookkeeping makes each augmentation cost . For every column outside the tree, keep its current slack and update it in when a row joins. Each is then read from the slacks rather than found by rescanning the matrix. Every lift either reaches a free column and enables an augmentation, or adds a matched column and its partner row to the tree. Thus at most lifts occur between augmentations, giving work overall. The Jonker-Volgenant routine called by scipy is a faster-constant refinement of the same primal-dual idea.
The minimum assignment cost has one property the model needs.
Proposition (the matching objective ignores prediction order). Let , with the costs evaluated on the model’s current predictions. Relabeling the predictions by any permutation leaves unchanged.
Proof: relabeling only reindexes the search space
Proof. Let relabel the predictions, so that position now holds the prediction originally at position . Under the relabeling, assignment pairs target with the prediction originally at position , so its cost is
Minimize over . As ranges over , the composite ranges over all of too, because left multiplication by the fixed is a bijection of the group, undone by composing with , so every is hit exactly once, as . So
which is before relabeling.
The minimum cost is invariant even when several assignments tie. When the optimum is unique, relabeling maps it to the corresponding relabeled assignment, so the downstream loss is unchanged. With exact cost ties, index-dependent tie-breaking can select different minimizers and therefore different gradients.
The model’s storage order carries no meaning, and the matching objective respects that. Once the assignment is fixed, it determines which target supplies each query’s training signal. §8 shows that changing only the matching cost improves AP by more than two points.
An independent nearest-target choice could assign two queries to one object and leave another unmatched. One-to-one training discourages these duplicates and enables inference without non-maximum suppression.
3.2 The training loss
The mask loss is BCE plus Dice,
and the total loss adds classification, , where is plain cross-entropy against the matched target’s class , with on matched queries and on . The gradients show why these are the right terms.
BCE. At a point with mask logit , prediction , and target , the loss is
Its gradient through the logit collapses to one clean expression,
The BCE gradient, step by step
The two logarithms differentiate through the sigmoid, by the chain rule in the form . With (differentiate and factor the result),
Substitute both, then expand and cancel:
Clean, well conditioned (the gradient is bounded by 1 whatever the logit, so a confident mistake still gets a useful signal), and independent per point. The same expression holds for bilinearly sampled targets . The released loss averages BCE over sampled points and normalizes it by the number of matched masks. That per-point independence is also a weakness. Summed over a dense grid, the total gradient a segment receives scales with its area, so large segments dominate the update and small ones barely register.
Dice. Mask2Former uses a soft Dice loss that normalizes overlap by predicted and target size [Milletari et al. 2016]. Write for the overlap and for the size sum. The released implementation is
The added s smooth the empty-mask case, and Milletari’s original uses sums of squares in the denominator. Dice couples all sampled points through one region-level score. Writing the smoothing constant as , the gradient at a single point is
The Dice gradient, step by step
Differentiate with respect to the single probability . Every other term of each sum is constant, so
Then, using the quotient rule in the form ,
Read the fraction as a whole. The numerator is of order , so each point’s gradient scales like , and summed over the region’s roughly points the total gradient a segment receives is roughly independent of its area. The scale invariance is exact in one specific sense. Tile disjoint copies of the same prediction and target pattern, and every sum scales by , leaving the unsmoothed loss unchanged. Dice weights a ten-pixel object and a sky-sized region equally. Its price lands one step further back, in logit space. When the prediction confidently misses the target, is near 0 exactly where , and the chain rule multiplies the healthy by , so the gradient dies through the saturated sigmoid. BCE cancels that factor exactly, as its logit gradient shows. Dice does not. Summing the two losses is the standard combination. BCE supplies gradient at every point, and Dice makes that gradient scale-invariant.
What happened to focal loss? MaskFormer used focal loss [Lin et al. 2017] with weight , cross-entropy scaled down on already-confident predictions so easy background points stop dominating the gradient. Mask2Former reverts to plain BCE at weight . Focal loss exists to fight the extreme foreground-background imbalance of dense evaluation, and §8’s point sampling removes most of that imbalance at the source, so the simpler and better-conditioned loss suffices. The paper never measures this change on its own.
The down-weighting. With queries and typically 5 to 20 real segments in an image, no-object outnumbers real matches by roughly 4 to 19 times. At full weight, predicting nothing becomes the dominant gradient. Down-weighting the class term to on unmatched queries is the inexpensive fix, inherited from DETR.
Deep supervision. The model predicts once from and after each of nine decoder layers, ten supervised predictions per forward pass through the same shared heads. In the released criterion, Hungarian matching is recomputed for each of the ten outputs, so every intermediate prediction trains toward its own assignment. In most papers auxiliary losses are an optimization nicety. Here they are structural. The thresholded intermediate masks become attention masks in §5, and being a useful attention gate is otherwise never optimized.
4. The architecture
Mask2Former keeps MaskFormer’s three-part structure. A backbone produces image features. A pixel decoder turns them into a feature pyramid and a stride-4 pixel embedding map . A Transformer decoder processes queries against the image features. Each query produces a class distribution and a mask.
The class head is one linear layer with weights and bias . It predicts what the query represents. The mask head is a small multi-layer perceptron (MLP). It maps the same query into an embedding and compares it with every pixel embedding to predict where the segment lies. Masks are produced at stride 4 and then upsampled. The paper uses either a ResNet [He et al. 2016] or Swin [Liu et al. 2021] backbone. MaskFormer used a feature pyramid network (FPN) pixel decoder [Lin et al. 2017b] and six standard decoder layers over one stride-32 feature map.
5. Masked attention
Global cross-attention can learn where an object is, but the authors argue that learning this localization is slow. Masked attention starts from the region each query currently predicts and refines it layer by layer.
5.1 Why localization helps
A standard decoder layer updates queries by cross-attention over the whole feature map:
Here comes from the previous query state, while and come from the image features. For readability, the equation omits the standard scaling, the multi-head split, and the query and image position embeddings used by the implementation. It also omits the self-attention and feed-forward steps that complete the layer, folding them into . The paper writes the recurrence the same way.
Nothing restricts where a query looks. Earlier DETR studies linked slow convergence to the time needed for cross-attention to become spatially focused [Gao et al. 2021, Sun et al. 2021]. Mask2Former tests the same hypothesis. In its converged cross-attention baseline, about 20 percent of the attention mass falls inside the matched ground-truth segment on COCO val. This does not show that global attention cannot localize. It shows that this baseline remains diffuse, even after training.
One toy calculation shows the effect of having many background locations. Let foreground locations share logit , and let background locations share logit . Their foreground attention mass is
Now suppose the object covers 2 percent of the image, so , , and . With foreground logit margin and ,
In this toy model, the background wins because it has many more locations. Real attention logits are not two spikes, and sufficiently concentrated global attention can overcome the imbalance. The calculation only explains why explicit localization can make learning easier.
5.2 The masked update
Masked attention assumes that a query can update from features inside its current segment, while self-attention carries information between queries. The mask is added before the cross-attention softmax.
is the query’s mask from the previous layer. Its logits are bilinearly resized to the current attention resolution, passed through the sigmoid, and thresholded at . The initial mask is predicted directly from the supervised learnable queries (§7).
Adding before softmax gives forbidden locations zero weight and renormalizes the allowed weights to sum to 1. Zeroing weights after softmax would leave their sum below 1 unless they were normalized again. The proof is folded below.
Proposition (additive masking is exact renormalization). Let be logits and a nonempty allowed set (an index set, not §3.2’s size sum), with for and otherwise. Then
which is exactly the softmax of the original logits restricted to .
Proof: the forbidden exponentials become exact zeros
Proof. Fix an index and write its softmax entry from the definition:
Evaluate the numerator by cases, using :
so in one line the numerator is . Split the denominator at :
Divide numerator by denominator:
the softmax of the original logits restricted to .
The paper’s R50 ablation on COCO compares four updates. Plain cross-attention reaches 37.8 AP, spatially modulated co-attention (SMCA) [Gao et al. 2021] reaches 37.9, mask pooling reaches 43.1, and masked attention reaches 43.7. Mask pooling averages the features inside a mask. Masked attention still learns a distribution within the allowed region.
Additive attention masking already existed in Transformer decoders [Vaswani et al. 2017]. Mask2Former makes the mask spatial, query-specific, and dependent on the previous mask prediction. The prediction restricts the next read, and the next query state produces a new prediction.
5.3 Gradients and empty masks
The attention gate is Boolean, so gradients do not pass through the threshold. The learning signal for mask quality arrives only through §3.2’s per-layer auxiliary losses, and that proxy happens to be the right objective. The mask loss is minimized exactly at . For BCE that holds pointwise. For soft Dice it follows from , with equality only at . One line to check: for and binary , vanishing only at , then sum over . Better, the gate is already exactly right once every point’s error falls below , well before the mask itself converges. Imperfect intermediate masks therefore already make good gates. Residual connections preserve the previous query state alongside each new update, so one bad read cannot erase a query.
The implementation also handles an empty predicted region. The detail lives in the official code and not the paper, and without it training produces NaNs (not-a-number, the value floating-point math returns for ) within minutes. If a query’s thresholded mask is empty at some scale, every logit is and the softmax is . The code detects such rows and flips them to fully unmasked, quietly falling back to plain cross-attention for that query at that layer:
attn_mask = (mask_logits.sigmoid() < 0.5).flatten(2) # True = forbidden
attn_mask[attn_mask.all(dim=-1)] = False # the guard rail
One poisoned row would not stay contained. The following self-attention averages all queries together, so a single NaN spreads to every query in one step, then into the loss and every gradient behind it. The guard is also what keeps the masking proposition’s hypothesis true, since flipping the row to fully unmasked makes the allowed set the whole grid instead of empty.
5.4 Did it work?
In the supplementary analysis, average attention mass inside the matched foreground rises from about 0.20 to 0.59. One masked-attention layer also outperforms nine standard cross-attention layers on PQ in the reported layer-wise comparison. Removing masked attention costs 5.9 AP, 4.8 PQ, and 1.7 mIoU. This is the largest drop in the paper’s ablations.
6. Feeding the decoder
6.1 The cost structure
Cross-attention cost grows with the number of image tokens. Its main attention operations cost for queries, an by feature map, and channel width . For a 1024 by 1024 input, strides 32, 16, and 8 contain 1,024, 4,096, and 16,384 tokens. The finest map therefore costs about sixteen times more to attend over than the coarsest.
6.2 The schedule
Mask2Former reads one scale per decoder layer. Layers 1, 2, and 3 use strides 32, 16, and 8, and the cycle repeats twice more. Feeding all three scales to every layer reaches 44.0 AP at 247 GFLOPs. Using only stride 8 reaches the same AP at 239 GFLOPs. The round-robin schedule reaches 43.7 AP at 226 GFLOPs, trading 0.3 AP for lower cost. Removing high-resolution features lowers AP by 2.2.
Each feature also receives DETR’s two-dimensional sinusoidal position encoding and a learned embedding that identifies its scale. The position coordinates are normalized per axis before the sine and cosine features are formed. The scale embedding follows Deformable DETR [Zhu et al. 2021].
6.3 The pixel decoder
The default pixel decoder has six multi-scale deformable-attention (MSDeformAttn) layers over strides 8, 16, and 32. It then fuses the result with stride-4 backbone features to produce pixel embeddings. Each location samples a small learned set of points from every feature level instead of attending densely to all locations [Zhu et al. 2021]. The exact operator and cost are folded below.
Multi-scale deformable attention
For feature at normalized reference point ,
Here , , and index the heads, levels, and sample points per level, and is the feature map at level . This counts points, not classes, and this counts heads, not masks. projects values into head , projects that head back to width , and maps the normalized reference point into level . The offsets and weights are predicted from , with for each head and query . Bilinear interpolation reads fractional locations. The aggregation processes entries of width , so it costs per query apart from the learned projections. Dense attention would read every location at every level.
Among conventional pyramid decoders, BiFPN has the highest AP at 43.5 and ties FaPN at 51.8 PQ. FaPN has the highest mIoU at 46.8 [Tan et al. 2020, Huang et al. 2021]. MSDeformAttn is higher on all three at 43.7 AP, 51.9 PQ, and 47.2 mIoU.
7. Rewiring the decoder layer
Mask2Former changes the decoder layer in three ways without adding FLOPs. Together they improve AP by about 1.4, PQ by 1.1, and mIoU by 0.9. Their effects overlap, so the one-at-a-time ablations in §11 do not add to those totals.
Masked attention comes first. The standard order is self-attention, then cross-attention, then the feed-forward network. Mask2Former uses masked attention, then self-attention, then the feed-forward network. Running cross-attention first gives each query image context before the queries interact. Restoring the original order costs 0.5 AP.
Query features are learnable and directly supervised. DETR zero-initializes query features and learns only positional embeddings. Mask2Former makes learnable and supervises its masks before the decoder runs. The query positional embeddings stay learnable, as in DETR. Every decoder layer adds them to the query features when computing attention, and they appear as query_pos in Appendix A. Direct supervision also gives the first layer a useful gate. Without direct supervision, learnable queries match zero initialization on AP and PQ but improve mIoU from 45.5 to 47.0. Adding supervision reaches 43.7 AP, 51.9 PQ, and 47.2 mIoU. The paper compares the supervised initial predictions to region proposals [Ren et al. 2015] that the decoder refines.
Dropout is removed. Restoring dropout lowers AP by 0.7 and PQ by 0.6 in the ablation.
8. Matching and training on points
8.1 The memory problem and the estimator
Dense mask losses are expensive. Mask2Former evaluates them at sampled coordinates instead. Uniform points build matching costs, while prediction-dependent uncertain points train matched masks.
MaskFormer computed dense mask costs for every prediction-target pair and dense losses again for matched pairs at every supervised head. This limited training to one image per 32 GB GPU. Following PointRend [Kirillov et al. 2020], Mask2Former evaluates these terms at sampled points.
The implementation samples normalized continuous coordinates and reads masks with bilinear interpolation. For an additive point loss such as BCE, the mean over uniform samples is an unbiased estimate of the spatial average, and its variance falls as . The derivation is folded below.
Uniform point estimator
Let be independent uniform points in the unit square, and let be the additive loss on the interpolated masks. The Monte Carlo average is
Linearity of expectation gives the spatial mean. Independence removes the covariance terms in the variance.
This statement applies to additive point losses. Dice is a ratio of sampled sums, so its sampled value is not an unbiased estimate of dense Dice. The code and the paper rely on the empirical result in the section 8.3 ablation rather than an exact equivalence proof.
8.2 Two sampling rules for two jobs
The two sampling rules serve different parts of training.
Matching uses shared uniform points. One set of normalized coordinates is sampled uniformly and reused for every prediction and target mask in the image. Reuse makes the cost matrix cheaper to build. Sharing can also reduce the variance of a cost difference when the two sampled costs are positively correlated, but that is a conditional observation rather than a claim made by the paper.
The conditional covariance argument
Let and be two additive cost estimates evaluated on the same uniform points. Then
Independent point sets make the covariance term zero. Shared points can make it positive because both estimates respond to the same sampled locations. When it is positive, the variance of the difference falls. When it is negative, the variance rises. The equation gives a condition under which sharing stabilizes a comparison. It does not prove that every matching comparison becomes more stable.
Training uses uncertain points. For each matched mask, the PointRend sampler draws uniform candidates [Kirillov et al. 2020]. It keeps the candidates whose prediction logits are closest to zero, then adds fresh uniform points. The uncertainty score depends on the prediction, not the ground truth. These points often lie near a predicted boundary, but uncertain interiors can also be selected.
This training sampler is intentionally nonuniform and applies no importance correction. It therefore changes the training objective rather than providing an unbiased estimate of the dense loss. The section 8.3 ablation shows that the changed objective preserves performance while reducing memory.
8.3 Point-sampling ablation
| matching on | training loss on | AP (COCO) | PQ (COCO) | mIoU (ADE20K) | memory |
|---|---|---|---|---|---|
| masks | masks | 41.0 | 50.3 | 45.9 | 18 GB |
| masks | points | 41.0 | 50.8 | 45.9 | 6 GB |
| points | masks | 43.1 | 51.4 | 47.3 | 18 GB |
| points | points | 43.7 | 51.9 | 47.2 | 6 GB |
Using points for the training loss reduces reported training memory from 18 GB to 6 GB in the paper’s R50 COCO ablation. AP and mIoU stay the same in the dense-matching rows, while PQ rises from 50.3 to 50.8. Using points for matching raises AP from 41.0 to 43.1 with dense training, then to 43.7 with point training. The table measures the effect. Why point-based matching improves the assignment is left open.
9. Training recipe
The table compares Mask2Former’s training recipe with MaskFormer’s. In the decoder row, SA, CA, and MA abbreviate self-attention, cross-attention, and masked attention.
| MaskFormer | Mask2Former | |
|---|---|---|
| optimizer | AdamW [Loshchilov & Hutter 2019], lr | AdamW, lr |
| weight decay | 0.05 | |
| backbone lr multiplier | 0.1 (CNN backbones) | 0.1 (CNN and Transformer backbones) |
| schedule (COCO) | 300 epochs at batch 64 | 50 epochs at batch 16, lr ×0.1 at 90% and 95% of steps |
| augmentation | standard scale and crop | LSJ (large-scale jittering) [Ghiasi et al. 2021], scale 0.1 to 2.0 with a fixed crop |
| mask loss | focal () + dice (), dense | BCE () + dice () on 12,544 points |
| 1.0 | 2.0, with a 0.1 no-object multiplier | |
| decoder | 6 layers, SA→CA→FFN, dropout 0.1, stride 32 only, zero-init queries | 9 layers, MA→SA→FFN, no dropout, strides {32,16,8}×3, learnable supervised queries |
COCO inference resizes the shorter image side to 800 pixels and caps the longer side at 1333. Most models use 100 queries. The largest panoptic and instance models use 200. In the R50 ablation, 100 queries gives the best AP and mIoU, while 200 raises PQ from 51.9 to 52.2. The best setting depends on how many segments an image contains.
Training settings for the other datasets
Cityscapes [Cordts et al. 2016] uses 90,000 iterations with 512 by 1024 crops. ADE20K [Zhou et al. 2017] uses 640 by 640 crops for panoptic and instance training. Semantic crop size varies by backbone. Mapillary Vistas [Neuhold et al. 2017] uses 300,000 iterations with 1024 by 1024 crops.
Post-processing follows MaskFormer. Semantic output sums the masks weighted by each class probability, then selects the highest-scoring class at every pixel.
Panoptic output first keeps queries whose best class is not no-object and whose class probability exceeds . Each pixel chooses the kept query with the largest class-probability times mask-probability score. The pixel is written only if the winning query’s mask probability is at least . For each query, the code divides the number of pixels it wins by the number of pixels in its own thresholded mask and discards the segment when this ratio is below . The final segment is the intersection of the winning pixels and that thresholded mask. Stuff segments with the same class are merged. Rejected pixels remain void.
Instance output flattens the query-class probabilities and selects the highest-scoring pairs. The released code keeps the top 100 pairs per image. The same query mask can therefore appear with more than one class before the top-pair cutoff. For a selected pair , the final score multiplies its class probability by the average mask probability over the predicted foreground.
The implementation uses , so an empty foreground scores zero.
10. Results
The largest models reported in the paper achieve the following results.
| task / dataset | Mask2Former (Swin-L) | previous best | margin |
|---|---|---|---|
| Panoptic, COCO val | 57.8 PQ | MaskFormer 52.7, K-Net 54.6 | +5.1 / +3.2 |
| Instance, COCO val | 50.1 AP (36.2 boundary AP) | Swin-HTC++ 49.5 (34.1) | +0.6 (+2.1) |
| Semantic, ADE20K val | 57.7 mIoU (Swin-L, FaPN, multi-scale inference) | BEiT 57.0 | +0.7 at less than half the parameters |
Boundary AP uses the minimum of mask IoU and Boundary IoU [Cheng et al. 2021c]. Multi-scale in the semantic row means test-time inference over several input sizes. It is unrelated to the decoder schedule. The 57.7 mIoU model also uses FaPN instead of the default MSDeformAttn pixel decoder.
With ResNet-50, Mask2Former reaches 51.9 PQ after 50 epochs. MaskFormer reports 46.5 after 300 epochs. The comparison includes architecture, loss, augmentation, batch size, and optimizer-setting changes, so it should not be read as a controlled convergence experiment. The paper’s appendix isolates one of these variables. Trained with standard augmentation instead of LSJ, R50 Mask2Former converges in 25 epochs, so the short schedule is not an artifact of the augmentation.
The detailed results show three contrasts. Large-object AP reaches 71.2 on COCO test-dev, while small-object AP reaches 29.1. COCO buckets objects by mask area, small under 32 by 32 pixels and large over 96 by 96. Boundary AP improves by 2.1 over HTC++, compared with 0.6 overall. The larger Boundary AP gain shows better boundary accuracy, but the comparison does not isolate its cause. Swin-T Mask2Former reaches 53.2 PQ at 232 GFLOPs, while Swin-L MaskFormer reaches 52.7 at 792 GFLOPs. Throughput moves the other way. The R50 panoptic model runs at 8.6 frames per second, compared with MaskFormer’s 17.6.
The architecture is also evaluated on Cityscapes, ADE20K, and Mapillary Vistas. A Swin-L panoptic checkpoint reaches 66.6 PQ and 43.6 on Cityscapes, the instance AP on thing classes computed from the panoptic checkpoint. The separate Cityscapes instance checkpoint reaches 43.7 AP. Swin-L panoptic checkpoints reach 48.1 PQ on ADE20K and 45.5 PQ on Mapillary Vistas. Each checkpoint is trained for its dataset and task.
11. Ablations and interactions
The table reports controlled R50 ablations across all three tasks.
| change (removed or varied) | ΔAP | ΔPQ | ΔmIoU | takeaway |
|---|---|---|---|---|
| remove masked attention | −5.9 | −4.8 | −1.7 | largest measured drop |
| remove multi-scale high-res features | −2.2 | −1.7 | −1.1 | finer features matter |
| replace point matching with dense masks | −2.7 | −1.1 | −1.3* | point matching improves all three tasks |
| replace supervised learnable features with zero-init | −0.8 | −0.7 | −1.8 | direct supervision of initial queries matters |
| restore dropout | −0.7 | −0.6 | 0.0 | dropout hurts AP and PQ in this setup |
| vanilla layer order | −0.5 | −0.3 | −0.9 | masked attention first performs better |
*Measured with point-sampled training loss fixed. The full two-by-two comparison appears in §8.3.
The sequential substitutions show how the complete system was assembled. Retraining MaskFormer with Mask2Former’s recipe raises AP from 34.0 to 37.8. Replacing the decoder raises it to 41.5. Replacing the FPN pixel decoder with MSDeformAttn reaches 43.7. These increments are not independent causal shares. The components interact, and a different substitution order could produce different gains.
12. Limitations
Universal means one architecture, not one checkpoint. The paper trains separate models for each dataset and task. A panoptic COCO checkpoint reaches 41.7 instance AP, compared with 43.7 for instance-specific training. Its semantic score is 61.7 mIoU, compared with 61.5 for semantic-specific training. Results differ across ADE20K and Cityscapes, so panoptic training does not consistently replace task-specific training.
Small objects remain weaker. Small-object AP is 29.1, compared with 71.2 for large objects. The paper lists fuller use of the feature pyramid as future work. Mask2Former is also slower than MaskFormer, and its query count must be chosen for the expected number of segments.
13. Later work
The same group extended Mask2Former to video instance segmentation [Cheng et al. 2021b]. OneFormer [Jain et al. 2023] trains one task-conditioned model for all three image segmentation tasks. Mask DINO [Li et al. 2023] combines mask prediction with DETR-style detection. These models keep the query-based mask-classification structure while changing the training objective or supported outputs.
14. Conclusion
Mask2Former’s changes support one another rather than stack. Matching gives each query one target. Deep supervision makes every intermediate mask worth trusting. Masked attention turns those masks into the next layer’s reading list, and point sampling makes the loop affordable enough to train. That is why §11’s one-at-a-time deltas never add up to the whole. The parts were built as a loop, not a list.
The headline numbers were passed within a year, as headline numbers are. What the successors in §13 kept is the loop. A query states a hypothesis about a segment, the image grades it, and the next layer reads only where the hypothesis points. That design outlived its own results table.
Appendix A. Implementation notes
The reference implementation is facebookresearch/Mask2Former, built on Detectron2 [Wu et al. 2019]. It was archived on January 1, 2025. Hugging Face provides Mask2FormerForUniversalSegmentation with Mask2FormerImageProcessor or AutoImageProcessor. The image processor exposes semantic, instance, and panoptic post-processing methods. The decoder core is shown below in simplified PyTorch-style pseudocode.
def decoder_layer(
x, feats_l, size_l, pos_l, lvl_emb, query_pos,
prev_mask_logits, pixel_embeddings, num_heads,
):
# x: (N,B,C) · feats_l: (H_l*W_l,B,C) · size_l: (H_l,W_l)
m = F.interpolate(
prev_mask_logits,
size=size_l,
mode="bilinear",
align_corners=False,
)
attn_mask = (m.sigmoid() < 0.5).flatten(2) # (B,N,H_l*W_l)
attn_mask = attn_mask[:, None].repeat(
1, num_heads, 1, 1
).flatten(0, 1).detach() # (B*num_heads,N,H_l*W_l)
attn_mask[attn_mask.all(dim=-1)] = False # Prevent all-masked softmax.
# The scale embedding is part of both the key and value memory.
feats_l = feats_l + lvl_emb
x = norm1(x + cross_attn(
q=with_pos(x, query_pos),
k=with_pos(feats_l, pos_l),
v=feats_l,
attn_mask=attn_mask,
))
x = norm2(x + self_attn(
q=with_pos(x, query_pos),
k=with_pos(x, query_pos),
v=x,
))
x = norm3(x + ffn(x))
h = decoder_norm(x).transpose(0, 1)
cls_logits = class_head(h)
mask_logits = einsum(
"bnc,bchw->bnhw", mask_head(h), pixel_embeddings
)
return x, cls_logits, mask_logits
The heads run once on before the loop and after each of nine decoder layers. The initial prediction supplies . The final output receives the main loss, and the preceding nine outputs receive auxiliary losses.
Appendix B. Questions and answers
Prove that adding before the softmax renormalizes over the allowed set, and say precisely what post-softmax zeroing breaks.
Answer
The §5.2 proposition shows that vanishes outside . The remaining weights form a restricted softmax and still sum to 1. Zeroing after softmax leaves coefficients whose sum is below 1 unless they are normalized again. This does not imply that the resulting vector norm always shrinks.
Derive the foreground attention share for an object covering fraction of the image with logit margin , and evaluate it at , .
Answer
Share . This is the result for the two-logit toy model. It is not a prediction for real attention distributions.
Show that the minimum matching cost is permutation-invariant.
Answer
Relabeling by turns the cost of into the cost of . Composition with a fixed permutation is a bijection of , so the minimum is unchanged. When the optimum is unique, relabeling maps it to the corresponding relabeled assignment and the downstream loss is unchanged. With exact ties, index-dependent tie-breaking can select different minimizers and therefore different gradients.
Gradients do not flow through a thresholded attention mask. How do masks learn to be good gates?
Answer
They do not learn through the Boolean gate. Per-layer deep supervision trains every intermediate mask directly. The auxiliary losses are load-bearing.
Why does matching use shared uniform points while training uses per-mask uncertain points?
Answer
Sharing one uniform coordinate set makes the cost matrix efficient to build. For additive losses, each entry estimates the spatial average of the interpolated point loss. Training instead favors prediction logits near zero and keeps a random fraction for coverage. The uncertain sampler does not use the target mask.
Masked attention improves instance and panoptic metrics more than semantic mIoU in the ablation. What can and cannot be concluded from that?
Answer
The ablation shows a larger gain for instance and panoptic segmentation than for semantic segmentation. Identity separation is a plausible explanation, but the experiment cannot single it out.
Mask2Former produces overlapping soft masks, while panoptic output must be a partition. How are they reconciled?
Answer
Post-processing (§9) imposes exclusivity. Panoptic inference keeps confident non-no-object queries and finds each pixel’s strongest query. It writes the pixel only when the winning mask probability is at least , applies the overlap filter, and merges same-class stuff. Rejected pixels remain void. The surviving segments do not overlap.
Why can PQ evaluation use greedy matching while training cannot?
Answer
The §1 lemma proves uniqueness for non-overlapping segments above 0.5 IoU. Training predictions can overlap and use soft costs, so they still require an assignment algorithm.
References
- Cheng, Misra, Schwing, Kirillov, Girdhar. “Masked-attention Mask Transformer for Universal Image Segmentation.” CVPR 2022. Paper · Supplement · Code
- Cheng, Schwing, Kirillov. “Per-Pixel Classification is Not All You Need for Semantic Segmentation.” NeurIPS 2021. arXiv:2107.06278
- Carion, Massa, Synnaeve, Usunier, Kirillov, Zagoruyko. “End-to-End Object Detection with Transformers.” ECCV 2020. arXiv:2005.12872
- Kirillov, He, Girshick, Rother, Dollár. “Panoptic Segmentation.” CVPR 2019. arXiv:1801.00868
- Kirillov, Wu, He, Girshick. “PointRend: Image Segmentation as Rendering.” CVPR 2020. arXiv:1912.08193
- Zhu, Su, Lu, Li, Wang, Dai. “Deformable DETR.” ICLR 2021. arXiv:2010.04159
- Zhang, Pang, Chen, Loy. “K-Net: Towards Unified Image Segmentation.” NeurIPS 2021. arXiv:2106.14855
- Wang, Zhu, Adam, Yuille, Chen. “MaX-DeepLab: End-to-End Panoptic Segmentation with Mask Transformers.” CVPR 2021. arXiv:2012.00759
- He, Gkioxari, Dollár, Girshick. “Mask R-CNN.” ICCV 2017. arXiv:1703.06870
- Long, Shelhamer, Darrell. “Fully Convolutional Networks for Semantic Segmentation.” CVPR 2015. arXiv:1411.4038
- Vaswani et al. “Attention Is All You Need.” NeurIPS 2017. arXiv:1706.03762
- Kuhn. “The Hungarian Method for the Assignment Problem.” Naval Research Logistics Quarterly, 1955.
- Munkres. “Algorithms for the Assignment and Transportation Problems.” Journal of the SIAM, 1957.
- Milletari, Navab, Ahmadi. “V-Net: Fully Convolutional Neural Networks for Volumetric Medical Image Segmentation.” 3DV 2016. arXiv:1606.04797
- Lin, Goyal, Girshick, He, Dollár. “Focal Loss for Dense Object Detection.” ICCV 2017. arXiv:1708.02002
- Lin, Dollár, Girshick, He, Hariharan, Belongie. “Feature Pyramid Networks for Object Detection.” CVPR 2017. arXiv:1612.03144
- Gao, Zheng, Wang, Dai, Li. “Fast Convergence of DETR with Spatially Modulated Co-Attention.” ICCV 2021. arXiv:2101.07448
- Sun, Cao, Yang, Kitani. “Rethinking Transformer-based Set Prediction for Object Detection.” ICCV 2021. arXiv:2011.10881
- Liu et al. “Swin Transformer: Hierarchical Vision Transformer using Shifted Windows.” ICCV 2021. arXiv:2103.14030
- He, Zhang, Ren, Sun. “Deep Residual Learning for Image Recognition.” CVPR 2016. arXiv:1512.03385
- Chen et al. “Hybrid Task Cascade for Instance Segmentation.” CVPR 2019. arXiv:1901.07518
- Ren, He, Girshick, Sun. “Faster R-CNN.” NeurIPS 2015. arXiv:1506.01497
- Tan, Pang, Le. “EfficientDet: Scalable and Efficient Object Detection.” CVPR 2020. arXiv:1911.09070
- Huang, Lu, Cheng, He. “FaPN: Feature-Aligned Pyramid Network for Dense Image Prediction.” ICCV 2021. arXiv:2108.07058
- Loshchilov, Hutter. “Decoupled Weight Decay Regularization.” ICLR 2019. arXiv:1711.05101
- Ghiasi et al. “Simple Copy-Paste is a Strong Data Augmentation Method for Instance Segmentation.” CVPR 2021. arXiv:2012.07177
- Chen, Papandreou, Kokkinos, Murphy, Yuille. “DeepLab: Semantic Image Segmentation with Deep Convolutional Nets, Atrous Convolution, and Fully Connected CRFs.” TPAMI 2018. arXiv:1606.00915
- Zhao, Shi, Qi, Wang, Jia. “Pyramid Scene Parsing Network.” CVPR 2017. arXiv:1612.01105
- Wang, Girshick, Gupta, He. “Non-local Neural Networks.” CVPR 2018. arXiv:1711.07971
- Fu et al. “Dual Attention Network for Scene Segmentation.” CVPR 2019. arXiv:1809.02983
- Strudel, Garcia, Laptev, Schmid. “Segmenter: Transformer for Semantic Segmentation.” ICCV 2021. arXiv:2105.05633
- Xie et al. “SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers.” NeurIPS 2021. arXiv:2105.15203
- Bao, Dong, Wei. “BEiT: BERT Pre-Training of Image Transformers.” ICLR 2022. arXiv:2106.08254
- Everingham et al. “The PASCAL Visual Object Classes Challenge: A Retrospective.” IJCV 2015.
- Lin et al. “Microsoft COCO: Common Objects in Context.” ECCV 2014. arXiv:1405.0312
- Cordts et al. “The Cityscapes Dataset for Semantic Urban Scene Understanding.” CVPR 2016.
- Zhou et al. “Scene Parsing through ADE20K.” CVPR 2017.
- Neuhold, Ollmann, Rota Bulò, Kontschieder. “The Mapillary Vistas Dataset for Semantic Understanding of Street Scenes.” ICCV 2017.
- Cheng et al. “Mask2Former for Video Instance Segmentation.” 2021. arXiv:2112.10764
- Jain et al. “OneFormer: One Transformer to Rule Universal Image Segmentation.” CVPR 2023. arXiv:2211.06220
- Li et al. “Mask DINO: Towards a Unified Transformer-based Framework for Object Detection and Segmentation.” CVPR 2023. arXiv:2206.02777
- Wu, Kirillov, Massa, Lo, Girshick. “Detectron2.” 2019. github.com/facebookresearch/detectron2
- Cheng, Girshick, Dollár, Berg, Kirillov. “Boundary IoU: Improving Object-Centric Image Segmentation Evaluation.” CVPR 2021. arXiv:2103.16562
Citation
Suggested citation
Massih, Peter. “Mask2Former, Dissected.” Peter’s Patches, no. 1, Jul 2026. https://peteramassih.com/writing/mask2former.
BibTeX
@article{massih2026mask2former,
title = {Mask2Former, Dissected},
author = {Massih, Peter},
journal = {peteramassih.com},
series = {Peter's Patches},
number = {1},
year = {2026},
month = {July},
url = {https://peteramassih.com/writing/mask2former}
}