Back to paper library
arXiv 2025NeurIPS 2025Object detectionPaper notes

YOLOv12

Fashionably Late

Original paper

YOLOv12: Attention-Centric Real-Time Object Detectors

Paper authors

Yunjie Tian · Qixiang Ye · David Doermann

Publication
NeurIPS 2025Conference
First submitted to arXiv
arXiv:2502.12524
Cite this paper · BibTeX

The citation identifies the linked source version. It cites the original paper and its authors.

@misc{objectdetectionyolov122025,
  title = {{YOLOv12: Attention-Centric Real-Time Object Detectors}},
  author = {Yunjie Tian and Qixiang Ye and David Doermann},
  year = {2025},
  eprint = {2502.12524},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2502.12524}
}
On this page

From YOLOv4 to YOLOv11, the body of YOLO was always convolution. What changed were the loss functions, label assignment and the way modules connect; YOLOv10 and YOLOv11 did each add an attention module, but the vast majority of the computation was still convolution.

Over the same period, Transformers had long since proven themselves in image classification, and even in small models, attention has more modeling power than convolution. Yet the YOLO series never really switched to attention, for the simple reason that it's too slow.

In February 2025, Yunjie Tian and David Doermann of the University at Buffalo and Qixiang Ye of the University of Chinese Academy of Sciences released YOLOv12, with "attention-centric" right in the title. What they set out to build is a detector with attention at its core that is no slower than the convolutional YOLOs.

Left half of Figure 1 from the paper: latency on a T4 GPU (ms) on the horizontal axis and COCO mAP on the vertical axis. The solid red line is YOLOv12's five sizes, with mAP from 40.6 to 55.2, above and to the left of every other curve; the dashed black YOLOv10 line and the dashed purple YOLOv11 line hug it just below, while the other methods, including YOLOv6-3.0, YOLOv7, YOLOv8, RT-DETR, RT-DETRv2, YOLO-MS and Gold-YOLO, sit further down and to the right.
Left half of original Figure 1, Tian et al., from PDF page 1, arXiv license, scholarly quotation.

This is the result the paper shows on its first page. The red line is furthest up and to the left, but look closely, and the black YOLOv10 and purple YOLOv11 lines sit very close to it. We'll come back to that "very close" later.

Problem Definition

The authors trace attention's slowness relative to convolution to two causes.

Computation. Self-attention computes a similarity between every token and every other token, so a sequence of length LL costs O(L2d)O(L^2 d). Convolution looks only at kk neighboring positions, for O(kLd)O(kLd). On a 640×640 input, the stride-8 feature map alone has 6,400 tokens, and once that is squared, the gap is enormous.

Memory access. Attention first computes an L×LL\times L attention matrix and then a softmax, and these intermediate results have to be written from the GPU's fast SRAM back to video memory (HBM) and read back in when needed; SRAM reads and writes are more than ten times as fast as HBM. Convolution's memory access is far more regular and easy to cache.

FlashAttention has already solved the second problem, and YOLOv12 simply uses it. What remains is the first problem, computation.

There are many ways to cut attention's computation. Linear attention reduces the complexity to O(nhd2)O(nhd^2), but it loses global dependencies and trains unstably, and on 640×640 inputs the actual speedup is limited. Local attention, such as Swin Transformer's shifted windows, criss-cross attention and axial attention, confines attention to a region; but partitioning and shifting windows costs extra computation in itself, and some of these shrink the receptive field too much.

The authors wanted a simpler way to split things up.

Solution

Area Attention: Just Cut It into Four

Figure 2 from the paper: the same photo of a dog and a frisbee on grass, with a red dot marking a query position and a pink region showing what it can attend to. Criss-cross attention is a cross through the red dot; window attention is the square window containing the red dot; axial attention is also a cross but spans the entire row and column; area attention is a full horizontal band, or a full vertical strip, containing the red dot.
Original Figure 2, Tian et al., from PDF page 3, arXiv license, scholarly quotation.

The first three each mark out, for a given query position, a region it can look at; area attention instead divides the whole feature map into ll equal pieces, cut either horizontally or vertically, and runs full self-attention within each piece. ll defaults to 4.

The beauty of this split is that it costs almost no extra computation. The official code flattens the feature map into N=H×WN = H\times W tokens and then reshapes them directly into 4 segments of N/4N/4 tokens each. Because flattening lays the tokens out row after row, each run of N/4N/4 consecutive tokens is exactly a horizontal band. There's no need to partition windows, shift them and stitch them back together as Swin does.

How does the computation change? Originally, NN tokens attending to each other cost N2N^2; cut into 4 pieces, each piece costs (N/4)2(N/4)^2, and the 4 pieces together cost N2/4N^2/4. The paper writes the cost of ordinary attention as 2n2hd2n^2hd, which area attention brings down to 12n2hd\frac{1}{2}n^2hd.

The receptive field shrinks to a quarter of the original, but each piece is still a wide band spanning the full width (or height) of the image, much larger than a 7×7 window. The authors found that this change has little effect on accuracy while making things a good deal faster.

R-ELAN: Large Models Won't Train

The second problem comes from the ELAN structure YOLO has used since YOLOv7.

Figure 3 from the paper: structure diagrams of four modules. (a) CSPNet: after a transition, the path splits in two; one branch goes straight to the end, the other passes through several blocks and another transition, and the two are concatenated. (b) ELAN: after a transition, the path splits in two; one branch passes through several convolution layers, and every layer's output is routed to the end for concatenation. (c) C3K2: similar to ELAN, but its blocks are made of smaller CSP structures. (d) R-ELAN: the transition produces only a single feature map, which after a 1×1 convolution passes through several A2 (area attention) blocks in sequence, with each block's output concatenated; the whole module also has a shortcut straight from input to output, and the concatenated result is multiplied by a scaling factor and added to the shortcut.
Original Figure 3, Tian et al., from PDF page 4, arXiv license, scholarly quotation.

ELAN (panel b) first uses a 1×1 convolution as a transition layer and splits the output in two; one part passes through several convolution layers, with each layer's output pulled out, everything is concatenated at the end, and another transition layer adjusts the channels. YOLOv11's C3K2 (panel c) is a variant of it.

After replacing the convolutions in ELAN with area attention, the authors couldn't train the two large sizes, L and X; switching to Adam or AdamW didn't help, as training either failed to converge or was unstable. The authors attribute the problem to ELAN itself, which has no residual connection from input to output, making it hard for gradients to flow.

R-ELAN (panel d) makes two changes:

  1. A residual shortcut around the whole module. The output equals the input plus the concatenated result multiplied by a small scaling factor, 0.01 by default. This is much like the layer scale used to train deep ViTs. The authors also tried adding layer scale after each area attention separately, but training was still unstable, and slower too; this shows the problem lies in ELAN's overall structure, not just in attention.
  2. A new aggregation scheme. The original ELAN first splits the input in two, one part passing straight through and the other being processed; in R-ELAN, the transition layer outputs a single feature map, all of which gets processed, and the outputs of each layer are then concatenated, forming a bottleneck structure. This saves some computation and parameters.

Other Tweaks

Beyond these two main designs, the authors made a number of adjustments to attention for the sake of speed, some of which, they note, are not their own inventions:

  • MLP ratio lowered from 4 to 1.2 (2 for the N, S and M sizes), shifting computation from the feed-forward network to attention.
  • Convolution plus BatchNorm in place of linear layers plus LayerNorm, since convolution is more efficient on GPUs.
  • Positional encoding removed, replaced by a 7×7 depthwise separable convolution on the value, which the authors call the position perceiver, so that attention can still sense position. YOLOv10's PSA module already used this approach.
  • Only one R-ELAN in the last backbone stage, instead of stacking three as earlier generations did; the first two stages reuse YOLOv11's design as is, without R-ELAN.

The training setup is the same as YOLOv11's, 600 epochs from scratch on COCO with no pretraining. Latency is measured on a T4 GPU with TensorRT FP16.

Discussion

Main Results

SizeModelFLOPs (G)Params (M)mAPLatency (ms)
NYOLOv10-N6.72.338.51.84
NYOLO11-N6.52.639.41.50
NYOLOv12-N6.52.640.61.64
SYOLO11-S21.59.446.92.50
SRT-DETR-R1860.020.046.54.58
SYOLOv12-S21.49.348.02.61
LYOLO11-L86.925.353.36.20
LYOLOv12-L88.926.453.76.77
XYOLO11-X194.956.954.611.30
XYOLOv12-X199.059.155.211.79

Compiled from Table 1 of the paper, COCO val2017, 640×640, T4 TensorRT FP16.

YOLOv12 has the highest mAP at every size. At N it's 1.2 above YOLO11-N, and at S 1.1 above. Against RT-DETR, YOLOv12-S is 1.5 mAP higher with only 36% of its computation, and 42% faster.

But read the latency column carefully. YOLOv12 is slower than YOLO11 at every size, by 0.14 ms at N, 0.57 ms at L and 0.49 ms at X. The abstract calls YOLOv12-N's speed "comparable" to YOLO11-N's, which works out to about 9% slower. The accuracy gain is real, but it isn't free.

The large sizes also gain less than the small ones. L is only 0.4 above YOLO11-L, and X 0.6.

R-ELAN Ablation

ModelSettingConvergesmAP
NVanilla ELAN✓40.8
NNew aggregation✓40.6
NNew agg. + residual (0.1)✓40.3
LVanilla ELAN✗–
LNew agg. + residual (0.01)✓53.7
XNew agg. + residual (0.1)✗–
XNew agg. + residual (0.01)✓55.2

Compiled from Table 2 of the paper.

This table is honest. For the small N model, the residual connection actually lowers mAP from 40.6 to 40.3, and the new aggregation scheme is 0.2 below the original ELAN, saving only a little computation. R-ELAN really pays off on large models, since L and X can't be trained at all without it; X converges only with a scaling factor as small as 0.01, and even 0.1 fails.

Area Attention's Speed

Without FlashAttention, area attention gives an obvious speedup. YOLOv12-N's FP32 latency on an RTX 3080 drops from 2.7 ms to 2.0 ms, and on the CPU from 62.9 ms to 31.4 ms, cut in half; the X size on the CPU drops from 804 ms to 513 ms.

With FlashAttention on, the gap shrinks. YOLOv12-N with and without area attention runs at 1.64 ms vs. 1.70 ms, with mAP of 40.6 vs. 40.8; in other words, area attention saves only 0.06 ms on a T4, at a cost of 0.2 mAP. FlashAttention itself brings the N size from 1.92 ms down to 1.64 ms. On GPUs with FlashAttention, the speed rests mainly on FlashAttention; area attention earns its place on CPUs and on hardware that doesn't support FlashAttention.

Other Diagnostics

The authors also ran a series of small experiments on YOLOv12-N:

  • Keep the hierarchical design. Switching to a single-scale plain ViT architecture drops mAP from 40.6 to 38.3.
  • No positional encoding needed. Adding relative or absolute positional encoding actually lowers mAP slightly (40.3, 40.5) and increases latency.
  • Use a 7×7 position perceiver. 9×9 adds 0.1, but latency jumps from 1.64 ms to 1.79 ms.
  • Train for 600 epochs. 300 epochs give only 39.5; 800 epochs actually drop to 40.4.
  • An MLP ratio of 1.2 is best. At the L size, 1.2 gives 53.8, while the standard 4.0 gives only 53.1.

Heat Maps

Left half of Figure 5 from the paper: four rows of images, a riverbank under a bridge, a crowd flying kites on a lawn, a street sign reading GLADYS, and Big Ben. Each row shows, from left to right, the input image and the heat maps from the third backbone stage of the X-size YOLOv10, YOLO11 and YOLOv12 models. In YOLOv12's heat maps, object outlines are clearer and the background is darker.
Left half of original Figure 5, Tian et al., from PDF page 9, arXiv license, scholarly quotation.

The authors use heat maps from the third backbone stage to show that YOLOv12 sees objects more clearly. In YOLOv12's heat maps, the outline of Big Ben and the edges of the lettering on the sign are indeed sharper. Still, heat maps are a qualitative display, with no direct quantitative link to detection accuracy.

What the Community Did Next

Soon after its release, YOLOv12 was integrated into the Ultralytics package, but the two sides tell different stories.

The authors wrote in the official README that people should use their own repository, because the Ultralytics implementation is inefficient, uses more memory and trains unstably. The Ultralytics documentation, for its part, labels YOLO12 a community-driven model, warns that it may train unstably, use a lot of memory and run slower on CPUs, and recommends YOLO11 or YOLO26 for production deployment.

The authors later released YOLOv12-turbo, which became the default version in the official repository. The N size scores 40.4 mAP at 1.60 ms and the S size 47.6 mAP at 2.42 ms, faster than the paper versions but slightly less accurate.

Conclusion

A YOLO built around attention can run at about the same speed as the convolutional versions. It takes FlashAttention to handle memory access, area attention to cut computation to a quarter with a single reshape, and R-ELAN to make the large models trainable.

But "about the same" still isn't "as fast". On a T4, every size is a bit slower than YOLO11, and the speed depends heavily on FlashAttention; on hardware without it, area attention can win back only part of the gap.

If you want to use it, check that your GPU supports FlashAttention before training, then choose between the official repository and the Ultralytics version; the people behind each have already stated their positions in their documentation.