YOLOv12: Attention-Centric Real-Time Object Detectors
- 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}
}
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.

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 costs . Convolution looks only at neighboring positions, for . 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 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 , 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

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 equal pieces, cut either horizontally or vertically, and runs full self-attention within each piece. defaults to 4.
The beauty of this split is that it costs almost no extra computation. The official code flattens the feature map into tokens and then reshapes them directly into 4 segments of tokens each. Because flattening lays the tokens out row after row, each run of 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, tokens attending to each other cost ; cut into 4 pieces, each piece costs , and the 4 pieces together cost . The paper writes the cost of ordinary attention as , which area attention brings down to .
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.

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:
- 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.
- 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
| Size | Model | FLOPs (G) | Params (M) | mAP | Latency (ms) |
|---|---|---|---|---|---|
| N | YOLOv10-N | 6.7 | 2.3 | 38.5 | 1.84 |
| N | YOLO11-N | 6.5 | 2.6 | 39.4 | 1.50 |
| N | YOLOv12-N | 6.5 | 2.6 | 40.6 | 1.64 |
| S | YOLO11-S | 21.5 | 9.4 | 46.9 | 2.50 |
| S | RT-DETR-R18 | 60.0 | 20.0 | 46.5 | 4.58 |
| S | YOLOv12-S | 21.4 | 9.3 | 48.0 | 2.61 |
| L | YOLO11-L | 86.9 | 25.3 | 53.3 | 6.20 |
| L | YOLOv12-L | 88.9 | 26.4 | 53.7 | 6.77 |
| X | YOLO11-X | 194.9 | 56.9 | 54.6 | 11.30 |
| X | YOLOv12-X | 199.0 | 59.1 | 55.2 | 11.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
| Model | Setting | Converges | mAP |
|---|---|---|---|
| N | Vanilla ELAN | ✓ | 40.8 |
| N | New aggregation | ✓ | 40.6 |
| N | New agg. + residual (0.1) | ✓ | 40.3 |
| L | Vanilla ELAN | ✗ | – |
| L | New agg. + residual (0.01) | ✓ | 53.7 |
| X | New agg. + residual (0.1) | ✗ | – |
| X | New 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

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.